Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-31 Thread Roger Bivand
On Tue, 31 Jan 2023, Steve Gutreuter wrote: The need to re-scale the measurement units of the coordinates may not be commonplace, but it is also not unreasonable. So, given that R rgdal is to be retired in 2023, what is the "correct" way to preserve the new units and the datum? Sorry, there

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-31 Thread Steve Gutreuter
The need to re-scale the measurement units of the coordinates may not be commonplace, but it is also not unreasonable. So, given that R rgdal is to be retired in 2023, what is the "correct" way to preserve the new units and the datum? Thanks to all,Steve On Tue, 2023-01-31 at 18:36 +0100, Andrea

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-31 Thread Andrea Gilardi
Thanks, Roger. That's not a common problem (at least for me), but it is typically useful to adjust the unit of measurement when I need to integrate sf objects with other packages (e.g. spatstat) where the numerical algorithm might benefit from rescaling. Andrea Il giorno mar 31 gen 2023 alle ore

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-31 Thread Roger Bivand
On Tue, 31 Jan 2023, Andrea Gilardi wrote: Thanks again to both of you for the suggestion and the explanation. Using: meuse1 <- st_as_sf(meuse) meuse2 <- st_transform(meuse1, sub("units=m", "units=km", st_crs(meuse1)$proj4string)) gives st_crs(meuse2) Coordinate Reference System: User

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-31 Thread Andrea Gilardi
Thanks again to both of you for the suggestion and the explanation. Kind regards Andrea Il giorno mar 31 gen 2023 alle ore 15:28 Edzer Pebesma ha scritto: > > Yes, the pipeline approach bypasses GDAL, and doesn't result in an > object with an appropriate CRS as a consequence. > > On 31/01/2023

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-31 Thread Edzer Pebesma
Yes, the pipeline approach bypasses GDAL, and doesn't result in an object with an appropriate CRS as a consequence. On 31/01/2023 14:47, Andrea Gilardi wrote: Thank you very much for your example! I briefly checked the examples reported in ?st_transform and the docs at the PROJ website around

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-31 Thread Josiah Parry
While the package interface isn't the friendliest, I think the crsuggest package may be of interest for you. It's helpful for finding an appropriate CRS in the units you need given an input CRS. https://github.com/walkerke/crsuggest I've used this to find an appropriate CRS and then transform

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-31 Thread Andrea Gilardi
Thank you very much for your example! I briefly checked the examples reported in ?st_transform and the docs at the PROJ website around "Unit conversion" (https://proj.org/operations/conversions/unitconvert.html) and I found that the following code also seems to work (although with a warning

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-31 Thread Edzer Pebesma
On 31/01/2023 12:12, Andrea Gilardi wrote: st_transform can do transformations and conversions between different CRSs, unit conversions is a special case of that. Dear all, I'm sorry if this is a trivial or stupid question but I was wondering if you could provide an example of using

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-31 Thread Andrea Gilardi
> st_transform can do transformations and conversions between different CRSs, > unit conversions is a special case of that. Dear all, I'm sorry if this is a trivial or stupid question but I was wondering if you could provide an example of using st_transform to apply a unit conversion

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-25 Thread Edzer Pebesma
On 25/01/2023 18:42, Josiah Parry wrote: I wonder if `units::set_units()` is a better fit for the job https://r-quantities.github.io/units/articles/measurement_units_in_R.html It could definitely tell you which number to choose when going from, say, US feet to km. Coordinates in sf

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-25 Thread Edzer Pebesma
I guess the question is: "safe for what?" - if numerical errors are a problem without rescaling, then you should do it. You might be able to choose the rescaling factor such that these errors are minimized. On 25/01/2023 18:37, Steve Gutreuter wrote: Is it safe to re-scale sf geometry

Re: [R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-25 Thread Josiah Parry
I wonder if `units::set_units()` is a better fit for the job https://r-quantities.github.io/units/articles/measurement_units_in_R.html On Wed, Jan 25, 2023 at 12:37 PM Steve Gutreuter wrote: > Is it safe to re-scale sf geometry coordinates from meters to > kilometers using, for example: > >

[R-sig-Geo] Re-scale units of coordinates in sf geometry?

2023-01-25 Thread Steve Gutreuter
Is it safe to re-scale sf geometry coordinates from meters to kilometers using, for example: sfobj$geometry <- sfobj$geometry / 1000 It seems to work, but I understand too little about spatial data to know whether that practice is actually safe. I am working with spatial data in a