2

I have pandas dataframew ith two fields: ID and geometry (geometry is already in WKT). I want to change this dataframe into geodataframe so I can save it as shapefile.

I have tried to change it into geodataframe in the followong way:


covex = gdf(covex, crs="EPSG:4326", geometry='geometry')
covex.to_file("covex.shp")

that didn't work and I got this error message:

TypeError: 'GeoDataFrame' object is not callable

covex = gdf(covex, crs="EPSG:4326", geometry=covex.iloc[:,1])
covex.to_file("covex.shp")

but I got the same error messege.

What do I do wrong? I thought I should pass the geoemtry column there but seems like it should be somethng else. how can I change this into geodataframe and then to shapefile?

2
  • can you provide more on what gdf function is? or how your pandas convex look like by giving the result of convex.head(5)?
    – sutan
    Commented Sep 2, 2020 at 12:36
  • Please review this answer: gis.stackexchange.com/a/364355/29431 Commented Sep 2, 2020 at 14:00

1 Answer 1

4

I think you are missing a function there(gdf.GeoDataFrame), I'm assuming you are importing geopandas as gdf.

here is a link to the documentation for creating GeoDataFrames, although I don't see anything about using a df to create, but I can't imagine it wouldn't work https://geopandas.org/reference/geopandas.GeoDataFrame.html https://geopandas.org/reference.html#geodataframe

import geopandas as gdf

# Thish should create a new dataframe
covex = gdf.GeoDataFrame(covex, crs="EPSG:4326", geometry=covex.iloc[:,1])
covex.to_file("covex.shp")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.