pyproj4 / pyproj

Python interface to PROJ (cartographic projections and coordinate transformations library)
https://pyproj4.github.io/pyproj
MIT License
1.04k stars 210 forks source link

Internal Proj Error: proj_create: unrecognized format / unknown name #1369

Closed 1vcian closed 7 months ago

1vcian commented 7 months ago

Internal Proj Error: proj_create: unrecognized format / unknown name

I am using geopandas and i can't read a file with the mask options, i get a crs error

gpd.read_file(url,mask=maschera)

Error:

Traceback (most recent call last):
  File "C:\Users\\\\\testRiproietta&Snap.py", line 96, in <module>
    richiestaCNDS = gpd.read_file(url,mask=maschera)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\Programs\Python\Python312\Lib\site-packages\geopandas\io\file.py", line 297, in _read_file
    return _read_file_fiona(
           ^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\Programs\Python\Python312\Lib\site-packages\geopandas\io\file.py", line 362, in _read_file_fiona
    mask = mapping(mask.to_crs(crs).unary_union)
                   ^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\Programs\Python\Python312\Lib\site-packages\geopandas\geodataframe.py", line 1425, in to_crs
    geom = df.geometry.to_crs(crs=crs, epsg=epsg)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\Programs\Python\Python312\Lib\site-packages\geopandas\geoseries.py", line 1157, in to_crs
    self.values.to_crs(crs=crs, epsg=epsg), index=self.index, name=self.name
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\Programs\Python\Python312\Lib\site-packages\geopandas\array.py", line 860, in to_crs
    crs = CRS.from_user_input(crs)
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyproj\crs\crs.py", line 501, in from_user_input
    return cls(value, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyproj\crs\crs.py", line 348, in __init__
    self._local.crs = _CRS(self.srs)
                      ^^^^^^^^^^^^^^
  File "pyproj\\_crs.pyx", line 2378, in pyproj._crs._CRS.__init__
pyproj.exceptions.CRSError: Invalid projection: : (Internal Proj Error: proj_create: unrecognized format / unknown name)

Environment Information

pyproj info:
    pyproj: 3.6.1
      PROJ: 9.3.0
  data dir: C:\Users\\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyproj\proj_dir\share\proj
user_data_dir: C:\Users\\AppData\Local/proj
PROJ DATA (recommended version): 1.15
PROJ Database: 1.2
EPSG Database: v10.094 [2023-08-08]
ESRI Database: ArcGIS Pro 3.1 [2023-19-01]
IGNF Database: 3.1.0 [2019-05-24]
System:
    python: 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]
executable: C:\Users\\AppData\Local\Programs\Python\Python312\python.exe
   machine: Windows-11-10.0.22621-SP0
Python deps:
   certifi: 2023.11.17
    Cython: None
setuptools: 69.0.3
       pip: 23.3.2
djhoese commented 7 months ago

Sorry if I missed it in the output above, but what type of file is it? Can you paste the CRS/Proj information contained in the file here? As a last resort if you can provide the URL to the file that might help but I might not have experience with the file format so if you can extra the CRS information and paste it here that'd be best.

1vcian commented 7 months ago

Sorry if I missed it in the output above, but what type of file is it? Can you paste the CRS/Proj information contained in the file here? As a last resort if you can provide the URL to the file that might help but I might not have experience with the file format so if you can extra the CRS information and paste it here that'd be best.

the file format is flatgeobuf (EPSG:32633, the mask has the same crs) my problem is that it works on another computer (both with the same virtual env)

snowman2 commented 7 months ago

This may be helpful when debugging: https://pyproj4.github.io/pyproj/stable/advanced_examples.html#debugging-internal-proj

1vcian commented 7 months ago

This may be helpful when debugging: https://pyproj4.github.io/pyproj/stable/advanced_examples.html#debugging-internal-proj it was very helpful, tyvm

from the debug i got

DEBUG:GDAL_DATA found in environment.
DEBUG:PROJ_LIB found in environment.
ERROR:PROJ: proj_create_from_database: Cannot find proj.db
DEBUG:GDAL_DATA found in environment.
DEBUG:PROJ_LIB found in environment.
DEBUG:Got coordinate system
DEBUG:Got coordinate system
DEBUG:PROJ_ERROR: proj_create: unrecognized format / unknown name
DEBUG:PROJ_ERROR: proj_create: unrecognized format / unknown name
DEBUG:Flushed buffer
DEBUG:Stopped session

proj.db was my problem

i've checked my PROJ_LIB path and iv'e seen that there were no proj.db inside so i've installed gdal with conda, found the directory of proj.db (C:\ProgramData\miniconda3\Library\share\proj) and replaced the value of PROJ_LIB with the new path.

now it works