paleolimbot / geos

Open Source Geometry Engine ('GEOS') R API
https://paleolimbot.github.io/geos/
Other
61 stars 8 forks source link

Cannot find how to change the CRS of a GEOS geometry #81

Open oliviermeslin opened 1 year ago

oliviermeslin commented 1 year ago

Hi, I'm looking for the GEOS equivalent of sf::st_transform, because I want to change the CRS of a GEOS geometry in the package (from 2154 to 4326). I looked carefully in the list of functions but couldn't find it. Am I missing or misunderstanding something?

Thanks for developing this very useful package, it really helped me in my current project (along with wk and ggspatial)!

paleolimbot commented 1 year ago

You're welcome!

GEOS doesn't do coordinate transformations...you will need sf to do that for you because it contains a copy of GDAL and PROJ which provide the infrastructure for that. I had some early experiments to provide that infrastructure in a lighter way; however, none of them made it to CRAN. sf::st_transform() is your best bet for now! See also sf::sf_project() which is a lighter version that works better for points.

oliviermeslin commented 1 year ago

Thanks a lot for your very fast answer!

mdsumner commented 1 year ago

do we have a generalized round-trip, though? sfheaders had the beginning of something like

df <- sf_to_df(x)
df <- <do something here, like sf::project(df[c("x", "y")], to = <target>, from = wk::wk_crs(x))>
x <- df_restore_what_x_was(df)

that would be so sweet, and enable a whole lot of workflows now that wk handles so many types. This is just a OTOH thought, I'll actually have a look into it (it's not too hard, and could have a syntax like wk_coords(x) <- do_stuff(wk_coords(x), args...).