I am writing a generic script that would calculate areas covered by different classes in a categorical raster in R. I would like to provide two functions; one for use when the CRS of the raster is geographic (long, lat), and one to use when the CRS is projected.

Is there a way I can check that?

I imagine there is a property of the CRS string I'd check in an if() statement for that

  • Pyproj has a function proj.crs.is_geographic for that purpose, perhaps you can find something similar.
    – user30184
    Commented Oct 15, 2021 at 8:43

1 Answer 1


The raster package has a function isLonLat for this purpose. Analogous for vector data, there is the st_is_longlat function from sf.

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.