Closed tahentx closed 9 months ago
Also, when I load my geodataframe, I get a fiona error on the "fread" method that indicates an issue loading the .dbf file. It might be related.
This is now fixed in version 2.0.2. Thank you for bringing it to our attention!
Hi,
My intention is to disaggregate precincts to blocks. The traceback I receive below indicates an attribute error at the geopandas layer, which is being called from maup's assign method. Please advise.
`--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/geopandas/geodataframe.py in crs(self) 436 try: --> 437 return self.geometry.crs 438 except AttributeError:
14 frames /usr/local/lib/python3.10/dist-packages/pandas/core/generic.py in getattr(self, name) 6292 return self[name] -> 6293 return object.getattribute(self, name) 6294
/usr/local/lib/python3.10/dist-packages/geopandas/geodataframe.py in _get_geometry(self) 235 --> 236 raise AttributeError(msg) 237 return self[self._geometry_column_name]
AttributeError: You are calling a geospatial method on the GeoDataFrame, but the active geometry column to use has not been set. There are columns with geometry data type (['geometry']), and you can either set one as the active geometry with df.set_geometry("name") or access the column as a GeoSeries (df["name"]) and call the method directly on it.
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/pandas/core/generic.py in setattr(self, name, value) 6318 try: -> 6319 existing = getattr(self, name) 6320 if isinstance(existing, Index):
/usr/local/lib/python3.10/dist-packages/pandas/core/generic.py in getattr(self, name) 6292 return self[name] -> 6293 return object.getattribute(self, name) 6294
/usr/local/lib/python3.10/dist-packages/geopandas/geodataframe.py in crs(self) 438 except AttributeError: --> 439 raise AttributeError( 440 "The CRS attribute of a GeoDataFrame without an active "
AttributeError: The CRS attribute of a GeoDataFrame without an active geometry column is not defined. Use GeoDataFrame.set_geometry to set the active geometry column.
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last) in <cell line: 2>()
1 blocks = blocks.set_geometry("geometry")
----> 2 mauped_blocks = maup_precinct_to_blocks(blocks, precincts, ['G22SOSDLAF','G22SOSRALL'])
/usr/local/lib/python3.10/dist-packages/maup/crs.py in wrapped(*args, *kwargs) 12 ) 13 ) ---> 14 return f(args, **kwargs) 15 16 return wrapped
/usr/local/lib/python3.10/dist-packages/maup/assign.py in assign(sources, targets) 21 if len(unassigned): # skip if done 22 assignments_by_area = pandas.Series( ---> 23 assign_by_area(unassigned, targets), 24 dtype="float" 25 )
/usr/local/lib/python3.10/dist-packages/maup/assign.py in assign_by_area(sources, targets) 36 37 def assign_by_area(sources, targets): ---> 38 return assign_to_max(intersections(sources, targets, area_cutoff=0).area) 39 40
/usr/local/lib/python3.10/dist-packages/maup/crs.py in wrapped(*args, *kwargs) 12 ) 13 ) ---> 14 return f(args, **kwargs) 15 16 return wrapped
/usr/local/lib/python3.10/dist-packages/maup/intersections.py in intersections(sources, targets, output_type, area_cutoff) 40 df = GeoDataFrame.from_records(records, columns=["source", "target", "geometry"]) 41 df = df.sort_values(by=["source", "target"]).reset_index(drop=True) ---> 42 df.crs = sources.crs 43 44 geometries = df.set_index(["source", "target"]).geometry
/usr/local/lib/python3.10/dist-packages/geopandas/geodataframe.py in setattr(self, attr, val) 204 object.setattr(self, attr, val) 205 else: --> 206 super().setattr(attr, val) 207 208 def _get_geometry(self):
/usr/local/lib/python3.10/dist-packages/pandas/core/generic.py in setattr(self, name, value) 6333 stacklevel=find_stack_level(), 6334 ) -> 6335 object.setattr(self, name, value) 6336 6337 @final
/usr/local/lib/python3.10/dist-packages/geopandas/geodataframe.py in crs(self, value) 447 """Sets the value of the crs""" 448 if self._geometry_column_name is None: --> 449 raise ValueError( 450 "Assigning CRS to a GeoDataFrame without a geometry column is not " 451 "supported. Use GeoDataFrame.set_geometry to set the active "
ValueError: Assigning CRS to a GeoDataFrame without a geometry column is not supported. Use GeoDataFrame.set_geometry to set the active geometry column.`