Skip to main content
2 of 5
added 5 characters in body
Losbaltica
  • 1.5k
  • 1
  • 10
  • 29

Geopanda write GeoDataFrame into shapefile or spatialite

I trying to save file from GeoDataFrame to shapefile or spatialite. But for some reason i got error:

Error

My GeoDataFrame appear correctly without any issuesi look's like there is something wrong with my gdf.to_file commend but i have no idea what. I also checked if i got most up to date lib.

def writeIntoDatabase(fd, pts, clearance_zone_max):
    
    print ('Reading data into shp')
    df = pd.DataFrame(pts)
    dfthresh = df.loc[df[3] < clearance_zone_max]
    geometry = [Point(xyz) for xyz in zip(dfthresh[0], dfthresh[1], dfthresh[2])]
    #df = df.drop(['Lon', 'Lat', 'Alt'], axis=1)

    print(geometry)    

    crs = {'init': 'epsg:27700'}

    gdf = GeoDataFrame(dfthresh, crs=crs, geometry = geometry)
    print (gdf)


    gdf.to_file(driver = 'ESRI Shapefile', filename = fd)

Can you help me?

Losbaltica
  • 1.5k
  • 1
  • 10
  • 29