[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-sig-geo
Subject:    Re: [R-sig-Geo] Migrating from proj strings to WKT/EPSG
From:       Ben Tupper <btupper () bigelow ! org>
Date:       2021-11-22 21:51:12
Message-ID: CALrbzg0qY6RM4dBZjC17FuF_05uuzM+sZKmPGovhZ8pFwCP80Q () mail ! gmail ! com
[Download RAW message or body]

Doh!  Forehead slap!  How the heck did I overlook that simple
solution.  Thank you!

On Mon, Nov 22, 2021 at 2:51 PM Diego Hernangómez Herrero
<diego.hernangomezherrero@gmail.com> wrote:
> 
> 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@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"]],PR \
> > IMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTH \
> > ORITY["EPSG","9122"]]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_or \
> > igin",42.8333333333333],PARAMETER["central_meridian",-70.1666666666667],PARAMETER[ \
> > "scale_factor",0.999966666666667],PARAMETER["false_easting",900000],PARAMETER["fal \
> > se_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@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 
> 
> 
> --
> 
> 
> 
> Have a nice day!



-- 
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@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic