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

Completely rewrote geometry handling #244

Merged
merged 13 commits into from Oct 25, 2018
Merged

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented Oct 21, 2018

This PR completely overhauls handling of paths, polygons and geometries in GeoViews. First of all it introduces a GeomDictionaryInterface which can process shapely geometries in the form:

{'geometry': <shapely.Geometry>, 'value': 1, 'index': 1, ...}

This means that the MultiInterface interface can process lists of these objects, providing a native representation of geometries and value dimensions without relying on geopandas. Conversion from geopandas to this new format is as simple as:

[row.to_dict() for _, row in gdf.iterrows()]

Secondly it provides utilities to convert all supported types of path/polygon data to this format, which hugely simplifies the projection operations since everything can now uniformly operate on shapely geometries.

Lastly this PR adds support for handling polygon holes, which has been a longstanding limitation.

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 to me, though my eyes glaze over for code like that...

@@ -65,6 +81,34 @@ def project_extents(extents, src_proj, dest_proj, tol=1e-6):
return geom_in_crs.bounds


def geom_dict_to_array_dict(geom_dict, coord_names=['Longitude', 'Latitude']):
"""
Converts a dictionary containing an geometry key to a dictionary
Copy link
Member

Choose a reason for hiding this comment

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

a geometry


For array conversion the following conventions are applied:

* Any nan separated array are converted into a MultiPolygon
Copy link
Member

Choose a reason for hiding this comment

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

arrays

@philippjfr philippjfr merged commit af2d3b0 into master Oct 25, 2018
@philippjfr philippjfr deleted the geometry_improvements branch March 22, 2020 12:34
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