@@ -55,12 +55,7 @@ class _Frame(dd.core._Frame, OperatorMethodMixin):
55
55
56
56
def __init__ (self , dsk , name , meta , divisions , spatial_partitions = None ):
57
57
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
64
59
65
60
def to_dask_dataframe (self ):
66
61
"""Create a dask.dataframe object from a dask_geopandas object"""
@@ -72,6 +67,28 @@ def __dask_postcompute__(self):
72
67
def __dask_postpersist__ (self ):
73
68
return type (self ), (self ._name , self ._meta , self .divisions )
74
69
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
+
75
92
@classmethod
76
93
def _bind_property (cls , attr , preserve_spatial_partitions = False ):
77
94
"""Map property to partitions and bind to class"""
0 commit comments