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

Allow using geopandas interface without using geometry column #464

Merged
merged 1 commit into from
Mar 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions geoviews/data/geopandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def init(cls, eltype, data, kdims, vdims):
def validate(cls, dataset, vdims=True):
dim_types = 'key' if vdims else 'all'
geom_dims = cls.geom_dims(dataset)
if len(geom_dims) != 2:
if len(geom_dims) > 0 and len(geom_dims) != 2:
raise DataError('Expected %s instance to declare two key '
'dimensions corresponding to the geometry '
'coordinates but %d dimensions were found '
Expand Down Expand Up @@ -247,13 +247,13 @@ def geom_dims(cls, dataset):

@classmethod
def dimension_type(cls, dataset, dim):
col = cls.geo_column(dataset.data)
if len(dataset.data):
arr = geom_to_array(dataset.data[col].iloc[0])
geom_dims = cls.geom_dims(dataset)
if dim in geom_dims:
return float
elif len(dataset.data):
return type(dataset.data[dim.name].iloc[0])
else:
return float
ds = dataset.clone(arr, datatype=cls.subtypes, vdims=[])
return ds.interface.dimension_type(ds, dim)

@classmethod
def isscalar(cls, dataset, dim, per_geom=False):
Expand Down