I have geodataframe that has two geometry fields. I'm trying to set new CRS but every time I get the next error message:
AttributeError: 'NoneType' object has no attribute 'is_empty'
when I am able to check the original CRS of the layer:
print('original crs is:',tost.crs)
>>>original crs is: EPSG:4326
but then when I try to set new CRS to the copy:
tast = tost.copy()
tast= tast.to_crs({'init': 'epsg:3857'})
print('projected the copy df to:',tast.crs)
>>>AttributeError: 'NoneType' object has no attribute 'is_empty'
I don't understand why is this hapenning. What cause this error? My goal here is to be able to set the crs
.to_crs(epsg=3857)
None
exists in thegeometry
column, like this>>> True if None in tost.geometry else False
. if this returns True, then there is aNone
in the geometry column, you should drop the row. or filter the none like thistast = tost[tost.geometry != None]
, then you can dotast.to_crs(epsg=3857)