[R-sig-Geo] Migrating from proj strings to WKT/EPSG
Diego Hernangómez Herrero
d|ego@hern@ngomezherrero @end|ng |rom gm@||@com
Mon Nov 22 20:51:02 CET 2021
Hi Ben:
I don't know if this is relevant for your question, but you can use
proj4strings with sf::st_crs() without using rgdal:
``` r
proj <- "+proj=tmerc +datum=NAD83 +lon_0=-70d10 lat_0=42d50
k=.9999666666666667 x_0=900000 y_0=0"
sf::st_crs(proj)
#> Coordinate Reference System:
#> User input: +proj=tmerc +datum=NAD83 +lon_0=-70d10 lat_0=42d50
k=.9999666666666667 x_0=900000 y_0=0
#> wkt:
#> PROJCRS["unknown",
#> BASEGEOGCRS["unknown",
#> DATUM["North American Datum 1983",
#> ELLIPSOID["GRS 1980",6378137,298.257222101,
#> LENGTHUNIT["metre",1]],
#> ID["EPSG",6269]],
#> PRIMEM["Greenwich",0,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8901]]],
#> CONVERSION["unknown",
#> METHOD["Transverse Mercator",
#> ID["EPSG",9807]],
#> PARAMETER["Latitude of natural origin",42.8333333333333,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8801]],
#> PARAMETER["Longitude of natural origin",-70.1666666666667,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8802]],
#> PARAMETER["Scale factor at natural origin",0.999966666666667,
#> SCALEUNIT["unity",1],
#> ID["EPSG",8805]],
#> PARAMETER["False easting",900000,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8806]],
#> PARAMETER["False northing",0,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8807]]],
#> CS[Cartesian,2],
#> AXIS["(E)",east,
#> ORDER[1],
#> LENGTHUNIT["metre",1,
#> ID["EPSG",9001]]],
#> AXIS["(N)",north,
#> ORDER[2],
#> LENGTHUNIT["metre",1,
#> ID["EPSG",9001]]]]
```
El lun, 22 nov 2021 a las 20:11, Ben Tupper (<btupper using bigelow.org>)
escribió:
> Hello,
>
> I have a spatial mesh that provides the following CRS.
>
> proj <- "proj=tmerc +datum=NAD83 +lon_0=-70d10 lat_0=42d50
> k=.9999666666666667 x_0=900000 y_0=0"
>
> To use this with the sf package it must be formed as Well Known Text
> or a EPSG code. In this particular case there is no EPSG code in the
> registry.
>
> My current workflow so I can use this data in sf is to leverage
> showWKT() from the rgdal package to cast the proj string to WKT. The
> following message is printed when the packages is loaded.
>
> > Please note that rgdal will be retired by the end of 2023, plan
> transition to sf/stars/terra functions using GDAL and PROJ at your earliest
> convenience.
>
>
> rgdal::showWKT(proj) |> sf::st_crs(wkt)
>
> #> Coordinate Reference System:
> #> User input:
>
> PROJCS["unknown",GEOGCS["unknown",DATUM["North_American_Datum_1983",SPHEROID["GRS
>
> 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",42.8333333333333],PARAMETER["central_meridian",-70.1666666666667],PARAMETER["scale_factor",0.999966666666667],PARAMETER["false_easting",900000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH]]
> #> wkt:
> #> PROJCRS["unknown",
> #> BASEGEOGCRS["unknown",
> #> DATUM["North American Datum 1983",
> #> ELLIPSOID["GRS 1980",6378137,298.257222101,
> #> LENGTHUNIT["metre",1]],
> #> ID["EPSG",6269]],
> #> PRIMEM["Greenwich",0,
> #> ANGLEUNIT["degree",0.0174532925199433],
> #> ID["EPSG",8901]]],
> #> CONVERSION["unnamed",
> #> METHOD["Transverse Mercator",
> #> ID["EPSG",9807]],
> #> PARAMETER["Latitude of natural origin",42.8333333333333,
> #> ANGLEUNIT["degree",0.0174532925199433],
> #> ID["EPSG",8801]],
> #> PARAMETER["Longitude of natural origin",-70.1666666666667,
> #> ANGLEUNIT["degree",0.0174532925199433],
> #> ID["EPSG",8802]],
> #> PARAMETER["Scale factor at natural origin",0.999966666666667,
> #> SCALEUNIT["unity",1],
> #> ID["EPSG",8805]],
> #> PARAMETER["False easting",900000,
> #> LENGTHUNIT["metre",1],
> #> ID["EPSG",8806]],
> #> PARAMETER["False northing",0,
> #> LENGTHUNIT["metre",1],
> #> ID["EPSG",8807]]],
> #> CS[Cartesian,2],
> #> AXIS["easting",east,
> #> ORDER[1],
> #> LENGTHUNIT["metre",1,
> #> ID["EPSG",9001]]],
> #> AXIS["northing",north,
> #> ORDER[2],
> #> LENGTHUNIT["metre",1,
> #> ID["EPSG",9001]]]]
>
> In the spirit of not leaving things to the last minute (that's never
> happened before!), what are the current options for converting proj
> strings to WKT that don’t use rgdal?
>
> Cheers and thanks,
> Ben
>
> --
> Ben Tupper (he/him)
> Bigelow Laboratory for Ocean Science
> East Boothbay, Maine
> http://www.bigelow.org/
> https://eco.bigelow.org
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Have a nice day!
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list