I have tabular data with columns longitude, latitude, time, and intensity, like so:


## 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) %>% 

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:

stars object with 1 dimensions and 2 attributes
     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  
         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?

  • Welcome to GIS SE. As a new user, please take the Tour, which emphasizes the importance of asking One question per Question. Please Edit your question to ask a single question.
    – Vince
    Mar 12, 2020 at 2:36
  • Thanks! I've revised my question accordingly!
    – cboettig
    Mar 12, 2020 at 4:12

1 Answer 1


Not full answer but

ex_star <- st_as_stars(ex) 

will create a stars with the first two columns from the tibble as the first two dimensions of the stars, so make sure you pass a tibble with the correct arrangement of columns. There is a dimensions argument which I honestly till now I thought that giving a number would tell st_stars to keep adding columns as dimensions but I tested it and does not seem to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.