I'm trying to read all shapefiles in a folder using this script:
import glob
import geopandas as gpd
infolder = r'E:/folder/test_input'
shapefiles = glob.iglob(infolder+'/*.shp')
gdfs = [gpd.read_file(file) for file in shapefiles]
All of the shapefiles have Chinese/Japanese characters in their names and I am getting this error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 8: invalid start byte
It works fine with shapefiles of English names. How do I solve this issue?
EDIT: I am also getting this error:
UnboundLocalError: local variable 'crs_wkt' referenced before assignment
I'm not sure why as all shapefiles including English name ones are of the same coordinate system epsg:6668
fiona
is not able to determine the encoding of your file (and it is not UTF-8). If you know the encoding, you can pass it toread_file
asgpd.read_file(file, encoding="utf-8")
. I don't thinkfile.encode
will work on shapefile with multiple input files. See also stackoverflow.com/questions/48305400/…