Open rokoeh opened 3 months ago
Dear @rokoeh,
The issue you're encountering stems from missing arguments in the t_intersects()
and s_intersects()
functions. It appears that the tutorial inadvertently omitted these parameters, likely due to the requirement of double curly braces ({{...}}
) to properly reference the variables time_range
and ashe
.
Here is the corrected example:
library(sf)
library(rstac)
ashe <- sf::read_sf(system.file("shape/nc.shp", package = "sf"))[1, ]
time_range <- rstac::cql2_interval("2021-01-01", "2021-01-31")
rstac::stac("https://planetarycomputer.microsoft.com/api/stac/v1") |>
rstac::ext_filter(
collection == "landsat-c2-l2" &&
t_intersects(datetime, {{time_range}}) &&
s_intersects(geometry, {{ashe}})
) |>
rstac::post_request()
CQL2 utilizes non-evaluated expressions to construct complex queries using R syntax. Without the double curly braces, the names provided will be interpreted as feature properties. For example, using t_intersects(datetime, time_range)
would still be syntactically correct, but it will not return any results because time_range
will be interpreted as NULL
inside the items, as it does not exist as a property. To refer to the variable time_range
, you need to escape the expression by enclosing it within double curly braces {{...}}
.
Using double curly braces ensures that the actual variables time_range
and ashe
are correctly passed to the functions t_intersects
and s_intersects
.
Please let us know if you have any further questions or issues.
Best regards, Rolf
I was following along the code in https://stacspec.org/en/tutorials/2-using-rstac-and-cql2-to-query-stac-api/ and it seems that this part is not running:
Not sure I'm doing something wrong or if it is a bug
Complete code :