Plotting polygons defined in degrees

I’m trying to plot the polygons from GADM.jl. I do the following:

using GeoTables
using GeoArtifacts
using Countries
using DataFrames
using Meshes
using GLMakie 
using GeoMakie

> gdf = GADM.get("FIN"; level=0)
> p = reduce(vcat, gdf.geometry)
> typeof(p.geoms[1])
 PolyArea{🌐, CoordRefSystems.GeodeticLatLon{CoordRefSystems.WGS84Latest, Unitful.Quantity{Float64, NoDims, Unitful.FreeUnits{(°,), NoDims, nothing}}}, Ring{🌐, CoordRefSystems.GeodeticLatLon{CoordRefSystems.WGS84Latest, Unitful.Quantity{Float64, NoDims, Unitful.FreeUnits{(°,), NoDims, nothing}}}, CircularArrays.CircularVector{Meshes.Point{🌐, CoordRefSystems.GeodeticLatLon{CoordRefSystems.WGS84Latest, Unitful.Quantity{Float64, NoDims, Unitful.FreeUnits{(°,), NoDims, nothing}}}}, Vector{Meshes.Point{🌐, CoordRefSystems.GeodeticLatLon{CoordRefSystems.WGS84Latest, Unitful.Quantity{Float64, NoDims, Unitful.FreeUnits{(°,), NoDims, nothing}}}}}}}, Vector{Ring{🌐, CoordRefSystems.GeodeticLatLon{CoordRefSystems.WGS84Latest, Unitful.Quantity{Float64, NoDims, Unitful.FreeUnits{(°,), NoDims, nothing}}}, CircularArrays.CircularVector{Meshes.Point{🌐, CoordRefSystems.GeodeticLatLon{CoordRefSystems.WGS84Latest, Unitful.Quantity{Float64, NoDims, Unitful.FreeUnits{(°,), NoDims, nothing}}}}, Vector{Meshes.Point{🌐, CoordRefSystems.GeodeticLatLon{CoordRefSystems.WGS84Latest, Unitful.Quantity{Float64, NoDims, Unitful.FreeUnits{(°,), NoDims, nothing}}}}}}}}}

This is not plottable by viz!() (from Meshes.jl I believe). Simply nothing is plotted. I can plot PolyAreas when the coordinates are plain numbers, not (:lat, :lon) tuples in degree units.

Check Optimize visualization of non-Euclidean geometries and domains Β· Issue #1367 Β· JuliaGeometry/Meshes.jl Β· GitHub for additional information.

The current workaround is to project the spherical geometries into β€œflat” Euclidean geometries before plotting, and that is already optimized:

julia> using GeoStats

julia> using GeoArtifacts

julia> import GLMakie as Mke

julia> gtb = GADM.get("FIN")
               1Γ—3 GeoTable over 1 GeometrySet
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    GID_0    β”‚   COUNTRY   β”‚           geometry            β”‚
β”‚ Categorical β”‚ Categorical β”‚         MultiPolygon          β”‚
β”‚  [NoUnits]  β”‚  [NoUnits]  β”‚ πŸ–ˆ GeodeticLatLon{WGS84Latest} β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     FIN     β”‚   Finland   β”‚     Multi(2879Γ—PolyArea)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

julia> ptb = gtb |> Proj(Robinson)
            1Γ—3 GeoTable over 1 GeometrySet
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    GID_0    β”‚   COUNTRY   β”‚        geometry         β”‚
β”‚ Categorical β”‚ Categorical β”‚      MultiPolygon       β”‚
β”‚  [NoUnits]  β”‚  [NoUnits]  β”‚ πŸ–ˆ Robinson{WGS84Latest} β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     FIN     β”‚   Finland   β”‚  Multi(2879Γ—PolyArea)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

julia> viewer(ptb)

If you have the time and skill to contribute, please reach out in our community channels.

Ok this works. Although the color is not what I expected.

Please share the script used, otherwise it is impossible to debug. The color is assigned by the viewer or you can specify it with the lower level viz function.

I highly recommend reading the GDSJL book:

Another simple way to plot this is

using DataFrames
using GADM
using GeoMakie
using CairoMakie  # Or GLMakie should work
gdf = GADM.get("FIN"; depth=0) |> DataFrame

fig = Figure()
ga = GeoAxis(fig[1, 1]; dest="+proj=eqdc +datum=WGS84 +lat_1=60 +lat_2=71")
poly!(ga, gdf.geom; color=:blue, strokecolor=:darkblue, strokewidth=1, shading=NoShading)
fig