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

Add support for GeoPandas lines and points #1293

Merged
merged 3 commits into from Oct 20, 2023
Merged

Add support for GeoPandas lines and points #1293

merged 3 commits into from Oct 20, 2023

Conversation

ianthomas23
Copy link
Member

This builds on PR #1285 to support rendering GeoPandas GeoSeries as lines and points as well as the existing polygons.

  • Canvas.line accepts LineString, MultiLineString, MultiPolygon and Polygon geometry types.
  • Canvas.points accepts MultiPoint and Point.
  • Canvas.polygons accepts MultiPolygon and Polygon.

There is no support for LinearRing yet as that is not supported by shapely.to_ragged_array.

Example:

import colorcet as cc
import datashader as ds
import geodatasets
import geopandas

df = geopandas.read_file(geodatasets.get_path("nybb"))
df["area"] = df.area

canvas = ds.Canvas(plot_height=600, plot_width=600)
agg = canvas.line(source=df, geometry="geometry", agg=ds.max("area"))
ds.transfer_functions.shade(agg, cmap=cc.bgy, how="linear")

generates this image:
temp

Lines support antialiasing as usual. All GeoPandas tests moved to their own file test_geopandas.py which also includes equivalent SpatialPandas tests that are pixel identical.

Example notebook to follow in separate PR.

Pinging @jorisvandenbossche and @martinfleis for visibility.

@ianthomas23 ianthomas23 added this to the v0.15.3 milestone Oct 18, 2023
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #1293 (637f1f8) into main (606f7bf) will decrease coverage by 0.09%.
The diff coverage is 80.70%.

@@            Coverage Diff             @@
##             main    #1293      +/-   ##
==========================================
- Coverage   85.74%   85.66%   -0.09%     
==========================================
  Files          52       52              
  Lines       10946    11114     +168     
==========================================
+ Hits         9386     9521     +135     
- Misses       1560     1593      +33     

Copy link
Member

@jbednar jbednar left a comment

Choose a reason for hiding this comment

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

Looks good!

@ianthomas23 ianthomas23 merged commit 81ce9b8 into main Oct 20, 2023
13 checks passed
@ianthomas23 ianthomas23 deleted the geopandas_line branch October 20, 2023 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants