Open effnstfn opened 1 year ago
you could template the set of rct() coordinates pretty easily if every pixel-as-a-polygon is what you want, or do you mean polygonize with seas of values defining region polygons?
I can put together examples , but note that pixel as polygon is terribly redundant and heavy on storage - essentially every pixel value adding 10 more numeric values when you only needed six numbers to describe the scheme (extent and dimension)
I have the raster converted to points using terra::rasterToPoints() and would like to do some calculation on these points using geos
oh points, well that should be much easier sorry, use xy() - definitely do not go via sf, for POINT it puts everything in a list and has always been slow
happy to pursue example , and also I could contribute a fast raster-spec to geos workflow but I think xy() will be enough, I'd use xyFromCell or geom() and not even go through SpatVector
I see, I wasn't aware of using the wk::xy() function for geos geometries. Could you please provide an example?
once my object is in wk, do i need to convert it to geos?
the wk types and geos and sfc are interchangeable in the wk scheme👌
I'm sorry not to provide examples but I can in time, I think it's worth describing tho because I think it's easier than might be for you
sorry 'geom()' is for vector I forgot. Here's how to turn a raster centre coordinates to geos, I hope it's relevant:
library(terra)
r <- rast(volcano)
library(wk)
cell <- seq_len(ncell(r))
geos::as_geos_geometry(xy(xFromCell(r, cell), yFromCell(r, cell)))
I think @fanpageste is referring to the vect()
/geom()
structure in terra? Maybe:
x <- terra::vect(c("POINT (0 1)", "POINT (2 3)"))
df <- as.data.frame(terra::geom(x))
geos::geos_make_point(df$x, df$y)
#> <geos_geometry[2]>
#> [1] <POINT (0 1)> <POINT (2 3)>
Created on 2023-10-16 with reprex v2.0.2
there was a mix in the convo above, in the end I would do this
library(terra)
r <- rast(volcano)
library(wk)
cell <- seq_len(ncell(r))
geos::geos_make_point(xFromCell(r, cell), yFromCell(r, cell))
Hi, I work with a lot of raster data and was wondering if there was an easy way to convert objects from Terra into a Geos Geometry. I'm currently converting from Terra > sf > geos which is quite memory and computationally inefficient. Was there an easy way to convert it?