0

I'm using pyproj and I'd like to run an error trap on the EPSG CRS code. Specifically, if the user enters a EPSG CRS code that is not in the proj database, it would provide a Boolean flag I can check before proceeding. I currently get this message if I enter a bad EPSG CRS:

File "pyproj\_crs.pyx", line 2338, in pyproj._crs._CRS.__init__
pyproj.exceptions.CRSError: Invalid projection: epsg:000: (Internal Proj Error: proj_create: crs not found)

1 Answer 1

1
from pyproj import CRS
from pyproj.exceptions import CRSError

try:
    CRS.from_epsg(...)
    valid = True
except CRSError:
    valid = False
1
  • Worked! Thank you @snowman2
    – wg1562
    Commented Jun 5, 2020 at 13:50

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.