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

Convenience plotting method for use with GeoMakie? #66

Open
ConnectedSystems opened this issue Mar 10, 2024 · 3 comments
Open

Convenience plotting method for use with GeoMakie? #66

ConnectedSystems opened this issue Mar 10, 2024 · 3 comments

Comments

@ConnectedSystems
Copy link

ConnectedSystems commented Mar 10, 2024

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
@asinghvi17
Copy link
Contributor

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.

@evetion
Copy link
Owner

evetion commented Jun 13, 2024

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?

@ConnectedSystems
Copy link
Author

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.

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

3 participants