Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native support for geometry attribute #736

Merged
merged 5 commits into from
Feb 11, 2025
Merged

Conversation

loreabad6
Copy link
Contributor

@loreabad6 loreabad6 commented Feb 11, 2025

In loreabad6/post the function as_post_array() takes care of the data cube creation, but probably in a redundant way of what is offered by st_as_stars.data.frame(). Supporting this directly with stars, this PR passes the geometries as an array instead of as a list which was the previous behaviour.

library(stars)
date = seq(
    from = as.Date("2020-10-01"),
    to = as.Date("2020-10-05"),
    length.out = 5
)
geom = st_sample(st_bbox(c(xmin = 0, xmax = 1, ymin = 0, ymax = 1)), 25)
df = st_sf(id = rep(letters[1:5], each = 5), date = date, geom)
st_as_stars(df, dims = c("id", "date"))
#> stars object with 2 dimensions and 1 attribute
#> attribute(s):
#>      geom    
#>  POINT  :25  
#>  epsg:NA: 0  
#> dimension(s):
#>      from to     offset  delta refsys  values
#> id      1  5         NA     NA     NA a,...,e
#> date    1  5 2020-10-01 1 days   Date    NULL

@edzer edzer merged commit 6a56d85 into r-spatial:main Feb 11, 2025
7 checks passed
@edzer
Copy link
Member

edzer commented Feb 11, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants