Is your feature request related to a problem? Please describe.
I have a workflow in which I process a geopandas GeoDataFrame in order to draw a map on a dashboard. At some point, I wish to make use of datashader reduction capabilities and thus, I convert my df into a spatialpandas GeoDataFrame. My dashboard allows to set filters which can lead my GeoDataFrame to be empty, and in that case, the conversion into a spatialpandas GeoDataFrame fails:
ValueError: A spatialpandas GeoDataFrame must contain at least one spatialpandas GeometryArray column
This led me to realize that spatialpandas does not allow the instanciation of an empty DataFrame, or at least not in the way pandas and geopandas allow it:
import pandas as pd
import geopandas as gpd
import spatialpandas as spd
pd.DataFrame() # works
gpd.GeoDataFrame() # works
spd.GeoDataFrame() # fails
Describe the solution you'd like
I would like to be able to generate empty spatialpandas GeoDataFrame.
Describe alternatives you've considered
An alternative I have is to first convert into a spatialpandas GeoDataFrame, and then filter this new DataFrame. When I do it in this order, query() is able to return an empty spatialpandas GeoDataFrame if there are indeed no matching results.
This should be fairly easy to implement, the question is whether it will break anything because of the previously valid assumption that a GeoDataFrame always contains data. I'll take a look.
Is your feature request related to a problem? Please describe.
I have a workflow in which I process a
geopandas
GeoDataFrame in order to draw a map on a dashboard. At some point, I wish to make use ofdatashader
reduction capabilities and thus, I convert mydf
into aspatialpandas
GeoDataFrame. My dashboard allows to set filters which can lead my GeoDataFrame to be empty, and in that case, the conversion into aspatialpandas
GeoDataFrame fails:ValueError: A spatialpandas GeoDataFrame must contain at least one spatialpandas GeometryArray column
This led me to realize that
spatialpandas
does not allow the instanciation of an empty DataFrame, or at least not in the waypandas
andgeopandas
allow it:Describe the solution you'd like
I would like to be able to generate empty
spatialpandas
GeoDataFrame.Describe alternatives you've considered
An alternative I have is to first convert into a
spatialpandas
GeoDataFrame, and then filter this new DataFrame. When I do it in this order,query()
is able to return an emptyspatialpandas
GeoDataFrame if there are indeed no matching results.