8

Can one tell that from the number of digits or a similar rule?

1

2 Answers 2

10

You can use PyCRS library.

import pycrs

crs3857 = pycrs.parse.from_epsg_code(3857)
print("EPSG:3857 is " + crs3857.cs_type)

crs4326 = pycrs.parse.from_epsg_code(4326)
print("EPSG:4326 is " + crs4326.cs_type)

Output:

EPSG:3857 is Projected
EPSG:4326 is Geographic

You can also use isinstance method of Python with PyCRS:

isinstance(crs3857, pycrs.ProjCS)
# True

isinstance(crs4326, pycrs.GeogCS)
# True
2
  • Worked fine for me thanks!. But the 'pycrs.parse.from_epsg_code' part takes soo long for me (at least 2 minutes). Is there a faster solution?
    – David
    Commented Feb 4, 2021 at 14:07
  • @David Maybe it is related to your internet connection or epsg.io. When using EPSG code, the package uses epsg.io. Commented Feb 4, 2021 at 18:05
4

The best way, I guess, is to use pyproj itself.

from pyproj import CRS

crs3857 = CRS(3857) # Web Mercator
crs4326 = CRS(4326) # WGS84

crs3857.is_projected  # True
crs3857.is_geographic # False

crs4326.is_projected  # False
crs4326.is_geographic # True

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.