# -*- coding: utf-8 -*-
"""
Created on Wed Jul 14 15:57:33 2021
@author: LESNIAM
"""
import geopandas as gpd
#import arcpy
import mapping_module1 as MM
from IPython.display import display
#from arcpy.display import display
gdf_corr = gpd.read_file('G:\Jason Ma\2022Q3 HERE shapefiles\Corridors\Old corridors\Toronto1.shp')
corridor_name = 'Toronto1'
gdf_corridor_sorted = MM.Order_the_Links(corridor_name,gdf_corr)
display(gdf_corridor_sorted)
gdf_corridor_sorted.to_file('G:\Jason Ma\2022Q3 HERE shapefiles\Corridors\Old corridors\Toronto1_done.shp')
output:
Runtime error
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "C:\Python27\ArcGIS10.8\lib\site-packages\geopandas\io\file.py", line 76, in read_file
with reader(path_or_bytes, **kwargs) as features:
File "C:\Python27\ArcGIS10.8\lib\site-packages\fiona\env.py", line 398, in wrapper
return f(*args, **kwargs)
File "C:\Python27\ArcGIS10.8\lib\site-packages\fiona\__init__.py", line 257, in open
layer=layer, enabled_drivers=enabled_drivers, **kwargs)
File "C:\Python27\ArcGIS10.8\lib\site-packages\fiona\collection.py", line 154, in __init__
self.session.start(self, **kwargs)
File "fiona\ogrext.pyx", line 466, in fiona.ogrext.Session.start
UnicodeDecodeError: 'ascii' codec can't decode byte 0x82 in position 11: ordinal not in range(128)
There unifcode error that something wrong with the range I believe , this is something new, I not sure if I change the decoding or something ? Any help and suggestion would be helpful , Thanks for the time , it worked with other shape file but not this one
I would raw-encode the string. (Python 2.7???)
r'G:\Jason Ma\2022Q3 HERE shapefiles\Corridors\Old corridors\Toronto1.shp' # -- little r in front
'G:\\Jason Ma\\2022Q3 HERE shapefiles\\Corridors\\Old corridors\\Toronto1.shp'
in any event, paths with spaces and those beginning with numbers are courting errors. Move it would be the best solutioin
You are having a text encoding issue. See geopandas.read_file -- GeoPandas 0.12.2 documentation:
Notes
The format drivers will attempt to detect the encoding of your data, but may fail. In this case, the proper encoding can be specified explicitly by using the encoding keyword parameter, e.g. encoding='utf-8'.