Skip to content

Add add_vector_layer function #445

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

giswqs
Copy link

@giswqs giswqs commented Feb 5, 2025

Fix #437

This PR adds:

  • add_vector_layer function for loading any geopandas supported vector format, including shapefile, geopackage, kml
  • vector_to_geojson function for converting any geopandas supported vector format to GeoJSON
  • Update the notebook example to include the add_vector_layer examples.

📚 Documentation preview: https://jupytergis--445.org.readthedocs.build/en/445/
💡 JupyterLite preview: https://jupytergis--445.org.readthedocs.build/en/445/lite

Copy link
Contributor

github-actions bot commented Feb 5, 2025

Binder 👈 Launch a Binder on branch giswqs/jupytergis/vector

@mfisher87 mfisher87 added the enhancement New feature or request label Feb 5, 2025
Copy link
Contributor

github-actions bot commented Feb 5, 2025

Integration tests report: appsharing.space

**kwargs,
)
else:
df = gpd.read_file(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this will download the GeoJSON if I do something like:

url = "https://github.com/opengeos/datasets/releases/download/world/countries.geojson"
doc.add_vector_layer(path=url, name="GeoJSON")

This is unfortunate since it will embed the GeoJSON data into the JGIS file, which may be an unwanted behavior. Keeping the GeoJSON source pointed by URL may be better.

So I guess we'd want to consider two approaches in this function:

  • if it's a URL, we keep the URL as-is and don't embed the data
  • if it's a local file or some in-memory data in Python, we don't have the choice but to embed the data so we keep this logic here

@mfisher87
Copy link
Member

@martinRenou @giswqs how can we get this PR moving forward?

On Martin's comment above, I prefer not embedding the data in the project file. GeoJSON files can get quite large, and I think if we're ever going to be embedding data in the project file we should consider a string-encoded binary format.

@martinRenou
Copy link
Member

we should consider a string-encoded binary format

There are cases we embed JSON data already (e.g. when passing data from Python's memory directly, instead of through file url/path), we should definitely improve things and consider another approach 👍🏽

@mfisher87
Copy link
Member

Yeah. I think it makes sense to punt on a better format until later :)

@arjxn-py arjxn-py requested a review from martinRenou June 2, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Adding Shapefile Layers via Python API
4 participants