Skip to main content
added 21 characters in body; edited tags; edited title
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

Geopanda write AttributeError "'int' object has no attribute 'encode'" when writing GeoDataFrame into shapefile or spatialite with GeoPandas

I am trying to save a GeoDataFrame as a shapefile or spatialite, but for some reason, I get this error:

File "fiona\ogrext.pyx", line 951, in fiona.ogrext.WritingSession.start (fiona/ogrext.c:16479) AttributeError: 'int' object has no attribute 'encode'

My GeoDataFrame appears correctly without any issues, look's like there is something wrong with my gdf.to_file command, but I have no idea what.

I checked if I have the most up to date-to-date libraries.

This is the code I use:

def writeIntoDatabase(input_path, numpy_point_array, 30):
    
    print ('Reading data into shp')
    df = pd.DataFrame(numpy_point_array)
    dfthresh = df.loc[df[3] < 30]
    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 = input_path)
def writeIntoDatabase(input_path, numpy_point_array, 30):
    
    print ('Reading data into shp')
    df = pd.DataFrame(numpy_point_array)
    dfthresh = df.loc[df[3] < 30]
    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 = input_path)

Can you help me?

Geopanda write GeoDataFrame into shapefile or spatialite

I am trying to save a GeoDataFrame as a shapefile or spatialite, but for some reason I get this error:

File "fiona\ogrext.pyx", line 951, in fiona.ogrext.WritingSession.start (fiona/ogrext.c:16479) AttributeError: 'int' object has no attribute 'encode'

My GeoDataFrame appears correctly without any issues, look's like there is something wrong with my gdf.to_file command, but I have no idea what.

I checked if I have the most up to date libraries.

This is the code I use:

def writeIntoDatabase(input_path, numpy_point_array, 30):
    
    print ('Reading data into shp')
    df = pd.DataFrame(numpy_point_array)
    dfthresh = df.loc[df[3] < 30]
    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 = input_path)

Can you help me?

AttributeError "'int' object has no attribute 'encode'" when writing GeoDataFrame into shapefile or spatialite with GeoPandas

I am trying to save a GeoDataFrame as a shapefile or spatialite, but for some reason, I get this error:

File "fiona\ogrext.pyx", line 951, in fiona.ogrext.WritingSession.start (fiona/ogrext.c:16479) AttributeError: 'int' object has no attribute 'encode'

My GeoDataFrame appears correctly without any issues, look's like there is something wrong with my gdf.to_file command, but I have no idea what.

I checked if I have the most up-to-date libraries.

This is the code I use:

def writeIntoDatabase(input_path, numpy_point_array, 30):
    
    print ('Reading data into shp')
    df = pd.DataFrame(numpy_point_array)
    dfthresh = df.loc[df[3] < 30]
    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 = input_path)

Can you help me?

I am trying to save file froma GeoDataFrame toas a shapefile or spatialite. But, but for some reason i gotI get this error:

Error

File "fiona\ogrext.pyx", line 951, in fiona.ogrext.WritingSession.start (fiona/ogrext.c:16479) AttributeError: 'int' object has no attribute 'encode'

My GeoDataFrame appearappears correctly without any issuesiissues, look's like there is something wrong with my gdf.to_file commendgdf.to_file command, but iI have no idea what. I also

I checked if i gotI have the most up to date liblibraries.

This is the code I use:

def writeIntoDatabase(input_path, numpy_point_array, 30):
    
    print ('Reading data into shp')
    df = pd.DataFrame(numpy_point_array)
    dfthresh = df.loc[df[3] < 30]
    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 = input_path)

Can you help me?

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(input_path, numpy_point_array, 30):
    
    print ('Reading data into shp')
    df = pd.DataFrame(numpy_point_array)
    dfthresh = df.loc[df[3] < 30]
    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 = input_path)

Can you help me?

I am trying to save a GeoDataFrame as a shapefile or spatialite, but for some reason I get this error:

File "fiona\ogrext.pyx", line 951, in fiona.ogrext.WritingSession.start (fiona/ogrext.c:16479) AttributeError: 'int' object has no attribute 'encode'

My GeoDataFrame appears correctly without any issues, look's like there is something wrong with my gdf.to_file command, but I have no idea what.

I checked if I have the most up to date libraries.

This is the code I use:

def writeIntoDatabase(input_path, numpy_point_array, 30):
    
    print ('Reading data into shp')
    df = pd.DataFrame(numpy_point_array)
    dfthresh = df.loc[df[3] < 30]
    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 = input_path)

Can you help me?

Tweeted twitter.com/StackGIS/status/1367852415140179978
added 12 characters in body
Source Link
Losbaltica
  • 1.5k
  • 1
  • 10
  • 29

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(fdinput_path, ptsnumpy_point_array, clearance_zone_max30):
    
    print ('Reading data into shp')
    df = pd.DataFrame(ptsnumpy_point_array)
    dfthresh = df.loc[df[3] < clearance_zone_max]30]
    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 = fdinput_path)

Can you help me?

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?

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(input_path, numpy_point_array, 30):
    
    print ('Reading data into shp')
    df = pd.DataFrame(numpy_point_array)
    dfthresh = df.loc[df[3] < 30]
    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 = input_path)

Can you help me?

added 5 characters in body
Source Link
Losbaltica
  • 1.5k
  • 1
  • 10
  • 29
Loading
Source Link
Losbaltica
  • 1.5k
  • 1
  • 10
  • 29
Loading