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

turn GeoAxis into a block and fix projection #148

Closed
wants to merge 13 commits into from
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- run: julia --project=. -e 'using Pkg; pkg"add Makie#sd/geomakie CairoMakie#sd/geomakie GLMakie#sd/geomakie"' # TODO remove this later!
- uses: julia-actions/julia-runtest@v1
- uses: actions/upload-artifact@v3
if: always()
Expand Down
3 changes: 2 additions & 1 deletion examples/axis_config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ fig = Figure(resolution = (1000,1000))
axs = [GeoAxis(fig[i, j]) for i in 1:2, j in 1:2]

# axis 1 - I want an orthographic projection.
axs[1, 1].scene.transformation.transform_func[] = Proj.Transformation("+proj=latlong","+proj=ortho")
# axis 1 does not work - TODO!
axs[1, 1].source_projection[] = "+proj=ortho"
xlims!(axs[1, 1], -90, 90)

# axis 2 - wacky spines
Expand Down
7 changes: 5 additions & 2 deletions examples/field_and_countries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using GeometryBasics
using GeoInterface

# https://datahub.io/core/geo-countries#curl # download data from here
worldCountries = GeoJSON.read(read(Downloads.download("https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json"), String))
worldCountries = GeoJSON.read(read(Downloads.download("https://raw.githack.com/johan/world.geo.json/master/countries.geo.json"), String))
n = length(worldCountries)
lons = -180:180
lats = -90:90
Expand All @@ -18,9 +18,10 @@ fig = Figure(resolution = (1200,800), fontsize = 22)

ax = GeoAxis(
fig[1,1];
dest = "+proj=wintri",
target_projection = "+proj=vandg",
title = "World Countries",
tellheight = true,
limits = ((-180, 180), (-90, 90))
)

hm1 = surface!(ax, lons, lats, field; shading = false)
Expand All @@ -36,4 +37,6 @@ hm2 = poly!(

cb = Colorbar(fig[1,2]; colorrange = (1, n), colormap = Reverse(:plasma), label = "variable, color code", height = Relative(0.65))



fig
12 changes: 7 additions & 5 deletions examples/orthographic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ field = [exp(cosd(l)) + 3(y/90) for l in lons, y in lats]
fig = Figure()
ga = GeoAxis(
fig[1, 1],
dest="+proj=ortho",
lonlims = automatic,
coastlines = true,
title = "Orthographic projection with proper limits"
target_projection="+proj=ortho",
title = "Orthographic projection with proper limits",
limits = ((-90, 90), (-90, 90)) # have to specify proper limits here - TODO bring back autolimit finding!
)
# hidedecorations!(ga)

# TODO: bring back coastlines, or create it as a recipe...
lp = lines!(ga, GeoMakie.coastlines())
translate!(lp, 0, 0, 10)
sp = surface!(ga, lons, lats, field; shading = false, colormap = :rainbow_bgyrm_35_85_c69_n256)
cb = Colorbar(fig[1, 2], sp)

Expand Down
4 changes: 2 additions & 2 deletions examples/projections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ lats = -90:90
field = [exp(cosd(l)) + 3(y / 90) for l in lons, y in lats]

fig = Figure()
ax1 = GeoAxis(fig[1, 1], dest = "+proj=vitk1 +lat_1=45 +lat_2=55",
ax1 = GeoAxis(fig[1, 1], target_projection = "+proj=vitk1 +lat_1=45 +lat_2=55",
coastlines = true, title = "vitk1")
ax2 = GeoAxis(fig[1, 2], dest = "+proj=wintri",
ax2 = GeoAxis(fig[1, 2], target_projection = "+proj=wintri",
coastlines = true, title = "wintri")

surface!(ax1, lons, lats, field; shading = false, colormap = (:plasma, 0.45))
Expand Down
9 changes: 4 additions & 5 deletions examples/rotating_earth.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ destnode = Observable("+proj=ortho")
fig = Figure()
ga = GeoAxis(
fig[1, 1],
coastlines = true,
dest = destnode,
lonlims = Makie.automatic
target_projection = destnode,
)
image!(-180..180, -90..90, rotr90(GeoMakie.earth()); interpolate = false)
hidedecorations!(ga)
image!(ga, -180..180, -90..90, rotr90(GeoMakie.earth()); interpolate = false)
hidedecorations!(ga) # TODO implement hidedecorations/spines

record(fig, "rotating_earth_ortho.mp4"; framerate=30) do io
for lon in -90:90
Expand All @@ -20,3 +18,4 @@ record(fig, "rotating_earth_ortho.mp4"; framerate=30) do io
recordframe!(io)
end
end
# TODO this doesn't work!
6 changes: 3 additions & 3 deletions examples/world_population.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Downloads
source = "+proj=longlat +datum=WGS84"
dest = "+proj=natearth2"

url = "https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson/"
url = "https://raw.githack.com/nvkelso/natural-earth-vector/master/geojson/"
land = Downloads.download(url * "ne_110m_land.geojson")
land_geo = GeoJSON.read(read(land, String))
pop = Downloads.download(url * "ne_10m_populated_places_simple.geojson")
Expand All @@ -17,8 +17,8 @@ begin
fig = Figure(resolution = (1000,500))
ga = GeoAxis(
fig[1, 1];
source = source,
dest = dest
source_projection = source,
target_projection = dest
)

ga.xticklabelsvisible[] = false
Expand Down
1 change: 1 addition & 0 deletions src/GeoMakie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export Proj
export FileIO

include("geoaxis.jl")
include("makie-axis.jl")

export GeoAxis, datalims, datalims!, automatic

Expand Down
Loading