GeoDataFrames.jl
GeoDataFrames.jl copied to clipboard
Convenience plotting method for use with GeoMakie?
Is there any interest in an extension package to support plotting GeoDataFrames with GeoMakie?
Not being able to nicely plot GeoDataFrames directly with GeoMakie has been a small pain point of mine.
Below is a tentative working example implementation. It was written quickly for a specific purpose but could be generalised.
import ArchGDAL as AG
import Dataframes, GeoDataFrames
using GeoMakie
function plot_map(gdf::DataFrame; geom_col=:geometry)
f = Figure(; size=(600, 900))
ga = GeoAxis(
f[1,1];
dest="+proj=latlong +datum=WGS84",
xlabel="Longitude",
ylabel="Latitude",
xticklabelpad=15,
yticklabelpad=40,
xticklabelsize=10,
yticklabelsize=10,
aspect=AxisAspect(0.75)
)
plottable = GeoMakie.geo2basic(AG.forceto.(gdf[!, geom_col], AG.wkbPolygon))
poly!(ga, plottable)
# Need to auto-set limits explicitly, otherwise tick labels don't appear properly (?)
autolimits!(ga)
xlims!(ga)
ylims!(ga)
display(f)
return f
end
In terms of plotting tables you may be better off using AlgebraOfGraphics. The forcing is a bit tricky though, there's not a good heuristic to know whether you want to preserve linestrings (coerce to MultiLineString) or polygons (coerce to MultiPolygon). GeoMakie has utilities for both, of course.
I'm fine with having an GeoMakie extension. Are you proposing or asking 😅?
We can work with the example and go from there. Ideally it wouldn't require the ArchGDAL forceto stuff, and we can use GeoInterface?
I'm offering to set something up, though I don't know how long it will take me (travelling soon and will be time poor for a while).
I saw @asinghvi17 had something I could potentially use in GeoMakie v0.7.1 instead of my use of ArchGDAL.