-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question on adding wkt<- to set CRS of a Spatial* object (get more consistent R code) #91
Comments
Update: here I am wrong in my words:
> proj4string(meuse.xy) <- wkt(crs_rdh)
Error in CRS(value) :
PROJ4 argument-value pairs must begin with +: PROJCRS["Amersfoort / RD New",
BASEGEOGCRS["Amersfoort",
DATUM["Amersfoort",
ELLIPSOID["Bessel 1841",6377397.155,299.1528128,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4289]],
CONVERSION["RD New",
METHOD["Oblique Stereographic",
ID["EPSG",9809]],
PARAMETER["Latitude of natural origin",52.1561605555556,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8801]],
PARAMETER["Longitude of natural origin",5.38763888888889,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8802]],
PARAMETER["Scale factor at natural origin",0.9999079,
SCALEUNIT["unity",1],
ID["EPSG",8805]],
PARAMETER["False easting",155000,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["Fa I think the error demonstrates that > comment(crs_rdh)
[1] "PROJCRS[\"Amersfoort / RD New\",\n BASEGEOGCRS[\"Amersfoort\",\n DATUM[\"Amersfoort\",\n ELLIPSOID[\"Bessel 1841\",6377397.155,299.1528128,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4289]],\n CONVERSION[\"RD New\",\n METHOD[\"Oblique Stereographic\",\n ID[\"EPSG\",9809]],\n PARAMETER[\"Latitude of natural origin\",52.1561605555556,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8801]],\n PARAMETER[\"Longitude of natural origin\",5.38763888888889,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8802]],\n PARAMETER[\"Scale factor at natural origin\",0.9999079,\n SCALEUNIT[\"unity\",1],\n ID[\"EPSG\",8805]],\n PARAMETER[\"False easting\",155000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8806]],\n PARAMETER[\"False northing\",463000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8807]],\n ID[\"EPSG\",19914]],\n CS[Cartesian,2],\n AXIS[\"(E)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1,\n ID[\"EPSG\",9001]]],\n AXIS[\"(N)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1,\n ID[\"EPSG\",9001]]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"Netherlands - onshore\"],\n BBOX[50.75,3.2,53.7,7.22]]]" And I understand that wkt(meuse.xy)
comment(meuse.xy@proj4string) Then, is a |
I think the following could be a more general solution than adding
Essentially, 'proj4string' is masked here. The above could be promoted After all, my main point was to avoid referencing the term 'proj4string' in R code, not necessarily to have 'wkt' equivalents in function and argument names. And the input for |
Only and always use |
Thank you for explaining. I'm trying to look at it from a user's perspective.
Still I think slot creation (or checking for its existence) and subsequent CRS assignment would best be taken care of by a simple replacement function, which does not require the user to know about the |
I'll continue to look at this, but in general users now should instantiate |
This is about avoiding the use of proj4strings in R code, in the light of changes in PROJ/GDAL and spatial R packages. I understand that WKT2 strings are preferred and proj4strings to be avoided.
We 'had' (and of course still have) the
proj4string()
/proj4string<-
approach of getting and setting a CRS by using the (by PROJ>=6 less/un-) supported PROJ.4 string. They work with WKT2 strings as well [not really, see next message].I think it would still be nicer if the current
wkt()
function to get an object's CRS as WKT2, could also be extended to set the CRS of a Spatial object, by usingwkt<-
(currently not possible). I believe that would result in more consistent code. Now one still has to 'mix'proj4string<-
andwkt()
in R code (forsp
). Or maybe, I am missing something 😉 .Created on 2020-09-16 by the reprex package (v0.3.0)
Session info
The text was updated successfully, but these errors were encountered: