@@ -55,12 +55,7 @@ class _Frame(dd.core._Frame, OperatorMethodMixin):
5555
5656 def __init__ (self , dsk , name , meta , divisions , spatial_partitions = None ):
5757 super ().__init__ (dsk , name , meta , divisions )
58- if spatial_partitions is not None and not isinstance (
59- spatial_partitions , geopandas .GeoSeries
60- ):
61- spatial_partitions = geopandas .GeoSeries (spatial_partitions )
62- # TODO make this a property
63- self .spatial_partitions = spatial_partitions
58+ self ._spatial_partitions = spatial_partitions
6459
6560 def to_dask_dataframe (self ):
6661 """Create a dask.dataframe object from a dask_geopandas object"""
@@ -72,6 +67,28 @@ def __dask_postcompute__(self):
7267 def __dask_postpersist__ (self ):
7368 return type (self ), (self ._name , self ._meta , self .divisions )
7469
70+ @property
71+ def spatial_partitions (self ):
72+ """
73+ The spatial extent of each of the partitions of the dask GeoDataFrame.
74+ """
75+ return self ._spatial_partitions
76+
77+ @spatial_partitions .setter
78+ def spatial_partitions (self , value ):
79+ if value is not None :
80+ if not isinstance (value , geopandas .GeoSeries ):
81+ raise TypeError (
82+ "Expected a geopandas.GeoSeries for the spatial_partitions, "
83+ f"got { type (value )} instead."
84+ )
85+ if len (value ) != self .npartitions :
86+ raise ValueError (
87+ f"Expected spatial partitions of length { self .npartitions } , "
88+ f"got { len (value )} instead."
89+ )
90+ self ._spatial_partitions = value
91+
7592 @classmethod
7693 def _bind_property (cls , attr , preserve_spatial_partitions = False ):
7794 """Map property to partitions and bind to class"""
0 commit comments