Skip to content

Avoid line-wrapping artifacts #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aplavin opened this issue Nov 21, 2024 · 3 comments
Open

Avoid line-wrapping artifacts #292

aplavin opened this issue Nov 21, 2024 · 3 comments

Comments

@aplavin
Copy link

aplavin commented Nov 21, 2024

upd 2025: call MakieExtra.GeoAxis_splitwrap!() before all GeoAxis plotting to avoid these artifacts

A simple line plot like

lines(
	[(x, x/4) for x in range(0, 300, length=100)];
	axis=(;type=GeoAxis)
)

results in
Image
with a clear wrapping artifact. It's possible to manually split the line into multiple separate ones, or add a NaN point in the middle – but would be great to have it automatically :) Also, different projections may presumably have different wrapping lines, right?

Probably relevant to #290, but could be easier :)

@asinghvi17
Copy link
Member

This and #290 are all symptoms of the same problem - Makie does not know the nature of a geographic transformation, and so cannot rescale / resample accordingly. All the tools to do that live in GIS world, it's just that Makie doesn't know how to use them :(

This is part of a larger refactor that we have to do to make transform_funcs easier to use in general, for which GeoMakie currently has several hacks :)

But for now, @gaelforget implemented a line splitting algorithm in https://github.com/MakieOrg/GeoMakie.jl/blob/master/src/linesplitting.jl that should help - you just call split(linestring::GeometryBasics.LineString, ga::GeoAxis) and it gives you a "split-up" line

@asinghvi17
Copy link
Member

JuliaGeo/GeometryOps.jl#283 contains some code that will solve this for all geometries, and MakieOrg/Makie.jl#4630 may introduce a mechanism that will allow GeoMakie transform funcs to operate on geometry as well.

@aplavin
Copy link
Author

aplavin commented Apr 11, 2025

In the meantime, just call MakieExtra.GeoAxis_splitwrap!() before doing GeoAxis plotting, and lines + polygons will automatically be cut to avoid artifacts.

The actual implementation is in https://github.com/JuliaAPlavin/MakieExtra.jl/blob/00000000c7ca5b037a54c87203bab78b6a4013d3/ext/GeoMakieExt.jl#L57-L122, I think a pretty simple extensible mechanism. The only issue is that it always cuts at +- half a turn, I don't know how to extract the antimeridian from a GeoAxis (https://github.com/JuliaAPlavin/MakieExtra.jl/blob/00000000c7ca5b037a54c87203bab78b6a4013d3/ext/GeoMakieExt.jl#L48).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants