Skip to content

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!

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.

3 participants