I had a shapefile which I converted to a geodataframe, and created a geometry column. I did some manipulation with it in pandas. I am now trying to convert it back into a geodataframe and eventually a shapefile but cannot make it work. I have tried the usual methods:
import pandas as pd import geopandas as gpd df = pd.read_csv('DirectMail.csv') df = gpd.GeoDataFrame(df, geometry='GEOMETRY__C')
and get the following error. This is the first row in the dataframe by the way:
TypeError: Input must be valid geometry objects: MULTIPOLYGON (((1241887.500623662 949342.9993114918, 1241827.375743911...
After looking at other Stack Overflow threads I tried this way using shapely wkt
import pandas as pd import geopandas as gpd from shapely import wkt df = pd.read_csv('DirectMail.csv') df['GEOMETRY__C'] = df['GEOMETRY__C'].apply(wkt.loads)
and I get this error:
WKTReadingError: Could not create geometry because of errors while reading input.
If I check to see if the geometries in the 'GEOMETRY__C' column are valid like this...
import geopandas as gpd import shapely as sh gdf = gpd.read_file("DirectMail.csv") gdf['validation'] = gdf['GEOMETRY__C']
I have the following result:
0 False 1 False 2 False
and so on...
This makes me wonder, is the 'GEOMETRY__C' column in the wrong data type? I checked the data type of this column and it is pandas
Does anyone have other suggestions what I can do? Do I need to changes the datatype of the geometry column?