Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The PROJ format for defining Coordinate Reference Systems (CRS) is becoming deprecated, as PROJ strings cannot accurately store modern datum transformations, coordinate epoch information, or complex axis order rules. However, that format is much easier and more practical for humans to type and read, and it is still often used as a legacy convenience. I, for one, use it often for centering a map projection on the mapped region, thus avoiding the distortion that occurs away from the projection center. For example, imagine I want to map New Zealand in a Lambert Azimuthal Equal-Area projection in R:
library(terra)library(geodata)nz <- gadm(country = "New Zealand", level = 0, path = tempdir())nz_prj <- project(nz, "+proj=laea")plot(nz_prj)
The map is heavily distorted, because it is far away from the center of the projection, which is 0,0 by default. With the PROJ format, we can easily set the center wherever we want, e.g.:
nz_centr <- crds(centroids(aggregate(nz)))nz_centr # 172.6104 -41.82592nz_prj <- project(nz, "+proj=laea +lat_0=-41.8 +lon_0=172.6")# (this can be further automated to avoid the hard-coding,# but I keep it like this here for simplicity) plot(nz_prj)
Much better! We now have an equal-area map of New Zealand without visibly distorting the shape, and without having to look for specific equal-area CRSs normally used over there (and again every time we need to map another region of the world). This works as long as we use the WGS84 ellipsoid rather than a local datum, as those are currently not supported when using PROJ. So, I’m still using this regularly, and apprehensive about PROJ being deprecated… If anyone knows of a non-PROJ way of easily defining user-centered projections like this, please let me know!
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
