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

Makie ext #74

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

ConnectedSystems
Copy link

@ConnectedSystems ConnectedSystems commented Jul 2, 2024

Draft PR for #66 - currently just a proof of concept.

There's currently some issue with GDAL.jl which prevents successful precompilation.
I've resolved it temporarily with:

Plotting certain types of polygons currently does not work!
Now correctly supports points and multipolys but need to test with a wider variety of data.

using Revise, Infiltrator
using GeoMakie, WGLMakie
import GeoDataFrames as GDF
using Downloads

# Point data
if !@isdefined point_gdf_fn
    point_gdf_fn = Downloads.download("https://github.com/ngageoint/GeoPackage/raw/master/docs/examples/java/example.gpkg")
end

point_gdf = GDF.read(point_gdf_fn)
pnt_fig = GDF.plot(point_gdf, :geometry)

# Polygon data
if !@isdefined poly_gdf_fn
    poly_gdf_fn = Downloads.download("http://www.geopackage.org/data/sample1_2.gpkg")
end

poly_gdf = GDF.read(poly_gdf_fn)
poly_fig = GDF.plot(poly_gdf, :Shape)

GDF.plot(poly_gdf)

@ConnectedSystems ConnectedSystems marked this pull request as draft July 2, 2024 01:18
@ConnectedSystems
Copy link
Author

Would appreciate any input @evetion @asinghvi17 as I'm not so familiar with GeoMakie/GeoInterface internals.

@asinghvi17
Copy link
Contributor

asinghvi17 commented Jul 3, 2024

Hey, thanks for the PR! In this case it's probably better to stick with the existing Makie machinery in e.g GeoInterfaceMakie, and maybe make an extension on that as well as regular Makie. I think Shapefile.jl does something similar, and GeoMakie loads GeoInterfaceMakie which brings all of these extensions as well.

The issue here, though, is that GeoDataFrames are not their own type, but rather a simple DataFrame. This means that there is no way to disambiguate between a GeoDataFrame and a regular dataframe. If we do create a GeoDataFrame type, even if just by wrapping a DataFrame and forwarding all possible method combinations, then this issue goes away and it's a lot easier to plot these.

Is there a fundamental difference between e.g. plot(gdf.geometry) and plot(gdf, :geometry) for your usecase? The number of characters is similar and IMO plot(gdf.geometry) should already work with the GeoInterface/Makie/ArchGDAL integration. I also have a PR JuliaGeo/GeoInterface.jl#139 which fixes plotting Vector{<: Missing, Geometry} which is the last step to smooth integration. This plus my earlier PR should also remove the need to use eg GeoMakie.to_multipoly since the Makie recipe for vectors of geometries calls that internally.

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

Successfully merging this pull request may close these issues.

2 participants