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
fionais 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_fileasgpd.read_file(file, encoding="utf-8"). I don't thinkfile.encodewill work on shapefile with multiple input files. See also https://stackoverflow.com/questions/48305400/cant-open-shape-file-with-geopandas – martinfleis Apr 23 '21 at 08:46