Skip to content
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

unexpected behavior for lines! in GeoAxis #251

Open
LukasBarner opened this issue Jun 21, 2024 · 1 comment
Open

unexpected behavior for lines! in GeoAxis #251

LukasBarner opened this issue Jun 21, 2024 · 1 comment

Comments

@LukasBarner
Copy link

Thanks so much for an amazing package :)
Recently, I stumbled upon some unexpected behavior for the lines! plot in GeoAxis.
See the following MWE, which intends to draw a simplified shipping route from Australia to Chile.

using GeoMakie, CairoMakie, GeometryOps, GeometryBasics

path = LineString(Point2f.([145, 170, -170, -70], [-38, -30, -20, -33]))
fig = Figure()
ga = GeoAxis(fig[1, 1])
lines!(ga, GeoMakie.coastlines())
lines!(ga, path, color = :red)
fig
image

However, based on how the easternmost parts of Russia are treated, I would expect the red line to cross the date line.
Is this expected behavior, or is there a different function I could use to achieve the desired behavior?

@asinghvi17
Copy link
Member

Hey, glad GeoMakie was useful to you!

The "correct" solution is a bit involved for now, but basically involves using GeometryOps to interpolate the path along the globe, then cutting the resulting line at the antimeridian. I'm hoping to move this within GeoMakie at some stage, but that would need a refactor at the Makie level as well.

import GeometryOps as GO
using GeoMakie, CairoMakie, GeometryBasics

path = LineString(Point2f.([145, 170, -170, -70], [-38, -30, -20, -33]))
interpolated_path = GO.segmentize(GO.GeodesicSegments(; max_distance = 100_000), path) # 100km segments
split_path = Base.split(GeoMakie.geo2basic(interpolated_path), 180.0)

fig = Figure()
ga = GeoAxis(fig[1, 1])
lines!(ga, GeoMakie.coastlines())
lines!(ga, split_path, color = :red)
fig

iTerm2 wC0P3f

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