The ValueError: Invalid field type is caused at the last line of this code: fs.to_file(out,encoding='iso8859_7')
Full code:
q=gpd.read_file(fname + "\ASTENOT\simplify_centerline.shp",encoding='utf-8')
q.reset_index(inplace=True)
final = pd.merge(df, q, on=['FID_buffer'], how='inner')
#Turn it to geodataframe so it can be exported to shp
fs=gpd.GeoDataFrame(final, geometry='geometry')
o = fname + "\ASTENOT"
out = o + '\\simplify2.shp'
fs.to_file(out,encoding='iso8859_7')
After printing the data frame, one of the columns has be turned to this b'\xc5\
kind of characters. Apparently this is causing the error but I don't know how to fix it. Probably encoding issue? Tried many ways but no results.
How can this be corrected?
Best Answer
Solved it.
It needed a different encoding than
utf-8
. I put theiso8859_7
when reading the file and it worked, the letters look normal and it completed the script as intended.