I have tabular data with columns longitude
, latitude
, time
, and intensity
, like so:
library(lubridate)
## mock example data
ex <- tibble(longitude = 1:10,
latitude = 10:1,
date = today() : (today() + 9),
intensity = rnorm(10))
In reality, it is a collection of ~ 230 compressed tab-separated text files, 10 MB each, in the above format.
I am trying to go from this tabular representation (e.g. reading this data with readr::read_tsv()
) to a stars
object (eventually/ideally a stars_proxy
object, given the data size).
One thing I've considered is converting to an st
object first:
star1 <- ex %>%
st_as_sf(coords = c("longitude", "latitude"),
crs = 4326) %>%
st_as_stars()
but this creates a stars
object with only one dimension
, which is a geometry. Since I have a point geometry, I'd rather have this as x
and y
dimensions in the 4326 (WGS84) CRS, and I'd like time
to be a dimension. I can coerce the dimension (I think), with:
star2 <- st_set_dimensions(star1, 1, star1$date, "date")
though I still see only 1 listed dimension:
star2
stars object with 1 dimensions and 2 attributes
attribute(s):
date intensity
Min. :18332 Min. :-1.3239
1st Qu.:18334 1st Qu.:-0.9127
Median :18336 Median :-0.1671
Mean :18336 Mean :-0.1405
3rd Qu.:18339 3rd Qu.: 0.4975
Max. :18341 Max. : 1.0076
dimension(s):
from to offset delta refsys point values
geometry 1 10 18332 1 NA date NULL
So, given data in this tabular format, how do I generate a proper a stars
object (ideally stars_proxy
object), with proper x,y, and time dimension
attributes?