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

Cutout of Projection / Correct handling of limits #254

Open
yum-yab opened this issue Jun 24, 2024 · 3 comments
Open

Cutout of Projection / Correct handling of limits #254

yum-yab opened this issue Jun 24, 2024 · 3 comments

Comments

@yum-yab
Copy link

yum-yab commented Jun 24, 2024

For my thesis I wanted to use Albers Equal Area Projection or Orthographic projection, but unfortunately im not able to cut out my area of interest (Europe). I tried following along the Documentation provided here.

My code is the following:

using GLMakie, GeoMakie

fig = Figure()
ga1 = GeoAxis(fig[1, 1]; dest = "+proj=aea +lat_1=20 +lat_2=80 +lat_0=90 +lon_0=-25 +x_0=0 +y_0=0", limits=((-90, 40), (20, 80)))
ga2 = GeoAxis(fig[1, 2]; dest = "+proj=merc", limits=((-90, 40), (20, 80)))

ga3 = GeoAxis(fig[2, 1]; dest = "+proj=ortho +lat_0=50 +lon_0=-25", limits=((-90, 40), (20, 80)))
ga4 = GeoAxis(fig[2, 2]; dest = "+proj=ortho +lat_0=50 +lon_0=-25")


lines!(ga1, GeoMakie.coastlines())
lines!(ga2, GeoMakie.coastlines())
lines!(ga3, GeoMakie.coastlines())
lines!(ga4, GeoMakie.coastlines())

fig

And the result looks like:
weird_cutouts

I expected the orthographic and aea projection to cut out along lon/lat lines simiar to the merc projection in the top right, but the behaviour is pretty strange.
Without the limits the center and everything looks right to me (bottom right).

I'm also not able to fix the limits afterward because using xlims!(ga4, (-90, 40)) yields:

InexactError: trunc(Int64, Inf)

Stacktrace:
  [1] trunc
    @ ./float.jl:905 [inlined]
  [2] round
    @ ./float.jl:385 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/StaticArrays/YN0oL/src/broadcast.jl:135 [inlined]
  [4] __broadcast
    @ ~/.julia/packages/StaticArrays/YN0oL/src/broadcast.jl:123 [inlined]
  [5] _broadcast
    @ ~/.julia/packages/StaticArrays/YN0oL/src/broadcast.jl:119 [inlined]
  [6] copy
    @ ~/.julia/packages/StaticArrays/YN0oL/src/broadcast.jl:60 [inlined]
  [7] materialize
    @ ./broadcast.jl:903 [inlined]
  [8] round_to_IRect2D(r::GeometryBasics.HyperRectangle{2, Float32})
    @ Makie ~/.julia/packages/Makie/iRM0c/src/makielayout/helpers.jl:7
  [9] (::Makie.var"#1456#1457")(bbox::GeometryBasics.HyperRectangle{2, Float32}, limits::GeometryBasics.HyperRectangle{2, Float64}, aspect::DataAspect)
    @ Makie ~/.julia/packages/Makie/iRM0c/src/makielayout/helpers.jl:49
 [10] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Base ./essentials.jl:892
 [11] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:889
...
    @ ~/.julia/packages/GeoMakie/DMLIe/src/makie-axis.jl:44 [inlined]
 [28] xlims!(ax::GeoAxis, xlims::Tuple{Int64, Int64})
    @ GeoMakie ~/.julia/packages/GeoMakie/DMLIe/src/makie-axis.jl:449

Am I doing something wrong? Or how could I achieve my goal?

Thanks for the help in advance!

@yum-yab
Copy link
Author

yum-yab commented Jun 24, 2024

I also tried to find how I could configure the GeoAxis for my needs but the corresponding page looks very weird, is that a bug? https://geo.makie.org/v0.7.2/examples/axis_config

@asinghvi17
Copy link
Member

asinghvi17 commented Jun 24, 2024

Ah yeah, there are quite a few bugs and issues surrounding limits :D

I could possibly add a polygon that just "clips" everything outside certain lat/lon boundaries. That would probably solve your first issue but not the second.

Am a bit tied up right now but will write a full response later today!

@yum-yab
Copy link
Author

yum-yab commented Jul 3, 2024

Hi, thanks a lot for the help! Are there any updates on a workaround @asinghvi17 ?

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