paleolimbot / geos

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

as_geos_geometry() method for sfg objects #82

Closed JosiahParry closed 1 year ago

JosiahParry commented 1 year ago

Title says it all. I like to subset sfc objects and pass them into geos. I will always use [[ for subsetting, get the error no applicable method for 'as_geos_geometry' applied to an object of class "c('XY', 'POLYGON', 'sfg')", remove a level of brackets and do it again.

I suggest the following implementation.

as_geos_geometry.sfg <- function(x) {
  geos_read_wkb(list(sf::st_as_binary(x)), crs = NA)
}

I'd make a PR but I can't find the source code for the sf methods!

JosiahParry commented 1 year ago

@davilaaDEV Hm?

JosiahParry commented 1 year ago

I've updated my version of geos and all is well! It appears that the default method now handles this and delegates the work out to {wk}. It has a method for sfc but not sfg. The magic continues