# GeoMakie.jl: Stereographic projection at pole did not work

**URL:** <https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [June 23, 2022, 3:41pm UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258 "2022-06-23T15:41:06Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![JanJereczek](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@JanJereczek](https://discourse.julialang.org/u/JanJereczek)\
**Post date:** [June 23, 2022, 3:41pm UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/1 "2022-06-23T15:41:06Z")

</div>

Hi all,

I started to code in Julia half a year ago and I am quite excited about using GeoMakie. I work on ice sheet dynamics so I mostly want to visualize the poles. Therefore I want to use a stereographic projection and as a first example I tried to adapt the keyword argument in a GeoMakie example of the documentation ([Examples · GeoMakie.jl](https://juliaplots.org/GeoMakie.jl/stable/examples/#Orthographic-projection)). The problem I face is that I obtain a blank plot:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/0/8032382a9202198e7710ce7cd6663f083a98d08b.png)

Here goes the code:

```julia
using GeoMakie, CairoMakie

lons = -180:180
lats = -90:90
field = [exp(cosd(l)) + 3(y/90) for l in lons, y in lats]

fig = Figure()
ga = GeoAxis(
    fig[1, 1],
    dest="+proj=sterea +lat_0=90", # Only lined that was changed compared to example!
    lonlims = automatic,
    coastlines = true,
    title = "Stereographic projection"
)

sp = surface!(ga, lons, lats, field; shading = false, colormap = :rainbow_bgyrm_35_85_c69_n256)
cb = Colorbar(fig[1, 2], sp)

fig

```

I’d be very thankful if anyone can help!

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [June 23, 2022, 4:10pm UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/2 "2022-06-23T16:10:45Z")

</div>

> [@JanJereczek](#):
>
> `sterea`

Just wondering whether that’s the correct spelling… ?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [June 23, 2022, 4:26pm UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/3 "2022-06-23T16:26:02Z")

</div>

Should exist:

[https://proj.org/operations/projections/sterea.html](https://proj.org/operations/projections/sterea.html)

Maybe @asinghvi17 can help

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [June 23, 2022, 4:28pm UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/4 "2022-06-23T16:28:27Z")

</div>

🙂 well you learn something every day

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [June 23, 2022, 8:01pm UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/5 "2022-06-23T20:01:37Z")

</div>

If you want to consider an alternative

```julia
using GMT
lons = -180:180;
lats = 0:90; # No need for the whole Earth
field = [exp(cosd(l)) + 3(y/90) for y in lats, l in lons];

G = mat2grid(field, x=lons, y=lats, proj4="+proj=longlat");
imshow(G, proj="+proj=sterea +lat_0=90", coast=true)

```

 ![GMTjl_tmp-fs8](https://global.discourse-cdn.com/julialang/original/3X/c/3/c3fdd7905e377b488869306c01bf269d1d4f8b5b.png)

---

<div class="post-metadata">

**Author:** ![JanJereczek](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@JanJereczek](https://discourse.julialang.org/u/JanJereczek)\
**Post date:** [June 24, 2022, 8:44am UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/6 "2022-06-24T08:44:09Z")

</div>

Thanks a lot for the neat answer! On the longer term I’d really like to rely as much as possible on native julia tools, so I’d still be very interested if anyone has a solution in GeoMakie 🙂

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [June 24, 2022, 10:06am UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/7 "2022-06-24T10:06:13Z")

</div>

That is an illusion. No plotting package is Julia native.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [June 24, 2022, 10:30am UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/8 "2022-06-24T10:30:47Z")

</div>

Well it does make a difference if the primitives are julia objects because that’s what people mainly hack around with. Of course the rendering itself is not Julia.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [June 24, 2022, 11:09am UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/9 "2022-06-24T11:09:49Z")

</div>

I suspect that with that definition then all (most?) plotting packages are Julia natives.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [June 24, 2022, 11:33am UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/10 "2022-06-24T11:33:31Z")

</div>

They differ in the depth that their Julia stack reaches

---

<div class="post-metadata">

**Author:** ![JanJereczek](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@JanJereczek](https://discourse.julialang.org/u/JanJereczek)\
**Post date:** [June 24, 2022, 12:49pm UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/11 "2022-06-24T12:49:22Z")

</div>

Then I guess my wish would be better formulated by saying: I want to use (Geo)Makie because it presents a large julia stack and it would be more coherent with the rest of my plotting routines!

---

<div class="post-metadata">

**Author:** ![j\_u](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_u/32/219081_2.png) [@j\_u](https://discourse.julialang.org/u/j_u)\
**Post date:** [June 24, 2022, 1:02pm UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/12 "2022-06-24T13:02:04Z")

</div>

> [@JanJereczek](#):
>
> The problem I face is that I obtain a blank plot

Maybe because of those gotchas=\> [Redirecting to https://geo.makie.org/stable](https://juliaplots.org/GeoMakie.jl/stable/#Gotchas) or =\> [Redirecting to https://geo.makie.org/stable](https://juliaplots.org/GeoMakie.jl/stable/#Gotchas-2) ?

---

<div class="post-metadata">

**Author:** ![j\_u](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_u/32/219081_2.png) [@j\_u](https://discourse.julialang.org/u/j_u)\
**Post date:** [June 25, 2022, 10:48am UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/13 "2022-06-25T10:48:37Z")

</div>

I see no reply so probably there is some other cause that makes the plot not showing. Just wanted to add that I like both of those plotting packages (GMT and GeoMakie).

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [June 25, 2022, 4:51pm UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/14 "2022-06-25T16:51:54Z")

</div>

Following @j_u’s suggestion on one of the gotchas. Playing with the xlimits! and ylimits! make the plot appear.

```julia

using GeoMakie, CairoMakie

lons = -180:180
lats = -90:90
field = [exp(cosd(l)) + 3(y/90) for l in lons, y in lats]

fig = Figure()
ga = GeoAxis(
    fig[1, 1],
    dest="+proj=sterea +lat_0=90", # Only lined that was changed compared to example!
    lonlims = automatic,
    coastlines = true,
    title = "Stereographic projection"
)

xlims!(ga, -90, 90)
ylims!(ga, -50, 50)
sp = surface!(ga, lons, lats, field; shading = false, colormap = :rainbow_bgyrm_35_85_c69_n256)
cb = Colorbar(fig[1, 2], sp)
fig

```

Produces:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/5/356c17fe7e38b3c6726fab042ed58306a5cdf778.jpeg)

---

<div class="post-metadata">

**Author:** ![JanJereczek](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@JanJereczek](https://discourse.julialang.org/u/JanJereczek)\
**Post date:** [June 27, 2022, 9:43am UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/15 "2022-06-27T09:43:26Z")

</div>

> [@aramirezreyes](#):
>
> ```julia
> xlims!(ga, -90, 90)
> ylims!(ga, -50, 50)
> 
> ```

Muchas gracias Argel, it solved it!

Here goes my code (this time for Antarctica), where the aspect ratio is fixed and the limits are adapted. Hope it can be useful for others.

```julia
using GeoMakie, CairoMakie

lons = -180:180
lats = -90:-60
field = [exp(cosd(l)) + 3(y/90) for l in lons, y in lats]

fig = Figure()
ga = GeoAxis(
    fig[1, 1],
    aspect = AxisAspect(1),
    dest="+proj=sterea +lat_0=-90",
    lonlims = automatic,
    coastlines = true,
    title = "Stereographic projection"
)

xlims!(ga, -180, 180)
ylims!(ga, -90, -60)
sp = surface!(ga, lons, lats, field; shading = false, colormap = :rainbow_bgyrm_35_85_c69_n256)
cb = Colorbar(fig[1, 2], sp)
fig

```

Should display the following picture:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/3/c3bfb39261101948d30a8b5e8224ed839fa1008d.jpeg)

---

<div class="post-metadata">

**Author:** ![j\_u](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_u/32/219081_2.png) [@j\_u](https://discourse.julialang.org/u/j_u)\
**Post date:** [June 27, 2022, 1:12pm UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/16 "2022-06-27T13:12:51Z")

</div>

Great to see it working on your sides @aramirezreyes and @JanJereczek and sorry for providing only a very general advice. Really happy that GeoMakie as I understand received a significant refresh recently. Hope the development efforts will continue.

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [June 28, 2022, 6:07pm UTC](https://discourse.julialang.org/t/geomakie-jl-stereographic-projection-at-pole-did-not-work/83258/17 "2022-06-28T18:07:32Z")

</div>

Hey, was on vacation for a bit so just saw this. Thanks @aramirezreyes for the solution!

Yeah, in general this is an issue in GeoMakie - if the limits of the plot are greater than the intrinsic limits of the projection, the whole thing goes blank, since the transformed limits become infinity. It’s hard to define a general solution because not all projections have well-defined rectangular boundingboxes.

You will see that the surface is not clipped by the edge of the Axis. My current thought is to just add a white polygon on top to simulate clipping until we get a proper nonlinear clip implemented, but not totally sure how that should work still.
