-
-
Notifications
You must be signed in to change notification settings - Fork 376
Support GeoPandas Polygons and MultiPolygons #1285
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
Merged
+264
−18
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
08c604e
Add rendering of GeoPandas polygons and multipolygons via ragged arrays
ianthomas23 ebd0f7e
Add example notebooks
ianthomas23 415513f
Correct scope of shapely function call
ianthomas23 126d62e
Calculate geopandas bounds once only
ianthomas23 92c53eb
Support dask-geopandas and use lazy imports
ianthomas23 9c7f1aa
Add optional dependencies so can "pip install datashader[geopandas]"
ianthomas23 a2180ed
Explicit Shapely version check
ianthomas23 a81dbac
Add tests comparing geopandas, dask-geopandas and spatialpandas
ianthomas23 bf8d91a
Remove demo notebooks
ianthomas23 761f007
Use sindex.query instead of cx for GeoPandas.GeoDataFrame
ianthomas23 d9ad50f
Better error reporting
ianthomas23 0bddc97
Move geopandas check and spatial filtering to separate function for r…
ianthomas23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "715a71bf-104a-4447-96a2-e6a56147561a", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "# Natural Earth dataset: GeoPandas and SpatialPandas" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "17d8133a-60fe-4c5a-91af-784ee4e78ee2", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "import datashader as ds\n", | ||
| "import geopandas\n", | ||
| "import geodatasets\n", | ||
| "import spatialpandas" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "a55e8a5e-1039-4f63-a95c-5ca2034384b6", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# Load data into GeoPandas and SpatialPandas GeoDataFrames\n", | ||
| "gdf = geopandas.read_file(geodatasets.get_path(\"naturalearth.land\"))\n", | ||
| "sdf = spatialpandas.GeoDataFrame(gdf) # Convert to SpatialPandas" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "94e7ba4c-62b7-4477-aaec-929a511f8bf8", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Display both outputs" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "25b7ca9d-649e-491d-9848-1d45f92b1bf1", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# GeoPandas\n", | ||
| "canvas = ds.Canvas(plot_height=600, plot_width=1200)\n", | ||
| "agg = canvas.polygons(source=gdf, geometry=\"geometry\", agg=ds.count())\n", | ||
| "ds.transfer_functions.shade(agg, cmap=[\"white\", \"green\"], how=\"eq_hist\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "10964acc-1b8f-4411-b4ef-45be064ce32b", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# SpatialPandas\n", | ||
| "canvas = ds.Canvas(plot_height=600, plot_width=1200)\n", | ||
| "agg = canvas.polygons(source=sdf, geometry=\"geometry\", agg=ds.count())\n", | ||
| "ds.transfer_functions.shade(agg, cmap=[\"white\", \"green\"], how=\"eq_hist\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "f4e187a1-0bd1-4b89-b64b-0b4d86567015", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Time GeoPandas" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "7a7c5cca-9fac-4ef5-8429-cf8a8f89384f", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "%%timeit\n", | ||
| "agg = canvas.polygons(source=gdf, geometry=\"geometry\", agg=ds.count())" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "92c4549d-1dcd-40d7-bcd7-a60ab194fcae", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Time SpatialPandas" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "0e5b956e-7163-4762-9953-5353ddd661b4", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "%%timeit\n", | ||
| "agg = canvas.polygons(source=sdf, geometry=\"geometry\", agg=ds.count())" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": "Python 3 (ipykernel)", | ||
| "language": "python", | ||
| "name": "python3" | ||
| }, | ||
| "language_info": { | ||
| "codemirror_mode": { | ||
| "name": "ipython", | ||
| "version": 3 | ||
| }, | ||
| "file_extension": ".py", | ||
| "mimetype": "text/x-python", | ||
| "name": "python", | ||
| "nbconvert_exporter": "python", | ||
| "pygments_lexer": "ipython3", | ||
| "version": "3.11.4" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.