API between Parquet files and GeoDataFrames for fast input/output of GIS data. // This project was a proof of concept. For current development please see https://github.com/geopandas/geo-arrow-spec
MIT License
24
stars
1
forks
source link
TypeError: Object of type CRS is not JSON serializable #2
I got the following error using geoparquet when converting a geodataframe into a geoparquet file:
import geopandas as gpd
import geoparquet as gpq
import os
# define filepath and read in file from shapefile or other format using geopandas
filepath = os.path.join(r'path2directory', 'shapefile.shp')
gdf = gpd.read_file(filepath)
# convert geodataframe into geoparquet file
gdf.to_geoparquet(os.path.join(r'path2directory', 'testfile.geoparquet'))
By doing that, I got the following error:
Traceback (most recent call last):
File "O:\GIS\GEP\RLS\GIS+IT\Python_Clones\JBL\envs\OpenSourceGIS_DL_Clone_Python38\lib\site-packages\IPython\core\interactiveshell.py", line 3437, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-46-1a3f800ddf02>", line 1, in <module>
testdata.to_geoparquet(os.path.join(r'O:\GIS\GEP\RLS\_Mitarbeitende\JBL2020\ABX_only\InSAR\9999_Diverses\Test', 'test3.geoparquet'))
File "O:\GIS\GEP\RLS\GIS+IT\Python_Clones\JBL\envs\OpenSourceGIS_DL_Clone_Python38\lib\site-packages\geoparquet\__init__.py", line 94, in to_geoparquet
self = _update_metadata(self, new_metadata=geometry_metadata)
File "O:\GIS\GEP\RLS\GIS+IT\Python_Clones\JBL\envs\OpenSourceGIS_DL_Clone_Python38\lib\site-packages\geoparquet\__init__.py", line 53, in _update_metadata
tbl_metadata[k] = json.dumps(v).encode('utf-8')
File "O:\GIS\GEP\RLS\GIS+IT\Python_Clones\JBL\envs\OpenSourceGIS_DL_Clone_Python38\lib\json\__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "O:\GIS\GEP\RLS\GIS+IT\Python_Clones\JBL\envs\OpenSourceGIS_DL_Clone_Python38\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "O:\GIS\GEP\RLS\GIS+IT\Python_Clones\JBL\envs\OpenSourceGIS_DL_Clone_Python38\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "O:\GIS\GEP\RLS\GIS+IT\Python_Clones\JBL\envs\OpenSourceGIS_DL_Clone_Python38\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type CRS is not JSON serializable
Debugging of the code showed a bug in the init.py file. When changing the following line, the bug can be removed:
# OLD version of line 74 in the __init__.py file
crs = self.crs
# NEW version (works fine) of line 74 in the __init__.py file
crs = self.crs.to_wkt(version='WKT2_2018')
I hope, with these information I can contribute to remove this bug.
I got the following error using geoparquet when converting a geodataframe into a geoparquet file:
By doing that, I got the following error:
Debugging of the code showed a bug in the init.py file. When changing the following line, the bug can be removed:
I hope, with these information I can contribute to remove this bug.