0

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.

1
  • Assuming you've activated your dzpro conda env - os.environ["PROJ_LIB"]=os.path.join(os.environ["CONDA_PREFIX"], "share/proj")
    – user2856
    Commented Jul 10, 2023 at 3:25

1 Answer 1

0

Downgrading Shapely from 2.01 to 1.8.4 worked for me. Please refer to this link for further details https://cleanenergyfutures.insightworks.com/pages/9119.html

1
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Vince
    Commented Nov 10, 2023 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.