I need to use the GeoDataFrame.to_crs("EPSG:4326",inplace=True) function to convert my vector layer to the WGS84 coordinate system.
My code was written on Windows, but the actual runtime environment is Linux.
On Windows, I need to set the environment variable 'PROJ_LIB'.
PROJ_LIB_PATH = r"D:\anaconda3\Lib\site-packages\rasterio\proj_data"
def judege_platform():
import platform
if platform.system() == "Windows":
os.environ['PROJ_LIB'] = PROJ_LIB_PATH
elif platform.system() == "Linux":
pass
But I cannot find the location of 'PROJ_LIB' on Linux.
result_gdf.to_crs("EPSG:4326",inplace=True)
However, it will raise an error on Linux.
File "/root/anaconda3/envs/dzpro/lib/python3.8/site-packages/geopandas/geodataframe.py", line 1364, in to_crs
geom = df.geometry.to_crs(crs=crs, epsg=epsg)
File "/root/anaconda3/envs/dzpro/lib/python3.8/site-packages/geopandas/geoseries.py", line 1124, in to_crs
self.values.to_crs(crs=crs, epsg=epsg), index=self.index, name=self.name
File "/root/anaconda3/envs/dzpro/lib/python3.8/site-packages/geopandas/array.py", line 779, in to_crs
new_data = vectorized.transform(self.data, transformer.transform)
File "/root/anaconda3/envs/dzpro/lib/python3.8/site-packages/geopandas/_vectorized.py", line 1114, in transform
new_coords_z = func(coords_z[:, 0], coords_z[:, 1], coords_z[:, 2])
File "/root/anaconda3/envs/dzpro/lib/python3.8/site-packages/pyproj/transformer.py", line 430, in transform
self._transformer._transform(
File "pyproj/_transformer.pyx", line 459, in pyproj._transformer._Transformer._transform
pyproj.exceptions.ProjError: x, y, z, and time must be same size
I have also set the 'PROJ_LIB' environment variable on the Linux platform.
def judege_platform():
import platform
if platform.system() == "Windows":
os.environ['PROJ_LIB'] = PROJ_LIB_PATH
elif platform.system() == "Linux":
os.environ['PROJ_LIB'] ='/root/anaconda3/lib/python3.8/site-packages/rasterio/proj_data'
However, this is not useful.
dzpro
conda env -os.environ["PROJ_LIB"]=os.path.join(os.environ["CONDA_PREFIX"], "share/proj")