5

I got the following GeoDataFrame taken from a CSV file and after some slincing and CRS and geometry asignment

    ctf_nom         geometry                                    id      
0   Prunus mahaleb  POINT (429125.795043319 4579664.7564311)    2616    
1   Betula pendula  POINT (425079.292045901 4585098.09043407)   940     
2   Betula pendula  POINT (425088.115045896 4585093.66943407)   940     
3   Abelia triflora POINT (429116.661043325 4579685.93743111)   2002    
4   Abies alba      POINT (428219.962044021 4587346.66843531)   797  

I've converted the geometry from a str through:

from shapely import wkt

df['geometry'] = df['geometry'].apply(wkt.loads)
df_geo = gpd.GeoDataFrame(df, geometry = 'geometry')

and asigned a crs by :

df_geo.crs = {'init' :'epsg:25831'}
df_geo.crs

when I'm trying to save again the reduced geodataframe by gdf.to_file() function it returns the following attribute error:

AttributeError: 'Series' object has no attribute 'has_z'

How can I solve this?

Rodrigo Vargas
  • 273
  • 3
  • 17

1 Answers1

0

You need to explicitly set the geometry column in the GeoDataFrame:

df_geo.set_geometry(col='geometry', inplace=True)

Taken from: https://gis.stackexchange.com/a/342635/6998

Campa
  • 4,267
  • 3
  • 37
  • 42