You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a better interaction between post_array and stars objects with raster data would greatly benefit the enrichment of post objects from raster information.
Currently, the majority of functions do work when giving a sf object, which is then easier to do when passing a post_table in long form, but passing a post_array would be the most intuitive way, specially if the we can work with the dimensions attribute.
Also, enabling time matching for all these functions would be a great way to perform the operations in a "spatio-temporal"-aware manner.
Dummy raster data cube (rdc)
remotes::install_github("loreabad6/stars@time-polygon")
#> Skipping install of 'stars' from a github remote, the SHA1 (f70aca5e) has not changed since last install.#> Use `force = TRUE` to force installation
library(stars)
library(sf)
library(post)
library(cubble)
library(tidyverse)
x= seq(-0.5, 1, length.out=20)
y= seq(0, 1.5, length.out=20)
s1= st_as_stars(data.frame(expand.grid(x=x, y=y), z= rnorm(400)))
s2= st_as_stars(data.frame(expand.grid(x=x, y=y), z= rnorm(400)))
s3= st_as_stars(data.frame(expand.grid(x=x, y=y), z= rnorm(400)))
s4= st_as_stars(data.frame(expand.grid(x=x, y=y), z= rnorm(400)))
s5= st_as_stars(data.frame(expand.grid(x=x, y=y), z= rnorm(400)))
rdc= c(s1,s2,s3,s4,s5, along="datetime") |>
st_set_dimensions(
"datetime",
values= unique(polygons$datetime),
) |>
st_set_crs(4326)
arr=polygons|> as_post_array()
tab=polygons|> as_post_table() |> face_temporal()
1. stars::aggregate.stars()
We can pass the polygons from the temporal face of a post_table to aggregate().stars.
The way the geometries are then organised within the array is unclear, should be looked into.
This should also work for post_array geometries.
Including time-matching already at the aggregation level might be beneficial to avoid aggregating on all the geometries as it works in st_extract()
(agg= aggregate(rdc, tab, mean, na.rm=TRUE))
#> stars object with 2 dimensions and 1 attribute#> attribute(s):#> Min. 1st Qu. Median Mean 3rd Qu. Max. NA's#> z -1.547645 -0.2601401 0.09971962 0.08011473 0.3912051 1.321302 35#> dimension(s):#> from to offset delta refsys point#> geometry 1 25 NA NA WGS 84 FALSE#> datetime 1 5 2020-10-01 1 days Date NA#> values#> geometry POLYGON ((0.5474949 0.808...,...,POLYGON ((0.4750757 0.262...#> datetime NULL
st_as_sf(agg)
#> Simple feature collection with 25 features and 5 fields#> Geometry type: POLYGON#> Dimension: XY#> Bounding box: xmin: -0.2974337 ymin: -0.00297557 xmax: 0.9730806 ymax: 1.153558#> Geodetic CRS: WGS 84#> First 10 features:#> 2020-10-01 2020-10-02 2020-10-03 2020-10-04 2020-10-05#> 1 -0.71838423 0.692081576 0.08165758 -0.70646498 -0.2634729#> 2 -0.30162972 -0.002314025 0.12940001 0.18564799 0.2301074#> 3 1.32130231 1.016536556 0.26029296 0.87806310 0.4007806#> 4 NA NA NA NA NA#> 5 -1.10219328 -0.250141796 0.24053519 0.40932174 0.2253243#> 6 -0.07874849 0.153725017 -0.43001741 0.08132226 0.2510174#> 7 0.14342283 -0.437820714 0.06228408 0.09273263 0.1770414#> 8 NA NA NA NA NA#> 9 NA NA NA NA NA#> 10 0.83302258 0.144860774 -0.02748157 0.19337529 0.6889722#> geometry#> 1 POLYGON ((0.5474949 0.80889...#> 2 POLYGON ((0.4961102 0.87283...#> 3 POLYGON ((0.5578801 0.86163...#> 4 POLYGON ((0.5652241 0.87205...#> 5 POLYGON ((0.6063791 0.83041...#> 6 POLYGON ((0.2791708 0.83373...#> 7 POLYGON ((0.3298312 0.76120...#> 8 POLYGON ((0.3796448 0.76785...#> 9 POLYGON ((0.3642467 0.77972...#> 10 POLYGON ((0.2665368 0.86499...
The text was updated successfully, but these errors were encountered:
loreabad6
changed the title
Let aggregate.stars() accept post_arrays and include time matching{stars} functions for raster data cube and post object interaction, including time matching
Sep 18, 2024
Having a better interaction between
post_array
andstars
objects with raster data would greatly benefit the enrichment of post objects from raster information.Currently, the majority of functions do work when giving a
sf
object, which is then easier to do when passing apost_table
in long form, but passing apost_array
would be the most intuitive way, specially if the we can work with the dimensions attribute.Also, enabling time matching for all these functions would be a great way to perform the operations in a "spatio-temporal"-aware manner.
Dummy raster data cube (rdc)
1.
stars::aggregate.stars()
post_table
toaggregate().stars
.post_array
geometries.st_extract()
2.
stars::st_extract()
st_extract()
for polygons is added to loreabad6/stars@time-polygonsf
, it would be good if, when passing apost_array
to theat
argument should return apost_array
with the extra attribute.Session info
The text was updated successfully, but these errors were encountered: