From ca389f46b746c230145ce0eec64e7b89a81ef261 Mon Sep 17 00:00:00 2001 From: edzer Date: Thu, 16 May 2024 21:47:03 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20r-spatia?= =?UTF-8?q?l/stars@1dbd5d246cb8764ac1ef428c69853662728a9008=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- articles/stars1.html | 105 +++++++++++++++------------ articles/stars2.html | 124 +++++++++++++++++--------------- articles/stars3.html | 31 ++++---- articles/stars4.html | 81 ++++++++++++--------- articles/stars5.html | 42 ++++++----- articles/stars7.html | 69 ++++++++++-------- articles/stars8.html | 19 ++--- pkgdown.yml | 2 +- reference/aggregate.stars-2.png | Bin 23193 -> 23080 bytes reference/print_stars.html | 2 +- reference/read_stars.html | 6 +- reference/st_cells.html | 7 +- reference/st_crop.html | 7 +- reference/st_extract.html | 2 +- reference/st_rasterize.html | 2 +- search.json | 2 +- 16 files changed, 281 insertions(+), 220 deletions(-) diff --git a/articles/stars1.html b/articles/stars1.html index f0ee8c2d..1985514b 100644 --- a/articles/stars1.html +++ b/articles/stars1.html @@ -246,8 +246,9 @@

Switching attributes to dim ## dimension(s): ## from to offset delta refsys point x/y ## x 1 349 288776 28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] -## y 1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] -merge(x.spl) +## y 1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] +
+merge(x.spl)
 ## stars object with 3 dimensions and 1 attribute
 ## attribute(s):
 ##                    Min. 1st Qu. Median     Mean 3rd Qu. Max.
@@ -265,7 +266,7 @@ 

Switching attributes to dim attribute got a default name. We can set attribute names with setNames, and dimension names and values with st_set_dimensions:

-
+
 merge(x.spl) |>
   setNames(names(x)) |> 
   st_set_dimensions(3, values = paste0("band", 1:6)) |>
@@ -293,13 +294,15 @@ 

Subsetting
+
 class(x[[1]])
-## [1] "array"
-dim(x[[1]])
+## [1] "array"
+
+dim(x[[1]])
 ##    x    y band 
-##  349  352    6
-x$two = 2 * x[[1]]
+##  349  352    6
+
+x$two = 2 * x[[1]]
 x
 ## stars object with 3 dimensions and 2 attributes
 ## attribute(s):
@@ -321,7 +324,7 @@ 

Subsetting
+
 x["two", 1:10, , 2:4]
 ## stars object with 3 dimensions and 1 attribute
 ## attribute(s):
@@ -337,7 +340,7 @@ 

Subsetting
+
 circle = st_sfc(st_buffer(st_point(c(293749.5, 9115745)), 400), crs = st_crs(x))
 plot(x[circle][, , , 1], reset = FALSE)
 plot(circle, col = NA, border = 'red', add = TRUE, lwd = 2)
@@ -353,20 +356,23 @@

Overviews
+
 x1 = read_stars(tif, options = c("OVERVIEW_LEVEL=1"))
 x2 = read_stars(tif, options = c("OVERVIEW_LEVEL=2"))
 x3 = read_stars(tif, options = c("OVERVIEW_LEVEL=3"))
 dim(x1)
 ##    x    y band 
-##   88   88    6
-dim(x2)
+##   88   88    6
+
+dim(x2)
 ##    x    y band 
-##   44   44    6
-dim(x3)
+##   44   44    6
+
+dim(x3)
 ##    x    y band 
-##   22   22    6
-par(mfrow = c(1, 3), mar = rep(0.2, 4))
+##   22   22    6
+
+par(mfrow = c(1, 3), mar = rep(0.2, 4))
 image(x1[,,,1])
 image(x2[,,,1])
 image(x3[,,,1])
@@ -378,12 +384,12 @@

Reading a raster time series: NetCD

Another example is when we read raster time series model outputs in a NetCDF file, e.g. by

-
+
 system.file("nc/bcsd_obs_1999.nc", package = "stars") |>
     read_stars() -> w
 ## pr, tas,

We see that

-
+
 w
 ## stars object with 3 dimensions and 2 attributes
 ## attribute(s):
@@ -403,7 +409,7 @@ 

Reading a raster time series: NetCD

Alternatively, this dataset can be read using read_ncdf, as in

-
+
 system.file("nc/bcsd_obs_1999.nc", package = "stars") |>
     read_ncdf()
 ## no 'var' specified, using pr, tas
@@ -437,7 +443,7 @@ 

Reading datasets from multiple fil eclipse.ncdc.noaa.gov/pub/OI-daily-v2/NetCDF/1981/AVHRR/).

We read the data by giving read_stars a vector with character names:

-
+
 x = c(
 "avhrr-only-v2.19810901.nc",
 "avhrr-only-v2.19810902.nc",
@@ -469,7 +475,7 @@ 

Reading datasets from multiple fil

Next, we select sea surface temperature (sst), and drop the singular zlev (depth) dimension using adrop:

-
+
 library(dplyr)
 ## 
 ## Attaching package: 'dplyr'
@@ -478,19 +484,21 @@ 

Reading datasets from multiple fil ## filter, lag ## The following objects are masked from 'package:base': ## -## intersect, setdiff, setequal, union -library(abind) +## intersect, setdiff, setequal, union

+
+library(abind)
 z <- y |> select(sst) |> adrop()

We can now graph the sea surface temperature (SST) using ggplot, which needs data in a long table form, and without units:

-
+
 # convert POSIXct time to character, to please ggplot's facet_wrap()
 z1 = st_set_dimensions(z, 3, values = as.character(st_get_dimension_values(z, 3)))
 library(ggplot2)
 library(viridis)
-## Loading required package: viridisLite
-library(ggthemes)
+## Loading required package: viridisLite
+
+library(ggthemes)
 ggplot() +  
   geom_stars(data = z1[1], alpha = 0.8, downsample = c(10, 10, 1)) + 
   facet_wrap("time") +
@@ -510,7 +518,7 @@ 

Writing stars objects to disk
+
 write_stars(adrop(y[1]), "sst.tif")

See the explanation of merge above to see how multiple attributes can be merged (folded) into a dimension.

@@ -520,7 +528,7 @@

Cropping a raster’s extent

Using a curvilinear grid, taken from the example of read_ncdf:

-
+
 prec_file = system.file("nc/test_stageiv_xyt.nc", package = "stars")
 prec = read_ncdf(prec_file, curvilinear = c("lon", "lat"))
 ## no 'var' specified, using Total_precipitation_surface_1_Hour_Accumulation
@@ -529,8 +537,9 @@ 

Cropping a raster’s extent## Will return stars object with 236118 cells. ## No projection information found in nc file. ## Coordinate variable units found to be degrees, -## assuming WGS84 Lat/Lon. -##plot(prec) ## gives error about unique breaks +## assuming WGS84 Lat/Lon.

+

We can now crop the grid to those cells falling in

-
+
 nc = st_transform(nc, st_crs(prec_slice)) # datum transformation
 plot(prec_slice[nc], border = NA, breaks = qu_0_omit(prec_slice[[1]]), reset = FALSE)
 plot(st_geometry(nc), add = TRUE, reset = FALSE, col = NA, border = 'red')
@@ -571,7 +580,7 @@

OD: space x space x travel by time of day, and by travel mode. Having day and time of day each as dimension is an advantage when we want to compute patterns over the day, for a certain period.

-
+
 nc = st_read(system.file("gpkg/nc.gpkg", package="sf")) 
 ## Reading layer `nc.gpkg' from data source 
 ##   `/home/runner/work/_temp/Library/sf/gpkg/nc.gpkg' using driver `GPKG'
@@ -579,19 +588,22 @@ 

OD: space x space x travel ## Geometry type: MULTIPOLYGON ## Dimension: XY ## Bounding box: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965 -## Geodetic CRS: NAD27 -to = from = st_geometry(nc) # 100 polygons: O and D regions +## Geodetic CRS: NAD27

+
+to = from = st_geometry(nc) # 100 polygons: O and D regions
 mode = c("car", "bike", "foot") # travel mode
 day = 1:100 # arbitrary
 library(units)
-## udunits database from /usr/share/xml/udunits/udunits2.xml
-units(day) = as_units("days since 2015-01-01")
+## udunits database from /usr/share/xml/udunits/udunits2.xml
+
+units(day) = as_units("days since 2015-01-01")
 hour = set_units(0:23, h) # hour of day
 dims = st_dimensions(origin = from, destination = to, mode = mode, day = day, hour = hour)
 (n = dim(dims))
 ##      origin destination        mode         day        hour 
-##         100         100           3         100          24
-traffic = array(rpois(prod(n), 10), dim = n) # simulated traffic counts
+##         100         100           3         100          24
+
+traffic = array(rpois(prod(n), 10), dim = n) # simulated traffic counts
 (st = st_as_stars(list(traffic = traffic),  dimensions = dims))
 ## stars object with 5 dimensions and 1 attribute
 ## attribute(s), summary of first 1e+05 cells:
@@ -621,7 +633,7 @@ 

OD: space x space x travel table joins. If we want to represent such an array as a tbl_cube, the simple feature geometry dimensions need to be replaced by indexes:

-
+
 st |> as.tbl_cube()
 ## Source: local array [72,000,000 x 5]
 ## D: origin [int, 100]
@@ -633,7 +645,7 @@ 

OD: space x space x travel

The following demonstrates how we can use dplyr to filter travel mode bike, and compute mean bike traffic by hour of day:

-
+
 b <- st |> 
   as.tbl_cube() |> 
   filter(mode == "bike") |> 
@@ -641,8 +653,9 @@ 

OD: space x space x travel summarise(traffic = mean(traffic)) |> as.data.frame() require(ggforce) # for plotting a units variable -## Loading required package: ggforce -ggplot() + +## Loading required package: ggforce

+
+ggplot() +  
   geom_line(data = b, aes(x = hour, y = traffic))
 ## Warning: The `scale_name` argument of `continuous_scale()` is deprecated as of ggplot2
 ## 3.5.0.
@@ -661,7 +674,7 @@ 

Extracting at p aggregate. In this example we use a categorical raster, and try to find the modal (most frequent) class within two circular polygons:

-
+
 s = system.file("tif/lc.tif", package = "stars")
 r = read_stars(s, proxy = FALSE) |> droplevels()
 levels(r[[1]]) = abbreviate(levels(r[[1]]), 10) # shorten text labels
@@ -675,12 +688,12 @@ 

Extracting at p

To find the modal value, we need a function that gives back the label corresponding to the class which is most frequent, using table:

-
+
 f = function(x) { tb = table(x); names(tb)[which.max(tb)] }

We can then call aggregate on the raster map, and the set of the two circular polygons pol1 and pol2, and pass the function f:

-
+
 aggregate(r, c(pol1, pol2), f) |> st_as_sf()
 ## Simple feature collection with 2 features and 1 field
 ## Geometry type: POLYGON
diff --git a/articles/stars2.html b/articles/stars2.html
index 6a265025..1848167e 100644
--- a/articles/stars2.html
+++ b/articles/stars2.html
@@ -131,8 +131,9 @@ 

Reading a particular chunklibrary(stars) ## Loading required package: abind ## Loading required package: sf -## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE -tif = system.file("tif/L7_ETMs.tif", package = "stars") +## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE

+
+tif = system.file("tif/L7_ETMs.tif", package = "stars")
 rasterio = list(nXOff = 6, nYOff = 6, nXSize = 100, nYSize = 100, bands = c(1, 3, 4))
 (x = read_stars(tif, RasterIO = rasterio))
 ## stars object with 3 dimensions and 1 attribute
@@ -143,12 +144,13 @@ 

Reading a particular chunk## from to offset delta refsys point x/y ## x 6 105 288776 28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y 6 105 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] -## band 1 3 NA NA NA NA -dim(x) +## band 1 3 NA NA NA NA

+
+dim(x)
 ##    x    y band 
 ##  100  100    3

Compare this to

-
+
 st_dimensions(read_stars(tif))
 ##      from  to  offset delta                     refsys point x/y
 ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x]
@@ -171,7 +173,7 @@ 

Reading at a different resolution

Reading datasets at a lower (but also higher!) resolution can be done by setting nBufXSize and nBufYSize

-
+
 rasterio = list(nXOff = 6, nYOff = 6, nXSize = 100, nYSize = 100,
                 nBufXSize = 20, nBufYSize = 20, bands = c(1, 3, 4))
 (x = read_stars(tif, RasterIO = rasterio))
@@ -197,25 +199,27 @@ 

Reading at a different resolution

We can also read at higher resolution; here we read a 3 x 3 area and blow it up to 100 x 100:

-
+
 rasterio = list(nXOff = 6, nYOff = 6, nXSize = 3, nYSize = 3,
    nBufXSize = 100, nBufYSize = 100, bands = 1)
 x = read_stars(tif, RasterIO = rasterio)
 dim(x)
 ##   x   y 
-## 100 100
-plot(x)
+## 100 100
+
+plot(x)

The reason we “see” only three grid cells is that the default sampling method is “nearest neighbour”. We can modify this by

-
+
 rasterio = list(nXOff = 6, nYOff = 6, nXSize = 3, nYSize = 3,
    nBufXSize = 100, nBufYSize = 100, bands = 1, resample = "cubic_spline")
 x = read_stars(tif, RasterIO = rasterio)
 dim(x)
 ##   x   y 
-## 100 100
-plot(x)
+## 100 100
+
+plot(x)

The following methods are allowed for parameter resample:

@@ -277,7 +281,7 @@

Stars proxy objects
+
 granule = system.file("sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip", package = "starsdata")
 s2 = paste0("SENTINEL2_L1C:/vsizip/", granule, "/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/MTD_MSIL1C.xml:10m:EPSG_32632")
 (p = read_stars(s2, proxy = TRUE))
@@ -292,23 +296,23 @@ 

Stars proxy objects## band 1 4 NA NA NA B4,...,B8

and this happens instantly, because no data is read. When we plot this object,

-
+
 system.time(plot(p))
 ## downsample set to 18

##    user  system elapsed 
-##   1.012   0.173   0.682
+## 0.982 0.189 0.677

This takes only around 1 second, since only those pixels are read that can be seen on the plot. If we read the entire image in memory first, as we would do with

-
+
 p = read_stars(s2, proxy = FALSE)

then only the reading would take over a minute, and require 5 Gb memory.

Methods for stars proxy objects

-
+
 methods(class = "stars_proxy")
 ##  [1] [               [[<-            [<-             adrop          
 ##  [5] aggregate       aperm           as.data.frame   c              
@@ -327,7 +331,7 @@ 

Select attributes
+
 x = c("avhrr-only-v2.19810901.nc",
 "avhrr-only-v2.19810902.nc",
 "avhrr-only-v2.19810903.nc",
@@ -340,8 +344,9 @@ 

Select attributesfile_list = system.file(paste0("netcdf/", x), package = "starsdata") y = read_stars(file_list, quiet = TRUE, proxy = TRUE) names(y) -## [1] "sst" "anom" "err" "ice" -y["sst"] +## [1] "sst" "anom" "err" "ice"

+
+y["sst"]
 ## stars_proxy object with 1 attribute in 9 file(s):
 ## $sst
 ## [1] "[...]/avhrr-only-v2.19810901.nc:sst" "[...]/avhrr-only-v2.19810902.nc:sst"
@@ -366,7 +371,7 @@ 

Select an areabbox object, or an sf, sfc or stars object from which the bounding box will be taken. An example:

-
+
 bb = st_bbox(c(xmin = 10.125, ymin = 0.125, xmax = 70.125, ymax = 70.125))
 ysub = y[bb]
 st_dimensions(ysub)
@@ -374,10 +379,12 @@ 

Select an area## x 41 281 0 0.25 NA [x] ## y 80 360 90 -0.25 NA [y] ## zlev 1 1 0 [m] NA NA -## time 1 9 1981-09-01 UTC 1 days POSIXct -class(ysub) # still no data here!! -## [1] "stars_proxy" "stars" -plot(ysub, reset = FALSE) # plot reads the data, at resolution that is relevant +## time 1 9 1981-09-01 UTC 1 days POSIXct

+
+class(ysub) # still no data here!!
+## [1] "stars_proxy" "stars"
+
+plot(ysub, reset = FALSE) # plot reads the data, at resolution that is relevant
 plot(st_as_sfc(bb), add = TRUE, lwd = .5, border = 'red')

@@ -390,27 +397,29 @@

Lazy evaluation, changing eva selections on dimensions other than shown above first need data, and can only then be carried out. Such functions are added to the object, in an attribute called call_list:

-
+
 yy = adrop(y)
 yyy = yy[,1:10,1:10,]
 class(yyy) # still no data
-## [1] "stars_proxy" "stars"
-st_dimensions(yyy) # and dimensions not adjusted
+## [1] "stars_proxy" "stars"
+
+st_dimensions(yyy) # and dimensions not adjusted
 ##      from   to         offset  delta  refsys x/y
 ## x       1 1440              0   0.25      NA [x]
 ## y       1  720             90  -0.25      NA [y]
 ## zlev    1    1          0 [m]     NA      NA    
-## time    1    9 1981-09-01 UTC 1 days POSIXct
-attr(yyy, "call_list") # the name of object in the call (y) is replaced with x:
+## time    1    9 1981-09-01 UTC 1 days POSIXct
+
+attr(yyy, "call_list") # the name of object in the call (y) is replaced with x:
 ## [[1]]
 ## adrop(x = x, drop = drop)
 ## attr(,".Environment")
-## <environment: 0x557edd9221e8>
+## <environment: 0x5592fe0dd740>
 ## 
 ## [[2]]
 ## x[i = i, 1:10, 1:10, , drop = drop, crop = crop]
 ## attr(,".Environment")
-## <environment: 0x557edd722fb0>
+## <environment: 0x5592fe024c10>

Doing this allows for optimizing the order in which operations are done. As an example, for st_apply, reading can be done sequentially over the dimensions over which the function is applied:

@@ -422,7 +431,7 @@

Lazy evaluation, changing eva result is plotted on a map, the time series function is only evaluated on the pixels actually plotted. This means that e.g. in -
+
 plot(st_apply(x, c("x", "y"), range))

the order of evaluation is reversed: plot knows which pixels are going to be shown, and controls how x is @@ -433,7 +442,7 @@

Fetching the data
+
 (x = st_as_stars(yyy)) # read, adrop, subset
 ## stars object with 3 dimensions and 4 attributes
 ## attribute(s):
@@ -453,7 +462,7 @@ 

Plotting with changed evaluation

For the Sentinel 2 data, band 4 represents NIR and band 1 red, so we can compute NDVI by

-
+
 # S2 10m: band 4: near infrared, band 1: red.
 #ndvi = function(x) (x[4] - x[1])/(x[4] + x[1])
 ndvi = function(x1, x2, x3, x4) (x4 - x1)/(x4 + x1)
@@ -473,14 +482,15 @@ 

Plotting with changed evaluation ## st_apply(X = X, MARGIN = MARGIN, FUN = FUN, CLUSTER = CLUSTER, ## PROGRESS = PROGRESS, FUTURE = FUTURE, rename = rename, .fname = .fname) ## attr(,".Environment") -## <environment: 0x557edd3b12c8> +## <environment: 0x5592fdf6a198> ## -## This object has pending lazy operations: dimensions as printed may not reflect this. -system.time(plot(s2.ndvi)) # read - compute ndvi - plot +## This object has pending lazy operations: dimensions as printed may not reflect this.

+
+system.time(plot(s2.ndvi)) # read - compute ndvi - plot 
 ## downsample set to 18

##    user  system elapsed 
-##   0.720   0.168   0.385
+## 0.675 0.173 0.369

@@ -497,7 +507,7 @@

Multi-resolution proxy objects
+
 s1 = st_as_stars(matrix(1:16, 4))
 s2 = st_as_stars(matrix(1:16, 4))
 s3 = st_as_stars(matrix(1:16, 4))
@@ -515,16 +525,16 @@ 

Multi-resolution proxy objectsattr(s3, "dimensions")$X2$delta = -3 plot(s1, axes = TRUE, text_values = TRUE, text_color = 'orange')

-
+
 plot(s2, axes = TRUE, text_values = TRUE, text_color = 'orange')

-
+
 plot(s3, axes = TRUE, text_values = TRUE, text_color = 'orange')

We created three rasters with identical cell values and dimensions, but different cell sizes, and hence extents. If we bind them in a single proxy object, with

-
+
 fn1 = paste0(tempdir(), .Platform$file.sep, "img1.tif")
 fn2 = paste0(tempdir(), .Platform$file.sep, "img2.tif")
 fn3 = paste0(tempdir(), .Platform$file.sep, "img3.tif")
@@ -550,21 +560,21 @@ 

Multi-resolution proxy objects
+
 st_as_stars(r1) %>%
   merge() %>%
   plot(breaks = "equal", text_values = TRUE, text_color = 'orange', axes = TRUE)

If we do this for a sub-range, defined for the object resolutions, we get:

-
+
 st_as_stars(r1[,2:4,2:4]) %>%
   merge() %>%
   plot(breaks = "equal", text_values = TRUE, text_color = 'orange', axes = TRUE)

We now create four maps, all over the same region ([0,4] x [0,4]), with different resolutions (cell size 1, 1/2 and 1/3):

-
+
 s4 = st_as_stars(matrix(1: 16, 4))
 s5 = st_as_stars(matrix(1: 64, 8))
 s6 = st_as_stars(matrix(1:144,12))
@@ -582,13 +592,13 @@ 

Multi-resolution proxy objectsattr(s6, "dimensions")$X2$delta = -1/3 plot(s4, axes = TRUE, text_values = TRUE, text_color = 'orange')

-
+
 plot(s5, axes = TRUE, text_values = TRUE, text_color = 'orange')

-
+
 plot(s6, axes = TRUE, text_values = TRUE, text_color = 'orange')

-
+
 fn4 = paste0(tempdir(), .Platform$file.sep, "img4.tif")
 fn5 = paste0(tempdir(), .Platform$file.sep, "img5.tif")
 fn6 = paste0(tempdir(), .Platform$file.sep, "img6.tif")
@@ -609,20 +619,21 @@ 

Multi-resolution proxy objects## dimension(s): ## from to offset delta x/y ## x 1 4 0 1 [x] -## y 1 4 4 -1 [y] - +## y 1 4 4 -1 [y]

+
+
 st_as_stars(r2) %>%
   merge() %>%
   plot(breaks = "equal", text_values = TRUE, text_color = 'orange', axes = TRUE)

-
+
 st_as_stars(r2[,2:4,2:4]) %>%
   merge() %>%
   plot(breaks = "equal", text_values = TRUE, text_color = 'orange', axes = TRUE)

Finally, an example where the first raster has the higher resolution:

-
+
 (r3 = read_stars(c(fn6, fn5, fn4), proxy = TRUE))
 ## multi-resolution stars_proxy object with 3 attributes in 3 file(s):
 ## $`6`
@@ -637,13 +648,14 @@ 

Multi-resolution proxy objects## dimension(s): ## from to offset delta x/y ## x 1 12 0 0.3333 [x] -## y 1 12 4 -0.3333 [y] - +## y 1 12 4 -0.3333 [y]

+
+
 st_as_stars(r3) %>%
   merge() %>%
   plot(breaks = "equal", text_values = TRUE, text_color = 'orange', axes = TRUE)

-
+
 st_as_stars(r3[,2:6,3:6]) %>%
   merge() %>%
   plot(breaks = "equal", text_values = TRUE, text_color = 'orange', axes = TRUE)
diff --git a/articles/stars3.html b/articles/stars3.html index c28274f8..5f3b97a1 100644 --- a/articles/stars3.html +++ b/articles/stars3.html @@ -97,8 +97,9 @@

Edzer library(stars) ## Loading required package: abind ## Loading required package: sf -## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE -library(dplyr) +## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE

+
+library(dplyr)
 ## 
 ## Attaching package: 'dplyr'
 ## The following objects are masked from 'package:stats':
@@ -108,7 +109,7 @@ 

Edzer ## ## intersect, setdiff, setequal, union

Methods now available for class stars are

-
+
 methods(class = "stars")
 ##  [1] [                 [[<-              [<-               %in%             
 ##  [5] $<-               adrop             aggregate         aperm            
@@ -130,7 +131,7 @@ 

Edzer ## [69] time transmute write_stars ## see '?methods' for accessing help and source code

We will work with a three-band section of a landsat image:

-
+
 system.file("tif/L7_ETMs.tif", package = "stars") %>%
     read_stars -> x
 x
@@ -149,7 +150,7 @@ 

slice slices a sub-array out of the cube; this is done by specifying the dimension on which to act, and the slice number.

-
+
 x %>% slice(band, 6) -> x6
 x6
 ## stars object with 2 dimensions and 1 attribute
@@ -169,7 +170,7 @@ 

Similar to slice, filter selects on dimensions but evaluates their values rather than their index: in

-
+
 x %>% filter(x > 289000, x < 291000, band > 3) -> x7
 x7
 ## stars object with 3 dimensions and 1 attribute
@@ -196,11 +197,12 @@ 

pull

pull pulls out an array from a stars object:

-
+
 x %>% pull(1) -> x8
 class(x8)
-## [1] "array"
-dim(x8)
+## [1] "array"
+
+dim(x8)
 ##    x    y band 
 ##  349  352    6
@@ -208,7 +210,7 @@

mutate

-
+
 x %>% mutate(band2 = 2 * L7_ETMs.tif) -> x2 
 x2
 ## stars object with 3 dimensions and 2 attributes
@@ -227,7 +229,7 @@ 

select

select selects an attribute, or a set of attributes:

-
+
 x2 %>% select(band2) -> x9
 x9
 ## stars object with 3 dimensions and 1 attribute
@@ -257,11 +259,12 @@ 

geometry is regular, rectilinear or has vector geometries

An example use is

-
+
 library(ggplot2)
 library(viridis)
-## Loading required package: viridisLite
-ggplot() + 
+## Loading required package: viridisLite
+
+ggplot() + 
   geom_stars(data = x) +
   coord_equal() +
   facet_wrap(~band) +
diff --git a/articles/stars4.html b/articles/stars4.html
index 20c70595..a731aa17 100644
--- a/articles/stars4.html
+++ b/articles/stars4.html
@@ -330,16 +330,18 @@ 

Rectilinear grids## dimension(s): ## from to point values x/y ## x 1 5 FALSE [0,0.5),...,[4,5) [x] -## y 1 4 FALSE [0.3,0.5),...,[2,2.2) [y] -st_bbox(r) +## y 1 4 FALSE [0.3,0.5),...,[2,2.2) [y]

+
+st_bbox(r)
 ## xmin ymin xmax ymax 
-##  0.0  0.3  5.0  2.2
-image(r, axes = TRUE, col = grey((1:20)/20))
+## 0.0 0.3 5.0 2.2
+
+image(r, axes = TRUE, col = grey((1:20)/20))

Would we leave out the last value, than stars may come up with a different cell boundary for the last cell, as this is now derived from the width of the one-but-last cell:

-
+
 x = c(0, 0.5, 1, 2, 4)  # 5 numbers: offsets only!
 y = c(0.3, 0.5, 1, 2)   # 4 numbers: offsets only!
 (r = st_as_stars(list(m = m), dimensions = st_dimensions(x = x, y = y)))
@@ -350,15 +352,16 @@ 

Rectilinear grids## dimension(s): ## from to point values x/y ## x 1 5 FALSE [0,0.5),...,[4,6) [x] -## y 1 4 FALSE [0.3,0.5),...,[2,3) [y] -st_bbox(r) +## y 1 4 FALSE [0.3,0.5),...,[2,3) [y]

+
+st_bbox(r)
 ## xmin ymin xmax ymax 
 ##  0.0  0.3  6.0  3.0

This is not problematic if cells have a constant width, in which case the boundaries are reduced to an offset and delta value, irrespective whether an upper boundary is given:

-
+
 x = c(0, 1, 2, 3, 4)  # 5 numbers: offsets only!
 y = c(0.5, 1, 1.5, 2)   # 4 numbers: offsets only!
 (r = st_as_stars(list(m = m), dimensions = st_dimensions(x = x, y = y)))
@@ -369,14 +372,15 @@ 

Rectilinear grids## dimension(s): ## from to offset delta point x/y ## x 1 5 0 1 FALSE [x] -## y 1 4 0.5 0.5 FALSE [y] -st_bbox(r) +## y 1 4 0.5 0.5 FALSE [y]

+
+st_bbox(r)
 ## xmin ymin xmax ymax 
 ##  0.0  0.5  5.0  2.5

Alternatively, one can also set the cell midpoints by specifying arguments cell_midpoints to the st_dimensions call:

-
+
 x = st_as_stars(matrix(1:9, 3, 3), 
                 st_dimensions(x = c(1, 2, 3), y = c(2, 3, 10), cell_midpoints = TRUE))

When the dimension is regular, this results in offset @@ -394,21 +398,21 @@

Curvilinear grids
+
 install.packages("starsdata", repos = "http://pebesma.staff.ifgi.de", type = "source") 

The dataset is found here:

-
+
 (s5p = system.file("sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc", package = "starsdata"))
 ## [1] "/home/runner/work/_temp/Library/starsdata/sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc"

We can construct the curvilinear stars raster by calling read_stars on the right sub-array:

-
+
 subs = gdal_subdatasets(s5p)
 subs[[6]]
 ## [1] "NETCDF:\"/home/runner/work/_temp/Library/starsdata/sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc\":/PRODUCT/nitrogendioxide_tropospheric_column"

For this array, we can see the GDAL metadata under item GEOLOCATION:

-
+
 gdal_metadata(subs[[6]], "GEOLOCATION")
 ## $LINE_OFFSET
 ## [1] "0"
@@ -441,7 +445,7 @@ 

Curvilinear grids## [1] "gdal_metadata"

which reveals where, in this dataset, the longitude and latitude arrays are kept.

-
+
 nit.c = read_stars(subs[[6]]) 
 ## Warning in CPL_read_gdal(as.character(x), as.character(options),
 ## as.character(driver), : GDAL Message 1: The dataset has several variables that
@@ -482,8 +486,9 @@ 

Curvilinear grids## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary -## dimension. Consequently they will be ignored. -threshold = units::set_units(9e+36, mol/m^2) +## dimension. Consequently they will be ignored.

+
+threshold = units::set_units(9e+36, mol/m^2)
 nit.c[[1]][nit.c[[1]] > threshold] = NA
 nit.c
 ## stars object with 3 dimensions and 1 attribute
@@ -503,22 +508,24 @@ 

Curvilinear grids
+
 plot(nit.c, breaks = "equal", reset = FALSE, axes = TRUE, as_points = TRUE, 
          pch = 16,  logz = TRUE, key.length = 1)
 ## Warning in NextMethod(): NaNs produced
-## Warning in plot.sf(x, pal = col, ...): NaNs produced
-maps::map('world', add = TRUE, col = 'red')
+## Warning in plot.sf(x, pal = col, ...): NaNs produced

+
+maps::map('world', add = TRUE, col = 'red')

-
+
 plot(nit.c, breaks = "equal", reset = FALSE, axes = TRUE, as_points = FALSE, 
          border = NA, logz = TRUE, key.length = 1)
 ## Warning in NextMethod(): NaNs produced
-## Warning in plot.sf(x, pal = col, ...): NaNs produced
-maps::map('world', add = TRUE, col = 'red')
+## Warning in plot.sf(x, pal = col, ...): NaNs produced
+
+maps::map('world', add = TRUE, col = 'red')

We can downsample the data by

-
+
 (nit.c_ds = stars:::st_downsample(nit.c, 8))
 ## stars object with 3 dimensions and 1 attribute
 ## attribute(s):
@@ -533,30 +540,34 @@ 

Curvilinear grids## x 1 50 NA WGS 84 [50x31] -5.811 [°],...,30.14 [°] [x] ## y 1 31 NA WGS 84 [50x31] 28.78 [°],...,51.47 [°] [y] ## time 1 1 2018-07-17 UTC POSIXct NULL -## curvilinear grid -plot(nit.c_ds, breaks = "equal", reset = FALSE, axes = TRUE, as_points = TRUE, +## curvilinear grid

+
+plot(nit.c_ds, breaks = "equal", reset = FALSE, axes = TRUE, as_points = TRUE, 
          pch = 16, logz = TRUE, key.length = 1)
 ## Warning in NextMethod(): NaNs produced
-## Warning in plot.sf(x, pal = col, ...): NaNs produced
-maps::map('world', add = TRUE, col = 'red')
+## Warning in plot.sf(x, pal = col, ...): NaNs produced
+
+maps::map('world', add = TRUE, col = 'red')

which doesn’t look nice, but plotting the cells as polygons looks better:

-
+
 plot(nit.c_ds, breaks = "equal", reset = FALSE, axes = TRUE, as_points = FALSE, 
          border = NA, logz = TRUE, key.length = 1)
 ## Warning in NextMethod(): NaNs produced
-## Warning in plot.sf(x, pal = col, ...): NaNs produced
-maps::map('world', add = TRUE, col = 'red')
+## Warning in plot.sf(x, pal = col, ...): NaNs produced
+
+maps::map('world', add = TRUE, col = 'red')

Another approach would be to warp the curvilinear grid to a regular grid, e.g. by

-
+
 w = st_warp(nit.c, crs = 4326, cellsize = 0.25)
 ## Warning in transform_grid_grid(st_as_stars(src), st_dimensions(dest),
 ## threshold): using Euclidean distance measures on geodetic coordinates
-## threshold set to 0.108545 : set a larger value if you see missing values where there shouldn't be
-plot(w)
+## threshold set to 0.108545 : set a larger value if you see missing values where there shouldn't be
+
+plot(w)

+
+plot(nc.st)

The algorithm used is the GDAL rasterize utility, all options of this utility can be passed to st_rasterize. The @@ -128,7 +130,7 @@

Vectorizing a raster object center, or small square polygons with a single value.

We will work again with the landsat-7 6-band image, but will select the first band and round the values:

-
+
 tif = system.file("tif/L7_ETMs.tif", package = "stars")
 x = read_stars(tif)[, 1:50, 1:50, 1:2]
 x[[1]] = round(x[[1]]/5)
@@ -139,7 +141,7 @@

Polygonizing
+
 l =  st_contour(x, contour_lines = TRUE, breaks = 11:15)
 plot(l[1], key.pos = 1, pal = sf.colors, lwd = 2, key.length = 0.8)

@@ -150,7 +152,7 @@

Exporting to points
+
 st_as_sf(x, as_points = TRUE, merge = FALSE)
 ## Simple feature collection with 2500 features and 2 fields
 ## Geometry type: POINT
@@ -171,7 +173,7 @@ 

Exporting to points## 10 13 10 POINT (289047 9120747)

or as a long table with a single attribute and all points replicated:

-
+
 st_as_sf(x, as_points = TRUE, merge = FALSE, long = TRUE)
 ## Simple feature collection with 5000 features and 2 fields
 ## Geometry type: POINT
@@ -198,7 +200,7 @@ 

Exporting to polygons

Alternatively, we can export to polygons and either get a single polygon per pixel, as in

-
+
 st_as_sf(x[1], as_points = FALSE, merge = FALSE)
 ## Simple feature collection with 2500 features and 2 fields
 ## Geometry type: POLYGON
@@ -218,11 +220,11 @@ 

Exporting to polygons## 9 13 10 POLYGON ((289004.3 9120761,... ## 10 13 10 POLYGON ((289032.8 9120761,...

or merge polygons that have identical pixel values;

-
+
 p = st_as_sf(x, as_points = FALSE, merge = TRUE)

When plotted with boundaries, we see the resolved boundaries of areas with the same pixel value:

-
+
 plot(p)

A further option connect8 can be set to @@ -238,7 +240,7 @@

Switching between

We can convert a raster dimension to a vector dimension while keeping other dimensions as they are in a stars object by

-
+
 x.sf = st_xy2sfc(x, as_points = TRUE)
 x.sf
 ## stars object with 2 dimensions and 1 attribute
@@ -268,7 +270,7 @@ 

Reprojecting a raster

An example of the reprojection of the grid created above is

-
+
 nc.st %>% st_transform("+proj=laea +lat_0=34 +lon_0=-60") -> nc.curv
 nc.curv
 ## stars object with 2 dimensions and 1 attribute
@@ -282,8 +284,9 @@ 

Reprojecting a raster## x/y ## x [x] ## y [y] -## curvilinear grid -plot(nc.curv, border = NA, graticule = TRUE)

+## curvilinear grid
+
+plot(nc.curv, border = NA, graticule = TRUE)

where it should be noted that the dimensionality of the grid didn’t change: the same set of raster cells has been replotted in the new CRS, @@ -296,11 +299,11 @@

Warping a raster -
+
 nc %>% st_transform("+proj=laea +lat_0=34 +lon_0=-60") %>% st_bbox() %>%
     st_as_stars() -> newgrid

and then warping the old raster to the new

-
+
 nc.st %>% st_warp(newgrid) -> nc.new
 nc.new 
 ## stars object with 2 dimensions and 1 attribute
@@ -310,8 +313,9 @@ 

Warping a raster## dimension(s): ## from to offset delta refsys x/y ## x 1 380 -2188110 2098 +proj=laea +lat_0=34 +lon... [x] -## y 1 171 494924 -2098 +proj=laea +lat_0=34 +lon... [y] -plot(nc.new)

+## y 1 171 494924 -2098 +proj=laea +lat_0=34 +lon... [y]
+
+plot(nc.new)

This new object has a regular grid in the new CRS, aligned with the new x- and y-axes.

diff --git a/articles/stars7.html b/articles/stars7.html index 62c8e377..0bf92220 100644 --- a/articles/stars7.html +++ b/articles/stars7.html @@ -125,8 +125,9 @@

stars objects as data.frameslibrary(stars) ## Loading required package: abind ## Loading required package: sf -## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE -l7 = system.file("tif/L7_ETMs.tif", package = "stars") %>% +## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE

+
+l7 = system.file("tif/L7_ETMs.tif", package = "stars") %>%
   read_stars()
 l7
 ## stars object with 3 dimensions and 1 attribute
@@ -137,8 +138,9 @@ 

stars objects as data.frames## from to offset delta refsys point x/y ## x 1 349 288776 28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y 1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] -## band 1 6 NA NA NA NA -as.data.frame(l7) %>% head() +## band 1 6 NA NA NA NA

+
+as.data.frame(l7) %>% head()
 ##          x       y band L7_ETMs.tif
 ## 1 288790.5 9120747    1          69
 ## 2 288819.0 9120747    1          69
@@ -156,7 +158,7 @@ 

stars objects as data.frames
+
 l7 %>% split("band") %>%
   as.data.frame() %>% 
   head()
@@ -208,7 +210,7 @@ 

models fitted for every pixelLinear regression on pixel time series

We can read in the avhrr dataset, containing only 9 days:

-
+
 library(stars)
 x = c("avhrr-only-v2.19810901.nc",
 "avhrr-only-v2.19810902.nc",
@@ -229,7 +231,7 @@ 

Linear regression on pixel time for temperature with time. We get temperatures as a vector in the first argument of the function supplied to st_apply, and have t already defined. The function could look like

-
+
 slope = function(x) {
   if (any(is.na(x)))
     NA_real_
@@ -238,7 +240,7 @@ 

Linear regression on pixel time }

but we will optimize this a bit, using anyNA and lm.fit rather than lm:

-
+
 slope = function(x) {
   if (anyNA(x))
     NA_real_
@@ -247,11 +249,11 @@ 

Linear regression on pixel time }

The result is lazily defined by (adrop drops the singular dimension)

-
+
 out = st_apply(adrop(y), c(1,2), slope)

but only computed by the following command, where the computations are restricted to the pixels plotted:

-
+
 plot(out, breaks = "equal", main = "9-day time trend (slope)")
 ## downsample set to 1

@@ -271,7 +273,7 @@

Principal components
+
 tif = system.file("tif/L7_ETMs.tif", package = "stars")
 r = split(read_stars(tif))
 pc = prcomp(as.data.frame(r)[,-(1:2)]) # based on all data
@@ -284,7 +286,7 @@ 

Principal components
+
 granule = system.file("sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip", 
    package = "starsdata")
 s2 = paste0("SENTINEL2_L1C:/vsizip/", granule, 
@@ -296,7 +298,7 @@ 

Principal componentsout = predict(p, pc)

Before plotting this, we’ll add country borders that delineate sea, obtained from the mapdata package:

-
+
 bb = st_bbox(p) %>% 
   st_as_sfc() %>%
   st_transform(4326) %>%
@@ -308,7 +310,7 @@ 

Principal componentsst_transform(st_crs(r))

We plot the results with independent color ranges, so every PC is stretched over the entire grey scale.

-
+
 plt_boundary = function() plot(m, border = 'orange', add = TRUE)
 plot(merge(out), hook = plt_boundary, join_zlim = FALSE)
 ## downsample set to 18
@@ -319,19 +321,19 @@

Principal components
+
 write_stars(merge(out), "out.tif")

K-means clustering

-
+
 library(clue)
 predict.kmeans = function(object, newdata, ...) {
     unclass(clue::cl_predict(object, newdata[, -c(1:2)], ...))
 }

For a small dataset:

-
+
 tif = system.file("tif/L7_ETMs.tif", package = "stars")
 i = read_stars(tif, proxy = TRUE) %>%
     split()
@@ -345,15 +347,16 @@ 

K-means clustering
+
 i = read_stars(s2, proxy = TRUE, NA_value = 0) %>%
     split()
 sam = st_sample(i, 1000)
 k = kmeans(na.omit(as.data.frame(sam)[, -c(1:2)]), nclus)
 out = predict(i, k)
 plot(out, col = sf.colors(nclus, categorical=TRUE), reset = FALSE)
-## downsample set to 18
-plot(m, add = TRUE)
+## downsample set to 18

+
+plot(m, add = TRUE)

we see that class 1 and 3 identify with the unclouded area, 3 with land, the other classes seem to mainly catch aspects of the cloud @@ -374,7 +377,7 @@

Random Forest land use classifica

We have polygon areas where the land use was classified, residing in a GeoPackage file. (This file was created using QGIS, using the instructions found here.)

-
+
 # for all, multi-resolution, use:
 bands = c("B04", "B03", "B02", "B08", "B01", "B05", "B06", "B07", "B8A", "B09", "B10", "B11", "B12")
 # bands = c("B04", "B03", "B02", "B08")
@@ -385,19 +388,21 @@ 

Random Forest land use classifica cl = read_sf(system.file("gpkg/s2.gpkg", package = "stars")) %>% st_transform(st_crs(r)) plot(r, reset = FALSE) -## downsample set to 8 -plot(cl, add = TRUE) +## downsample set to 8

+
+plot(cl, add = TRUE)
 plot(m, add = TRUE, border = 'orange')

Next, we need points, sampled inside these polygons, for which we need to extract the satellite spectral data

-
+
 pts = st_sample(cl, 1000, "regular") %>%
     st_as_sf() %>%
     st_intersection(cl)
 ## Warning: attribute variables are assumed to be spatially constant throughout
-## all geometries
-train = st_extract(r, pts)
+## all geometries
+
+train = st_extract(r, pts)
 train$use = as.factor(pts$use) # no need for join, since the order did not change
 train
 ## Simple feature collection with 1000 features and 14 fields
@@ -428,7 +433,7 @@ 

Random Forest land use classifica ## 8 POINT (392185.2 5940074) land ## 9 POINT (387142.8 5936359) land ## 10 POINT (390877.6 5927178) land

-
+
 library(randomForest)
 ## randomForest 4.7-1.1
 ## Type rfNews() to see new features/changes/bug fixes.
@@ -436,14 +441,16 @@ 

Random Forest land use classifica ## Attaching package: 'randomForest' ## The following object is masked from 'package:dplyr': ## -## combine -train = as.data.frame(train) +## combine

+
+train = as.data.frame(train)
 train$x = NULL # remove geometry
 rf = randomForest(use ~ ., train) # ~ . : use all other attributes
 pr = predict(r, rf)
 plot(pr, reset = FALSE, key.pos = 1)
-## downsample set to 8
-# add country outline:
+## downsample set to 8
+
+# add country outline:
 plot(m, add = TRUE)

This comes with the rather trivial finding that land and sea can be diff --git a/articles/stars8.html b/articles/stars8.html index 44700326..5fa513d4 100644 --- a/articles/stars8.html +++ b/articles/stars8.html @@ -102,8 +102,9 @@

David library(stars) ## Loading required package: abind ## Loading required package: sf -## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE -f <- system.file("nc/reduced.nc", package = "stars") +## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE

+
+f <- system.file("nc/reduced.nc", package = "stars")
 (nc <- read_ncdf(f))
 ## no 'var' specified, using sst, anom, err, ice
 ## other available variables:
@@ -136,7 +137,7 @@ 

David option that controls whether read_ncdf() defaults to proxy and use proxy = TRUE to show both ways of getting the same result.

-
+
 old_options <- options("stars.n_proxy" = 100)
 (nc <- read_ncdf(f, proxy = TRUE))
 ## no 'var' specified, using sst, anom, err, ice
@@ -161,8 +162,9 @@ 

David ## lon 1 180 -1 2 WGS 84 NULL [x] ## lat 1 90 -90 2 WGS 84 NULL [y] ## zlev 1 1 NA NA NA 0 -## time 1 1 NA NA POSIXct 1981-12-31 UTC -options(old_options)

+## time 1 1 NA NA POSIXct 1981-12-31 UTC
+
+options(old_options)

The above shows that we have a NetCDF sourced stars proxy derived from the reduced.nc file. We see it has four variables and their units are displayed. The normal stars @@ -172,7 +174,7 @@

David dimensions of the NetCDF data source. With this information, we have what we need to request a chunk of data that is what we want and not too large.

-
+
 (nc <- read_ncdf(f, 
                  var = "sst", 
                  ncsub = cbind(start = c(90, 45, 1 , 1), 
@@ -192,8 +194,9 @@ 

David ## lon 1 90 177 2 WGS 84 NULL [x] ## lat 1 45 -2 2 WGS 84 NULL [y] ## zlev 1 1 NA NA NA 0 -## time 1 1 NA NA POSIXct 1981-12-31 UTC - +## time 1 1 NA NA POSIXct 1981-12-31 UTC

+
+
 plot(nc)

The ability to view NetCDF metadata so we can make well formed diff --git a/pkgdown.yml b/pkgdown.yml index 20acbd14..717b04f2 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -10,5 +10,5 @@ articles: stars6: stars6.html stars7: stars7.html stars8: stars8.html -last_built: 2024-04-24T15:50Z +last_built: 2024-05-16T21:44Z diff --git a/reference/aggregate.stars-2.png b/reference/aggregate.stars-2.png index dcf3ebc3a6e32e6f0dd992526474663bd51d7dd1..c66c8a6f4ffa8fdb7654da0d06aa1f376e43c85d 100644 GIT binary patch literal 23080 zcmdVC30RV8+doV-<;=7=Jxy6@Iy0iS>bRxmLNiSnxwVa2Zk4II;VvQqwojQ_n3|$e zxn=ITrQlMQL@t!OB4CLcDImBYBJjVUd7kh4p6__S_x&Ho|9jt=`#9n@xVP)P&h7gB z&hx%?+|hRZx7)vkKp^YkM}IpBfvk>!KvrG&dJXu7p7v-4?7j&-dL{w_*>O|xZ$(+tdgAAb+6CH~LWKdf8VO87lt;D_694{jFt+#-K<;pAa*{HCo3 zUp&2h6alHiyL0t(9oJnkaOY}XwR^pD&lJ9>|5o@fUm?N^4=k=cGPB|K?+@dz{83ST z%=Wu&H$M0j@U=)?PchNNr)3;$&Vl(zoK0Zg=PKHe1es$~L#(2S`>TlA;1U0mO@-e8 zEkwgyoa!t>KUx1YhVg~Lw9ILf%lCe1L}&R~KY!|fm==C8gYLm(}PugE`J8$1YQrR$+S|6=x4d@J{j;!O8QM;&oaRmtr2tCzkGbyjs0 zRzS71Mhr%;H}Epp^k~$y7>*r-(2eHQ;hJCMjRpCcSb<1^d%?gYp6DmJI-J!yG5=^``X5RAX!tFKj2XfNb z4jh|hW+v~DI2J#kC%(Ca?!1~VKl|L;Y*?NJq)!GG}l{V*UhcN zJ#Uoy;?1C_V(ns9Mm=L@? zlN~5}-xO3XD&{2Bt5TN7JZcG%K@GYL8%$us7>j_n z3VT^A;iC2P)<6!?c`&TG+95_1fxi(0%Eb%~{I)MP;ZppTHhg5q)*B3g2u8Jy!Ap;)q$co(0zcLP`n z({n}njM}+x?~JbAIdvE=^9d1mL2=paQ&;D)2hb|JVX5qA9-8QI{CGt0=)t0erUO*i z))5gME_+sIweCHh_xYVR-%+TBwo*|`+Jldq*MzA~m0A+m1(837bz?qA8zWzE-nc+f zlxPNn9G5OJa1u^TV}C5VD3oEE=Bzi6=-r7iPWbZn#UX8}7%AHR!Yu;k)BuZ?1+*EM zNBK3}yP<81Unau0EIg5K8j{+_tN93b#ysH+!Fli9u-*;+ClNe`C~G?8?Q7!5xXdnP z`FNY{x2k>SvK7ZK$E!Uok@Y3P?(5&rgqy)WM4*#*z|9IjAZ&=d-r1XlYe_e>XO3Zp z_VzLL3N6R^7aMA2{tX60&E0O3d%Cl?*a&?%j`SUz^7iY&hEx^NV*R5!-kvIBl@GoR zC>ZfB+mNGg6cH<_RM8W^sIuY(eg5nCN`$fg{v4JTodQW7+T z)g&!oN>z^v_eq{aiJ-7F-k_P4Oovf9i~n$h9-twIJZU-H4|%(EsX_GxTo?$qd5;dl zRPeM#Pa-@T44!J+_GH^wZXa6wG<(V0t7t*y+3@}ZaoY&a8_(zLgBg3or$e3K$m^f- z*5>g(`%Byxc`0n2#&P0NvmLE()bVkC(FJf+7@p6{?=Qc&Y{H%Do-cfVX)(lMpj>wG zWi5%znmokHUClox45SC;TK{$|Axw?0@<&OMEc`2u0JG|i@xtwRcz=ijBodmN} zboxk{o!M^Db$Yu?J|S7wxT&@@Y*0-w*>c`Ou`gF0DB>J+sCU z-X}7jmi@%gf@o%Cqn?T^<-DV%(q$Wt?1{0k@|&r+{fw_)Rb_mC4&$#y|7E?j$iaqS zEQbgRroSSK?97Hmxakui-GY!97Q*jF27blEjT57*&3jIDCkAbmTKVw%C~;2sx_kml z_$;z8MIP6X(Bb}jb*j((0KVEn%yc@sE;(;)y5?{(&bH0Au;mSgcAmh{uinowriE6s z5QUli8XR#CCfWJU5sr-;B;3r=zhEeAh%D?({55arr&3Fj zUBrZn2>zk}mm1MkPT4EjB6r-+ck=NWxX^8={<{rx>uon!$G*f!=08Oix{KCN_Gu)2 zYAl|!*8h!v%uFS&JMpFT2A8f5N6@`V!xHg6xJ@eJEAQ^r?+$sT@gDnYYf%@g^+N}( zU?i`ZATzlY)vgM?Rq`pzBKz&kom6;k+=@$oY$QYcmfoC0ZCz;{U19ZYR@vLG>j`*v z=Qgb$U8i=Bv>FsAZ{G|1ImN&;;x3n)3|;PzESyd&#*aP(DqsUCouXq<7lq0{A-sACR zr$q$&Rd_?Z9=u84Qq6pKu=!(wUw2~v^Pi}&V`c{QJcAmQA*MVndthz_yo}i-&5w+r zzJTH~*k!z7r4Hjh< zd^imEyvN%*6Ay)vF|0R)lx1mCeh8Yat+EWGD9ykHwk zZ;G55427QSzJ55D!WtmSH*&5_G!BbjGr4t|$I&;LhL0vZ)mDFaDfr`#oXHARtHlI0 zNW-hSlPM!vyq7nnnRULCy@EWt7jjA!xgm}JX7SCkl*a<82tLrLDS27K^ya_Kki2t2 zz!sjokeVS_xbGz5d`{BM*2%@YOHS>Kf%y^^{SQ7ca`N z+YTQ`uHzL}85_(Ot3(~4JhF_K5b*7`5mnL6n2>UtYNBlQ!Sg`t?H8nQ+2oo2`dwpQ zM`7uRug5@~&O)Dzb*g`2l&oo9&-(dC|a!5FKQ({;?) zdKCnsMh4Hca`9%5hyBDVj$?+T*18tuj7Ju%&9lk6Xi7a*r-cq_vo&2#;Yw(JU-92m zr7TC|n;ns+Y*8M;z;Fl+Jz2W2!TRU1+-)!-f@!WFH)(tY$^H@UnSwC+T-crX4sDC) zcP?IUJ#s@krraLcuwaQ__P{s8g>83|-M7~lOX`{^*Uy!2B-3_S^|R8E>MtzA!Q9+~ z%5CvpPC`G9EOb@^$NtEW(C%&|YwQPE6ESYqrWQ4Pj*vnZsoKtXX0k1N=5NuvrI#lh zEM_zRaSIqWq{U{=X)~_o?R_Om~Tfl%o^keuP8M9=@14Pnq4>d8W z;G2~zJs}&0`Fiz;;l%iayG<&gAJjdLu8&W6qtk~YY^MBXTbNja|rH%JDB!f=6&^VEY=V~aBnRji-Hbe_d>(y>J` zow>HjTgolW%)mAGnI`#ERaJRorV9v&r{NmKf^8)?rplX}jxn}Vo^9uQ6gp<__KY}x z{!vUP^o+avUeBsFzjqXvOkiLwIST>ifPBH}DU|nB(<`(JorpQnn-)q_Yjd0|wS;$X zeqU;~ely*2;gJ+?r|5o=xr)^p*b@ISvr@4) zIrcwzzyTxf8i-n5Mn=X*Q!_KOgaPv4J_7@nBJ{^sw{}O_5wf#OPa?g&y@ODJfyGM^ z_n$R2d4dTQT|HIkxVij{T_OvYm>C!t_&QLRy1X1G$ZVC$7X@RliDSco<@-F1i)Kk~ zuC6;hBYb@FV>1k=V z2TJC*m9)v5Q)x9V*QsB7Dg+gOI=VbL({OQ%np(nuJ-()<=A&s{Z7mp)AhWBhYfJf=_V>BAK+v+KsXq^>9Gm(0 z@q)l6y0ZAaR{y|&;%l*3{L$16l??w}9W_V+qPi`r93LO=)=7b?tE;~b>>or1?$Fw@ zWed1)WpdvoKZRkm+SJz9pBXo=ZD=?PW=Z;}U-C<$9G6&IR#NhPdA-sY_n9_b?da-y z8x)T*yz&{ zR%d|Fu!LR|%-zjR-Oba>%Rr_9&z1sPKVg?hQ!&N5n2m%U5@hb#vj-@A6jL=2qq1U9 z6*y#t`u#Q4^55keb#Zt-WY|#QOegyLoq@@fl$AM>zL6MNT3T{-?fW`9>;;*#v$G15 zZfk2B3{R9*R8$-%`*wFt#c^u}fCi7rbD(y1b_y*lOiNEs7_iz|N^Yz9tgo-XrF;m# zUBVk4J`1kQ^bV+wdg6?`RK)K;?#&7wmwOdwn=TE_MC@q!#prLOeahjuxw(N6KYRY% zl|1qJbATYz)U)UM_3Ix^Q`o&lr(OqY!m#9+&J;bTE#;`=0n^?!9g3J*Utd4;8wf=} znLHyMjPUg>i0K3e13j%@7!FJT{sMb^3PZ}L zxgP=n58OG1Ryx0ZAeOkR6gb85Z z$a#7>BvY(YjZFkZP4jPIy*o0ZSH(w{l$WcOTNoRkBKz9uFAPK~z2DH#5D?FDj&6}4 zw)f;%R1Sdv9HTM;QfgYDzd!M*K;orvX=UJ$K??qhzV^o?29njFQCJtC$Vxv6;<;S@ z4!GLXhT`Jl*Ma&52H<{iv|T=7VU@tomizDFyVZPFMw4$Uyg)LgP`v-q1m-_fxPQ;G zJ}ba)_mSG#+5*Nk3?U-}*qm}y^YimSei=lff#>WEbp(hIZTwvp5ppk}l`;*bo71II zQ}lr1DkIFN_qneFzXTzmMqftYO;I?qM7NXPxF_?PRkgLwYBDNjdRTayH=>@Un@)ew{Wa@!2j=UL$4{^(P`15p?%4P`%ISD=k{$dNq-D8 z@tLzkfO1uK-6>*K38@gzd1lY>xQWhAZja|YbEE`(*%c>_}Y z=4;RR*6|l`&HW#+;Mjxce-cJ2L*GI4-2qJ5`XQx}?zGh^8il7gx~f6|>2wCpW4Oua z%-|jq$nk6OYNMesNd7`-=8bY%*G)Nca#}$Q!DTzCrJSatC3+|f9%t?}Ja2XInScwI~ z?pZ1urz0MK^P+h2edfJgg)DAc<(<}P%hc(co8dMrA7h>5YIi=$);}h{5liS15$F8^| zVRc`xq8$@mmoni^KT?wmBo{E$b5cEBaVwNX(2r^GYY=ZGK4AN$kPSR8t;@>x-gdKZ zGbc$^JESW^;#umyotMLQ>5*QRyWvOlr~r-&#%pzDQ1VY=cQPhB`Sv35ER&NI!n)7< z=&$7{^hnK7AAJngPUad2JGBKUb-*X?l^1N35%?890l(bN6lTL^2dIT>rsi#(6o|^S z^+L%vQ4+7)tZcTy!lhO2CD`3mAClDq8`|DDJ_I$>LA_cKa^YA5#vf1al^+!*MSg%( zm{E*26#MDb+lGh};WjzEb;(KI!n3&~BxNI*&%Nfse z6%%{1=kZVgPrc$5qUp=L1x&N+qeO@rbcI372gB{z=;S+2`9FUfQ`e0-%5;!_+o^R- zO|vsk{e@(N>23SW_}F3>w7DBSy{9`-S3~?P@|4Y;xq;QuaW;(JZ&jU;k6sO|)8rG4 zWN)WCD9xib?_5 z@;Rm(b2<9h9{XsIh8|B?P8oj(qsdzMiHqYaxEBfTC#r31d&p6{snr)Dkf>vpLV1zLS_eJrMrdp)r8C3Q2zGeePrQp>9 zjd(g>RmMuce4SP$(C|#a&;J|HyE@#LgJcohDp*K?&N35P?kmNuit2WwiZcy=G&8@XY9gv zQ_J%So3_TkR7jBGl_%*Ik51niW$>3t+O(tLdw*APartL005#>AB<^9#$OGQvt#C81 zPpKS7ooU*cPxqZS9fx>{Nojfli>+9Gi|Nftj8AVJub3nK2vjyj z)_aENU?z%X5uRHc(SUPWIDCGMKfaGrVF*zpsz_E!;Udc4bSHE1D4%|a+ykUhJop_ogw9tj0CHjKJ*mxFik1FZ(vo$}#D>Vq1>vo$&UzG}X}eATiR= zm-=tbxzARw4GDqP2PbpOjtadS#|QG&cP%pDGP`K~fJ%ZYa5qe$v9ZlZPF=Uh-c=h2 z2J6!JHm;gErI8fP8vX20FAnV(?tm*cvfV`v*YcRRyytBX`+pFJfVLv+FBYm^&##MLtZG zZ-*a2OBRL-{GRU~)55c|5F6gz)8miTOSFkiri@5cZAbs{3P6X51J|@C@7OC^)lXMR zwhpLRZn2kLh_kUVcg-PGbZPfoKbfm_Dj;l7V*)z~6mI59ReAW0Jt=$V(rAU{bA>)J z-Ph(l@zfVwu@yh4A>m0PR`VVkxZ!}s$C0@l7xWZMo0`t=zR?}AY8B+*<^e!vHsYEw za_jDFBjf>(gO;&z{t|)h`dW1l)8#3>5qS%j(xgu%@`Z62RduV$9dtR?kh-dC3b%IN zYUh}Q8_X%#bLJ>Ab;dF_8KXbub;;|204sp?BtB{UiLoosOcjK&5PJFsO?B)F$A%Owj_9NBj;&ZNcF zD0yIcmv}BUWSiB3gidGfp&|o*4 zpwa%I4A2#P>yYFq1GrGYY#=&{C^Gi)(lLOGhd!6>AoX%o$dj{VIi`XMh}~^&w2VhW zr}e{<9Huw2z_OT&MqPo1@xZh|qs&TSmIZ!E76RNkR^SkD<-pjnn`d?&MCKcAwvBc0UP*x-=tW`}1F zs=VAc7L5NavZNRla1^-#jfrzN&t?zAw!7q^`A%KUiu^!p9Zwx22duc$^fLy~ptU`# z8?-@Lje7&<4_+Th&b62gdgjGvG(o9mAt3 zi<}&svwv`cJt~Oc?9mn-3kN}?XP$;EBt0LxcgKk}fBPGH&eW`DCgSrgFDK-*guSq! zWpDOU^w~bgTl5SH%i=Y%BLLqe|M|Q%1aeMmsj#-m=WXzc_=pd#Ye<%Of&W%d6UGE2 zw8{QGjN+c`%|=V8kE4RXD&v8WZjWp0K^{Jm%9)swIt^{> z40CJP^V6z>Yc<**&fdA>B$=s%!X6+#Un9O<{9ZStoxN)l0CU^O27aDDikt0g4nsl* z%+p>ZX}yWLYss0MfQkstt5!hbpWOhdNyr^Sx zQ~ch&djS^$gLwf^a3E3%&wN2~s=#6Zvnmx+ z*DpIhCilvPDc5!xUm#nsF1j;cNkB9d#b^}^w(C)EZPL3v5HxO{*30oTT^dv_acY=# zfz?sb(a|NzjL_EguO+VgzAzg8{(uO{>ymhv(xUVG0{j%nJM9R->5SCRdGYoG7+x{pP9D0Mj>C^Fh15%cZeV?F&Z4E|5rpu78| zAXAA@l$DkO!m7RKRNn%6rZfCJ}Z|$+Acwq4#X%e{c3DB%_UJ(3O(cD zQ3`&3{rdIpDAkXk)J360fm~H31<-Gv6cQBleL1RRqV?@dWk*eTd9 zThRbf06xzH^@Axm1SPRBH8lmmp78IQ<-p)S(@wlyZ#DvG1OPFgs8F3e6 z0;^X-KVgk+O>O`e8dngAf&GhQ*H+*mpZ1mtGW#o@Ju~9!LK1)e8<7Uf%gfb-3Ijk| z{r*`~iCQ~*_5fG(dl5+yGrq7d%E3DtDY@;^+JQwz-zU}o3wzDzMe&~sG7$=dFhiq5 zaz4?mCXuQuL^Q@&RzJyQ3rljj&#G8{h+h zrzmDArGCa6_uz|*P4aFr+4kZu%;oMX0H-srelw8h$YF)gI5PBU*N!8_O`J z!_00FQLPKwY|^S{NlyiuZeyaz;{i2|ZCK~r=fk|H|! z+9^4}3Bedeahp`p*3p+2|2Cp~ci(HT$IKk3C*RJw=cJomAV2}kRXyZXn?&}r; z5uIIXuImLg42@{jDsIWtDp_`frfADe63l)n8YiB>aTgu42i@T^(DeeUJ6@h86(;^32yej$T zojQxt(<4yUJ+>)awx4S4FPuLFFLM%RL2DQ}XR*iM_HEkWYf(GPWhe`S9x9&1D$xRamn*Pv5KH-$~q23^|}Q#+-OA4yM~oC=1Q?H##MCUgXk z{A4A62VB>7Z*dFBrXEiBT}v*8YubnRZ5=+l%3@7L>xMg|6_6c^OsJD)jBLRqJz$Xx z^}5R@>Y}(U%U9vpK+0K_IqO}W<7!7$`P{AmA6 zMAUh_+=_RkMRUFk>SZ(&a~7ZLum58&@&{_Uj)h;Lx(Wm$dBJDT{c+hz7d5yh&CTHy zM6)higk~at4+(@2|&OI`-(0o~#U+N=T z`r4DC-%#2d*j{0)0qTX<4>JY2`TJ|6tYQYEvZn1^i1<*vtxDfKDoMdVD*iyJ>DqE$ha-+NO>Pcrb48W#*w>y;? zvgNUDJQt@O8~H<}KA!I~`GY!UqATN2*!#@=b#2cGTx|@&A}M&1Pc?)fmtb_GD`QI&~3e%j|APO{f&DZE|&%GDK7*E^_n2>^I`IZjkueP$%b`&3ZL0>Ku)T0 zw5$V-HEAUbqUKQ{UnPxoiRp2F;_Cd__Ob%;jCD^y^76y`3tux`p!K*>v9U^;M+o$z z^V00t*;!olZ|bxVWJ{rY-(urFKk$Yk|f(BhNm>bnO69a;_xvcx$ht$z1I>C=OFX%5vuG1s)270c)Iwr*=H{^6_(kxh zeN?|S6OE;2+&y(e1qHR`nHe$}+ARqL9HQviK6vkz+Ec#529FElPi znfWXp@be>W`Q%LRwYe-mnyKFDpd(H)Nw3(NCC@R@HU-t`th{ZvYWh`jPUy|ZO{v-g zF^xFa(fMkpQOOjoa92#V0qzB_8s8(~cdaj*U0lZ(4XAdYv4Knjo%)An`~+jG;m_Hn z&;8m-g>@fgKAD78oz8(XxJFa?q)LCP)_tR=E$Fb!sSZ)0l+JwSx94jH=2+>F<|@9SOsFGqj*mGghX2bE#Nw z%>*XTv>fQArS@C|*!?LL8 zYSw%pJBYVK_v|1!rVvO9?<%jVSw0opQ`ci#8?KS!T}U-N=Ve(f`w8-UgC!MbAL0E# zPft7y^~zzlhfkQ2x||{&%RqIvS!c}})eRlEm`pp%bq&Z-5fz&37?E9G>*eV^Jgbu9 zb9L!5BCQlhMsY0$U3zo-$1f zOwkIWw0D1x(IonQ#dCs+i>mfEXUmq~gO0$S+|itS0HAJG#d<6!_k2&-q_9q;M|UjN zmOmN2wCtSZ?KIfN3QX~aY(542alLWG zM~Lp&bE|rWaUu8d!41e))lHI~J6VHIPn3%=rIX3D3<{A;&QV32^N1!Uk4Ih>y);3g zrVdP1&yJ3*no{*_6-{iM!tVF;%sg+cmRG+D$vUf@NSDgK+2%0{^fB6q`X2a@Jn`^c z`+#fhZ#e8>N3|H$!d(#9-HAX3rrC0ai1)!Tr# zO*xXf?-B%PyD4$i{t8EQhRo%XR(EDow(6tcsl;Q)x;i+s{jQGKch_M@jRW?>yWruB zGieM24(sD68d{5wi^^h?SkjsiPjJaOy)9IK;(wCZpV4|ej1_FHrm~YSnC6D0#(&+gSh17jB#)ru)9a$}62W zM!)m$KeAm^6H&*%RXWM{@U{^D;)2~-n4sh2=AH2msTh<(7|kqi+ty^&dTZU}g?*Sa zh-ceq9W!4u>r|JU`fQ%{jk)f_oJ?8~X@6O5Fc8r`U+t%=<16Sd*^JRTm z;+j6r#wnWvoem*O$u;_@*()1+nn?4@)`2CK=G{*(5*kcC&tpTT#12K1^Y5}@Q`SrR zPQs^mG#h6Jq2=wND;Cp@m(Rz{;J>C(Go<5Q`5d%ae*MI}MPPNY^~A>G>hyVJ*Y)uYZhve*?NGZR^Kj<%ac zQeU^;_*Mvnun@7WDS=1n9=SGg%m21*dZ9%a)+MlBZT+j5o|ZY0-}9r(iza3T9GZOW zGRnaJwY!6{k)WG7cDNM9J#nXQU5BK#pIlm7gh^*dui)a=caZe_V#iyS7fic`k#J83 z;YSm%0WNFCZ>DStcO3X;K7ORhUvvI}qwznGp*XC0XX1&R6gItk1R^jl^^xgPUzfVF z2F^~Hb>DgGlzGqbs+8kU8bwP((t=)NTr#gj;N9;}=$^Vds}cg$hV2~xypBH*eR-Gv z?HVMz!$vf5*{8OLDA9MAb;ytzNm=}<*Owxu1KxBpxDiHV95cfgx1i+(@{ewf+%@Tv z<6X-)KR8R?I466Dm;6Y9Ko%a{%(E~IA-d*p1^w%Y4{`9!dv;Q>C|~@;GP6Gxq_)DA zSnkRY`Bi?=I^vtMg^#LC_C9~!aq@wRE_zSge6(foFlW=^iv?91T!m=+QteV~RttY0 z%`PIFoH+4WFC}j14|A22<=+E`Qv7e%UBw7wP_OrAMM0=^6Zs$hbz`+Am{>*JU8_is z_MaSez-x78V7Q&7KDEO{mB#bG-5DsaEcp^{xhwfcG*xx$1AZ$hUAR}ONnyJl0y)I= zFU0isS_f^dJ&6;0kij%NVNq2H679%xAeV#u=pM*;jH%6A1!lMlubwqmcJAl0zgf2J zzcjETkQ_&c?T0|Ny;QsxfLTh`)SE%mV0IC$t@GjYZFicIyjYw4%ZeNOmqdBu+ky00 z6fz9Y@+=I-Wn3)S>;m%hBWuZ%I$}ClO(6DF^~tP0(QQj2*n8V8qp6(?MAd30sb}tL zO;CO^)C~q46UYuK3Z=Ow13JqoCad$%Jy{oYRjUxmPQ#UPwGMqwBv`vcd z>A~WNiKF9O)7jUP1NDD`{}kzAcE50vOqL}RNOeRTG43{@2IgA z2|BgFHn?5+4J7{9t}oS~rvn<*cS0&Gr0PY=s(8ggEtfWpAt1+-r^-mYQ~BPY4I*tr zh5`*ROu49N4Czo{l!oQavZarP$vZ5at$YEM|Z%Q6Y4J@lKi0RO0wv*o6EDJAL%N-l^N%wHJqI{Zg?e9aY`7mOqO4Cc4zmK;w zfe<1D&($I5ERCy(&9ur}w_@AudV8Hen;05?Fn9ijuL40Q5K5FIJ$>x*mwt+q-+tlX zQcr%VKzwq4^Jv58Y&ny@Qs2lO$IF{CilHPG$>__3&Y(%rbI^UoqC)cCCDK}&Mv8e zju^`H1w!=uuDq(TvExY&j*eSsm3d{{k?Uo`l4|{hQ)-kOWuQ4_OETbH%Y9b`DY{`5 z+h0VI|LJ@d9a8G~COt0sJBmF%u)MK0rbD5=hI)E>2^0l*tyxw4Tq$;a zP?Mf)@wT`3wBUh9O=AKU0NIrv4HeiTW%_Zl4ugG2jqm0$*ON!U^zq~#LCN~Vj8y%k zWCcCytxHu9#}8^WB9b*MPFnePccO#b)ad4L1z}1V;ZNFmkdaYQ8<^MiJ#pYV5cPjT ziT^X|_@4^#Uq;~oK#_yipt;A{j*@OPLG_m z0aT6geQ(=j&3!rE9@BMs1W~p=Q;QTU^{B4NwE=F)#iAd$t?Q382;gyYyy0ea0G8Ls zbd)W4sEOYlb_?|P>+VF^tMLs1KNzsT<;K=8gu#E0q5sz<`%ho}FL!gZjR84_Q;bS; zRzbf3`6!*Lg8$Q0Ht%&P7(gIoMGuy@re$;q@SwGzJC{J1g7UCDlAdGMPR*)49%Pw* z_+EwXS>CdIlHl#AW|*Sz)WPmOQ~aN_q93!;K% zsvtqivT^y!HR12(MFEx!c|w^V@M=DLU;@}F=dLnZ8N-#9ot2rnTeE5{80i?|<&7N* zX0@ZtQ(iORX$c}1AnS6x+uPeg5keFq z2S2>#Ua&M!*r$TtQ^b}1*+3sb)UxS2>_%_+K4=veoR*B8dOqBTMAXn|&gGOVW{ zhKCQ^M1mxU#69q&IPTN0YW#8FHp@Vy`9$(~Qsl(FR znhSy(K*7j;@0663*AXRqOtTFl!}d;nv@S?c{GdpZ9Nb8QPQVBM4T7{%5l@fzfYfq2 zEPP#q4rOrO*~JCKmVJO|P4!NFl27dGc2p+H|LI4(VTNMqcJAg5d*Mu&*-FT#jva7K z4Wu^YTp>WRDp=(G)PZEuM#w=wtN}Hmjqx>PaF-%GfDE2@I)(>4pS}GeOpioE@Y7W` zXl$jkGzV%qLQ|wTGawkra$Eo$9Wtl`)Ch%7W+QbQy{#eBY9L@w+kv-6_;1j(GUxfW zYy(;V9=|FxGjsc&7vSG+tj(SdBw6zZAE@FMTTyRM}1k ziQi}V4`-~FZpP=4&+noJ;0<;l4=vOaovO4v&3QMbBWTB}w6M65^+S_g zc2!yn{DD2u$uNg1gPa4r8xV;4m~Nm_vHnl5E~jBg5f&R=QrdzY+_6NL^Q!a@4>;=9 z8!WUUMjI9Ecyzs5MM1QV4U93Q1C)V@Rk{L3VAP8hj2&G4=wgXS(Tjj7Tx^^z42m} z)PBRXz8Bt?V2w_gYQJSvTcyQToH>1$4-Yq@V&F_XdzHUU9BwBy*KFhDCOFSQ*kr0X zsTL?;9uFX;->xE3FEb`nhhop4aJ*lYE&V|YoPAEkN}no)BluFLDA(VnxB2|lur4Ri z`J=TZn8E!0U+0ZIg%0S}8y4E45VaLM^=kP~gK)4nfXapp{wUY!yeZP!YRE5Ok|{wy zILZUb@?7_xh3b>^#?#8@*3|0A@ET(Ufjb9z-BR57oSNm&JWw!wcn41!$M^$P9=I=J ze==9PJX-5k4ZAGb>`Nam(qF(^O8#LuNyq<2o zHnmfGg4HV#=dFMBIr$ItZ<*x>Svl-9Xo$UVj%yl0+f~D`<26f<0qGHsR%sy|g(5ds zFUR|p4C!4kfWbasKj--7Fe(aeQ{T2Mo3k_ft{8T93Lvijc<{0}l8N>>^Dg_fTgXJt zDIgE<+RaprK{xg*-j9l50D33Bag5BQS@u6*5u5H=X5&s|lKPu>Qq`a+Up(M`drc0f zYB>l~-GU}P|DP8S9KNRtsR&d$lz0b=`@UcGJv`OuPjnQX!>{dk6@6$V1}5H6pQ8;t zkWDr=&nLi>=5qMR{8}_sTIWT*+<4e=T2r_J5^V@TtS9X+pfF};v{9$Z^eH&PE}Xi3 zYM~H!fe;*H$Df?rKQ_HNzgFVNZEggLv@iVeh7gYQzAEHrUH$hENL0N+XX4E@T9fNK zTkPL-g)SO| z^0^K;9Nwj{9@VwV|44Xe)WC8;>L8Dh*m?=*+L>~o+0kvzqN{P>;o^5J%=S#r05J8aqkxCeCqqPOn3X=-NN%7~?Qkg2tdn?Ws`*_HVoBL#jY9 z|7}}*Bl`p>WqCG?wn8R^HJMUX(*nL%-hE2)C`+GLri&Wiav_Vr1}tR3Ig;`hS4yJ) zwlx!!&Lq)b<0{=N%>BY>K)17co z?U659R_#B-uZPQQTGOMC1EBTcF%?Cc0vUWfDZ*+xoqC8l%ohjY?Yf>Z1MtbZ^+lq^ z-(1#zrFei*d#{`x?GWNSLi8DYN~1rk{+26C`67rX_Z4g9-cN357%*WOlV4X*Zx7)2 zc1N?XA&|CTz=OmOYrNsCCf`D zX5aNV^g|#|(v;7`=D_tiQk#41cYjb`wJc9^BSHVmIXy)_aXdvfzKxky5KrnKOKco> zF93}()((p2JZrU=T7_XC?j;F_#63Bc)gC{XApud7nBh!e5(<(_^+1Nrr9 z05uSip12YcAEwA>9&VAg8Rdd{ZL&0SyjL?X(-U@fKY#YF&Z?hp>8zEe75J@ zz1R?=xT>0R4%V<9u(Oza^?fr<(WA)RFL1YV&i@M^@s$#}wOVLdD66SeaX9?2<8NiZ Ip1bnD0F~o?&;S4c literal 23193 zcmdVC2~?BU+BO_&m9|znJ+?(bNLwN}0VnsL9()*JlXr+ z_q4C;zW49PTpTuhq4Na<0@;8%^3w?jWNj1#vgVi1)`3r04<1j0m(MRBaSMe&^b%Bm z8cAa_eh|oa5Y$fxe~!wWV&m@nxp_fl;yvwm_Uws^KW*$CKmO#)r$114|B-s&vs0Va z961MBOG*D}_R~GP=s72yyM8}7edAKkX3w21Wfi|rR<8VM``steX*;La-f3KO>(ryT z>%Y}JceMZ8mYc(V`6Q$Z`xHN$ddiF05P3={V)z%k;}{JRnW)6WpA#w~OZtp7z!3lU z*CJ;F%0+_DzEakH?U4BK7O@$2d3h+B%1iok!V90hF!W=jm!agBmD(`?tS6{J~zz3o^gwbS!pB#F(QmrQ<%u}mBF>&cJtmO<* zCyAahkYJ6WzipcS1OkD7HT|L~dhk~%)rP)FQujS%E5>0XMFY}!*x!OK$sV)z8A!Sb z@n498X}Qe)-X#CT`^ls}it3xtnw`Pzk(3)BqGfaMHH;A{#lepoP042M!5Vg z5fZWR6y{SKF5SCDE2{K$L=BUmf2@O9Xu)qCI=1)l znge>Sj2~_;w$s+1n_^;IDkz{!#7Rs3>BH^K3qhbTslid3Km~R9#S+sBqn+ zOM0p>zM+-l`LsdH@#;>xG3xHNXyK5xYuYis?m9-F;1|SY4$LZ_^&rHlB8{uem0rg( z?1~5|if~av?&chsrNENXrw1B>IKNX{ZwS2_Sj_=CRBIMXT6Z6i+0*4)<7ObTV0SnTHF%fnlSt(mn7a&WM=zFaYo>Bob+4-@4Ru! zfUmnR<&t=mnU!tjjz3Q^)tB?@V}7htIE!cC$+j0>gkIttGNT&Ti%d$Cy)Z(07MYQh zFa3MJ#2}tue=#9E#M#R6S%@hs@=x)V^R*_UtoB_M4bYXWrqCowwnV&cl5HM^DHg_Z zzenLiQ~P}!XDbfM&+lKrp%CQe725vToO4jmH11+hNJ6Qz)hR~;OU8f~!3V758Ak`J zX_?%VEztR@9xBE!3gt${gnpusQOq3lCiQfF@Hui_d4udINMnv=mldWeAmsh;-`U6-|7%_u+<0VRR zL&6qZXWlDC%`O&G;L(DO5}$kA#J=SpPtdtSX{-RdHG-U{JChCL+@Gm*SeX-xEU%M! z5!qqNzU5t8XhU6D0(+giTT!!6;#=VfrBTIP8pQN1_xSWNrdhJ*pa&jD2{3Ah9uX>H=L(o!Sc~Cp9(^)B(oG1>Av*(OfEb)GFRzo5;TWGJa1#r z2Sa`C39Ub~>TH)TKZGS6iM*G_^hmP%j;@tG7Va8k7h*G7Kp8Yw3|W(^<<;@W>#%Gf@g#eilahCc{JGL*zO{J|&=t&?969E{do` z3@@BVE*$Eip=PU#Ss~+W!YQJW_;I%%3cs684XIH&QE>ci%_-Ggy-JN^*KQYS++QdU z(`-V`7NQjOlHUHIS}j&y#|8oQ$z4y9Xuj|L>y|=BP9iR^Un&aA$w9ztl=(0Y%LDID zftaGQ{}6rg9;JPR{eihyJI#jEZ^yJD?_q3i-s{;GeXzO!wOoLr5)#~LnKR7iAxC;h z_Bq2eJ1^Qw&gYY&=QxrUF6rBPGdgXMA`cc+lQnZQl0)a01fNePb`5s;bk@oFf_y7V zD0*3|)A_?}rAHelQ)K3M0;xy~%ZYWM!r8ASyQ&}1hVNKB%9i@ekh7dj%(HvBx^(HY zL0?YVg|XcWE_oS_e%za3Iaf)vs#s^r@;JxpJX=SKgzWqq(BBWp4YFHd2DkO^VPNkg z2XEMf=ea3vC_tLb>9EM*kB{}Wr#;8cJoC#n#S3<>i?Rys;-crr#3LCN{ z%F4O+zKxL%_`P&2wk>k%n3C5t%TJd1RZCr;;!LJqRhlX6ZfLMC^OVC7h+^Vl>o zNV73nR-h-s;zO1vz{Al~O30G~jq5MxJLKvPTh88v5u&ua34z2{VcIFZ0s8F9W!bON z2zV3{x~;#CwF7JAC!LqH8r6nSm>Z;_aW;o#BeP1w=nnmCtF2EJx9p0{vgjJ(1fu~- zQ`2mZ_*iB4j;Aa732aiHR4Y#N0ycZ1p@RlLfrir}Dax)b%S*rVV@=qfy{t_8`W!A= zYx3X*`BP^^s+n@l$cDa+QQ}n0bFs2NZ!lNRnWkoSd}+3A%>jeAO<=%Axw?IOR-#{s zT%mIfs6iqI-&R)u&yw+(UKe=je-`h~`58;AY4fFZ)!|@XHS>?WU;S0_*UN7zB}_96Mz7Kc`s6QOWgY}xKV#(tb`yaSE& zz9&M;T_t#h{9G14JCB!(V_i0v@*~cYTNGMxU)&j5yPr9IZn2_icDgb&?2lMK%I&jv z>Mhv;p*epGpd6X(5Oroo4=n5_{!|uY4clPq7|K#(XUz2eG|fud+-gKMZz+pk@VO2Ah*j;`CQ; zg=stME?;UX2*1|MtLV^1^mDo1HdHoL&3qd*E?11v&9!=Rcc& z-88%XGR2UkZQ@9@x)}TGx#GghTC^fWY+0=GC^f1bUrk05r&-Lb3i!y^S0ZK~H_g8N zm2bP7{krQt!$lb_ANgF;5LPC;R@Y^NOS*lCpg*YXCq;hVVQJTl58}(MD@kc)Qe|Yp zWDoR+6>YrM}nWR{SW2X7BE zq3=qzEtK>M1tu5nXIfwV<$JHjWZ$j#@ZhgOGCa_0?P$MqLNDb~x?Ux6M35-Q- z%qgOO5LnZ5V^LMV(t&5ZG^%i;GFAethP0QYzPh89eHfhQag`y0J0> zw&8KuWRfFGcdxEp_!Qb)7#^yhNA@)$_UThx0;2+C~6g1mLC@X zg`wQj>TD!AK*#$bcTBLTac0}{aIw^W@FCZg(a;BhT#k~5weaCA0Y9Z7Ty#&==Bu1B zEr2J6byAR>9+Fq_tv3xcl1+B&*eMi)axG_Vb8&Zv=>mopP3niwFMe(jS-1T&?YjvV zWnu-Tu1sXW3{K4nr~SdT6PU#ImPVtiUG-ck!tescW&XM4yLXb_awZpxfx4(7_iLKa zZm}b?b^}h>?W+YHATYb-((){ybPQpCY$EM#6jJ#Mv30&1+j1_e)%l6MX>c?odwT!< zh(j&pHnxd<42tMFpDj%bVmQg49n5-<9|sRpO0Tx?n+MSxRGxb+Trc$fd}f$7W4{lSv1FTY2$?KA-hz{|2Yu2nlTN<0 z&d`EI<0-Y4$rzU@pv{R5d|5c<-iS z=E2NLxflbof0HN%Dst^~Qf}SDx0=kXeG=`cNL#TN93xXxOk5NX_nEznx?t7pg|xTN(>7=tL1T~raxSZsbh z@&dAY&H$wl!)Onnr_8?i*|$o%Z5O(?~tct&YA+@+=C5%1-~^b z-bqxuiv9i)XDj{);qBrjB8xa6{Z4nSwgygXXvFtZ)5gQ&uMb*5;?@tsukvg|tnxAp zzIx)oSp$i?9T%q!a`ieCX8*W-KhX$VY@F+Y%o)^<7 z6dP=-UgQAZTSDm(YGHeu5zAa7K3ybh~&b`U)?d|cH7uoEn z(ZpBij*gCR!4mJDeDKb#^Ab>TP@bH>I`DpZ{FXd-3AOnRHYImFiv3 zyR5tG@oB=78L2qIoiu8Jh*T@q#l+y=dXzF6GxXxZr=}_~9mx5#UiAt|{JYAQAP{rM#`UV#ciVv( zf$QIT!xICrHGib1tE>A_SZ;0o{qCDA&=1qo1M@M7>C%Nr8@0&RuV4QPZAhP;y*iWb zL~Kh3u%1$DGqaN_-4!E$_Qjs{@-p@|ds>;5wg1YWQSB!STvWE^ zkfd+yU3r>g9E`&?II?xbg3CU~(AZ03mGvp3l-!QJQHhf0r)gOk8N0kITOue>sr}H4 zbAKU0GMP+G_OEtsDi;zN5m6o0URzr`VsYloncF=@e$mmjQSCQw+!(QtI3)%bJ=kRA z@^z`3FDol8ZHISgXlP|rdu|7Z0Av%@?j9I)vd0@M?7a%^>_+$lMRR0#1}-G%5DIe~ zlD;kNI{~c&PNR@!pE#NhOG{7R>0N2hDgFQr1p3?4oAhCcWfYF^4GdO7u;>2@BK)U4 z+}#?sCN3feZ_e3v?`|C&tyv%BrwS=yCS!cJI)O7xPuJ=DQ>c zhhP4_Nu}9u-Z;*rTMROFq%%6CwWusf7_F<9-!)!Wg@B@`py>I8(bgpGQnyL7{1!w( zi~sIM?=4OLIhOoS>HSxCGocE)H8sUWML?W(c3$-tiASBCPd)YM2bMmQ-g;MWm$w<} zqQ5`T&>0D5U|_d*C{Z0@lhiKngn!19_pR;%GOD7i3RH}o3HZhAt#c@Aqxctm8Cc~iu3mL+zmVevs;IxY0+O>U+-Ce zv9m+0Rdz<5Wc-IY#{VWxo2&0OK>GKp1jthh4&)6gwdv~mc_zKGvJyDNC|5q8uX2db zt6H$`=#2iP9ycE!Q!wc{M9;XdMPPTo{j+axg|0N)J`xBW@culN^;eYl!;JTh-!5* z1p{j!oweZ?c1w?gM9AJ_HGwKt>`^bTQ|nOUjn=<}a8=C10eE+J_pP1*wNF$>b68(* zF9;v%K(0e0By#LfJU+j$%Q*Pr#fv`P1@?p|etv#=QSAbO03@X`uIPETI$B3h^_GJV zfLXf`)v`s;vvi~&i*$G2=^d)x$>>NEbc9DILMU&0w)?wOjFWjrH)-4E~r>07gn z)z+7fKlvce-upya^JDnq>N=z4pIgYBo~@T|Luwuk2*Dnp@nHySSm7W>?}9+KkM+YO zx&x73L?^9B#t9$L$@Q2?z7O=W2P8dIwP9%73{vjK8)MO%MA8YE>(SXs>A-{Li2zhS z8NFQzjKtem}}Yxow8H#2IZ#uMbc>)C!Oo8+TvHD29rgq{s&igzB_E>}Z|2^eEeHkU21|0yxn znMf{JuNlYgOTBW|&Wt|RFxF$V{1e5@);>GMMjJ^8C-Q-+w1x7H^#7eltp8zjc!p%S zoE)YsCx%JiDDR7kQen%rVFnRMrUyT=S|nwB)BoA!gCI0+)z5ifo9Z9C^TzSUx-`*u z(MIxJ=78ymGEc#LDz3yP>CqRr55tpXSHNrCS}6)g8b7_M=0yJ zQDdf~l=o-OT)-k)62n4+kcR9hQvOA$)ASmm>|EaBiyJEac!soV=H$Y23(v`@N zOvvcnIDdHPhB#xD!sihF22W3rXrT1Fu(Gg-#qzMZtSm?EFXYkU@~Wm#Xm=fsIaIEA zTI_lxaw4h|cP+wk*U^YW6s9-wUWwR?7LMgk6cfZ*+`|o0!Vh!@Y+I?5Rg(BM(wKd$ z<^T|Q?*MXCSu5cMxwbB>G=rL6V^+*yo<%UlPR~JhbXLAc<+QhEp z5YPUVfmI?_+UPF=+KlvjxiIukbz2yZuIJKGZ$t329V zog;^`V9F2^e{Gkgbp#5C7B{y1XT^6L*9XFFM{R9Sbwq6S2yZWH;3n=;1+y349 z4`=XK4pWq$*|Md}lKAj!kEh1)#4i*--soA0qP$!2*|wY*)>?`KjHpzg$Qc{^#v3~H zCx|)wJy)1}Y)$C@q%geFxUDg5fG0jNjU~!bgM7MvF@ieIN*l%s{9<1+L-Om+uG?zq zvvs$ReeDwC|sJ_6r7r2cN7EYa6}Z2Zj}>d+&-ZoI!w%lVmsfdzq<0@X3) zgp158jm?dep5LUeycHJz`Qk{);(MC2)!LWI%=SaF0hm$pz`m$KtqWL85Tqkn<%R@| zX6c_W38*iq7Hlb@FCCoKWwvYB%r4p0M-aG705XftzuZy0^)ys(H=+65^1b*md}EAs zs60XIftW=1xx;8pSl4E@DSNIg>~Yt4>wWjFmI<{SU=N#Z#Z#`<&A8;Z3lA6trSk=T zQ3Jp78@4CMv*x1N!2KTAmD`%r{X4z7rf&%BnWmC#LNu{-@bQK`{CyGVXz>7SDI5~$}~JC35OWYDBLXo&wZEGG^_;f6;wNJ)$O;5%oafmbD zNldXxa>j55sMAS!@1haX>CC(wGi^rMx#XfDwj;(yO!uZT^=!4!0Ma*rKc5tC%J!JJ z4n5Z9>OUKSkVTK3Ye>k~efpeb<1@iF`DPliZ`9{H?GMrVIq1f~!E|AO`%sznZ+LQQ zoK?B$=sETuGr?l(I$H@5MjE%1mNNXCE7^Xb9KUSd!?-FR%^XDka(CK;)rn6b~ z1G7V8B%SAyhK5$r(a6&*iEybyV^7Q18z2b`xMmyqLaa#@3PIxf#Y;`v7cb>O+m;2{dm8Biwe5k`=Bb1CAOccI~4Cq9Lf-950S)VK$9HPFLC_zM<)9Z$l zdT@Bkfk^Hx7{Q7i_LF3at*p+Bw(KiizyNZeRo%T75_bp<;wnSmwi~*ooCz3>0;6aL z%FsCQPBz$)ZeOu(kyOj*`J`eCG-c*SSm=v`>$8)&#)4`&ix|6yoQ z&j{={H(0S{zxF*l9`jGqquI3pZnq#5*zabeU(5~f>1W`{Jzv!?`fa_B-bYQOUeTJg z4Jhk)+BC}VJYz3PyRd`a+PT1p%&V*EyLZQxvoQPlWcK8wcRFU`cONIRSlZRS0(G={ zA=#2<+bUuw%PvzGL`K2-bS3*&K7h6X%~7?WqB$V@wHN)$Dh;-fZVunjWNn3Xr0&px zjMsTk3b!Wh&-*5>yEpYpIrbE#@<)4QlAbMoH!DJ6p_uYCuMAOjZQXN8*k z^tmo8(XK?P-p^|^AaNBpeQt3wF035z_!JVEh}&`p8%6XvGONt1JKJB3Li{26|F5=Z}7ML}~oF0MUWe)Y*Iwm@hBG|JDiFtOAxr#l--|P+?%aRROB-vOLWC{DJ~4%I8>16>@p8n4<*SH{Ujkm9vSG(O=Gt zitoeb=H@>;J*r%|Et^UH8=7o|?c@BMqJ^Xx0p+-g5)xQb9CW z_t6j^r$ibPFIP-XPO9OZz^5~0fcdIXqqMHR4mAr=l-DioCsQcyAJJlf-;VymX;EY0 zO9PHXAika9QUDx1>ngqybS8&a?%S#Y-DJYR*oY5Ha&#~mAWMH)@CR^~ySziybeI}> zNWP$kEAsO4Ml4prulF79YV5J7T<8iEv&^*gMJR|QzeP1$ z$AZt}0lY1*#WEcDkP(Y(>yyF0T6O(Ll3@SEj#v4Er%#`L1i*?;MV>$ZII2A*C1vE} z%=|(_=N@HT?g#|x12k&~&{TfY)Kt(+dRtrDD>UH1Xi$LaKI`&Qn`Vpu+ut`C-RcPf zGzIXiRVzOhkLFO_SWdv-vNku*R%s9KQQ>Gui9k1ZhI{OV!{OCX#FdesW)PNuG^AW0UI3ie@97pRtB4oC zD(?i)@$=<6tg|QhAw8Xo$3`m)TlP96%6*+$?VAzRH8p4JleW>-+^t&V-4nhRi*PlM z*}cD{F#JpRLy7XHsvhrMl^TnG4LEldaRhK8APCgv91}x{YKK{?DFHR!YO;Gb;0s41 zT_=K0s=;my2J>yH^(qGefN+($R#)nXLjjB0y;!EESQ0rjdz$lvOmWDfnx$4@^wXK; zvrdVl@j8L?-zyQky}0J9B3)>l`bu1~6ZZr61z zhtu7QQBe^v$9m2HsQ(R6veU0C|@oEor>N&yED6J4N>uD?mzpF)T@_aK+!ZFE=gWa8JGUjn)O7?VYARP%F93>m zK&U}A2#db4K=|L)gIjjDs`;Cw54~2fVBCWbtIWYJ>5O||Yzs(T!4jzW4P4PSVE8Js zy|5gLRNIKf;wYdl;&p=c{yK71H#p=uJ3H%zZCVUc^9t&U0YFv*J~pofOHt8WJQye} z0K7`V2Q?!AVywITJaDs)?9+gtHug|u<*THbJAr(9MT8eZ9iLo@-6NBl0!b4RbAkHV zLo-y73e;o>yZ3uj)w&xb=)DviEPRv!@q7tNO;r*4-&)qAN)4BktUBrbHW39eM51Gk ze5rxDo_5gOaoh00f!|*jp3+DxjX3?q^WV1b6g>()6?^H`8%*J;UB%n0>waeauyod< zlKQvkzd!$^?wdcp`0;nsN`s`?N5f5TVc)-m!7e0E%_oJHVtG?pS$%MtStQ;}ESU`V zF_UD6Qs?UU3cMs!nik3cd%-9FC~i9OvHHpJWA)R{s>sd_kY}@n$(TkLGYbm~f#KAC zP+ydcdC?29%RA*S0!3PN?cX+>ZaI72BC$NZ-@V+s&VdT%N~|5Hrj5B#SxP(%4b%xVM$ZN zVu^+5j+UcfT|Fo;4oZw(TR&-LDR4I(5)O(SXQzID{(NK0W(XuB;$ZrBmvZ0&$+l(6 z@6YFtTJgf_zBL?pkXW{caS<0v#8%AA#Do$H*OMQYUh$7T_U1_(sBdH%@V=QYVf5xs zdafBvfk}*NFMbkSd~NT#vR54$VQU~U(`!)K?$KTd5lZL8FWV|wp$SB#%X=8de21M0eeQB$O3N;_r?92=awx+|0GO+6Q zZ?xvF-j+zhJ>GVC zYZ%Wi^-3zt6+j?fM7RpoDNMFS>cX$LEj_xQ(!{VsDOe9JI`WXp3#TQ8Mu|@(cRFkt zlSj$IeU_2e^I*si(LwmcXhv1imsxEQL1qNT<~5LW9#W(mE{s{@a5^?Py>z5FTvU~m z-xnP;xvrk!ntf>w7v}B^6m~viLzhP=VH85 z7HCa-l6k-756?y#MV}!`A}8=W>G2+I;cEsLO!OBro34Tev@8?`?Tl?5DlhH3kU@b@ zXVl7L{q4ddhZqrcv;|MgxmfTaTMHI3G1)_ zEm~Fi&=5Ne>%$&PGC9<)itb@EM|PdFz(BY7!>iM1{&zGWWyLseqJ%dEPmavD?v!xy zYp30NN}ux@_7*1neW|-h@!i1SQ=!URc;7dyPj{KE%nA^Zv_A}|$FmjJ zg#p$DJ~X&x&D)%cm2ko#bbqJ~6TgH0Dn7s``-6i=L)}S9(5Prf76oYQ$Ys=AcsFPK zsPaa4MT=(MoiCzHQK8w(!@kOkd&GU$pS92P4`l^tg*ey!X(q&aFoWuJT6l{QB^qLJ z7%zmh9y@^8CyIEx8NJyTbSl0(96u9SE%Q{9sy z*9;!l4w}GkUwYI1yy|*>`*YP?pLbkcpC#~Nr{U`@guYn;KrK0X?@Q3|InOG(YI=m8 zNBZFbga%o>t|xDfW1|=f8 zz+gwBmgAOhrVZPx(M!Dr%wMVg>z`RNNu{qR&W&N++hm2^qY}f~py`_6o`8=NQ;xq? zzHA!J5EzUGwcaUb-r0NZ469DD8*+-Wi%vKadj6piZ22b4Cxts>J(uaFo!56r#Uf0H85?YSP;(is-G52Ai4Q;!a*)1>Z+iUX5@5ky(T@0QZU_koTCIq z6cO1b$QjB`=k|c!O`3_KHQ)vBWp!KcK&^>zfQFk6HN)XEg}pgeGZM<3y>YibkGhs6 z`kAP-s@dR`eStuPI?bh!ACr!3ny!v4ORglG)la97XSHbs50#5Jx_K8e5LP4QkCOxL zW^V3z!k1p_kUNaM6*4YnGZL)IcC#2pS8axH$I`DvGi}r z_Ok5TOwViBOT`9>b#le~Eqc>B(EAZS#Q1<0k8+p$=XZ5KB>zOf`?+Y=hX#Bygk{DS zW5*@#G*-lx4ETp;8%ct)YcrVvc#dk{mWO-S{c%Bl`%8_kORkfa6F5;m%z^3o?s3B! z`NJlLC?(EnqzP?H-8WJ$x))DkACMD+Czwwb*mj@zZSx~B=z9bAMu$ue5LVVb5OkQy zz7Vd>YPFjC{yDlKhe$MQoxg#8>mU0r0eLjED~Om$;!eBq*g*vRDHloK?POc)_JEuE zHc?Z9uu^n;2+J=>^b_`K3~6t`i$0p33<3N^B>du?Exr)cr}d2;b87<-=LW56HQVU^?#zRG^5&!0CG#e|c3ID%3#InErN5bLH*6W~wi#=mv$tKu zWl6;zzI}`LPH$s%6&z6gt8Q{o&q?WU6%`?ML{0d@)DdHqJDIwP?!Sj?U`pJ}mu-fbrS= zRCik8?LX+gQc+H~_sV8!TW<~Y$pnghAyatP7}p8n=uoCS_O#Do$)*64ALkyL55NB= zAR?2)OcUQI)(Hu)Q#2KA{2iLYdtu%zAPl50j<~d^m^&DHTh=s`nH6Kd9!)F`Aatc! zVlpUaP@;90l$91jQKsNjv49<#8D2`PCvt%gEP>Y#xk{f+63z}Shm{fs8ZPNC^rrHT z3@lDAzc<&mkG@D09}U%b$+DS~g%h1@s_TsnXrE&G{@A+c6ay65L*yrmzijOAmSTC4Y+o&v;~? z8hoa?cVG~KEc78o7DU@6kV~Csn**wk3zrc@Gv)dHA9YZb=*H>suA9SoY`wNh_F(o0 z_;`|2D7W+Sid_KWGa9XOAPc0H?j^d@8<9)dZzlBmQVz-&4-XP~U%c8?>^GRkDPrUm9q>HlOYyj)*=RXJ%0?<@z ziiS9;xO_?vrC9!rwtUinCvSJI4%ihrgsir&!}yFY->(-3~IdoQd|DrbPB0L;~m%dAl*z-i1;H~uID8)MEZ?9FpRarhJ zlCLv8n34}I^2I;+L4}!?0nO~dlz@_&b9VCB$3tROgYaQ1a$OC z%MT_ZU1xWps239bEcc0syh$O=?n$J7`g$1Eu)Qb3A#2S$pmmAs>QS@8tmrxo@w-~E z6b#o&J3U1r!%w)YPpc0&VOC#^hL{es%3HqKdb?uf2Q=Ec2eHq*BO)kMof0+b*soQi z-3|Lgz+O>xowNOK+sMJSUqkj=HLrjA&jT46FP%)rK#nEFYibR;Q&dIo0%F4|`lkl_ z^bxT&AKM3#FQ}1%HJTg0E{#_A6(wIde}1@gQNFyqJmOnq3gCiQXwW@S1=>2^z6Cc; z4>f^eTKu5aN>ov4a62cnhef`Y?GdB=b*={Z^?*DH>(X!il|>7Guhe zd30c4;F+Yo5#-{iB#V}b^BL>QDr;WrsN``V?_-sE%E!9kpFe_k$98;diurfk5Gc;o zg-l_9u)%KrX1l74eYI>;TSa$zs)~lqP&^(l=BbCf4}&(@cx}xq^eS_bOQK@cB9=x8 z??RE@0P%D6kZ$(H)wjavK%S=I(rSWI;XSdqw*~Nl0O3{DeVPgUZKrtYC?u{*ihtJ= zHSU`=zgK@{GZ{q~EqdOZpalj1mTJU8BjN|JZB$9_KSEIdaJpj?>&8e#A3Ax0Xk`p z0&*R6Vpjw6__j2f`}&@$1yHGwzd|qW#YivtuU5hLwPJ&OMjvZ=lpBk4k{0|TA|g7S zd&>YZin2O?Xe98m|0b!e?AsPbOb%QO`eJ*T$y#TgsWl%Q&4Q&&oeI5b*RySgCW+7UWA3Sj@soXMP#eG z<(#YSeM-Hc@}eY3Gh)8nCl#h{(y4q9{>9YMyQ?tmf0pe2TXa)_q!X*nGHS$HJ!wO^ zt&-aB-aj+iihaszog^$x506-A>DhoT%+vBL>PoMgCCyZK!+~CnsCKzjq79_2<_s3g zU8EByam78=h?PUms;c`ZeW{4*QQSQ1V<)eAQ6f0xl_gyil9h>wQjC!ZK8%K>a+ZS! zdbtR4H2Y)8{LX)eg8f$^{mU_^q2`Ib>WUJzGN~m~xfOc$!|N~09GAShZ#%cAO=a|VA6U#SY=UB2qBTy>*m(pGCgzY(Wc z zR87q0(j;lrh4&%JcmVH+RWRXocAfxjk!dP!cupO_7gcSnx6;*&=v`Hf7*N1*UldZTiR+~i2s7ypceetX zNl+kGJF|8~x8StEH^XdIL01<7v4ZiDKTe{uS~pJ~^1%g?#i7ABfc?+Uhk^2lI|+zv ztg1T>klk%IYa(sq-Y%K6Q)%RP^b@a!^(gSnZ3u!$z!} zg@UX|?K@TPSqX?iA63>5ehtgHyG_1O*}2jSUhBo`*7()#Ofpda~du zI8Fihm$BzBbwk%6$_fH89OlxK`zrkzxf#b_ z(vywU?CixU8=xhqia<68)Gj0kcHA7mN!ZDlA2GFK51e~y_}SR2ie)~(ey$sFdibU; zrgxs>#)#LSfAmAR33X}Yhwy&Ks^IaF+om0$jS|za(Crz~=XV$#@{@pnGNVpRg{OL6 zMU~XgzCl^}d8iuljo6<;9)1S4v32cm22v?Yz$82>{8cKZDG!2%OB+I`@X-~1R-_B% z^Tv&fHLZ4{>ISSNJ3S0uT?vjUu>r?a$l*rpjgVf)jS`JGN`no(k{G+4ZUo3vHgA$> z`yHK?oSAvqBO*Bg7X2eQWyRBKxO&R+%(mJe=%7zx=~q?-%hs9>(2)IfBO_4F41qj) zlxpaPnmv?^d2RCi{zbN{E9LvTx5>;R30d{-ooT+Cgh2{B6!F*dm~kDZ9NR`eUH$;_vq7F~fs{vWx5-dLch=QQ5B}2(*-m$9Y+2V4_%otKi{Zpb(a4pke%%K`)=XxyzcO)Hg&(_5!O90 z>-$_vCSqjH^N>9bZ`*TWZql0sykK0gh?cwjPT6db-w?S+*k*ame`$fE^ezd2yF3l| zde(vYljPa~I_u7?Ff1-~@mo*+!k(Oi93XP*RfctzIWWYZbU2E|`Da%~bBFi|R_s5s z3cDyKr_?j%r^9?~Y8qnS>a573O6a^E)udsdV!JWIB89sbg>k*w{F^|mCySk07q}rQ z8+$3e)CrWQx4=RiXYaRLggR^obEjUcyMafzksK=rLypWw`tB}eB!yH?BHr^g;xvFc z1-WW(tKCB{=y`~Ul~ru$($ODVV4|q1QVCgbdd>tmA?xs{)&KG=Zz~+WVm=!3-S6O_ zn(D&!n#d3z-<9c^M9=T#PE5~X#SN8-Fp06?EW*6c&*5$9J$L##vL1nXEvE~=U5RGT zFVj~#$5n!80LUC<>K80?YxIYR!0BFp;sA*|V(|bsJ;Zl+=%|u2E%cR@O`Mnj;+lAA z-Ekn*Sqql&{2WCvmz>8~qhdfHdr$xzzQ8XB4E7#y7$pyuT2ekWJ>wc&u^~iPHbAD^ zSnR4QAx~JaQ0gzTdRXg_3(=6?wE$j&81l2twRZ$^IzpV47l;Y4v@PXRIhx3x^)4Mw zR}Xe83PiYg5;^!$1KjQRaIXs0n)W!8NMGXgAxl^gAbP3ZsfP2omEQtfUFS3uTHQ}) z4x;jlL1ajZFIJ&ESKM@bXg;=_q~ut-?#pPrS4KL>h|(0cQ8!jV@2-5j&-hb0V&|3G*t z5CP=C+U!)`5B7u%E@7MX1H+@sM~Dt#Jo&6Sbn#4QYF{zKslvmqE)ka^mopE-mVTZZ217ur)_-BE894(c0ZkAw9JH& zjX5Jt1*8+c`tZ4PP zrE|AEQ?ck)Hmw{@a%8iV#)t z;M;LKv#bQ*tg^<3*=9@8=FSJCZ<^$ClnG!BcA-FbN<%!WU?uQ7wOssHo@F9t7vIOX znz&x&43&$m6Wlr9s1osGJJkPk#G7UHzWwC z#D`4J=@Q=tx!neC>_^ogyHqjEwq39pPc{=)#kVq?W{W)rOdycntEwy}(9G7ZIfFPb zkQU)YMC!{#=Bo%g>-91Uk;VJ-5(pXak%(s&awp4UOjU?_@<5fdKB1o^dfF`EcG3sG zB0ue(_YVmN%`@kAsmivV(5FG?@{vtLCE-}+IYdDK7>k4I#NlJNH4UR%h9qZ7&BSO; zB$UKG-ca=!$Rv(}Bbp8vXW!%gY0huMwcE^55$)Dd$z0Y-(AN;iQP4{RiF5zbl`&lc zBc1gh%pl4F{H?(huBc}?Q~~4cU&1vo&A!~=%A6jDNpF$CQ>#^83}UhL0LItCb1pSX qDc$0`BkH0%waEY9{4*3O*Bs6I^`RXES*E%lb=c*nk{{1q|9=2H`!{s} diff --git a/reference/print_stars.html b/reference/print_stars.html index 5c1b111b..adc672a3 100644 --- a/reference/print_stars.html +++ b/reference/print_stars.html @@ -70,7 +70,7 @@

Usage ..., digits = max(3, getOption("digits") - 3), usetz = TRUE, - stars_crs = getOption("stars.crs") %||% 28, + stars_crs = getOption("stars.crs") %||% 28, all = FALSE ) diff --git a/reference/read_stars.html b/reference/read_stars.html index 1e431914..d509fcbd 100644 --- a/reference/read_stars.html +++ b/reference/read_stars.html @@ -74,7 +74,7 @@

Usage NA_value = NA_real_, along = NA_integer_, RasterIO = list(), - proxy = getOption("stars.n_proxy") %||% 1e+08, + proxy = getOption("stars.n_proxy") %||% 1e+08, curvilinear = character(0), normalize_path = TRUE, RAT = character(0), @@ -256,7 +256,7 @@

Examples#> stars object with 2 dimensions and 1 attribute #> attribute(s): #> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> file22f42df83ed7.tif 1 30.75 60.5 60.5 90.25 120 +#> file21d014e9bb37.tif 1 30.75 60.5 60.5 90.25 120 #> dimension(s): #> from to offset delta x/y #> x 1 10 0 1 [x] @@ -271,7 +271,7 @@

Examples#> stars object with 2 dimensions and 1 attribute #> attribute(s): #> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> file22f42df83ed7.tif 33 36.75 65.5 65.5 94.25 98 +#> file21d014e9bb37.tif 33 36.75 65.5 65.5 94.25 98 #> dimension(s): #> from to offset delta x/y #> x 1 2 0 5 [x] diff --git a/reference/st_cells.html b/reference/st_cells.html index f41bdbd6..ad0f7cb7 100644 --- a/reference/st_cells.html +++ b/reference/st_cells.html @@ -1,5 +1,7 @@ -return the cell index corresponding to the location of a set of points — st_cells • starsreturn the cell index corresponding to the location of a set of points — st_cells • stars @@ -59,7 +61,8 @@

diff --git a/reference/st_crop.html b/reference/st_crop.html index 1e518c64..ba14d33f 100644 --- a/reference/st_crop.html +++ b/reference/st_crop.html @@ -81,7 +81,8 @@

Usage ..., crop = TRUE, epsilon = sqrt(.Machine$double.eps), - as_points = all(st_dimension(y) == 2, na.rm = TRUE) + as_points = all(st_dimension(y) == 2, na.rm = TRUE), + normalize = FALSE )

@@ -114,6 +115,10 @@

Argumentsst_normalize before returning.

+

Details

diff --git a/reference/st_extract.html b/reference/st_extract.html index 7386882b..484ca1ba 100644 --- a/reference/st_extract.html +++ b/reference/st_extract.html @@ -72,7 +72,7 @@

Usage at, ..., bilinear = FALSE, - time_column = attr(at, "time_column") %||% attr(at, "time_col"), + time_column = attr(at, "time_column") %||% attr(at, "time_col"), interpolate_time = bilinear, FUN = mean )

diff --git a/reference/st_rasterize.html b/reference/st_rasterize.html index 245d5087..54af3d4b 100644 --- a/reference/st_rasterize.html +++ b/reference/st_rasterize.html @@ -66,7 +66,7 @@

Usage

st_rasterize(
   sf,
-  template = guess_raster(sf, ...) %||% st_as_stars(st_bbox(sf), values = NA_real_,
+  template = guess_raster(sf, ...) %||% st_as_stars(st_bbox(sf), values = NA_real_,
     ...),
   file = tempfile(),
   driver = "GTiff",
diff --git a/search.json b/search.json
index 517a812a..a79ec0b3 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":"/PROPOSAL.html","id":null,"dir":"","previous_headings":"","what":"Scalable, spatiotemporal Tidy Arrays for R","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"Edzer Pebesma, Michael Sumner, Etienne Racine","code":""},{"path":"/PROPOSAL.html","id":"summary","dir":"","previous_headings":"","what":"Summary","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"lot spatiotemporal data takes form dense, multidimensional arrays. Examples population counts region, year age group weather data variable, time step sensor location satellite imagery, e.g. energy spectral band, location (pixel) time collection climate model data, e.g. surface temperature location, time climate scenario. financial data, e.g. share price company time Although data can represented long tables, larger datasets array form beneficial replicate dimension indexes, array form provides faster access implicitly indexed. R’s native arrays number limitations, handle heterogeneous data records (e.g. consisting numeric, logical Date) like typically data.frame’s, can deal -memory data, handle spatial temporal array dimensions. project () implement flexible generic multidimensional array model heterogeneous records (ii) handles strong spatial temporal referencing array indexes, (iii) scales moderately sized - memory data, large -disk data, massive data held remote servers, using unified user interface follows tidy tools manifesto.","code":""},{"path":"/PROPOSAL.html","id":"the-problem","dir":"","previous_headings":"","what":"The Problem","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"handle analyze large amounts spatially referenced time series data R? handle satellite imagery don’t fit local disc R, need small cluster finish computation within acceptable time? can quickly easily develop analysis testing small portion spatiotemporal datasets, deploying massive data set? can use pipe-based workflows dplyr-verbs data sets? can visually explore high-dimensional raster data? Today, people use R large spatiotemporal data, hit limits related usability, user interface, scalability. r-sig-geo mailing list documents many cases. Now simple features R project largely modernized handling analysis vector data (points, lines, polygons) R tidyverse-friendly fashion, time raster data catch . proposal aims spatiotemporal raster data, well time series feature data.","code":""},{"path":"/PROPOSAL.html","id":"existing-work","dir":"","previous_headings":"The Problem","what":"Existing work","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"Base R supports n-dimensional homogeneous arrays basic types (double, integer, logical, logical), -memory. Package ff supports --memory data structures, held local disc, spatial temporal references dimensions. Spatial packages include rgdal, lets read write raster data, possibly piece--piece, one 142 different file formats. Package raster allows users work raster maps stacks , stack can either refer different bands (color) different time steps, . Package raster can iterate functions large files disc, takes care caching, using either rgdal ncdf4. Another package reading writing NetCDF RNetCDF. Packages dedicated single data source type include include RStoolbox, MODIS, landsat, hsdar; relies raster rgdal file-based /O. CRAN package spacetime provides heterogeneous records, using data.frame attributes. keeps indexes record spatial geometry (grid cell/point/polygon) time instance period; keeps data memory builds xts temporal, sp spatial reference. support R Consortium, Distributed Computing Working Group started develop API distributed computing; initial version available package ddR. aims generic R data structures, works towards relieving users worrying data distributed. Relevant work outside R includes GDAL, particular gdal virtual tiles building arbitrary large grid data sets many individual files, SciDB, open source array database spatial temporal capabilities, strongly scalable architecture, extremely flexible array manipulation methods SciDB4geo, SciDB Plugin Managing Spatial Temporal Reference Information Arrays, SciDB4gdal, GDAL driver SciDB arrays, two activities make SciDB databases aware space time PostGIS Raster, raster data extension PostGIS Rasdaman, array database dedicate images, partially open source. Since definite trend downloading Earth observation data longer feasible, work towards solutions data accessed web service interface. Cloud services AWS starting give access large remote sensing imagery archives e.g. Landsat, MODIS Sentinel satellites.","code":""},{"path":"/PROPOSAL.html","id":"the-plan","dir":"","previous_headings":"","what":"The Plan:","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"develop R package container infrastructure supports dense, n-dimensional arrays heterogeneous records, supports flexible reference array dimensions space, space can gridded (2D/3D raster) set simple features (1D, irregular) supports flexible reference array dimensions time (POSIXct, Date) supports regular arrays (fixed cell size / time step) well irregular arrays allows working memory, local disc, remote computer (using web service interface), allows R functions passed web service back-end, executed parallel, uses -memory proxies large arrays, allowing work first n records computations carried full arrays (similar dplyr ) allows pipe-based workflows, using data.frames, dplyr-style verbs. document software provide tutorials reproducible data analysis examples using locally downloaded imagery, well scalable examples accessing larger (> 1 Tb) datasets using docker container images. document RESTful API connects R client web service holding (processing) big Earth observation data. also develop discuss migration path raster package (43K lines R, C C++ code), functionality, new infrastructure. publish resulting products open access form, R journal, also journal (conference) directed Earth observation community. Timeline: Month 1-2: work design, decide web service technology, basic web service API design Month 3-6: programming R package, testing smaller data sets Month 7-8: testing larger datasets, develop test cases, deploy docker containers Month 9-12: write tutorials, develop teaching material reproducible examples Month 9-12: experiment different back-ends: file-based, database SciDB Failure modes: can’t get RESTful API work properly; solution path: ask rOpenSci community help (Scott Chamberlain, Jeroen Ooms) downloading large image sets cumbersome (slow) larger tutorial examples; solution path: deploy test server teaching/experimenting purposes Amazon cloud, Landsat Sentinel imagery readily available","code":""},{"path":"/PROPOSAL.html","id":"how-can-the-isc-help","dir":"","previous_headings":"","what":"How Can The ISC Help:","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"use funding develop R package web service API. Total costs 10,000 USD, breaks : workshop: travel costs Etienne Racine Michael Sumner visit Muenster, another venue can meet (USD 2500). Programming, project communication: (USD 7000). Cloud deployment Amazon cloud (USD 500).","code":""},{"path":"/PROPOSAL.html","id":"dissemination","dir":"","previous_headings":"","what":"Dissemination:","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"regularly post blogs project r-spatial.org, use twitter, post r-sig-geo, stackoverflow, communicate github issues gitter discussion. project live GitHub, r-spatial organisation. work permissive open source license, probably LGPL-2.1. Pull requests encouraged. R consortium blogs provided start end. Publications R Journal scientific outlets foreseen.","code":""},{"path":"/articles/stars1.html","id":"reading-a-satellite-image","dir":"Articles","previous_headings":"","what":"Reading a satellite image","title":"1. introduction","text":"can read satellite image GDAL, e.g. GeoTIFF file package:  see image geographically referenced (coordinate values along axes), object returned (x) three dimensions called x, y band, one attribute: dimension name; meaning fields single dimension : means index (starting \\(=1\\)) along certain dimension, corresponding dimension value (coordinate, time) \\(\\mbox{offset} + (-1) \\times \\mbox{delta}\\). value refers start (edge) cell interval; order get interval middle cell centre, one needs add half offset. Dimension band simple sequence 1 6. Since bands refer colors, one put wavelength values values field. particular dataset (raster datasets), see delta dimension y negative: means consecutive array values decreasing \\(y\\) values: cell indexes increase top bottom, direction opposite \\(y\\) axis. read_stars reads bands raster dataset, optionally subset raster datasets, single stars array structure. , raster values (often UINT8 UINT16) converted double (numeric) values, scaled back original values needed file encodes scaling parameters. data structure stars generalization tbl_cube found cubelyr; can convert cause loss certain properties (cell size, reference system, vector geometries)","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) plot(x, axes = TRUE) x ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif     1      54     69 68.91242      86  255 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA library(cubelyr) as.tbl_cube(x) ## Source: local array [737,088 x 3] ## D: x [dbl, 349] ## D: y [dbl, 352] ## D: band [int, 6] ## M: L7_ETMs.tif [dbl[,352,6]]"},{"path":"/articles/stars1.html","id":"switching-attributes-to-dimensions-and-back","dir":"Articles","previous_headings":"Reading a satellite image","what":"Switching attributes to dimensions and back","title":"1. introduction","text":"see newly created dimension lost name, single attribute got default name. can set attribute names setNames, dimension names values st_set_dimensions:","code":"(x.spl = split(x, \"band\")) ## stars object with 2 dimensions and 6 attributes ## attribute(s): ##     Min. 1st Qu. Median     Mean 3rd Qu. Max. ## X1    47      67     78 79.14772      89  255 ## X2    32      55     66 67.57465      79  255 ## X3    21      49     63 64.35886      77  255 ## X4     9      52     63 59.23541      75  255 ## X5     1      63     89 83.18266     112  255 ## X6     1      32     60 59.97521      88  255 ## dimension(s): ##   from  to  offset delta                     refsys point x/y ## x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] merge(x.spl) ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##                    Min. 1st Qu. Median     Mean 3rd Qu. Max. ## X1.X2.X3.X4.X5.X6     1      54     69 68.91242      86  255 ## dimension(s): ##            from  to  offset delta                     refsys point    values ## x             1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE      NULL ## y             1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE      NULL ## attributes    1   6      NA    NA                         NA    NA X1,...,X6 ##            x/y ## x          [x] ## y          [y] ## attributes merge(x.spl) |>   setNames(names(x)) |>    st_set_dimensions(3, values = paste0(\"band\", 1:6)) |>   st_set_dimensions(names = c(\"x\", \"y\", \"band\")) ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif     1      54     69 68.91242      86  255 ## dimension(s): ##      from  to  offset delta                     refsys point          values ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE            NULL ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE            NULL ## band    1   6      NA    NA                         NA    NA band1,...,band6 ##      x/y ## x    [x] ## y    [y] ## band"},{"path":"/articles/stars1.html","id":"subsetting","dir":"Articles","previous_headings":"Reading a satellite image","what":"Subsetting","title":"1. introduction","text":"Besides tidyverse subsetting selection operators explained vignette, can also use [ [[. Since stars objects list arrays metadata table describing dimensions, list extraction (assignment) works expected: level, can work array objects directly. stars subset operator [ works bit different: first argument selects attributes second argument selects first dimension third argument selects second dimension, etc Thus, selects second attribute, first 10 columns (x-coordinate), rows, bands 2-4. Alternatively, [ given single argument class sf, sfc bbox, [ work crop operator:","code":"class(x[[1]]) ## [1] \"array\" dim(x[[1]]) ##    x    y band  ##  349  352    6 x$two = 2 * x[[1]] x ## stars object with 3 dimensions and 2 attributes ## attribute(s): ##              Min. 1st Qu. Median      Mean 3rd Qu. Max. ## L7_ETMs.tif     1      54     69  68.91242      86  255 ## two             2     108    138 137.82484     172  510 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA x[\"two\", 1:10, , 2:4] ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##      Min. 1st Qu. Median     Mean 3rd Qu. Max. ## two    36     100    116 119.7326     136  470 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1  10  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    2   4      NA    NA                         NA    NA circle = st_sfc(st_buffer(st_point(c(293749.5, 9115745)), 400), crs = st_crs(x)) plot(x[circle][, , , 1], reset = FALSE) plot(circle, col = NA, border = 'red', add = TRUE, lwd = 2)"},{"path":"/articles/stars1.html","id":"overviews","dir":"Articles","previous_headings":"Reading a satellite image","what":"Overviews","title":"1. introduction","text":"can read rasters lower resolution contain -called overviews. GeoTIFF file, created gdaladdo utility, particular adds coarse resolution versions using average resampling method compute values based blocks pixels. can read ","code":"gdaladdo -r average L7_ETMs.tif  2 4 8 16 x1 = read_stars(tif, options = c(\"OVERVIEW_LEVEL=1\")) x2 = read_stars(tif, options = c(\"OVERVIEW_LEVEL=2\")) x3 = read_stars(tif, options = c(\"OVERVIEW_LEVEL=3\")) dim(x1) ##    x    y band  ##   88   88    6 dim(x2) ##    x    y band  ##   44   44    6 dim(x3) ##    x    y band  ##   22   22    6 par(mfrow = c(1, 3), mar = rep(0.2, 4)) image(x1[,,,1]) image(x2[,,,1]) image(x3[,,,1])"},{"path":"/articles/stars1.html","id":"reading-a-raster-time-series-netcdf","dir":"Articles","previous_headings":"","what":"Reading a raster time series: NetCDF","title":"1. introduction","text":"Another example read raster time series model outputs NetCDF file, e.g. see dataset can see variables units associated (wrong unit, C assigned temperature) time now dimension, proper units time steps Alternatively, dataset can read using read_ncdf, difference read_ncdf read_stars NetCDF files former uses package RNetCDF directly read NetCDF file, latter uses GDAL driver NetCDF files.","code":"system.file(\"nc/bcsd_obs_1999.nc\", package = \"stars\") |>     read_stars() -> w ## pr, tas, w ## stars object with 3 dimensions and 2 attributes ## attribute(s): ##                 Min.   1st Qu.   Median      Mean   3rd Qu.      Max. NA's ## pr [mm/m]  0.5900000 56.139999 81.88000 101.26433 121.07250 848.54999 7116 ## tas [C]   -0.4209678  8.898887 15.65763  15.48932  21.77979  29.38581 7116 ## dimension(s): ##      from to offset  delta  refsys                    values x/y ## x       1 81    -85  0.125      NA                      NULL [x] ## y       1 33  37.12 -0.125      NA                      NULL [y] ## time    1 12     NA     NA POSIXct 1999-01-31,...,1999-12-31 system.file(\"nc/bcsd_obs_1999.nc\", package = \"stars\") |>     read_ncdf() ## no 'var' specified, using pr, tas ## other available variables: ##  latitude, longitude, time ## Will return stars object with 32076 cells. ## No projection information found in nc file.  ##  Coordinate variable units found to be degrees,  ##  assuming WGS84 Lat/Lon. ## stars object with 3 dimensions and 2 attributes ## attribute(s): ##                 Min.   1st Qu.   Median      Mean   3rd Qu.      Max. NA's ## pr [mm/m]  0.5900000 56.139999 81.88000 101.26433 121.07250 848.54999 7116 ## tas [C]   -0.4209678  8.898887 15.65763  15.48932  21.77979  29.38581 7116 ## dimension(s): ##           from to offset delta  refsys                    values x/y ## longitude    1 81    -85 0.125  WGS 84                      NULL [x] ## latitude     1 33     33 0.125  WGS 84                      NULL [y] ## time         1 12     NA    NA POSIXct 1999-01-31,...,1999-12-31"},{"path":"/articles/stars1.html","id":"reading-datasets-from-multiple-files","dir":"Articles","previous_headings":"Reading a raster time series: NetCDF","what":"Reading datasets from multiple files","title":"1. introduction","text":"Model data often spread across many files. example 0.25 degree grid, global daily sea surface temperature product found ; subset 1981 used downloaded NOAA ftp site longer available form. (ftp site used eclipse.ncdc.noaa.gov/pub/OI-daily-v2/NetCDF/1981/AVHRR/). read data giving read_stars vector character names: Next, select sea surface temperature (sst), drop singular zlev (depth) dimension using adrop: can now graph sea surface temperature (SST) using ggplot, needs data long table form, without units:","code":"x = c( \"avhrr-only-v2.19810901.nc\", \"avhrr-only-v2.19810902.nc\", \"avhrr-only-v2.19810903.nc\", \"avhrr-only-v2.19810904.nc\", \"avhrr-only-v2.19810905.nc\", \"avhrr-only-v2.19810906.nc\", \"avhrr-only-v2.19810907.nc\", \"avhrr-only-v2.19810908.nc\", \"avhrr-only-v2.19810909.nc\" ) # see the second vignette: # install.packages(\"starsdata\", repos = \"http://pebesma.staff.ifgi.de\", type = \"source\") file_list = system.file(paste0(\"netcdf/\", x), package = \"starsdata\") (y = read_stars(file_list, quiet = TRUE)) ## stars object with 4 dimensions and 4 attributes ## attribute(s), summary of first 1e+05 cells: ##                Min. 1st Qu. Median       Mean 3rd Qu. Max.  NA's ## sst [°*C]     -1.80   -1.19  -1.05 -0.3201670   -0.20 9.36 13360 ## anom [°*C]    -4.69   -0.06   0.52  0.2299385    0.71 3.70 13360 ## err [°*C]      0.11    0.30   0.30  0.2949421    0.30 0.48 13360 ## ice [percent]  0.01    0.73   0.83  0.7657695    0.87 1.00 27377 ## dimension(s): ##      from   to         offset  delta  refsys x/y ## x       1 1440              0   0.25      NA [x] ## y       1  720             90  -0.25      NA [y] ## zlev    1    1          0 [m]     NA      NA     ## time    1    9 1981-09-01 UTC 1 days POSIXct library(dplyr) ##  ## Attaching package: 'dplyr' ## The following objects are masked from 'package:stats': ##  ##     filter, lag ## The following objects are masked from 'package:base': ##  ##     intersect, setdiff, setequal, union library(abind) z <- y |> select(sst) |> adrop() # convert POSIXct time to character, to please ggplot's facet_wrap() z1 = st_set_dimensions(z, 3, values = as.character(st_get_dimension_values(z, 3))) library(ggplot2) library(viridis) ## Loading required package: viridisLite library(ggthemes) ggplot() +     geom_stars(data = z1[1], alpha = 0.8, downsample = c(10, 10, 1)) +    facet_wrap(\"time\") +   scale_fill_viridis() +   coord_equal() +   theme_map() +   theme(legend.position = \"bottom\") +   theme(legend.key.width = unit(2, \"cm\"))"},{"path":"/articles/stars1.html","id":"writing-stars-objects-to-disk","dir":"Articles","previous_headings":"","what":"Writing stars objects to disk","title":"1. introduction","text":"can write stars object disk using write_stars; used GDAL write engine. Writing NetCDF files without going GDAL interface currently supported. write_stars currently writes single attribute: See explanation merge see multiple attributes can merged (folded) dimension.","code":"write_stars(adrop(y[1]), \"sst.tif\")"},{"path":"/articles/stars1.html","id":"cropping-a-rasters-extent","dir":"Articles","previous_headings":"","what":"Cropping a raster’s extent","title":"1. introduction","text":"Using curvilinear grid, taken example read_ncdf:  can now crop grid cells falling  selection prec_slice[nc] essentially calls st_crop(prec_slice, nc) get cropped selection. happened cells intersecting North Carolina (sea) set NA values. regular grids, extent resulting stars object also reduced (cropped) default; can controlled crop parameter st_crop [.stars.","code":"prec_file = system.file(\"nc/test_stageiv_xyt.nc\", package = \"stars\") prec = read_ncdf(prec_file, curvilinear = c(\"lon\", \"lat\")) ## no 'var' specified, using Total_precipitation_surface_1_Hour_Accumulation ## other available variables: ##  lat, lon, time ## Will return stars object with 236118 cells. ## No projection information found in nc file.  ##  Coordinate variable units found to be degrees,  ##  assuming WGS84 Lat/Lon. ##plot(prec) ## gives error about unique breaks ## remove NAs, zeros, and give a large number ## of breaks (used for validating in detail) qu_0_omit = function(x, ..., n = 22) {   if (inherits(x, \"units\"))     x = units::drop_units(na.omit(x))   c(0, quantile(x[x > 0], seq(0, 1, length.out = n))) } library(dplyr) # loads slice generic prec_slice = slice(prec, index = 17, along = \"time\") plot(prec_slice, border = NA, breaks = qu_0_omit(prec_slice[[1]]), reset = FALSE) nc = sf::read_sf(system.file(\"gpkg/nc.gpkg\", package = \"sf\"), \"nc.gpkg\") plot(st_geometry(nc), add = TRUE, reset = FALSE, col = NA, border = 'red') nc = st_transform(nc, st_crs(prec_slice)) # datum transformation plot(prec_slice[nc], border = NA, breaks = qu_0_omit(prec_slice[[1]]), reset = FALSE) plot(st_geometry(nc), add = TRUE, reset = FALSE, col = NA, border = 'red')"},{"path":"/articles/stars1.html","id":"vector-data-cube-example","dir":"Articles","previous_headings":"","what":"Vector data cube example","title":"1. introduction","text":"Like tbl_cube, stars arrays limits number dimensions handle. example origin-destination (OD) matrix, time travel mode.","code":""},{"path":"/articles/stars1.html","id":"od-space-x-space-x-travel-mode-x-time-x-time","dir":"Articles","previous_headings":"Vector data cube example","what":"OD: space x space x travel mode x time x time","title":"1. introduction","text":"create 5-dimensional matrix traffic regions, day, time day, travel mode. day time day dimension advantage want compute patterns day, certain period. array contains simple feature geometries origin destination can directly plot every slice without additional table joins. want represent array tbl_cube, simple feature geometry dimensions need replaced indexes: following demonstrates can use dplyr filter travel mode bike, compute mean bike traffic hour day:","code":"nc = st_read(system.file(\"gpkg/nc.gpkg\", package=\"sf\"))  ## Reading layer `nc.gpkg' from data source  ##   `/home/runner/work/_temp/Library/sf/gpkg/nc.gpkg' using driver `GPKG' ## Simple feature collection with 100 features and 14 fields ## Geometry type: MULTIPOLYGON ## Dimension:     XY ## Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965 ## Geodetic CRS:  NAD27 to = from = st_geometry(nc) # 100 polygons: O and D regions mode = c(\"car\", \"bike\", \"foot\") # travel mode day = 1:100 # arbitrary library(units) ## udunits database from /usr/share/xml/udunits/udunits2.xml units(day) = as_units(\"days since 2015-01-01\") hour = set_units(0:23, h) # hour of day dims = st_dimensions(origin = from, destination = to, mode = mode, day = day, hour = hour) (n = dim(dims)) ##      origin destination        mode         day        hour  ##         100         100           3         100          24 traffic = array(rpois(prod(n), 10), dim = n) # simulated traffic counts (st = st_as_stars(list(traffic = traffic),  dimensions = dims)) ## stars object with 5 dimensions and 1 attribute ## attribute(s), summary of first 1e+05 cells: ##          Min. 1st Qu. Median    Mean 3rd Qu. Max. ## traffic     0       8     10 9.99961      12   26 ## dimension(s): ##             from  to                      offset                       delta ## origin         1 100                          NA                          NA ## destination    1 100                          NA                          NA ## mode           1   3                          NA                          NA ## day            1 100 1 [(days since 2015-01-01)] 1 [(days since 2015-01-01)] ## hour           1  24                       0 [h]                       1 [h] ##              refsys point ## origin        NAD27 FALSE ## destination   NAD27 FALSE ## mode             NA FALSE ## day         udunits FALSE ## hour        udunits FALSE ##                                                                    values ## origin      MULTIPOLYGON (((-81.47276...,...,MULTIPOLYGON (((-78.65572... ## destination MULTIPOLYGON (((-81.47276...,...,MULTIPOLYGON (((-78.65572... ## mode                                                     car , bike, foot ## day                                                                  NULL ## hour                                                                 NULL st |> as.tbl_cube() ## Source: local array [72,000,000 x 5] ## D: origin [int, 100] ## D: destination [int, 100] ## D: mode [chr, 3] ## D: day [[(days since 2015-01-01)], 100] ## D: hour [[h], 24] ## M: traffic [int[,100,3,100,24]] b <- st |>    as.tbl_cube() |>    filter(mode == \"bike\") |>    group_by(hour) |>   summarise(traffic = mean(traffic)) |>    as.data.frame() require(ggforce) # for plotting a units variable ## Loading required package: ggforce ggplot() +     geom_line(data = b, aes(x = hour, y = traffic)) ## Warning: The `scale_name` argument of `continuous_scale()` is deprecated as of ggplot2 ## 3.5.0. ## This warning is displayed once every 8 hours. ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was ## generated."},{"path":"/articles/stars1.html","id":"extracting-at-point-locations-aggregating-over-polygons","dir":"Articles","previous_headings":"","what":"Extracting at point locations, aggregating over polygons","title":"1. introduction","text":"Data cube values point location can extracted st_extract, example found vignette 7 Aggregates, mean, maximum modal values can obtained aggregate. example use categorical raster, try find modal (frequent) class within two circular polygons:  find modal value, need function gives back label corresponding class frequent, using table: can call aggregate raster map, set two circular polygons pol1 pol2, pass function f:","code":"s = system.file(\"tif/lc.tif\", package = \"stars\") r = read_stars(s, proxy = FALSE) |> droplevels() levels(r[[1]]) = abbreviate(levels(r[[1]]), 10) # shorten text labels st_point(c(3190631, 3125)) |> st_sfc(crs = st_crs(r)) |> st_buffer(25000) -> pol1 st_point(c(3233847, 21027)) |> st_sfc(crs = st_crs(r)) |> st_buffer(10000) -> pol2 if (isTRUE(dev.capabilities()$rasterImage == \"yes\")) {   plot(r, reset = FALSE, key.pos = 4)   plot(c(pol1, pol2), col = NA, border = c('yellow', 'green'), lwd = 2, add = TRUE) } f = function(x) { tb = table(x); names(tb)[which.max(tb)] } aggregate(r, c(pol1, pol2), f) |> st_as_sf() ## Simple feature collection with 2 features and 1 field ## Geometry type: POLYGON ## Dimension:     XY ## Bounding box:  xmin: 3165631 ymin: -21875 xmax: 3243847 ymax: 31027 ## Projected CRS: Albers Conical Equal Area ##       lc.tif                       geometry ## 1 EvrgrnFrst POLYGON ((3215631 3125, 321... ## 2 Dvlpd,MdmI POLYGON ((3243847 21027, 32..."},{"path":"/articles/stars2.html","id":"preamble-the-starsdata-package","dir":"Articles","previous_headings":"","what":"Preamble: the starsdata package","title":"2. stars proxy objects","text":"run examples vignette, must install package datasets large (1 Gb) held stars package. drat repo, installation done ","code":"install.packages(\"starsdata\", repos = \"http://gis-bigdata.uni-muenster.de/pebesma\", type = \"source\")  # possibly after: options(timeout = 100) # or from an alternative repository: # install.packages(\"starsdata\", repos = \"http://pebesma.staff.ifgi.de\", type = \"source\")"},{"path":"/articles/stars2.html","id":"reading-chunks-change-resolution-select-bands","dir":"Articles","previous_headings":"","what":"Reading chunks, change resolution, select bands","title":"2. stars proxy objects","text":"read_stars argument called RasterIO controls GDAL dataset read. default, pixels bands read memory. can consume lot time require lot memory. Remember file may compressed, pixel values represented file bytes converted 8-byte doubles R. reason using RasterIO parameters use directly mapped GDAL RasterIO function used (adapting 1-based offset index R 0-based offset C++).","code":""},{"path":"/articles/stars2.html","id":"reading-a-particular-chunk","dir":"Articles","previous_headings":"Reading chunks, change resolution, select bands","what":"Reading a particular chunk","title":"2. stars proxy objects","text":"example using RasterIO Compare see delta values remain , offset (x/y coordinates origin) grid remain reflect new area, relate new delta values dim(x) reflects new size, three bands read","code":"library(stars) ## Loading required package: abind ## Loading required package: sf ## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") rasterio = list(nXOff = 6, nYOff = 6, nXSize = 100, nYSize = 100, bands = c(1, 3, 4)) (x = read_stars(tif, RasterIO = rasterio)) ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif    23      54     63 62.05977   73.25  235 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       6 105  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       6 105 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   3      NA    NA                         NA    NA dim(x) ##    x    y band  ##  100  100    3 st_dimensions(read_stars(tif)) ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA"},{"path":"/articles/stars2.html","id":"reading-at-a-different-resolution","dir":"Articles","previous_headings":"Reading chunks, change resolution, select bands","what":"Reading at a different resolution","title":"2. stars proxy objects","text":"Reading datasets lower (also higher!) resolution can done setting nBufXSize nBufYSize see addition: delta (raster cell size) values increased factor 5, nBufXSize nBufYSize set values factor 5 smaller nXSize nYSize offset coordinates grid still reflect new area, relate new delta cell size values can also read higher resolution; read 3 x 3 area blow 100 x 100:  reason “see” three grid cells default sampling method “nearest neighbour”. can modify  following methods allowed parameter resample: methods implemented GDAL; methods exactly , refer GDAL documentation source code.","code":"rasterio = list(nXOff = 6, nYOff = 6, nXSize = 100, nYSize = 100,                 nBufXSize = 20, nBufYSize = 20, bands = c(1, 3, 4)) (x = read_stars(tif, RasterIO = rasterio)) ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif    27      53     63 62.09417      74  151 ## dimension(s): ##      from to  offset  delta                     refsys point x/y ## x       2 21  288776  142.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       2 21 9120761 -142.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1  3      NA     NA                         NA    NA rasterio = list(nXOff = 6, nYOff = 6, nXSize = 3, nYSize = 3,    nBufXSize = 100, nBufYSize = 100, bands = 1) x = read_stars(tif, RasterIO = rasterio) dim(x) ##   x   y  ## 100 100 plot(x) rasterio = list(nXOff = 6, nYOff = 6, nXSize = 3, nYSize = 3,    nBufXSize = 100, nBufYSize = 100, bands = 1, resample = \"cubic_spline\") x = read_stars(tif, RasterIO = rasterio) dim(x) ##   x   y  ## 100 100 plot(x)"},{"path":"/articles/stars2.html","id":"stars-proxy-objects","dir":"Articles","previous_headings":"","what":"Stars proxy objects","title":"2. stars proxy objects","text":"Stars proxy objects take another approach: upon creation contain data , pointers data can read. Data read needed, much needed: plot proxy objects, data read resolution pixels screen, rather native resolution, e.g. 10000 x 10000 Sentinel 2 (level 1C) image, can open happens instantly, data read. plot object,  takes around 1 second, since pixels read can seen plot. read entire image memory first, reading take minute, require 5 Gb memory.","code":"granule = system.file(\"sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip\", package = \"starsdata\") s2 = paste0(\"SENTINEL2_L1C:/vsizip/\", granule, \"/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/MTD_MSIL1C.xml:10m:EPSG_32632\") (p = read_stars(s2, proxy = TRUE)) ## stars_proxy object with 1 attribute in 1 file(s): ## $EPSG_32632 ## [1] \"[...]/MTD_MSIL1C.xml:10m:EPSG_32632\" ##  ## dimension(s): ##      from    to offset delta                refsys    values x/y ## x       1 10980  3e+05    10 WGS 84 / UTM zone 32N      NULL [x] ## y       1 10980  6e+06   -10 WGS 84 / UTM zone 32N      NULL [y] ## band    1     4     NA    NA                    NA B4,...,B8 system.time(plot(p)) ## downsample set to 18 ##    user  system elapsed  ##   1.012   0.173   0.682 p = read_stars(s2, proxy = FALSE)"},{"path":"/articles/stars2.html","id":"methods-for-stars-proxy-objects","dir":"Articles","previous_headings":"Stars proxy objects","what":"Methods for stars proxy objects","title":"2. stars proxy objects","text":"","code":"methods(class = \"stars_proxy\") ##  [1] [               [[<-            [<-             adrop           ##  [5] aggregate       aperm           as.data.frame   c               ##  [9] coerce          dim             droplevels      hist            ## [13] image           initialize      is.na           Math            ## [17] merge           Ops             plot            prcomp          ## [21] predict         print           show            slotsFromS3     ## [25] split           st_apply        st_as_sf        st_as_stars     ## [29] st_crop         st_dimensions<- st_downsample   st_mosaic       ## [33] st_normalize    st_redimension  st_sample       st_set_bbox     ## [37] write_stars     ## see '?methods' for accessing help and source code"},{"path":"/articles/stars2.html","id":"select-attributes","dir":"Articles","previous_headings":"Stars proxy objects","what":"Select attributes","title":"2. stars proxy objects","text":"can select attributes regular stars objects, using first argument [: Note selection limits reading 4 1 subdataset 9 NetCDF files.","code":"x = c(\"avhrr-only-v2.19810901.nc\", \"avhrr-only-v2.19810902.nc\", \"avhrr-only-v2.19810903.nc\", \"avhrr-only-v2.19810904.nc\", \"avhrr-only-v2.19810905.nc\", \"avhrr-only-v2.19810906.nc\", \"avhrr-only-v2.19810907.nc\", \"avhrr-only-v2.19810908.nc\", \"avhrr-only-v2.19810909.nc\") file_list = system.file(paste0(\"netcdf/\", x), package = \"starsdata\") y = read_stars(file_list, quiet = TRUE, proxy = TRUE) names(y) ## [1] \"sst\"  \"anom\" \"err\"  \"ice\" y[\"sst\"] ## stars_proxy object with 1 attribute in 9 file(s): ## $sst ## [1] \"[...]/avhrr-only-v2.19810901.nc:sst\" \"[...]/avhrr-only-v2.19810902.nc:sst\" ## [3] \"[...]/avhrr-only-v2.19810903.nc:sst\" \"[...]/avhrr-only-v2.19810904.nc:sst\" ## [5] \"[...]/avhrr-only-v2.19810905.nc:sst\" \"[...]/avhrr-only-v2.19810906.nc:sst\" ## [7] \"[...]/avhrr-only-v2.19810907.nc:sst\" \"[...]/avhrr-only-v2.19810908.nc:sst\" ## [9] \"[...]/avhrr-only-v2.19810909.nc:sst\" ##  ## dimension(s): ##      from   to         offset  delta  refsys x/y ## x       1 1440              0   0.25      NA [x] ## y       1  720             90  -0.25      NA [y] ## zlev    1    1          0 [m]     NA      NA     ## time    1    9 1981-09-01 UTC 1 days POSIXct"},{"path":"/articles/stars2.html","id":"select-an-area","dir":"Articles","previous_headings":"Stars proxy objects","what":"Select an area","title":"2. stars proxy objects","text":"Another possibility crop, select rectangular region based spatial object. can done passing bbox object, sf, sfc stars object bounding box taken. example:","code":"bb = st_bbox(c(xmin = 10.125, ymin = 0.125, xmax = 70.125, ymax = 70.125)) ysub = y[bb] st_dimensions(ysub) ##      from  to         offset  delta  refsys x/y ## x      41 281              0   0.25      NA [x] ## y      80 360             90  -0.25      NA [y] ## zlev    1   1          0 [m]     NA      NA     ## time    1   9 1981-09-01 UTC 1 days POSIXct class(ysub) # still no data here!! ## [1] \"stars_proxy\" \"stars\" plot(ysub, reset = FALSE) # plot reads the data, at resolution that is relevant plot(st_as_sfc(bb), add = TRUE, lwd = .5, border = 'red')"},{"path":"/articles/stars2.html","id":"lazy-evaluation-changing-evaluation-order","dir":"Articles","previous_headings":"Stars proxy objects","what":"Lazy evaluation, changing evaluation order","title":"2. stars proxy objects","text":"actions can carried stars_proxy objects, effect delayed data actually needed (plot, write_stars). instance, range selections dimensions shown first need data, can carried . functions added object, attribute called call_list: allows optimizing order operations done. example, st_apply, reading can done sequentially dimensions function applied: example function applied band (: compute band quantiles), bands can read sequentially, discarded quantiles computed. time series function applied pixel time series result plotted map, time series function evaluated pixels actually plotted. means e.g. order evaluation reversed: plot knows pixels going shown, controls x downsampled st_apply carried subset.","code":"yy = adrop(y) yyy = yy[,1:10,1:10,] class(yyy) # still no data ## [1] \"stars_proxy\" \"stars\" st_dimensions(yyy) # and dimensions not adjusted ##      from   to         offset  delta  refsys x/y ## x       1 1440              0   0.25      NA [x] ## y       1  720             90  -0.25      NA [y] ## zlev    1    1          0 [m]     NA      NA     ## time    1    9 1981-09-01 UTC 1 days POSIXct attr(yyy, \"call_list\") # the name of object in the call (y) is replaced with x: ## [[1]] ## adrop(x = x, drop = drop) ## attr(,\".Environment\") ##  ##  ## [[2]] ## x[i = i, 1:10, 1:10, , drop = drop, crop = crop] ## attr(,\".Environment\") ##  plot(st_apply(x, c(\"x\", \"y\"), range))"},{"path":"/articles/stars2.html","id":"fetching-the-data","dir":"Articles","previous_headings":"Stars proxy objects > Lazy evaluation, changing evaluation order","what":"Fetching the data","title":"2. stars proxy objects","text":"Fetching data now involves reading whole array evaluating call_list , sequentially:","code":"(x = st_as_stars(yyy)) # read, adrop, subset ## stars object with 3 dimensions and 4 attributes ## attribute(s): ##                Min. 1st Qu. Median       Mean 3rd Qu.  Max. ## sst [°*C]     -1.28   -1.17  -1.11 -1.1163555   -1.06 -0.95 ## anom [°*C]     0.48    0.62   0.69  0.6649555    0.72  0.77 ## err [°*C]      0.30    0.30   0.30  0.3000000    0.30  0.30 ## ice [percent]  0.76    0.79   0.81  0.8062889    0.82  0.85 ## dimension(s): ##      from to         offset  delta  refsys x/y ## x       1 10              0   0.25      NA [x] ## y       1 10             90  -0.25      NA [y] ## time    1  9 1981-09-01 UTC 1 days POSIXct"},{"path":"/articles/stars2.html","id":"plotting-with-changed-evaluation-order","dir":"Articles","previous_headings":"Stars proxy objects > Lazy evaluation, changing evaluation order","what":"Plotting with changed evaluation order","title":"2. stars proxy objects","text":"Sentinel 2 data, band 4 represents NIR band 1 red, can compute NDVI ","code":"# S2 10m: band 4: near infrared, band 1: red. #ndvi = function(x) (x[4] - x[1])/(x[4] + x[1]) ndvi = function(x1, x2, x3, x4) (x4 - x1)/(x4 + x1) rm(x) (s2.ndvi = st_apply(p, c(\"x\", \"y\"), ndvi)) ## stars_proxy object with 1 attribute in 1 file(s): ## $EPSG_32632 ## [1] \"[...]/MTD_MSIL1C.xml:10m:EPSG_32632\" ##  ## dimension(s): ##      from    to offset delta                refsys    values x/y ## x       1 10980  3e+05    10 WGS 84 / UTM zone 32N      NULL [x] ## y       1 10980  6e+06   -10 WGS 84 / UTM zone 32N      NULL [y] ## band    1     4     NA    NA                    NA B4,...,B8     ## call_list: ## [[1]] ## st_apply(X = X, MARGIN = MARGIN, FUN = FUN, CLUSTER = CLUSTER,  ##     PROGRESS = PROGRESS, FUTURE = FUTURE, rename = rename, .fname = .fname) ## attr(,\".Environment\") ##  ##  ## This object has pending lazy operations: dimensions as printed may not reflect this. system.time(plot(s2.ndvi)) # read - compute ndvi - plot  ## downsample set to 18 ##    user  system elapsed  ##   0.720   0.168   0.385"},{"path":"/articles/stars2.html","id":"multi-resolution-proxy-objects","dir":"Articles","previous_headings":"","what":"Multi-resolution proxy objects","title":"2. stars proxy objects","text":"sections shows examples stars_proxy objects deal situation different maps dissimilar resolution. assumptions : maps need origin coordinates (typically upper-left corner) CRS. first map determines “working” resolution, e.g. native downsampled resolutions refer ’ll create four maps cells size 1, 2 3:    created three rasters identical cell values dimensions, different cell sizes, hence extents. bind single proxy object, see multi-resolution mentioned printed summary. converting stars object, secondary rasters resampled cellsize + extent first:  sub-range, defined object resolutions, get:  now create four maps, region ([0,4] x [0,4]), different resolutions (cell size 1, 1/2 1/3):      Finally, example first raster higher resolution:","code":"s1 = st_as_stars(matrix(1:16, 4)) s2 = st_as_stars(matrix(1:16, 4)) s3 = st_as_stars(matrix(1:16, 4)) attr(s1, \"dimensions\")$X1$offset = 0 attr(s1, \"dimensions\")$X2$offset = 4 attr(s2, \"dimensions\")$X1$offset = 0 attr(s2, \"dimensions\")$X2$offset = 4 attr(s3, \"dimensions\")$X1$offset = 0 attr(s3, \"dimensions\")$X2$offset = 4 attr(s1, \"dimensions\")$X1$delta =  1 attr(s1, \"dimensions\")$X2$delta = -1 attr(s2, \"dimensions\")$X1$delta =  2 attr(s2, \"dimensions\")$X2$delta = -2 attr(s3, \"dimensions\")$X1$delta =  3 attr(s3, \"dimensions\")$X2$delta = -3 plot(s1, axes = TRUE, text_values = TRUE, text_color = 'orange') plot(s2, axes = TRUE, text_values = TRUE, text_color = 'orange') plot(s3, axes = TRUE, text_values = TRUE, text_color = 'orange') fn1 = paste0(tempdir(), .Platform$file.sep, \"img1.tif\") fn2 = paste0(tempdir(), .Platform$file.sep, \"img2.tif\") fn3 = paste0(tempdir(), .Platform$file.sep, \"img3.tif\") write_stars(s1, fn1) write_stars(s2, fn2) write_stars(s3, fn3)  (r1 = read_stars(c(fn1, fn2, fn3), proxy = TRUE)) ## multi-resolution stars_proxy object with 3 attributes in 3 file(s): ## $`1` ## [1] \"[...]/img1.tif\" ##  ## $`2` ## [1] \"[...]/img2.tif\" ##  ## $`3` ## [1] \"[...]/img3.tif\" ##  ## dimension(s): ##   from to offset delta x/y ## x    1  4      0     1 [x] ## y    1  4      4    -1 [y] st_as_stars(r1) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE) st_as_stars(r1[,2:4,2:4]) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE) s4 = st_as_stars(matrix(1: 16, 4)) s5 = st_as_stars(matrix(1: 64, 8)) s6 = st_as_stars(matrix(1:144,12)) attr(s4, \"dimensions\")$X1$offset = 0 attr(s4, \"dimensions\")$X2$offset = 4 attr(s5, \"dimensions\")$X1$offset = 0 attr(s5, \"dimensions\")$X2$offset = 4 attr(s6, \"dimensions\")$X1$offset = 0 attr(s6, \"dimensions\")$X2$offset = 4 attr(s4, \"dimensions\")$X1$delta =  1 attr(s4, \"dimensions\")$X2$delta = -1 attr(s5, \"dimensions\")$X1$delta =  1/2 attr(s5, \"dimensions\")$X2$delta = -1/2 attr(s6, \"dimensions\")$X1$delta =  1/3 attr(s6, \"dimensions\")$X2$delta = -1/3 plot(s4, axes = TRUE, text_values = TRUE, text_color = 'orange') plot(s5, axes = TRUE, text_values = TRUE, text_color = 'orange') plot(s6, axes = TRUE, text_values = TRUE, text_color = 'orange') fn4 = paste0(tempdir(), .Platform$file.sep, \"img4.tif\") fn5 = paste0(tempdir(), .Platform$file.sep, \"img5.tif\") fn6 = paste0(tempdir(), .Platform$file.sep, \"img6.tif\") write_stars(s4, fn4) write_stars(s5, fn5) write_stars(s6, fn6)  (r2 = read_stars(c(fn4, fn5, fn6), proxy = TRUE)) ## multi-resolution stars_proxy object with 3 attributes in 3 file(s): ## $`4` ## [1] \"[...]/img4.tif\" ##  ## $`5` ## [1] \"[...]/img5.tif\" ##  ## $`6` ## [1] \"[...]/img6.tif\" ##  ## dimension(s): ##   from to offset delta x/y ## x    1  4      0     1 [x] ## y    1  4      4    -1 [y]  st_as_stars(r2) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE) st_as_stars(r2[,2:4,2:4]) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE) (r3 = read_stars(c(fn6, fn5, fn4), proxy = TRUE)) ## multi-resolution stars_proxy object with 3 attributes in 3 file(s): ## $`6` ## [1] \"[...]/img6.tif\" ##  ## $`5` ## [1] \"[...]/img5.tif\" ##  ## $`4` ## [1] \"[...]/img4.tif\" ##  ## dimension(s): ##   from to offset   delta x/y ## x    1 12      0  0.3333 [x] ## y    1 12      4 -0.3333 [y]  st_as_stars(r3) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE) st_as_stars(r3[,2:6,3:6]) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE)"},{"path":"/articles/stars3.html","id":"slice","dir":"Articles","previous_headings":"","what":"slice","title":"3. stars tidyverse methods","text":"slice slices sub-array cube; done specifying dimension act, slice number. returns lower-dimensional array single element selected along slice dimension.","code":"x %>% slice(band, 6) -> x6 x6 ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif     1      32     60 59.97521      88  255 ## dimension(s): ##   from  to  offset delta                     refsys point x/y ## x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y]"},{"path":"/articles/stars3.html","id":"filter","dir":"Articles","previous_headings":"","what":"filter","title":"3. stars tidyverse methods","text":"Similar slice, filter selects dimensions evaluates values rather index: subarray created based x coordinate values. Note filter converts object tbl_cube, uses dplyr filter method tbl_cube objects. limitation stars objects rectilinear, curvilinear simple feature geometries handled. objects, using regular [ selection using st_crop may alternative.","code":"x %>% filter(x > 289000, x < 291000, band > 3) -> x7 x7 ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif     5      54     70 71.79194      88  252 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1  70  289004  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   3       4     1                         NA    NA"},{"path":"/articles/stars3.html","id":"pull","dir":"Articles","previous_headings":"","what":"pull","title":"3. stars tidyverse methods","text":"pull pulls array stars object:","code":"x %>% pull(1) -> x8 class(x8) ## [1] \"array\" dim(x8) ##    x    y band  ##  349  352    6"},{"path":"/articles/stars3.html","id":"mutate","dir":"Articles","previous_headings":"","what":"mutate","title":"3. stars tidyverse methods","text":"","code":"x %>% mutate(band2 = 2 * L7_ETMs.tif) -> x2  x2 ## stars object with 3 dimensions and 2 attributes ## attribute(s): ##              Min. 1st Qu. Median      Mean 3rd Qu. Max. ## L7_ETMs.tif     1      54     69  68.91242      86  255 ## band2           2     108    138 137.82484     172  510 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA"},{"path":"/articles/stars3.html","id":"select","dir":"Articles","previous_headings":"","what":"select","title":"3. stars tidyverse methods","text":"select selects attribute, set attributes:","code":"x2 %>% select(band2) -> x9 x9 ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##        Min. 1st Qu. Median     Mean 3rd Qu. Max. ## band2     2     108    138 137.8248     172  510 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA"},{"path":"/articles/stars3.html","id":"geom_stars","dir":"Articles","previous_headings":"","what":"geom_stars","title":"3. stars tidyverse methods","text":"geom_raster ggplot2 geom function accepts stars objects data argument sets raster vector spatial coordinates plot dimensions, first attribute fill variable allows downsampling (without choosing suitable downsampling level) chooses using geom_raster, geom_rect geom_sf depending whether geometry regular, rectilinear vector geometries example use ","code":"library(ggplot2) library(viridis) ## Loading required package: viridisLite ggplot() +    geom_stars(data = x) +   coord_equal() +   facet_wrap(~band) +   theme_void() +   scale_fill_viridis() +   scale_x_discrete(expand = c(0, 0)) +   scale_y_discrete(expand = c(0, 0))"},{"path":"/articles/stars4.html","id":"stars-objects","dir":"Articles","previous_headings":"","what":"Stars objects","title":"4. stars data model","text":"stars objects consist (possibly empty) named list arrays, named dimensions (dim) attribute attribute called dimensions class dimensions carries dimension metadata class name includes stars dimensions object named list dimension elements, describing semantics dimension data arrays (space, time, type etc). addition , dimensions object attribute called raster class stars_raster, named list three elements: dimensions length 2 character; dimension names constitute spatial raster (NA) affine length 2 numeric; two affine parameters geotransform (NA) curvilinear boolean indicating whether raster curvilinear raster (NA) affine curvilinear values relevant case raster data, indicated dimensions non-NA values. dimension object describes single dimension; list named elements : (numeric length 1): start index array : (numeric length 1): end index array offset: (numeric length 1): start coordinate (time) value first pixel (.e., pixel/cell boundary) delta: (numeric length 1): increment, cell size refsys: (character, crs): object describing reference system; e.g. PROJ string, string POSIXct PCICt (360 365 days/year calendars), object class crs (containing EPSG code proj4string) point: (logical length 1): boolean indicating whether cells/pixels refer areas/periods, points/instances (may NA) NULL (missing), vector coordinate values (numeric, POSIXct, PCICt, sfc), object class intervals (list two vectors, start end, interval start- end-values), matrix longitudes latitudes cells (case curvilinear grids) usually 1 dimension size, may larger 1 case sub-grid got selected (cropped). offset delta apply regularly discretized dimensions, NA case. NA, dimension values may held values field. Rectilinear curvilinear grids need grid values values can either: rectilinear grids: irregularly spaced coordinate values, coordinate intervals irregular width (rectilinear grid can one dimension regular), curvilinear grids: matrix grid cell centre values row/col combinations (usually longitude latitude). Alternatively, values can contains set spatial geometries encoded sfc vector (“list-column”), case vector data cube.","code":""},{"path":[]},{"path":"/articles/stars4.html","id":"regular-grids","dir":"Articles","previous_headings":"Grid type","what":"Regular grids","title":"4. stars data model","text":"simple file created \\(4 \\times 5\\) matrix see rows (5) mapped first dimension, x-coordinate columns (4) mapped second dimension, y-coordinate fields dimension define range corresponds array dimension: offset delta specify increasing row column index maps x y coordinate values respectively. plot object, using image method stars objects,  see \\((0,0)\\) origin grid (grid corner), \\(1\\) coordinate value increase one index (row, col) next. means consecutive matrix columns represent grid lines, going south north. Grids defined way regular: grid cell size constant everywhere. Many actual grid datasets y coordinates (grid rows) going North South (top bottom); realised negative value delta. see grid origin \\((0,0)\\) change:  example GeoTIFF carried package, , probably data sources read GDAL, negative delta y-coordinate:","code":"suppressPackageStartupMessages(library(stars)) m = matrix(1:20, nrow = 5, ncol = 4) dim(m) = c(x = 5, y = 4) # named dim (s = st_as_stars(m)) ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##     Min. 1st Qu. Median Mean 3rd Qu. Max. ## A1     1    5.75   10.5 10.5   15.25   20 ## dimension(s): ##   from to offset delta point x/y ## x    1  5      0     1 FALSE [x] ## y    1  4      0     1 FALSE [y] dim(s[[1]]) ## x y  ## 5 4 image(s, text_values = TRUE, axes = TRUE) attr(s, \"dimensions\")[[2]]$delta = -1 image(s, text_values = TRUE, axes = TRUE) tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") st_dimensions(read_stars(tif))[\"y\"] ##   from  to  offset delta                     refsys point ## y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE"},{"path":"/articles/stars4.html","id":"raster-attributes-rotated-and-sheared-grids","dir":"Articles","previous_headings":"Grid type","what":"Raster attributes, rotated and sheared grids","title":"4. stars data model","text":"Dimension tables stars objects carry raster attribute: list holds dimensions: character, names raster dimensions (), opposed e.g. spectral, temporal dimensions affine: numeric, affine parameters curvilinear: logical indicating whether raster curvilinear fields needed level, describe properties array higher level individual dimensions : pair dimensions forms raster, affine curvilinear describe x y pair derived grid indexes (see ) done per-dimension basis. two affine parameters \\(a_1\\) \\(a_2\\), \\(x\\) \\(y\\) coordinates derived (1-based) grid indexes \\(\\) \\(j\\), grid offset values \\(o_x\\) \\(o_y\\), grid cell sizes \\(d_x\\) \\(d_y\\) \\[x = o_x + (-1) d_x + (j-1) a_1\\] \\[y = o_y + (-1) a_2 + (j-1) d_y\\] Clearly, \\(a_1=a_2=0\\), \\(x\\) \\(y\\) entirely derived respective index, offset cellsize. Note integer indexes, coordinates starting edge grid cell; get grid cell center top left grid cell (case negative \\(d_y\\)), use \\(=1.5\\) \\(j=1.5\\). can rotate grids setting \\(a_1\\) \\(a_2\\) non-zero value:  rotation angle, degrees, Sheared grids obtained two rotation coefficients, \\(a_1\\) \\(a_2\\), unequal:  Now, y-axis x-axis different rotation degrees respectively","code":"str(attr(st_dimensions(s), \"raster\")) ## List of 4 ##  $ affine     : num [1:2] 0 0 ##  $ dimensions : chr [1:2] \"x\" \"y\" ##  $ curvilinear: logi FALSE ##  $ blocksizes : NULL ##  - attr(*, \"class\")= chr \"stars_raster\" attr(attr(s, \"dimensions\"), \"raster\")$affine = c(0.1, 0.1) plot(st_as_sf(s, as_points = FALSE), axes = TRUE, nbreaks = 20) atan2(0.1, 1) * 180 / pi ## [1] 5.710593 attr(attr(s, \"dimensions\"), \"raster\")$affine = c(0.1, 0.2) plot(st_as_sf(s, as_points = FALSE), axes = TRUE, nbreaks = 20) atan2(c(0.1, 0.2), 1) * 180 / pi ## [1]  5.710593 11.309932"},{"path":"/articles/stars4.html","id":"rectilinear-grids","dir":"Articles","previous_headings":"","what":"Rectilinear grids","title":"4. stars data model","text":"Rectilinear grids orthogonal axes, congruent (equally sized shaped) cells: axis irregular subdivision. can define rectilinear grid specifying cell boundaries, meaning every dimension specify one value dimension size:  leave last value, stars may come different cell boundary last cell, now derived width one--last cell: problematic cells constant width, case boundaries reduced offset delta value, irrespective whether upper boundary given: Alternatively, one can also set cell midpoints specifying arguments cell_midpoints st_dimensions call: dimension regular, results offset shifted back half delta, else intervals derived distances cell centers. obviously done cell boundaries specified.","code":"x = c(0, 0.5, 1, 2, 4, 5)  # 6 numbers: boundaries! y = c(0.3, 0.5, 1, 2, 2.2) # 5 numbers: boundaries! (r = st_as_stars(list(m = m), dimensions = st_dimensions(x = x, y = y))) ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##    Min. 1st Qu. Median Mean 3rd Qu. Max. ## m     1    5.75   10.5 10.5   15.25   20 ## dimension(s): ##   from to point                values x/y ## x    1  5 FALSE     [0,0.5),...,[4,5) [x] ## y    1  4 FALSE [0.3,0.5),...,[2,2.2) [y] st_bbox(r) ## xmin ymin xmax ymax  ##  0.0  0.3  5.0  2.2 image(r, axes = TRUE, col = grey((1:20)/20)) x = c(0, 0.5, 1, 2, 4)  # 5 numbers: offsets only! y = c(0.3, 0.5, 1, 2)   # 4 numbers: offsets only! (r = st_as_stars(list(m = m), dimensions = st_dimensions(x = x, y = y))) ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##    Min. 1st Qu. Median Mean 3rd Qu. Max. ## m     1    5.75   10.5 10.5   15.25   20 ## dimension(s): ##   from to point              values x/y ## x    1  5 FALSE   [0,0.5),...,[4,6) [x] ## y    1  4 FALSE [0.3,0.5),...,[2,3) [y] st_bbox(r) ## xmin ymin xmax ymax  ##  0.0  0.3  6.0  3.0 x = c(0, 1, 2, 3, 4)  # 5 numbers: offsets only! y = c(0.5, 1, 1.5, 2)   # 4 numbers: offsets only! (r = st_as_stars(list(m = m), dimensions = st_dimensions(x = x, y = y))) ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##    Min. 1st Qu. Median Mean 3rd Qu. Max. ## m     1    5.75   10.5 10.5   15.25   20 ## dimension(s): ##   from to offset delta point x/y ## x    1  5      0     1 FALSE [x] ## y    1  4    0.5   0.5 FALSE [y] st_bbox(r) ## xmin ymin xmax ymax  ##  0.0  0.5  5.0  2.5 x = st_as_stars(matrix(1:9, 3, 3),                  st_dimensions(x = c(1, 2, 3), y = c(2, 3, 10), cell_midpoints = TRUE))"},{"path":"/articles/stars4.html","id":"curvilinear-grids","dir":"Articles","previous_headings":"","what":"Curvilinear grids","title":"4. stars data model","text":"Curvilinear grids grids whose grid lines straight. Rather describing curvature parametrically, typical (HDF5 NetCDF) files found two raster layers longitudes latitudes every corresponding pixel remaining layers. example, use Sentinel 5P dataset available package starsdata; package can installed dataset found : can construct curvilinear stars raster calling read_stars right sub-array: array, can see GDAL metadata item GEOLOCATION: reveals , dataset, longitude latitude arrays kept. curvilinear array actual arrays (raster layers, matrices) longitude latitude values read dimension table. can plot file:   can downsample data  doesn’t look nice, plotting cells polygons looks better:  Another approach warp curvilinear grid regular grid, e.g. ","code":"install.packages(\"starsdata\", repos = \"http://pebesma.staff.ifgi.de\", type = \"source\") (s5p = system.file(\"sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc\", package = \"starsdata\")) ## [1] \"/home/runner/work/_temp/Library/starsdata/sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc\" subs = gdal_subdatasets(s5p) subs[[6]] ## [1] \"NETCDF:\\\"/home/runner/work/_temp/Library/starsdata/sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc\\\":/PRODUCT/nitrogendioxide_tropospheric_column\" gdal_metadata(subs[[6]], \"GEOLOCATION\") ## $LINE_OFFSET ## [1] \"0\" ##  ## $LINE_STEP ## [1] \"1\" ##  ## $PIXEL_OFFSET ## [1] \"0\" ##  ## $PIXEL_STEP ## [1] \"1\" ##  ## $SRS ## [1] \"GEOGCS[\\\"WGS 84\\\",DATUM[\\\"WGS_1984\\\",SPHEROID[\\\"WGS 84\\\",6378137,298.257223563,AUTHORITY[\\\"EPSG\\\",\\\"7030\\\"]],AUTHORITY[\\\"EPSG\\\",\\\"6326\\\"]],PRIMEM[\\\"Greenwich\\\",0,AUTHORITY[\\\"EPSG\\\",\\\"8901\\\"]],UNIT[\\\"degree\\\",0.0174532925199433,AUTHORITY[\\\"EPSG\\\",\\\"9122\\\"]],AXIS[\\\"Latitude\\\",NORTH],AXIS[\\\"Longitude\\\",EAST],AUTHORITY[\\\"EPSG\\\",\\\"4326\\\"]]\" ##  ## $X_BAND ## [1] \"1\" ##  ## $X_DATASET ## [1] \"NETCDF:\\\"/home/runner/work/_temp/Library/starsdata/sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc\\\":/PRODUCT/longitude\" ##  ## $Y_BAND ## [1] \"1\" ##  ## $Y_DATASET ## [1] \"NETCDF:\\\"/home/runner/work/_temp/Library/starsdata/sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc\\\":/PRODUCT/latitude\" ##  ## attr(,\"class\") ## [1] \"gdal_metadata\" nit.c = read_stars(subs[[6]])  ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. threshold = units::set_units(9e+36, mol/m^2) nit.c[[1]][nit.c[[1]] > threshold] = NA nit.c ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##                                                   Min.      1st Qu. ## nitrogendioxide_tropospheri... [mol/m^2] -3.301083e-05 1.868205e-05 ##                                                Median         Mean      3rd Qu. ## nitrogendioxide_tropospheri... [mol/m^2] 2.622178e-05 2.898976e-05 3.629641e-05 ##                                                  Max. NA's ## nitrogendioxide_tropospheri... [mol/m^2] 0.0003924858  330 ## dimension(s): ##      from  to         offset  refsys                             values x/y ## x       1 450             NA  WGS 84 [450x278] -5.811 [°],...,30.95 [°] [x] ## y       1 278             NA  WGS 84  [450x278] 28.36 [°],...,51.47 [°] [y] ## time    1   1 2018-07-17 UTC POSIXct                               NULL     ## curvilinear grid plot(nit.c, breaks = \"equal\", reset = FALSE, axes = TRUE, as_points = TRUE,           pch = 16,  logz = TRUE, key.length = 1) ## Warning in NextMethod(): NaNs produced ## Warning in plot.sf(x, pal = col, ...): NaNs produced maps::map('world', add = TRUE, col = 'red') plot(nit.c, breaks = \"equal\", reset = FALSE, axes = TRUE, as_points = FALSE,           border = NA, logz = TRUE, key.length = 1) ## Warning in NextMethod(): NaNs produced ## Warning in plot.sf(x, pal = col, ...): NaNs produced maps::map('world', add = TRUE, col = 'red') (nit.c_ds = stars:::st_downsample(nit.c, 8)) ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##                                                   Min.     1st Qu.       Median ## nitrogendioxide_tropospheri... [mol/m^2] -1.847503e-05 1.85778e-05 2.700901e-05 ##                                                Mean      3rd Qu.         Max. ## nitrogendioxide_tropospheri... [mol/m^2] 2.9113e-05 3.642568e-05 0.0001363282 ##                                          NA's ## nitrogendioxide_tropospheri... [mol/m^2]   32 ## dimension(s): ##      from to         offset  refsys                           values x/y ## x       1 50             NA  WGS 84 [50x31] -5.811 [°],...,30.14 [°] [x] ## y       1 31             NA  WGS 84  [50x31] 28.78 [°],...,51.47 [°] [y] ## time    1  1 2018-07-17 UTC POSIXct                             NULL     ## curvilinear grid plot(nit.c_ds, breaks = \"equal\", reset = FALSE, axes = TRUE, as_points = TRUE,           pch = 16, logz = TRUE, key.length = 1) ## Warning in NextMethod(): NaNs produced ## Warning in plot.sf(x, pal = col, ...): NaNs produced maps::map('world', add = TRUE, col = 'red') plot(nit.c_ds, breaks = \"equal\", reset = FALSE, axes = TRUE, as_points = FALSE,           border = NA, logz = TRUE, key.length = 1) ## Warning in NextMethod(): NaNs produced ## Warning in plot.sf(x, pal = col, ...): NaNs produced maps::map('world', add = TRUE, col = 'red') w = st_warp(nit.c, crs = 4326, cellsize = 0.25) ## Warning in transform_grid_grid(st_as_stars(src), st_dimensions(dest), ## threshold): using Euclidean distance measures on geodetic coordinates ## threshold set to 0.108545 : set a larger value if you see missing values where there shouldn't be plot(w)"},{"path":"/articles/stars5.html","id":"rasterizing-an-sf-vector-object","dir":"Articles","previous_headings":"","what":"Rasterizing an sf vector object","title":"5. vector-raster conversions, reprojection, warping","text":"algorithm used GDAL rasterize utility, options utility can passed st_rasterize. geometry final raster can controlled passing target bounding box either raster dimensions nx ny, pixel size dx dy parameters.","code":"library(stars) ## Loading required package: abind system.file(\"gpkg/nc.gpkg\", package = \"sf\") %>%   read_sf() %>%   st_transform(32119) -> nc nc$dens = nc$BIR79 / units::set_units(st_area(nc), km^2) (nc.st = st_rasterize(nc[\"dens\"], dx = 5000, dy = 5000)) ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##                    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. NA's ## dens [1/km^2] 0.2545072 1.225631 1.932222 3.345918 3.825745 21.24828 4808 ## dimension(s): ##   from  to offset delta                 refsys point x/y ## x    1 162 123829  5000 NAD83 / North Carolina FALSE [x] ## y    1  61 318260 -5000 NAD83 / North Carolina FALSE [y] plot(nc.st)"},{"path":"/articles/stars5.html","id":"vectorizing-a-raster-object-to-an-sf-object","dir":"Articles","previous_headings":"","what":"Vectorizing a raster object to an sf object","title":"5. vector-raster conversions, reprojection, warping","text":"stars objects can converted sf object using st_as_sf. number options, depending whether pixels represent point value pixel center, small square polygons single value. work landsat-7 6-band image, select first band round values:","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif)[, 1:50, 1:50, 1:2] x[[1]] = round(x[[1]]/5)"},{"path":"/articles/stars5.html","id":"polygonizing","dir":"Articles","previous_headings":"Vectorizing a raster object to an sf object","what":"Polygonizing","title":"5. vector-raster conversions, reprojection, warping","text":"case raster cells reflect point values want get vector representation whole field, can draw contour lines export contour sets (available GDAL version least 2.4.0):","code":"l =  st_contour(x, contour_lines = TRUE, breaks = 11:15) plot(l[1], key.pos = 1, pal = sf.colors, lwd = 2, key.length = 0.8)"},{"path":"/articles/stars5.html","id":"exporting-to-points","dir":"Articles","previous_headings":"Vectorizing a raster object to an sf object","what":"Exporting to points","title":"5. vector-raster conversions, reprojection, warping","text":"Alternatively, can simply export pixels points, get either wide table bands per point, replicated POINT geometries: long table single attribute points replicated: can see, additional attribute band now indicates band concerned.","code":"st_as_sf(x, as_points = TRUE, merge = FALSE) ## Simple feature collection with 2500 features and 2 fields ## Geometry type: POINT ## Dimension:     XY ## Bounding box:  xmin: 288790.5 ymin: 9119350 xmax: 290187 ymax: 9120747 ## Projected CRS: SIRGAS 2000 / UTM zone 25S ## First 10 features: ##    L7_ETMs.tif.V1 L7_ETMs.tif.V2                 geometry ## 1              14             11 POINT (288790.5 9120747) ## 2              14             11   POINT (288819 9120747) ## 3              13             10 POINT (288847.5 9120747) ## 4              12              9   POINT (288876 9120747) ## 5              12             10 POINT (288904.5 9120747) ## 6              12             10   POINT (288933 9120747) ## 7              12             10 POINT (288961.5 9120747) ## 8              12             10   POINT (288990 9120747) ## 9              13             10 POINT (289018.5 9120747) ## 10             13             10   POINT (289047 9120747) st_as_sf(x, as_points = TRUE, merge = FALSE, long = TRUE) ## Simple feature collection with 5000 features and 2 fields ## Geometry type: POINT ## Dimension:     XY ## Bounding box:  xmin: 288790.5 ymin: 9119350 xmax: 290187 ymax: 9120747 ## Projected CRS: SIRGAS 2000 / UTM zone 25S ## First 10 features: ##    band L7_ETMs.tif                 geometry ## 1     1          14 POINT (288790.5 9120747) ## 2     1          14   POINT (288819 9120747) ## 3     1          13 POINT (288847.5 9120747) ## 4     1          12   POINT (288876 9120747) ## 5     1          12 POINT (288904.5 9120747) ## 6     1          12   POINT (288933 9120747) ## 7     1          12 POINT (288961.5 9120747) ## 8     1          12   POINT (288990 9120747) ## 9     1          13 POINT (289018.5 9120747) ## 10    1          13   POINT (289047 9120747)"},{"path":"/articles/stars5.html","id":"exporting-to-polygons","dir":"Articles","previous_headings":"Vectorizing a raster object to an sf object","what":"Exporting to polygons","title":"5. vector-raster conversions, reprojection, warping","text":"Alternatively, can export polygons either get single polygon per pixel, merge polygons identical pixel values; plotted boundaries, see resolved boundaries areas pixel value:  option connect8 can set TRUE use 8 connectedness, rather default 4 connectedness algorithm. cases, polygons returned often invalid according simple feature standard, can made valid using lwgeom::st_make_valid.","code":"st_as_sf(x[1], as_points = FALSE, merge = FALSE) ## Simple feature collection with 2500 features and 2 fields ## Geometry type: POLYGON ## Dimension:     XY ## Bounding box:  xmin: 288776.3 ymin: 9119336 xmax: 290201.3 ymax: 9120761 ## Projected CRS: SIRGAS 2000 / UTM zone 25S ## First 10 features: ##    L7_ETMs.tif.V1 L7_ETMs.tif.V2                       geometry ## 1              14             11 POLYGON ((288776.3 9120761,... ## 2              14             11 POLYGON ((288804.8 9120761,... ## 3              13             10 POLYGON ((288833.3 9120761,... ## 4              12              9 POLYGON ((288861.8 9120761,... ## 5              12             10 POLYGON ((288890.3 9120761,... ## 6              12             10 POLYGON ((288918.8 9120761,... ## 7              12             10 POLYGON ((288947.3 9120761,... ## 8              12             10 POLYGON ((288975.8 9120761,... ## 9              13             10 POLYGON ((289004.3 9120761,... ## 10             13             10 POLYGON ((289032.8 9120761,... p = st_as_sf(x, as_points = FALSE, merge = TRUE) plot(p)"},{"path":"/articles/stars5.html","id":"switching-between-vector-and-raster-in-stars-objects","dir":"Articles","previous_headings":"","what":"Switching between vector and raster in stars objects","title":"5. vector-raster conversions, reprojection, warping","text":"can convert raster dimension vector dimension keeping dimensions stars object also requires setting as_points arguments st_as_sf.","code":"x.sf = st_xy2sfc(x, as_points = TRUE) x.sf ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median    Mean 3rd Qu. Max. ## L7_ETMs.tif     7       9     11 11.2548      12   28 ## dimension(s): ##          from   to                     refsys point ## geometry    1 2500 SIRGAS 2000 / UTM zone 25S  TRUE ## band        1    2                         NA    NA ##                                                       values ## geometry POINT (288790.5 9120747),...,POINT (290187 9119350) ## band                                                    NULL"},{"path":"/articles/stars5.html","id":"reprojecting-a-raster","dir":"Articles","previous_headings":"","what":"Reprojecting a raster","title":"5. vector-raster conversions, reprojection, warping","text":"accept curvilinear rasters rasters , regular rectilinear grids special cases curvilinear grids, reprojecting raster longer “problem”, just recomputes new coordinates every raster cell, generally results curvilinear grid (sometimes can brought back regular rectilinear grid). curvilinear grid cells represented coordinates cell center, actual shape grid cell gets lost, may larger effect grid cells large transformation stronger non-linear. example reprojection grid created  noted dimensionality grid didn’t change: set raster cells replotted new CRS, now curvilinear grid.","code":"nc.st %>% st_transform(\"+proj=laea +lat_0=34 +lon_0=-60\") -> nc.curv nc.curv ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##                    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. NA's ## dens [1/km^2] 0.2545072 1.225631 1.932222 3.345918 3.825745 21.24828 4808 ## dimension(s): ##   from  to                       refsys point                         values ## x    1 162 +proj=laea +lat_0=34 +lon... FALSE [162x61] -2210936,...,-1371611 ## y    1  61 +proj=laea +lat_0=34 +lon... FALSE      [162x61] 90650,...,538204 ##   x/y ## x [x] ## y [y] ## curvilinear grid plot(nc.curv, border = NA, graticule = TRUE)"},{"path":"/articles/stars5.html","id":"warping-a-raster","dir":"Articles","previous_headings":"","what":"Warping a raster","title":"5. vector-raster conversions, reprojection, warping","text":"Warping raster means creating new regular grid new CRS, based (usually regular) grid another CRS. can transformation previous section first creating target grid: warping old raster new  new object regular grid new CRS, aligned new x- y-axes.","code":"nc %>% st_transform(\"+proj=laea +lat_0=34 +lon_0=-60\") %>% st_bbox() %>%     st_as_stars() -> newgrid nc.st %>% st_warp(newgrid) -> nc.new nc.new  ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##                    Min.  1st Qu.   Median     Mean  3rd Qu.     Max.  NA's ## dens [1/km^2] 0.2545072 1.225631 1.932222 3.344805 3.825745 21.24828 36155 ## dimension(s): ##   from  to   offset delta                       refsys x/y ## x    1 380 -2188110  2098 +proj=laea +lat_0=34 +lon... [x] ## y    1 171   494924 -2098 +proj=laea +lat_0=34 +lon... [y] plot(nc.new)"},{"path":"/articles/stars6.html","id":"comment-legend","dir":"Articles","previous_headings":"","what":"COMMENT LEGEND","title":"6. How `raster` functions map to `stars` functions","text":"? = sure / unknown * = present, low priority # = present, high priority NA = available design","code":""},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":"/articles/stars6.html","id":"computing-row-column-cell-numbers-and-coordinates","dir":"Articles","previous_headings":"","what":"Computing row, column, cell numbers and coordinates","title":"6. How `raster` functions map to `stars` functions","text":"format table follows raster-package entry raster manual, found https://cran.r-project.org/web/packages/raster/raster.pdf.","code":""},{"path":"/articles/stars7.html","id":"training-and-prediction-with-stars-objects","dir":"Articles","previous_headings":"","what":"Training and prediction with stars objects","title":"7. Statistical modelling with stars objects","text":"usual way statistical modelling R uses data.frames (tibbles), proceeds like model function like lm, glm, randomForest etc. returns classed object, predict generic can choose right prediction function based class. formula looks like y ~ x1+x2 specifies dependent variable (y) predictors (x1, x2), found columns data. newdata needs predictors columns, returns predicted values y values predictors.","code":"m = model(formula, data) pr = predict(m, newdata)"},{"path":"/articles/stars7.html","id":"stars-objects-as-data-frames","dir":"Articles","previous_headings":"Training and prediction with stars objects","what":"stars objects as data.frames","title":"7. Statistical modelling with stars objects","text":"analogy stars objects data.frame : attribute (array) becomes single column dimensions become added (index) columns see works 6-band example dataset, consider : see get one single variable object (array) name, added columns dimension values (x, y, band). typical case, like six bands distributed six variables, single observation (row) x/y pair. , use e.g. utils::unstack dplyr::pivot_wider data.frame, efficient way use dedicated split method stars objects, resolves dimension splits attributes, one dimension value: reason split efficient mentioned alternatives () split match records based dimensions (x/y), (ii) works --memory (stars_proxy) arrays, chunked process/write loop write_stars(). ### Predict stars objects pattern obtain predictions pixels stars objects : use full dataset sample train model, using .data.frame() (possibly split) use predict(star_object, model) predict pixels stars_object, using stars-wrapper predict method model. predict method model, provide one (see kmeans example ) works stars objects (-memory) stars_proxy objects (-memory). plotting stars_proxy objects, downsampling done prediction (predicting pixels shown), full rasters can written disk write_stars(), carry predictions chunks read written.","code":"library(stars) ## Loading required package: abind ## Loading required package: sf ## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE l7 = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") %>%   read_stars() l7 ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif     1      54     69 68.91242      86  255 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA as.data.frame(l7) %>% head() ##          x       y band L7_ETMs.tif ## 1 288790.5 9120747    1          69 ## 2 288819.0 9120747    1          69 ## 3 288847.5 9120747    1          63 ## 4 288876.0 9120747    1          60 ## 5 288904.5 9120747    1          61 ## 6 288933.0 9120747    1          61 l7 %>% split(\"band\") %>%   as.data.frame() %>%    head() ##          x       y X1 X2 X3 X4 X5 X6 ## 1 288790.5 9120747 69 56 46 79 86 46 ## 2 288819.0 9120747 69 57 49 75 88 49 ## 3 288847.5 9120747 63 52 45 66 75 41 ## 4 288876.0 9120747 60 45 35 66 69 38 ## 5 288904.5 9120747 61 52 44 76 92 60 ## 6 288933.0 9120747 61 50 37 78 74 38"},{"path":"/articles/stars7.html","id":"models-fitted-for-every-pixel","dir":"Articles","previous_headings":"","what":"models fitted for every pixel","title":"7. Statistical modelling with stars objects","text":"can run models many different ways array data. One way run single model pixels, model operates e.g. spectral (band) temporal dimension. example given vignette 2, NDVI computed red near infrared band. NDVI involve estimating parameters, reducing two bands one. example fit model every pixel fit time series model pixel time series, output one model coefficients pixel; shown next.","code":""},{"path":"/articles/stars7.html","id":"linear-regression-on-pixel-time-series","dir":"Articles","previous_headings":"models fitted for every pixel","what":"Linear regression on pixel time series","title":"7. Statistical modelling with stars objects","text":"can read avhrr dataset, containing 9 days: use function computes slope regression line temperature time. get temperatures vector first argument function supplied st_apply, t already defined. function look like optimize bit, using anyNA lm.fit rather lm: result lazily defined (adrop drops singular dimension) computed following command, computations restricted pixels plotted:  interesting pattern appears (despite short time series!): SST reveals main signal colder getting equator, changes SST show much fine grained structures areas going , others going . diverging color ramp better choice , distinguish positive negative trends.","code":"library(stars) x = c(\"avhrr-only-v2.19810901.nc\", \"avhrr-only-v2.19810902.nc\", \"avhrr-only-v2.19810903.nc\", \"avhrr-only-v2.19810904.nc\", \"avhrr-only-v2.19810905.nc\", \"avhrr-only-v2.19810906.nc\", \"avhrr-only-v2.19810907.nc\", \"avhrr-only-v2.19810908.nc\", \"avhrr-only-v2.19810909.nc\") file_list = system.file(paste0(\"netcdf/\", x), package = \"starsdata\") y = read_stars(file_list, sub = \"sst\", quiet = TRUE, proxy = TRUE) (t = st_get_dimension_values(y, 4)) ## [1] \"1981-09-01 UTC\" \"1981-09-02 UTC\" \"1981-09-03 UTC\" \"1981-09-04 UTC\" ## [5] \"1981-09-05 UTC\" \"1981-09-06 UTC\" \"1981-09-07 UTC\" \"1981-09-08 UTC\" ## [9] \"1981-09-09 UTC\" slope = function(x) {   if (any(is.na(x)))     NA_real_   else     coeffients(lm(x~t))[2] } slope = function(x) {   if (anyNA(x))     NA_real_   else     lm.fit(cbind(1, t), x)$coefficients[2] } out = st_apply(adrop(y), c(1,2), slope) plot(out, breaks = \"equal\", main = \"9-day time trend (slope)\") ## downsample set to 1"},{"path":[]},{"path":"/articles/stars7.html","id":"principal-components","dir":"Articles","previous_headings":"Unsupervised learners","what":"Principal components","title":"7. Statistical modelling with stars objects","text":"first example, build principal components entire dataset, rather small.  see, amongst others, PC1 picks difference sea (dark) land, PC2 3 structures sea coastal waters. second example, build principal components sample entire dataset, entire dataset rather large. apply , using predict, pixels shown plot (.e. reduced rather full resolution) plotting , ’ll add country borders delineate sea, obtained mapdata package: plot results independent color ranges, every PC stretched entire grey scale.  suggests PC1 picks difference cloud signal (difference clouds non-clouds), PC2 difference sea land areas, PC4 sensor artefacts (striping swath direction). compute full resolution (10000 x 10000 pixels) results write file, use","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") r = split(read_stars(tif)) pc = prcomp(as.data.frame(r)[,-(1:2)]) # based on all data out = predict(r, pc) plot(merge(out), breaks = \"equal\", join_zlim = FALSE) granule = system.file(\"sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip\",     package = \"starsdata\") s2 = paste0(\"SENTINEL2_L1C:/vsizip/\", granule,  \"/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/MTD_MSIL1C.xml:10m:EPSG_32632\") p = read_stars(s2, proxy = TRUE, NA_value = 0) %>%     split() r = st_sample(p, 1000) pc = prcomp(na.omit(as.data.frame(r))[,-(1:2)]) # based on all data out = predict(p, pc) bb = st_bbox(p) %>%    st_as_sfc() %>%   st_transform(4326) %>%   st_bbox() library(maps) library(mapdata) m = map(\"worldHires\", xlim = bb[c(1,3)], ylim = bb[c(2,4)], plot=F,fill=TRUE) %>%   st_as_sfc() %>%   st_transform(st_crs(r)) plt_boundary = function() plot(m, border = 'orange', add = TRUE) plot(merge(out), hook = plt_boundary, join_zlim = FALSE) ## downsample set to 18 write_stars(merge(out), \"out.tif\")"},{"path":"/articles/stars7.html","id":"k-means-clustering","dir":"Articles","previous_headings":"Unsupervised learners","what":"K-means clustering","title":"7. Statistical modelling with stars objects","text":"small dataset:  seems pick fair number land cover classes: water (5), rural (3), densely populated (1, 2). large(r) dataset:  see class 1 3 identify unclouded area, 3 land, classes seem mainly catch aspects cloud signal.","code":"library(clue) predict.kmeans = function(object, newdata, ...) {     unclass(clue::cl_predict(object, newdata[, -c(1:2)], ...)) } tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") i = read_stars(tif, proxy = TRUE) %>%     split() nclus = 5  sam = st_sample(i, 1000) k = kmeans(na.omit(as.data.frame(sam)[, -c(1:2)]), nclus) out = predict(i, k) plot(out, col = sf.colors(nclus, categorical=TRUE)) i = read_stars(s2, proxy = TRUE, NA_value = 0) %>%     split() sam = st_sample(i, 1000) k = kmeans(na.omit(as.data.frame(sam)[, -c(1:2)]), nclus) out = predict(i, k) plot(out, col = sf.colors(nclus, categorical=TRUE), reset = FALSE) ## downsample set to 18 plot(m, add = TRUE)"},{"path":[]},{"path":"/articles/stars7.html","id":"random-forest-land-use-classification","dir":"Articles","previous_headings":"Supervised learners","what":"Random Forest land use classification","title":"7. Statistical modelling with stars objects","text":"following example purely educational purposes; classified “land use” just rough approximation seems easily visible image: sea, land, areas partially covered clouds. opted therefore four classes: sea, land, clouds sea, clouds land. polygon areas land use classified, residing GeoPackage file. (file created using QGIS, using instructions found .)  Next, need points, sampled inside polygons, need extract satellite spectral data  comes rather trivial finding land sea can well predicted clouds, less trivial finding can reasonably distinguished patchy clouds kind. Note predictions kind pure pixel-based: prediction spectral bands pixel considered, instance neighboring pixels.","code":"# for all, multi-resolution, use: bands = c(\"B04\", \"B03\", \"B02\", \"B08\", \"B01\", \"B05\", \"B06\", \"B07\", \"B8A\", \"B09\", \"B10\", \"B11\", \"B12\") # bands = c(\"B04\", \"B03\", \"B02\", \"B08\") s2 = paste0(\"/vsizip/\", granule,  \"/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/GRANULE/L1C_T32ULE_A013919_20180220T105539/IMG_DATA/T32ULE_20180220T105051_\", bands, \".jp2\") r = read_stars(s2, proxy = TRUE, NA_value = 0) %>%     setNames(bands)  cl = read_sf(system.file(\"gpkg/s2.gpkg\", package = \"stars\")) %>%   st_transform(st_crs(r)) plot(r, reset = FALSE) ## downsample set to 8 plot(cl, add = TRUE) plot(m, add = TRUE, border = 'orange') pts = st_sample(cl, 1000, \"regular\") %>%     st_as_sf() %>%     st_intersection(cl) ## Warning: attribute variables are assumed to be spatially constant throughout ## all geometries train = st_extract(r, pts) train$use = as.factor(pts$use) # no need for join, since the order did not change train ## Simple feature collection with 1000 features and 14 fields ## Geometry type: POINT ## Dimension:     XY ## Bounding box:  xmin: 328195.1 ymin: 5909563 xmax: 407928.8 ymax: 5970391 ## Projected CRS: WGS 84 / UTM zone 32N ## First 10 features: ##     B04  B03  B02  B08  B01  B05  B06  B07  B8A  B09 B10  B11  B12 ## 1   921 1139 1396 2375 1744 1180 1860 2099 2396 1006  15 1458  779 ## 2   879 1136 1366 2935 1728 1246 2148 2537 2814  994  14 1669  887 ## 3   870 1029 1338 1872 1694 1076 1567 1765 2042  824  14 1629  856 ## 4  1016 1228 1439 3054 1789 1477 2655 3057 3427 1207  15 2220 1210 ## 5  1010 1145 1449 2039 1782 1302 1724 1975 2144  860  10 1795  999 ## 6  1344 1213 1475 1943 1770 1427 1684 1901 2143  863  14 2276 1365 ## 7  1067 1204 1472 2348 1778 1369 2057 2306 2685 1032  17 2010 1179 ## 8  1035 1144 1437 2289 1760 1299 1891 2246 2637 1042  11 1788  920 ## 9   854 1047 1371 1902 1715 1146 1815 1941 2133  782  16 1568  949 ## 10  941 1155 1379 2802 1689 1380 2268 2595 2976 1058  15 2012 1086 ##                           x  use ## 1  POINT (394518.2 5940525) land ## 2  POINT (390045.1 5931738) land ## 3  POINT (390340.9 5929888) land ## 4    POINT (391254 5938829) land ## 5  POINT (391997.7 5937843) land ## 6  POINT (395680.9 5933296) land ## 7  POINT (388792.2 5934807) land ## 8  POINT (392185.2 5940074) land ## 9  POINT (387142.8 5936359) land ## 10 POINT (390877.6 5927178) land library(randomForest) ## randomForest 4.7-1.1 ## Type rfNews() to see new features/changes/bug fixes. ##  ## Attaching package: 'randomForest' ## The following object is masked from 'package:dplyr': ##  ##     combine train = as.data.frame(train) train$x = NULL # remove geometry rf = randomForest(use ~ ., train) # ~ . : use all other attributes pr = predict(r, rf) plot(pr, reset = FALSE, key.pos = 1) ## downsample set to 8 # add country outline: plot(m, add = TRUE)"},{"path":"/articles/stars7.html","id":"parallel-processing","dir":"Articles","previous_headings":"","what":"Parallel processing","title":"7. Statistical modelling with stars objects","text":"machine learning models support multithreading default (e.g., ranger xgboost), rule. R single-threaded, using appropriate packages can easily parallelize calculations, reduce data processing time. example tutorial showing step--step unsupervised classification using multithreading can found R-Spatial blog.","code":""},{"path":"/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Edzer Pebesma. Author, maintainer. Michael Sumner. Contributor. Etienne Racine. Contributor. Adriano Fantini. Contributor. David Blodgett. Contributor. Krzysztof Dyba. Contributor.","code":""},{"path":"/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Pebesma E, Bivand R (2023). Spatial Data Science: applications R. Chapman Hall/CRC, London. doi:10.1201/9780429459016, https://r-spatial.org/book/.","code":"@Book{,   title = {{Spatial Data Science: With applications in R}},   author = {Edzer Pebesma and Roger Bivand},   year = {2023},   publisher = {Chapman and Hall/CRC},   address = {London},   url = {https://r-spatial.org/book/},   pages = {352},   doi = {10.1201/9780429459016}, }"},{"path":"/index.html","id":"spatiotemporal-arrays-raster-and-vector-datacubes","dir":"","previous_headings":"","what":"Spatiotemporal Arrays, Raster and Vector Data Cubes","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"Spatiotemporal data often comes form dense arrays, space time array dimensions. Examples include socio-economic demographic data, environmental variables monitored fixed stations, raster maps time series satellite images multiple spectral bands, spatial simulations, climate weather model output. R package provides classes methods reading, manipulating, plotting writing data cubes, extent proper formats .","code":""},{"path":"/index.html","id":"raster-and-vector-data-cubes","dir":"","previous_headings":"","what":"Raster and vector data cubes","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"canonical data cube us mind two dimensions represent spatial raster dimensions, third time (band), e.g. shown :  data cubes however also consider higher-dimensional cubes (hypercubes) five-dimensional cube addition time, spectral band sensor form dimensions:  lower-dimensional cubes raster image:  Raster data need regular aligned North/East, package stars supports besides regular also rotated, sheared, rectilinear curvilinear rasters:  Vector data cubes arise two regularly discretized spatial dimensions, single dimension points distinct spatial feature geometries, polygons (e.g. denoting administrative regions):  points (e.g. denoting sensor locations):  NetCDF’s CF-convention calls discrete axis.","code":"suppressPackageStartupMessages(library(dplyr)) library(stars) # Loading required package: abind # Loading required package: sf # Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") read_stars(tif) |>   slice(index = 1, along = \"band\") |>   plot()"},{"path":"/index.html","id":"netcdf-gdal","dir":"","previous_headings":"","what":"NetCDF, GDAL","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"stars provides two functions read data: read_ncdf read_stars, latter reads GDAL. (future, integrated read_stars.) reading NetCDF files, package RNetCDF used, reading GDAL, package sf provides binary linking GDAL. vector raster operations, stars uses much possible routines available GDAL PROJ (e.g. st_transform, rasterize, polygonize, warp). Read vignette vector-raster conversions, reprojection, warping.","code":""},{"path":"/index.html","id":"out-of-memory-on-disk-rasters","dir":"","previous_headings":"","what":"Out-of-memory (on-disk) rasters","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"Package stars provides stars_proxy objects (currently read GDAL), contain dimensions metadata pointers files disk. objects work lazily: reading processing data postponed moment pixels really needed (plot time, writing disk), done lowest spatial resolution possible still fulfills resolution graphics device. details found stars proxy vignette. following methods currently available stars_proxy objects:","code":"methods(class = \"stars_proxy\") #  [1] [               [[<-            [<-             adrop           #  [5] aggregate       aperm           as.data.frame   c               #  [9] coerce          dim             droplevels      filter          # [13] hist            image           initialize      is.na           # [17] Math            merge           mutate          Ops             # [21] plot            predict         print           pull            # [25] rename          select          show            slice           # [29] slotsFromS3     split           st_apply        st_as_sf        # [33] st_as_stars     st_crop         st_dimensions<- st_downsample   # [37] st_mosaic       st_normalize    st_redimension  st_sample       # [41] st_set_bbox     transmute       write_stars     # see '?methods' for accessing help and source code"},{"path":"/index.html","id":"raster-and-vector-time-series-analysis-example","dir":"","previous_headings":"","what":"Raster and vector time series analysis example","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"following, curvilinear grid hourly precipitation values hurricane imported first 12 time steps plotted:  next, intersected counties North Carolina, maximum precipitation intensity obtained per county, plotted:  can integrate (reduce) time, instance find maximum precipitation occurred. following code finds time index, corresponding time value:  package cubble, can make glyph map see magnitude timings county maximum precipitation:","code":"prec_file = system.file(\"nc/test_stageiv_xyt.nc\", package = \"stars\") (prec = read_stars(gdal_subdatasets(prec_file)[[1]])) # stars object with 3 dimensions and 1 attribute # attribute(s): #                                         Min. 1st Qu. Median     Mean 3rd Qu. # Total_precipitation_surface... [kg/m^2]    0       0   0.75 4.143009    4.63 #                                           Max. # Total_precipitation_surface... [kg/m^2] 163.75 # dimension(s): #      from  to                  offset   delta         refsys # x       1  87                      NA      NA WGS 84 (CRS84) # y       1 118                      NA      NA WGS 84 (CRS84) # time    1  23 2018-09-13 19:00:00 UTC 1 hours        POSIXct #                                  values x/y # x    [87x118] -80.61 [°],...,-74.88 [°] [x] # y      [87x118] 32.44 [°],...,37.62 [°] [y] # time                               NULL     # curvilinear grid # or: (prec = read_ncdf(prec_file, curvilinear = c(\"lon\", \"lat\"), ignore_bounds = TRUE)) sf::read_sf(system.file(\"gpkg/nc.gpkg\", package = \"sf\"), \"nc.gpkg\") |>    st_transform(st_crs(prec)) -> nc # transform from NAD27 to WGS84 nc_outline = st_union(st_geometry(nc)) plot_hook = function() plot(nc_outline, border = 'red', add = TRUE) prec |>   slice(index = 1:12, along = \"time\") |>   plot(downsample = c(3, 3, 1), hook = plot_hook) a = aggregate(prec, by = nc, FUN = max) plot(a, max.plot = 23, border = 'grey', lwd = .5) index_max = function(x) ifelse(all(is.na(x)), NA, which.max(x)) b = st_apply(a, \"geom\", index_max) b |>  mutate(when = st_get_dimension_values(a, \"time\")[b$index_max]) |>   select(when) |>   plot(key.pos = 1, main = \"time of maximum precipitation\") library(cubble) #  # Attaching package: 'cubble' # The following object is masked from 'package:stats': #  #     filter library(ggplot2) a |> setNames(\"precip\") |>   st_set_dimensions(2, name = \"tm\") |>   units::drop_units() |>   as_cubble(key = id, index = tm) |>   suppressWarnings() -> a.cb a.cb |>   face_temporal() |>   unfold(long, lat) |>   mutate(tm = as.numeric(tm)) |>   ggplot(aes(x_major = long, x_minor = tm, y_major = lat, y_minor = precip)) +   geom_sf(data = nc, inherit.aes = FALSE) +   geom_glyph_box(width = 0.3, height = 0.1) +   geom_glyph(width = 0.3, height = 0.1) # Warning: There were 84 warnings in `dplyr::mutate()`. # The first warning was: # ℹ In argument: `y = .data$y_major + rescale11(.data$y_minor) * .data$height/2`. # ℹ In group 12: `group = 12`. # Caused by warning in `min()`: # ! no non-missing arguments to min; returning Inf # ℹ Run `dplyr::last_dplyr_warnings()` to see the 83 remaining warnings. # Warning: Removed 966 rows containing missing values or values outside the scale range # (`geom_glyph_box()`). # Warning: Removed 966 rows containing missing values or values outside the scale range # (`geom_glyph()`)."},{"path":[]},{"path":"/index.html","id":"gdalcubes","dir":"","previous_headings":"Other packages for data cubes","what":"gdalcubes","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"Package gdalcubes can used create data cubes (functions ) image collections, sets multi-band images varying spatial resolution spatial extent coordinate reference systems (e.g., spread multiple UTM zones) observation times resampling /aggregating space /time. reuses GDAL VRT’s gdalwarp spatial resampling /warping, handles temporal resampling aggregation .","code":""},{"path":"/index.html","id":"ncdfgeom","dir":"","previous_headings":"Other packages for data cubes","what":"ncdfgeom","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"ncdfgeom reads writes vector data cubes netcdf files standards-compliant way.","code":""},{"path":"/index.html","id":"raster-and-terra","dir":"","previous_headings":"Other packages for data cubes","what":"raster and terra","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"Packages raster successor, terra powerful packages handling raster maps stacks raster maps memory disk, address non-raster time series, multi-attribute rasters time series rasters mixed type attributes (e.g., numeric, logical, factor, POSIXct) rectilinear curvilinear rasters list stars commands matching existing raster commands found wiki. list translations opposite direction (stars raster terra) still needs made. comment differences stars terra found .","code":""},{"path":"/index.html","id":"other-stars-resources","dir":"","previous_headings":"","what":"Other stars resources:","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"blog posts: first, second, third, newer blog posts vignettes original R Consortium proposal.","code":""},{"path":"/index.html","id":"acknowledgment","dir":"","previous_headings":"Other stars resources:","what":"Acknowledgment","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"project realized financial support ","code":""},{"path":"/reference/L7_ETMs.html","id":null,"dir":"Reference","previous_headings":"","what":"Landsat-7 bands for a selected region around Olinda, BR — L7_ETMs","title":"Landsat-7 bands for a selected region around Olinda, BR — L7_ETMs","text":"Probably containing six 30 m bands: Band 1 Visible (0.45 - 0.52 µm) 30 m Band 2 Visible (0.52 - 0.60 µm) 30 m Band 3 Visible (0.63 - 0.69 µm) 30 m Band 4 Near-Infrared (0.77 - 0.90 µm) 30 m Band 5 Short-wave Infrared (1.55 - 1.75 µm) 30 m Band 7 Mid-Infrared (2.08 - 2.35 µm) 30 m","code":""},{"path":"/reference/L7_ETMs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Landsat-7 bands for a selected region around Olinda, BR — L7_ETMs","text":"","code":"L7_ETMs"},{"path":"/reference/L7_ETMs.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Landsat-7 bands for a selected region around Olinda, BR — L7_ETMs","text":"object class stars_proxy (inherits stars) dimension 349 x 352 x 6.","code":""},{"path":"/reference/aggregate.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"spatially or temporally aggregate stars object — aggregate.stars","title":"spatially or temporally aggregate stars object — aggregate.stars","text":"spatially temporally aggregate stars object, returning data cube lower spatial temporal resolution","code":""},{"path":"/reference/aggregate.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"spatially or temporally aggregate stars object — aggregate.stars","text":"","code":"# S3 method for stars aggregate(   x,   by,   FUN,   ...,   drop = FALSE,   join = st_intersects,   as_points = any(st_dimension(by) == 2, na.rm = TRUE),   rightmost.closed = FALSE,   left.open = FALSE,   exact = FALSE )"},{"path":"/reference/aggregate.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"spatially or temporally aggregate stars object — aggregate.stars","text":"x object class stars information aggregated object class sf sfc spatial aggregation, temporal aggregation vector time values (Date, POSIXct, PCICt) interpreted sequence left-closed, right-open time intervals string like \"months\", \"5 days\" like (see cut.POSIXt), function cuts time intervals; object class stars, converted sfc st_as_sfc(, as_points = FALSE) thus ignoring time component. Note: pixel assigned single group (order groups occur) non-overlapping spatial features temporal windows recommended. FUN aggregation function, mean ... arguments passed FUN, na.rm=TRUE drop logical; ignored join function; function used find matches x as_points see st_as_sf: shall raster pixels taken points, small square polygons? rightmost.closed see findInterval left.open logical; used time intervals, see findInterval cut.POSIXt exact logical; TRUE, use coverage_fraction compute exact overlap fractions polygons raster cells","code":""},{"path":[]},{"path":"/reference/aggregate.stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"spatially or temporally aggregate stars object — aggregate.stars","text":"","code":"# aggregate time dimension in format Date tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") t1 = as.Date(\"2018-07-31\") x = read_stars(c(tif, tif, tif, tif), along = list(time = c(t1, t1+1, t1+2, t1+3)))[,1:30,1:30] st_get_dimension_values(x, \"time\") #> [1] \"2018-07-31\" \"2018-08-01\" \"2018-08-02\" \"2018-08-03\" x_agg_time = aggregate(x, by = t1 + c(0, 2, 4), FUN = max)   # aggregate time dimension in format Date - interval by_t = \"2 days\" x_agg_time2 = aggregate(x, by = by_t, FUN = max)  st_get_dimension_values(x_agg_time2, \"time\") #> [1] \"2018-07-31\" \"2018-08-02\" #TBD: #x_agg_time - x_agg_time2  # aggregate time dimension in format POSIXct x = st_set_dimensions(x, 4, values = as.POSIXct(c(\"2018-07-31\",                                                    \"2018-08-01\",                                                    \"2018-08-02\",                                                    \"2018-08-03\")),                        names = \"time\") by_t = as.POSIXct(c(\"2018-07-31\", \"2018-08-02\")) x_agg_posix = aggregate(x, by = by_t, FUN = max) st_get_dimension_values(x_agg_posix, \"time\") #> [1] \"2018-07-31 UTC\" \"2018-08-02 UTC\" #TBD: # x_agg_time - x_agg_posix aggregate(x, \"2 days\", mean) #> stars object with 4 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43     58 57.58796      70  145 #> dimension(s): #>      from to         offset  delta                     refsys point x/y #> time    1  2 2018-07-31 UTC 2 days                    POSIXct    NA     #> x       1 30         288776   28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 30        9120761  -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6             NA     NA                         NA    NA     if (require(ncmeta, quietly = TRUE)) {  # Spatial aggregation, see https://github.com/r-spatial/stars/issues/299  prec_file = system.file(\"nc/test_stageiv_xyt.nc\", package = \"stars\")  prec = read_ncdf(prec_file, curvilinear = c(\"lon\", \"lat\"))  prec_slice = dplyr::slice(prec, index = 17, along = \"time\")  nc = sf::read_sf(system.file(\"gpkg/nc.gpkg\", package = \"sf\"), \"nc.gpkg\")  nc = st_transform(nc, st_crs(prec_slice))  agg = aggregate(prec_slice, st_geometry(nc), mean)  plot(agg) } #> no 'var' specified, using Total_precipitation_surface_1_Hour_Accumulation #> other available variables: #>  lat, lon, time #> Will return stars object with 236118 cells. #> No projection information found in nc file.  #>  Coordinate variable units found to be degrees,  #>  assuming WGS84 Lat/Lon.   # example of using a function for \"by\": aggregate by month-of-year d = c(10, 10, 150) a = array(rnorm(prod(d)), d) # pure noise times = Sys.Date() + seq(1, 2000, length.out = d[3]) m = as.numeric(format(times, \"%m\")) signal = rep(sin(m / 12 * pi), each = prod(d[1:2])) # yearly period s = (st_as_stars(a) + signal) %>%       st_set_dimensions(3, values = times) f = function(x, format = \"%B\") {     months = format(as.Date(paste0(\"01-\", 1:12, \"-1970\")), format)     factor(format(x, format), levels = months) } agg = aggregate(s, f, mean) plot(agg)"},{"path":"/reference/bcsd_obs.html","id":null,"dir":"Reference","previous_headings":"","what":"Monthly Gridded Meteorological Observations — bcsd_obs","title":"Monthly Gridded Meteorological Observations — bcsd_obs","text":"monthly observational data used BCSD downscaling. See:  information.\" ; \"Atmospheric Temperature, Air Temperature Atmosphere, Precipitation, Rain, Maximum Daily Temperature, Minimum  Daily Temperature\" ;","code":""},{"path":"/reference/bcsd_obs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Monthly Gridded Meteorological Observations — bcsd_obs","text":"","code":"bcsd_obs"},{"path":"/reference/bcsd_obs.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Monthly Gridded Meteorological Observations — bcsd_obs","text":"object class stars_proxy (inherits stars) dimension 81 x 33 x 12.","code":""},{"path":"/reference/c.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"combine multiple stars objects, combine multiple attributes single stars object single array","code":""},{"path":"/reference/c.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"","code":"# S3 method for stars_proxy c(   ...,   along = NA_integer_,   along_crs = FALSE,   try_hard = FALSE,   nms = names(list(...)),   tolerance = sqrt(.Machine$double.eps) )  # S3 method for stars c(   ...,   along = NA_integer_,   try_hard = FALSE,   nms = names(list(...)),   tolerance = sqrt(.Machine$double.eps) )"},{"path":"/reference/c.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"... object(s) class star: case multiple arguments, combined single stars object, case single argument, attributes combined single attribute. case multiple objects, objects dimensionality. along integer; see read_stars along_crs logical; TRUE, combine arrays along CRS dimension try_hard logical; TRUE arrays different dimensions, combine dimensions matching first array nms character; vector array names tolerance numeric; values used .equal compare dimension values combine dimensions matching first array","code":""},{"path":"/reference/c.stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"single stars object merged (binded) arrays.","code":""},{"path":"/reference/c.stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"error raised attempting combine arrays different measurement units single array. intentded, drop_units  can used remove units stars object merging.","code":""},{"path":"/reference/c.stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) (new = c(x, x)) #> stars object with 3 dimensions and 2 attributes #> attribute(s): #>                Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif       1      54     69 68.91242      86  255 #> L7_ETMs.tif.1     1      54     69 68.91242      86  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     c(new) # collapses two arrays into one with an additional dimension #> stars object with 3 dimensions and 2 attributes #> attribute(s): #>                Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif       1      54     69 68.91242      86  255 #> L7_ETMs.tif.1     1      54     69 68.91242      86  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     c(x, x, along = 3) #> stars object with 3 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>              Min. 1st Qu. Median    Mean 3rd Qu. Max. #> L7_ETMs.tif    47      65     76 77.3419      87  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  12      NA    NA                         NA    NA"},{"path":"/reference/coerce-methods.html","id":null,"dir":"Reference","previous_headings":"","what":"Coerce stars object into a Raster raster or brick — as","title":"Coerce stars object into a Raster raster or brick — as","text":"Coerce stars object Raster raster brick Coerce stars object terra SpatRaster","code":""},{"path":"/reference/coerce-methods.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Coerce stars object into a Raster raster or brick — as","text":"object coerce","code":""},{"path":"/reference/coerce-methods.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Coerce stars object into a Raster raster or brick — as","text":"RasterLayer RasterBrick SpatRaster","code":""},{"path":"/reference/coerce-methods.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Coerce stars object into a Raster raster or brick — as","text":"stars object three dimensions, dimensions higher third collapsed third dimensions. stars object x/y raster multiple attributes, merged first, put raster brick. stars object three dimensions, dimensions higher third collapsed third dimensions. stars object x/y raster multiple attributes, merged first, put SpatRaster.","code":""},{"path":"/reference/contour.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"plot contours of a stars object — contour.stars","title":"plot contours of a stars object — contour.stars","text":"plot contours stars object","code":""},{"path":"/reference/contour.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"plot contours of a stars object — contour.stars","text":"","code":"# S3 method for stars contour(x, ...)"},{"path":"/reference/contour.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"plot contours of a stars object — contour.stars","text":"x object class stars ... parameters passed contour","code":""},{"path":"/reference/contour.stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"plot contours of a stars object — contour.stars","text":"uses R internal contour algorithm, (default) plots contours; st_contour uses GDAL contour algorithm returns contours simple features.","code":""},{"path":"/reference/contour.stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"plot contours of a stars object — contour.stars","text":"","code":"d = st_dimensions(x = 1:ncol(volcano), y = 1:nrow(volcano)) r = st_as_stars(t(volcano)) r = st_set_dimensions(r, 1, offset = 0, delta = 1) r = st_set_dimensions(r, 2, offset = 0, delta = -1) plot(r, reset = FALSE) contour(r, add = TRUE)"},{"path":"/reference/cut_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"cut methods for stars objects — cut_stars","title":"cut methods for stars objects — cut_stars","text":"cut methods stars objects","code":""},{"path":"/reference/cut_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"cut methods for stars objects — cut_stars","text":"","code":"# S3 method for array cut(x, breaks, ...)  # S3 method for matrix cut(x, breaks, ...)  # S3 method for stars cut(x, breaks, ...)"},{"path":"/reference/cut_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"cut methods for stars objects — cut_stars","text":"x see cut breaks see cut ... see cut","code":""},{"path":"/reference/cut_stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"cut methods for stars objects — cut_stars","text":"array matrix levels attribute; see details","code":""},{"path":"/reference/cut_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"cut methods for stars objects — cut_stars","text":"R's factor works vectors, arrays matrices. work-around (hack?) keep factor levels generated cut use plots.","code":""},{"path":"/reference/cut_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"cut methods for stars objects — cut_stars","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) cut(x, c(0, 50, 100, 255)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>     L7_ETMs.tif     #>  (0,50]   :156060   #>  (50,100] :503764   #>  (100,255]: 77264   #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     cut(x[,,,1], c(0, 50, 100, 255)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>     L7_ETMs.tif     #>  (0,50]   :     1   #>  (50,100] :117134   #>  (100,255]:  5713   #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   1      NA    NA                         NA    NA     plot(cut(x[,,,1], c(0, 50, 100, 255)))  tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x1 = read_stars(tif) (x1_cut = cut(x1, breaks = c(0, 50, 100, Inf)))  # shows factor in summary #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>     L7_ETMs.tif     #>  (0,50]   :156060   #>  (50,100] :503764   #>  (100,Inf]: 77264   #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     plot(x1_cut[,,,c(3,6)]) # propagates through [ and plot"},{"path":"/reference/dplyr.html","id":null,"dir":"Reference","previous_headings":"","what":"dplyr verbs for stars objects — dplyr","title":"dplyr verbs for stars objects — dplyr","text":"dplyr verbs stars objects; package dplyr needs loaded methods can used stars objects.","code":""},{"path":"/reference/dplyr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"dplyr verbs for stars objects — dplyr","text":"","code":"filter.stars(.data, ...)  filter.stars_proxy(.data, ...)  mutate.stars(.data, ...)  mutate.stars_proxy(.data, ...)  transmute.stars(.data, ...)  transmute.stars_proxy(.data, ...)  select.stars(.data, ...)  select.stars_proxy(.data, ...)  rename.stars(.data, ...)  rename.stars_proxy(.data, ...)  pull.stars(.data, var = -1)  pull.stars_proxy(.data, ...)  as.tbl_cube.stars(x, ...)  slice.stars(.data, along, index, ..., drop = length(index) == 1)  slice.stars_proxy(.data, along, index, ...)  replace_na.stars(data, replace, ...)  replace_na.stars_proxy(data, ...)"},{"path":"/reference/dplyr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"dplyr verbs for stars objects — dplyr","text":".data object class stars ... see filter var see pull x object class stars along name index dimension slice applied index integer value(s) index drop logical; drop dimensions single index? data data set work replace see replace_na: list variable=value pairs, value replacement value NA's","code":""},{"path":"/reference/dplyr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"dplyr verbs for stars objects — dplyr","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x1 = read_stars(tif) if (require(dplyr, quietly = TRUE)) {  x1 %>% slice(\"band\", 2:3)  x1 %>% slice(\"x\", 50:100) } #>  #> Attaching package: ‘dplyr’ #> The following objects are masked from ‘package:stats’: #>  #>     filter, lag #> The following objects are masked from ‘package:base’: #>  #>     intersect, setdiff, setequal, union #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    11      56     68 70.50099      82  252 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x      50 100  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA"},{"path":"/reference/expand_dimensions.html","id":null,"dir":"Reference","previous_headings":"","what":"expand the dimension values into a list — expand_dimensions","title":"expand the dimension values into a list — expand_dimensions","text":"expand dimension values list","code":""},{"path":"/reference/expand_dimensions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"expand the dimension values into a list — expand_dimensions","text":"","code":"expand_dimensions(x, ...)  # S3 method for dimensions expand_dimensions(x, ..., max = FALSE, center = NA)"},{"path":"/reference/expand_dimensions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"expand the dimension values into a list — expand_dimensions","text":"x object class `stars` `dimensions` ... ignored max logical; `TRUE` return max (end) values dimensions intervals center logical; `TRUE` return center values intervals, otherwise return offset (start) intervals; `NA` (default) return centers x/y dimensions, offsets others","code":""},{"path":"/reference/geom_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"ggplot geom for stars objects — geom_stars","title":"ggplot geom for stars objects — geom_stars","text":"ggplot geom stars objects","code":""},{"path":"/reference/geom_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ggplot geom for stars objects — geom_stars","text":"","code":"geom_stars(   mapping = NULL,   data = NULL,   ...,   downsample = 0,   sf = FALSE,   na.action = na.pass )  theme_stars(...)"},{"path":"/reference/geom_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"ggplot geom for stars objects — geom_stars","text":"mapping see geom_raster data see geom_raster ... see geom_raster downsample downsampling rate: e.g. 3 keeps rows cols 1, 4, 7, 10 etc.; value 0 downsample; can specified dimension, e.g. c(5,5,0) downsample first two dimensions third. sf logical; TRUE rasters converted polygons plotted using geom_sf. na.action function; NA values need removed plotting use value na.omit (applies objects raster dimensions)","code":""},{"path":"/reference/geom_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"ggplot geom for stars objects — geom_stars","text":"geom_stars returns (call ) either geom_raster, geom_tile, geom_sf, depending raster vector geometry; first , aes call constructed raster dimension names first array fill variable. calls coord_equal facet_wrap needed control aspect ratio layers plotted; see examples. stars array contains hex color values, fill parameter given, color values used fill color; see example . visual artefacts occur (Moiré-Effekt), see details section plot.stars","code":""},{"path":"/reference/geom_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"ggplot geom for stars objects — geom_stars","text":"","code":"system.file(\"tif/L7_ETMs.tif\", package = \"stars\") %>% read_stars() -> x if (require(ggplot2, quietly = TRUE)) {   ggplot() + geom_stars(data = x) +     coord_equal() +     facet_wrap(~band) +     theme_void() +     scale_x_discrete(expand=c(0,0))+     scale_y_discrete(expand=c(0,0))   # plot rgb composite:   st_as_stars(L7_ETMs)[,,,1:3] |> st_rgb() -> x # x contains colors as pixel values   ggplot() + geom_stars(data = x) }"},{"path":"/reference/in-methods.html","id":null,"dir":"Reference","previous_headings":"","what":"evaluate whether cube values are in a given set — %in%,stars-method","title":"evaluate whether cube values are in a given set — %in%,stars-method","text":"evaluate whether cube values given set","code":""},{"path":"/reference/in-methods.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"evaluate whether cube values are in a given set — %in%,stars-method","text":"","code":"# S4 method for stars %in%(x, table)"},{"path":"/reference/in-methods.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"evaluate whether cube values are in a given set — %in%,stars-method","text":"x data cube value table values set","code":""},{"path":"/reference/make_intervals.html","id":null,"dir":"Reference","previous_headings":"","what":"create an intervals object — make_intervals","title":"create an intervals object — make_intervals","text":"create intervals object, assuming left-closed right-open intervals","code":""},{"path":"/reference/make_intervals.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"create an intervals object — make_intervals","text":"","code":"make_intervals(start, end)"},{"path":"/reference/make_intervals.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"create an intervals object — make_intervals","text":"start vector start values, 2-column matrix start end values column 1 2, respectively end vector end values","code":""},{"path":"/reference/mdim.html","id":null,"dir":"Reference","previous_headings":"","what":"Read or write data using GDAL's multidimensional array API — mdim","title":"Read or write data using GDAL's multidimensional array API — mdim","text":"Read write data using GDAL's multidimensional array API","code":""},{"path":"/reference/mdim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read or write data using GDAL's multidimensional array API — mdim","text":"","code":"read_mdim(   filename,   variable = character(0),   ...,   options = character(0),   raster = NULL,   offset = integer(0),   count = integer(0),   step = integer(0),   proxy = FALSE,   debug = FALSE,   bounds = TRUE,   curvilinear = NA )  write_mdim(   x,   filename,   driver = detect.driver(filename),   ...,   root_group_options = character(0),   options = character(0),   as_float = TRUE )"},{"path":"/reference/mdim.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read or write data using GDAL's multidimensional array API — mdim","text":"filename name source destination file data source variable name array read; `\"?\"`, list array names returned, group name list element names. ... ignored options character; driver specific options regarding opening (read_mdim) creation (write_mdim) dataset raster names raster variables (default: first two dimensions) offset integer; offset dimension (pixels) sub-array read, defaults 0 dimension(requires sf >= 1.0-9) count integer; size dimension (pixels) sub-array read (default: read ); value NA read corresponding dimension entirely; counts relative step size (requires sf >= 1.0-9) step integer; step size dimension (pixels) sub-array read; defaults 1 dimension (requires sf >= 1.0-9) proxy logical; return proxy object? (functional yet) debug logical; print debug info? bounds logical character: TRUE tries infer \"bounds\" attribute; character,  named vector form c(longitude=\"lon_bnds\", latitude=\"lat_bnds\") names dimension names curvilinear control reading curvilinear (geolocation) coordinate arrays; NA try reading x/y dimension names; character, defines arrays read; FALSE try; see also read_stars x stars object driver character; driver name root_group_options character; driver specific options regarding creation root group as_float logical; TRUE write 4-byte floating point numbers, FALSE write 8-byte doubles","code":""},{"path":"/reference/mdim.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Read or write data using GDAL's multidimensional array API — mdim","text":"assumed first two dimensions easting northing","code":""},{"path":[]},{"path":"/reference/mdim.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read or write data using GDAL's multidimensional array API — mdim","text":"","code":"set.seed(135) m = matrix(runif(10), 2, 5) names(dim(m)) = c(\"stations\", \"time\") times = as.Date(\"2022-05-01\") + 1:5 pts = st_as_sfc(c(\"POINT(0 1)\", \"POINT(3 5)\")) s = st_as_stars(list(Precipitation = m)) |>  st_set_dimensions(1, values = pts) |>  st_set_dimensions(2, values = times) nc = tempfile(fileext=\".nc\") if (compareVersion(sf_extSoftVersion()[\"GDAL\"], \"3.4.0\") > -1) {   write_mdim(s, nc)   # try ncdump on the generated file   print(read_mdim(nc)) } #> Warning: GDAL Error 6: SetIndexingVariable() not implemented #> Warning: GDAL Error 6: SetIndexingVariable() not implemented #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>                      Min.   1st Qu.    Median      Mean  3rd Qu.      Max. #> Precipitation  0.03524588 0.3224987 0.3772574 0.4289465 0.511113 0.9204841 #> dimension(s): #>          from to     offset  delta refsys point                   values #> stations    1  2         NA     NA     NA  TRUE POINT (0 1), POINT (3 5) #> time        1  5 2022-05-02 1 days   Date    NA                     NULL"},{"path":"/reference/merge.html","id":null,"dir":"Reference","previous_headings":"","what":"merge or split stars object — merge","title":"merge or split stars object — merge","text":"merge attributes dimension, split dimension attributes","code":""},{"path":"/reference/merge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"merge or split stars object — merge","text":"","code":"# S3 method for stars split(x, f = length(dim(x)), drop = TRUE, ...)  # S3 method for stars merge(x, y, ..., name = \"attributes\")"},{"path":"/reference/merge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"merge or split stars object — merge","text":"x object class stars f name index dimension split; default last dimension drop ignored ... defined, first unnamed argument used dimension values, defined, attribute names used dimension values y needs missing name name new dimension","code":""},{"path":"/reference/merge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"merge or split stars object — merge","text":"merge merges attributes stars object new dimension; split splits dimension attributes","code":""},{"path":"/reference/merge.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"merge or split stars object — merge","text":"split.stars works first attribute, give error one attribute present","code":""},{"path":"/reference/ops_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"S3 Ops Group Generic Functions for stars objects — ops_stars","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"Ops functions stars objects, including comparison, product divide, add, subtract","code":""},{"path":"/reference/ops_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"","code":"# S3 method for stars Ops(e1, e2)  # S3 method for stars Math(x, ...)  # S3 method for stars_proxy Ops(e1, e2)  # S3 method for stars_proxy Math(x, ...)"},{"path":"/reference/ops_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"e1 object class stars e2 object class stars x object class stars ... parameters passed Math functions","code":""},{"path":"/reference/ops_stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"object class stars","code":""},{"path":"/reference/ops_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"e1 e2 numeric vector, e2 less smaller dimensions e1, e2 recycled fits e1, using usual R array recycling rules. user needs make sure sensible; may needed use aperm permutate dimensions first.","code":""},{"path":"/reference/ops_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) x * x #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median    Mean 3rd Qu.  Max. #> L7_ETMs.tif     1    2916   4761 5512.41    7396 65025 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x / x #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median Mean 3rd Qu. Max. #> L7_ETMs.tif     1       1      1    1       1    1 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x + x #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     2     108    138 137.8248     172  510 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x + 10 #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    11      64     79 78.91242      96  265 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     all.equal(x * 10, 10 * x) #> [1] TRUE tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) a = sqrt(x) b = log(x, base = 10)"},{"path":"/reference/plot.html","id":null,"dir":"Reference","previous_headings":"","what":"plot stars object, with subplots for each level of first non-spatial dimension — plot","title":"plot stars object, with subplots for each level of first non-spatial dimension — plot","text":"plot stars object, subplots level first non-spatial dimension, customization legend key","code":""},{"path":"/reference/plot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"plot stars object, with subplots for each level of first non-spatial dimension — plot","text":"","code":"# S3 method for nc_proxy plot(x, y, ..., downsample = get_downsample(dim(x)), max_times = 16)  # S3 method for stars plot(   x,   y,   ...,   join_zlim = TRUE,   main = make_label(x, 1),   axes = FALSE,   downsample = TRUE,   nbreaks = 11,   breaks = \"quantile\",   col = grey(1:(nbreaks - 1)/nbreaks),   key.pos = get_key_pos(x, ...),   key.width = kw_dflt(x, key.pos),   key.length = 0.618,   key.lab = main,   reset = TRUE,   box_col = NA,   center_time = FALSE,   hook = NULL,   mfrow = NULL,   compact = TRUE )  # S3 method for stars image(   x,   ...,   band = 1,   attr = 1,   asp = NULL,   rgb = NULL,   maxColorValue = ifelse(inherits(rgb, \"data.frame\"), 255, max(x[[attr]], na.rm = TRUE)),   xlab = if (!axes) \"\" else names(d)[1],   ylab = if (!axes) \"\" else names(d)[2],   xlim = st_bbox(extent)$xlim,   ylim = st_bbox(extent)$ylim,   text_values = FALSE,   text_color = \"black\",   axes = FALSE,   interpolate = FALSE,   as_points = FALSE,   key.pos = NULL,   logz = FALSE,   key.width = kw_dflt(x, key.pos),   key.length = 0.618,   add.geom = NULL,   border = NA,   useRaster = isTRUE(dev.capabilities()$rasterImage == \"yes\"),   extent = x )  # S3 method for stars_proxy plot(x, y, ..., downsample = get_downsample(dim(x)))"},{"path":"/reference/plot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"plot stars object, with subplots for each level of first non-spatial dimension — plot","text":"x object class stars y ignored ... arguments: plot, passed image.stars; image, passed image.default rasterImage. downsample logical numeric; TRUE try plot many pixels actually visible, FALSE, downsampling takes place, numeric, number pixels/lines/bands etc skipped; see Details. max_times integer; maximum number time steps attempt plot. join_zlim logical; TRUE, compute single, joint zlim (color scale) subplots x main character; subplot title prefix; use \"\" get time, use NULL suppress subplot titles axes logical; axes box added plot? nbreaks number color breaks; one number colors. missing col specified, derived . breaks numeric vector actual color breaks, style name used classIntervals. col colors use grid cells, color palette function key.pos numeric; side plot color key: 1 bottom, 2 left, 3 top, 4 right; set NULL omit key. Ignored multiple columns plotted single function call. Default depends plot size, map aspect, , set, parameter asp. length 2, second value, ranging 0 1, determines key placed available space (default: 0.5, center). key.width amount space reserved width key (labels); relative absolute (using lcm) key.length amount space reserved length key (labels); relative absolute (using lcm) key.lab character; label color key case multiple subplots, use \"\" suppress reset logical; FALSE, keep plot mode allows adding map elements; TRUE restore original mode plotting box_col color box around sub-plots; use NA suppress plotting boxes around sub-plots. center_time logical; TRUE, sub-plot titles show center time intervals, otherwise start hook NULL function; hook function called every sub-plot; see examples. mfrow length-2 integer vector nrows, ncolumns composite plot, override default layout compact logical; place facets compactly (TRUE), spread plotting device area? band integer; band (dimension) plot attr integer; attribute plot asp numeric; aspect ratio image rgb integer; specify three bands form rgb composite. Experimental: rgb color table; see Details. maxColorValue numeric; passed rgb xlab character; x axis label ylab character; y axis label xlim x axis limits ylim y axis limits text_values logical; print values text image? text_color character; color printed text values interpolate logical; using rasterImage (rgb), pixels interpolated? as_points logical; curvilinear sheared grids: parameter passed st_as_sf, determining whether raster cells plotted symbols (fast, approximate) small polygons (slow, exact) logz logical; TRUE, use log10-scale attribute variable. case, breaks need given log10-values; see examples. add.geom object class sfc, list arguments plot, added image sub-image border color used cell borders (case x curvilinear rotated/sheared grid) useRaster logical; use rasterImage capabilities graphics device? extent object st_bbox method; sets plotting extent","code":""},{"path":"/reference/plot.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"plot stars object, with subplots for each level of first non-spatial dimension — plot","text":"plotting subsetted stars_proxy object, default value argument downsample computed correctly, set manually. Downsampling: value downsample 0: downsampling, 1: every dimension value (pixel/line/band), one value skipped (half original resolution), 2: every dimension value, 2 values skipped (one third original resolution), etc. downsample TRUE length 1 numeric vector, downsampling applied raster [x] [y] dimensions. remove unused classes categorical raster, use droplevels function. bitmaps show visual artefacts (Moiré effects), make sure device png used rather ragg::agg_png latter uses antialiasing filled polygons causes ; see also https://github.com/r-spatial/stars/issues/573 . use rgb color table experimental; see https://github.com/r-spatial/mapview/issues/208 plotting subsetted stars_proxy object, default value argument downsample computed correctly, set manually.","code":""},{"path":"/reference/plot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"plot stars object, with subplots for each level of first non-spatial dimension — plot","text":"","code":"st_bbox(L7_ETMs) |> st_as_sfc() |> st_centroid() |> st_coordinates() -> pt hook1 = function() {     text(pt[,\"X\"], pt[,\"Y\"], \"foo\", col = 'orange', cex = 2) } plot(L7_ETMs, hook = hook1)  x = st_set_dimensions(L7_ETMs, 3, paste0(\"B_\", 1:6)) hook2 = function(..., row, col, nr, nrow, ncol, value, bbox) {    str = paste0(\"row \", row, \"/\", nrow, \", col \", col, \"/\", ncol, \"\\nnr: \", nr, \" value: \", value)    bbox |> st_as_sfc() |> st_centroid() |> st_coordinates() -> pt    text(pt[,\"X\"], pt[,\"Y\"], str, col = 'red', cex = 2) } plot(x, hook = hook2, col = grey(c(.2,.25,.3,.35)))  if (isTRUE(dev.capabilities()$rasterImage == \"yes\")) {   lc = read_stars(system.file(\"tif/lc.tif\", package = \"stars\"))   levels(lc[[1]]) = abbreviate(levels(lc[[1]]), 6) # so it's not only legend   plot(lc, key.pos=4) } tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) image(x, col = grey((3:9)/10))  if (isTRUE(dev.capabilities()$rasterImage == \"yes\")) {   image(x, rgb = c(1,3,5)) # false color composite }"},{"path":"/reference/prcomp.html","id":null,"dir":"Reference","previous_headings":"","what":"Principle components of stars object — prcomp","title":"Principle components of stars object — prcomp","text":"Compute principle components stars object","code":""},{"path":"/reference/prcomp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Principle components of stars object — prcomp","text":"","code":"# S3 method for stars_proxy prcomp(x, ..., downsample = 0)  # S3 method for stars prcomp(x, ..., quiet = FALSE)"},{"path":"/reference/prcomp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Principle components of stars object — prcomp","text":"x object class `stars` `stars_proxy` ... see prcomp downsample see st_as_stars quiet logical; `TRUE`, suppress message PCs computed last dimension; see details","code":""},{"path":"/reference/prcomp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Principle components of stars object — prcomp","text":"object class `prcomp`, see prcomp","code":""},{"path":"/reference/prcomp.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Principle components of stars object — prcomp","text":"`x` one attribute, principle components computed space last dimension `x` predict PC scores `stars` object, use predict.stars; see example ","code":""},{"path":"/reference/prcomp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Principle components of stars object — prcomp","text":"","code":"l7 = split(st_as_stars(L7_ETMs), 3) # use bands as features l7 |> prcomp() |> plot()  l7 |> prcomp() |> predict(l7, model = _) |> merge() |> plot() #> downsample set to 1"},{"path":"/reference/predict.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict values, given a model object, for a stars or stars_proxy object — predict.stars","title":"Predict values, given a model object, for a stars or stars_proxy object — predict.stars","text":"Predict values, given model object, stars stars_proxy object","code":""},{"path":"/reference/predict.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict values, given a model object, for a stars or stars_proxy object — predict.stars","text":"","code":"# S3 method for stars_proxy predict(object, model, ...)  # S3 method for stars predict(object, model, ..., drop_dimensions = FALSE)"},{"path":"/reference/predict.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict values, given a model object, for a stars or stars_proxy object — predict.stars","text":"object object class `stars` model model object class predict method; check `methods(class = class(object))` ... arguments passed predict method drop_dimensions logical; `TRUE`, remove dimensions (coordinates etc) `data.frame` predictors","code":""},{"path":"/reference/predict.stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Predict values, given a model object, for a stars or stars_proxy object — predict.stars","text":"separate predictors object need separate attributes object;  case e.g. band dimension, use `split(object)`","code":""},{"path":"/reference/print_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"print stars or dimensions object — print_stars","title":"print stars or dimensions object — print_stars","text":"print stars dimensions object","code":""},{"path":"/reference/print_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"print stars or dimensions object — print_stars","text":"","code":"# S3 method for dimensions as.data.frame(   x,   ...,   digits = max(3, getOption(\"digits\") - 3),   usetz = TRUE,   stars_crs = getOption(\"stars.crs\") %||% 28,   all = FALSE )  # S3 method for dimensions print(x, ...)  # S3 method for stars print(x, ..., n = 1e+05, abbrev = 30)"},{"path":"/reference/print_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"print stars or dimensions object — print_stars","text":"x object class stars class dimensions ... passed .data.frame.dimensions digits number digits print numbers usetz logical; used format PCICt POSIXct values stars_crs maximum width string CRS objects logical; TRUE print also fields entirely filled NA NULL n prod(dim(x)) > 10 * n, first n cells used attribute summary statistics abbrev number characters abbreviate attribute names ","code":""},{"path":"/reference/read_ncdf.html","id":null,"dir":"Reference","previous_headings":"","what":"Read NetCDF into stars object — read_ncdf","title":"Read NetCDF into stars object — read_ncdf","text":"Read data file (source) using NetCDF library directly.","code":""},{"path":"/reference/read_ncdf.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read NetCDF into stars object — read_ncdf","text":"","code":"read_ncdf(   .x,   ...,   var = NULL,   ncsub = NULL,   curvilinear = character(0),   eps = sqrt(.Machine$double.eps),   ignore_bounds = FALSE,   make_time = TRUE,   make_units = TRUE,   proxy = NULL,   downsample = 0 )"},{"path":"/reference/read_ncdf.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read NetCDF into stars object — read_ncdf","text":".x NetCDF file source character vector nc_proxy object. ... ignored var variable name names (must matching grids) ncsub matrix start, count columns (see Details) curvilinear length two character named vector names variables holding longitude latitude values raster cells. `stars` attempts figure appropriate curvilinear coordinates supplied. eps numeric; dimension value increases considered identical differ less eps ignore_bounds logical; bounds values dimensions, present, ignored? make_time TRUE (default), attempt made provide date-time class \"time\" variable make_units TRUE (default), attempt made set units property variable proxy logical; TRUE, object class stars_proxy read contains array metadata ; FALSE full array data read memory. set, defaults TRUE number cells read larger options(stars.n_proxy), 1e8 option set. downsample integer; number cells omit samples along dimension.  e.g. c(1,1,2) return every cell x y every third cell third dimension (z t). 0, downsampling applied. Note transformation applied NetCDF data read using st_downsample. , proxy=TRUE,  option ignored.","code":""},{"path":"/reference/read_ncdf.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Read NetCDF into stars object — read_ncdf","text":"following logic applied coordinates. coordinate axes regularly spaced coordinate variables reduced offset/delta form 'affine = c(0, 0)', otherwise values coordinates stored used define rectilinear grid. data two dimensions first two regular nominated 'raster' plotting. curvilinear argument used specifies 2D arrays containing coordinate values first two dimensions data read. currently assumed coordinates 2D relate first two dimensions order. var set first set variables shared grid used. start count columns ncsub must correspond variable dimension (nrows) valid index using var.get.nc convention (start 1-based). count value NA steps included. Axis order must match variable/s read.","code":""},{"path":"/reference/read_ncdf.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read NetCDF into stars object — read_ncdf","text":"","code":"f <- system.file(\"nc/reduced.nc\", package = \"stars\") if (require(ncmeta, quietly = TRUE)) {  read_ncdf(f)  read_ncdf(f, var = c(\"anom\"))  read_ncdf(f, ncsub = cbind(start = c(1, 1, 1, 1), count = c(10, 12, 1, 1))) } #> no 'var' specified, using sst, anom, err, ice #> other available variables: #>  lon, lat, zlev, time #> 0-360 longitude crossing the international date line encountered. #> Longitude coordinates will be 0-360 in output. #> Will return stars object with 16200 cells. #> No projection information found in nc file.  #>  Coordinate variable units found to be degrees,  #>  assuming WGS84 Lat/Lon. #> 0-360 longitude crossing the international date line encountered. #> Longitude coordinates will be 0-360 in output. #> Will return stars object with 16200 cells. #> No projection information found in nc file.  #>  Coordinate variable units found to be degrees,  #>  assuming WGS84 Lat/Lon. #> no 'var' specified, using sst, anom, err, ice #> other available variables: #>  lon, lat, zlev, time #> Will return stars object with 120 cells. #> No projection information found in nc file.  #>  Coordinate variable units found to be degrees,  #>  assuming WGS84 Lat/Lon. #> stars object with 4 dimensions and 4 attributes #> attribute(s): #>                Min. 1st Qu. Median        Mean 3rd Qu. Max. NA's #> sst [°C]      -1.39 -0.7200 -0.515 -0.53399999  -0.275 0.03   90 #> anom [°C]     -1.07 -0.3625  0.195  0.05866667   0.555 0.92   90 #> err [°C]       0.30  0.3000  0.300  0.30299999   0.300 0.32   90 #> ice [percent]  0.01  0.1100  0.170  0.20937500   0.255 0.52  104 #> dimension(s): #>      from to offset delta  refsys         values x/y #> lon     1 10     -1     2  WGS 84           NULL [x] #> lat     1 12    -90     2  WGS 84           NULL [y] #> zlev    1  1     NA    NA      NA              0     #> time    1  1     NA    NA POSIXct 1981-12-31 UTC      if (require(ncmeta, quietly = TRUE)) {  #' precipitation data in a curvilinear NetCDF  prec_file = system.file(\"nc/test_stageiv_xyt.nc\", package = \"stars\")  prec = read_ncdf(prec_file, curvilinear = c(\"lon\", \"lat\"), ignore_bounds = TRUE) } #> no 'var' specified, using Total_precipitation_surface_1_Hour_Accumulation #> other available variables: #>  lat, lon, time #> Will return stars object with 236118 cells. #> No projection information found in nc file.  #>  Coordinate variable units found to be degrees,  #>  assuming WGS84 Lat/Lon.  ##plot(prec) ## gives error about unique breaks ## remove NAs, zeros, and give a large number ## of breaks (used for validating in detail) qu_0_omit = function(x, ..., n = 22) {   x = units::drop_units(na.omit(x))   c(0, quantile(x[x > 0], seq(0, 1, length.out = n))) } if (require(dplyr, quietly = TRUE)) {   prec_slice = slice(prec, index = 17, along = \"time\")   plot(prec_slice, border = NA, breaks = qu_0_omit(prec_slice[[1]]), reset = FALSE)   nc = sf::read_sf(system.file(\"gpkg/nc.gpkg\", package = \"sf\"), \"nc.gpkg\")   plot(st_geometry(nc), add = TRUE, reset = FALSE, col = NA) }"},{"path":"/reference/read_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"read raster/array dataset from file or connection — read_stars","title":"read raster/array dataset from file or connection — read_stars","text":"read raster/array dataset file connection","code":""},{"path":"/reference/read_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"read raster/array dataset from file or connection — read_stars","text":"","code":"read_stars(   .x,   sub = TRUE,   ...,   options = character(0),   driver = character(0),   quiet = FALSE,   NA_value = NA_real_,   along = NA_integer_,   RasterIO = list(),   proxy = getOption(\"stars.n_proxy\") %||% 1e+08,   curvilinear = character(0),   normalize_path = TRUE,   RAT = character(0),   tolerance = 1e-10,   exclude = \"\",   shorten = TRUE )"},{"path":"/reference/read_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"read raster/array dataset from file or connection — read_stars","text":".x character vector name(s) file(s) data source(s) read, function returns vector sub character, integer logical; name, index indicator sub-dataset(s) read ... passed st_as_stars curvilinear set options character; opening options driver character; driver use opening file. override fixing subdatasets autodetect well, use NULL. quiet logical; print progress output? NA_value numeric value used conversion NA values; default read input file along length-one character integer, list; determines several arrays combined, see Details. RasterIO list named parameters GDAL's RasterIO, control extent, resolution bands read data source; see details. proxy logical; TRUE, object class stars_proxy read contains array metadata ; FALSE full array data read memory. Always FALSE curvilinear girds. set number, defaults TRUE number cells read larger number. curvilinear length two character vector names subdatasets holding longitude latitude values raster cells, named length 2 list holding longitude latitude matrices; names list correspond raster dimensions referred normalize_path logical; FALSE, suppress call normalizePath .x RAT character; raster attribute table column name use factor levels tolerance numeric; passed .equal comparing dimension parameters. exclude character; vector category value(s) exclude shorten logical character; TRUE length(.x) > 1, remove common start end parts array names; character new prefix","code":""},{"path":"/reference/read_stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"read raster/array dataset from file or connection — read_stars","text":"object class stars","code":""},{"path":"/reference/read_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"read raster/array dataset from file or connection — read_stars","text":"case .x contains multiple files, read combined c.stars. Along dimension, objects merged? along set NA merge arrays new attributes objects identical dimensions, else try merge along time dimension called time indicates different time stamps. single name (positive value) along merge along dimension, create new one already exist. arrays arranged along one dimensions values (e.g. time stamps), named list can passed along specify ; see example. RasterIO list zero following named arguments: nXOff, nYOff (1-based: first row/col offset value 1), nXSize, nYSize, nBufXSize, nBufYSize, bands, resample. See https://gdal.org/doxygen/classGDALDataset.html meaning; bands integer vector containing band numbers read (1-based: first band 1). Note nBufXSize nBufYSize specified downsampling image, resulting adjusted geotransform. resample reflects resampling method one : \"nearest_neighbour\" (default), \"bilinear\", \"cubic\", \"cubic_spline\", \"lanczos\", \"average\", \"mode\", \"Gauss\". Data read memory (proxy=FALSE) read numeric (double) array, except categorical variables read numeric (integer) array class factor.","code":""},{"path":"/reference/read_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"read raster/array dataset from file or connection — read_stars","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") (x1 = read_stars(tif)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     1      54     69 68.91242      86  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     (x2 = read_stars(c(tif, tif))) #> stars object with 3 dimensions and 2 attributes #> attribute(s): #>                Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif       1      54     69 68.91242      86  255 #> L7_ETMs.tif.1     1      54     69 68.91242      86  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     (x3 = read_stars(c(tif, tif), along = \"band\")) #> stars object with 3 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>              Min. 1st Qu. Median    Mean 3rd Qu. Max. #> L7_ETMs.tif    47      65     76 77.3419      87  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  12      NA    NA                         NA    NA     (x4 = read_stars(c(tif, tif), along = \"new_dimensions\")) # create 4-dimensional array #> stars object with 4 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>              Min. 1st Qu. Median    Mean 3rd Qu. Max. #> L7_ETMs.tif    47      65     76 77.3419      87  255 #> dimension(s): #>                from  to  offset delta                     refsys point x/y #> x                 1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y                 1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band              1   6      NA    NA                         NA    NA     #> new_dimensions    1   2      NA    NA                         NA    NA     x1o = read_stars(tif, options = \"OVERVIEW_LEVEL=1\") t1 = as.Date(\"2018-07-31\") # along is a named list indicating two dimensions: read_stars(c(tif, tif, tif, tif), along = list(foo = c(\"bar1\", \"bar2\"), time = c(t1, t1+2))) #> stars object with 5 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>              Min. 1st Qu. Median    Mean 3rd Qu. Max. #> L7_ETMs.tif    47      65     76 77.3419      87  255 #> dimension(s): #>      from  to     offset  delta                     refsys point     values x/y #> x       1 349     288776   28.5 SIRGAS 2000 / UTM zone 25S FALSE       NULL [x] #> y       1 352    9120761  -28.5 SIRGAS 2000 / UTM zone 25S FALSE       NULL [y] #> band    1   6         NA     NA                         NA    NA       NULL     #> foo     1   2         NA     NA                         NA    NA bar1, bar2     #> time    1   2 2018-07-31 2 days                       Date    NA       NULL      m = matrix(1:120, nrow = 12, ncol = 10) dim(m) = c(x = 10, y = 12) # named dim st = st_as_stars(m) attr(st, \"dimensions\")$y$delta = -1 attr(st, \"dimensions\")$y$offset = 12 st #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1     1   30.75   60.5 60.5   90.25  120 #> dimension(s): #>   from to offset delta point x/y #> x    1 10      0     1 FALSE [x] #> y    1 12     12    -1 FALSE [y] tmp = tempfile(fileext = \".tif\") write_stars(st, tmp) (red <- read_stars(tmp)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>                       Min. 1st Qu. Median Mean 3rd Qu. Max. #> file22f42df83ed7.tif     1   30.75   60.5 60.5   90.25  120 #> dimension(s): #>   from to offset delta x/y #> x    1 10      0     1 [x] #> y    1 12     12    -1 [y] read_stars(tmp, RasterIO = list(nXOff = 1, nYOff = 1, nXSize = 10, nYSize = 12,    nBufXSize = 2, nBufYSize = 2))[[1]] #>      [,1] [,2] #> [1,]   33   93 #> [2,]   38   98 (red <- read_stars(tmp, RasterIO = list(nXOff = 1, nYOff = 1, nXSize = 10, nYSize = 12,    nBufXSize = 2, nBufYSize = 2))) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>                       Min. 1st Qu. Median Mean 3rd Qu. Max. #> file22f42df83ed7.tif    33   36.75   65.5 65.5   94.25   98 #> dimension(s): #>   from to offset delta x/y #> x    1  2      0     5 [x] #> y    1  2     12    -6 [y] red[[1]] # cell values of subsample grid: #>      [,1] [,2] #> [1,]   33   93 #> [2,]   38   98 if (FALSE) {   plot(st, reset = FALSE, axes = TRUE, ylim = c(-.1,12.1), xlim = c(-.1,10.1),     main = \"nBufXSize & nBufYSize demo\", text_values = TRUE)   plot(st_as_sfc(red, as_points = TRUE), add = TRUE, col = 'red', pch = 16)   plot(st_as_sfc(st_as_stars(st), as_points = FALSE), add = TRUE, border = 'grey')   plot(st_as_sfc(red, as_points = FALSE), add = TRUE, border = 'green', lwd = 2) } file.remove(tmp) #> [1] TRUE"},{"path":"/reference/redimension.html","id":null,"dir":"Reference","previous_headings":"","what":"redimension array, or collapse attributes into a new dimension — redimension","title":"redimension array, or collapse attributes into a new dimension — redimension","text":"redimension array, collapse attributes new dimension","code":""},{"path":"/reference/redimension.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"redimension array, or collapse attributes into a new dimension — redimension","text":"","code":"# S3 method for stars_proxy st_redimension(   x,   new_dims = st_dimensions(x),   along = list(new_dim = names(x)),   ... )  st_redimension(x, new_dims, along, ...)  # S3 method for stars st_redimension(   x,   new_dims = st_dimensions(x),   along = setNames(list(names(x)), name),   ...,   name = \"new_dim\" )"},{"path":"/reference/redimension.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"redimension array, or collapse attributes into a new dimension — redimension","text":"x object class stars new_dims target dimensions: either `dimensions` object integer vector dimensions' sizes along named list new dimension name values ... ignored name character name new dimension","code":""},{"path":"/reference/st_apply.html","id":null,"dir":"Reference","previous_headings":"","what":"st_apply apply a function to one or more array dimensions — st_apply","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"st_apply apply function array dimensions: aggregate space, time, something else","code":""},{"path":"/reference/st_apply.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"","code":"# S3 method for stars st_apply(   X,   MARGIN,   FUN,   ...,   CLUSTER = NULL,   PROGRESS = FALSE,   FUTURE = FALSE,   rename = TRUE,   .fname,   single_arg = has_single_arg(FUN, list(...)) || can_single_arg(FUN),   keep = FALSE )"},{"path":"/reference/st_apply.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"X object class stars MARGIN see apply; index number(s) name(s) dimensions FUN applied FUN see apply see Details. ... arguments passed FUN CLUSTER cluster use parallel apply; see makeCluster PROGRESS logical; TRUE, use pbapply::pbapply show progress bar FUTURE logical;TRUE, use future.apply::future_apply rename logical; TRUE X one attribute  FUN simple function name, rename attribute returned object  function name .fname function name new attribute name (one  dimensions reduced) new dimension (new dimension created);  missing, name FUN used single_arg logical; TRUE, FUN takes single argument (like fn_ndvi1 ),  FALSE FUN takes multiple arguments (like fn_ndvi2 ). keep logical; TRUE, preserve dimension metadata (e.g. time stamps)","code":""},{"path":"/reference/st_apply.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"object class stars accordingly reduced number dimensions;  case FUN returns one value, new dimension created carrying  name function used; see examples. Following logic  apply, new dimension put dimensions; use aperm rearrange , see last example.","code":""},{"path":"/reference/st_apply.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"FUN function either operates single object,  data iteration step dimensions MARGIN, function  many arguments elements object. See NDVI  examples . second form can much faster e.g. trivial  function called every pixel, (example). heuristics default single_arg work often, always; try setting right value st_apply gives error.","code":""},{"path":"/reference/st_apply.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) st_apply(x, 1:2, mean) # mean band value for each pixel #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>       Min.  1st Qu.   Median     Mean 3rd Qu. Max. #> mean  25.5 53.33333 68.33333 68.91242      82  255 #> dimension(s): #>   from  to  offset delta                     refsys point x/y #> x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] st_apply(x, c(\"x\", \"y\"), mean) # equivalent to the above #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>       Min.  1st Qu.   Median     Mean 3rd Qu. Max. #> mean  25.5 53.33333 68.33333 68.91242      82  255 #> dimension(s): #>   from  to  offset delta                     refsys point x/y #> x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] st_apply(x, 3, mean)   # mean of all pixels for each band #> stars object with 1 dimensions and 1 attribute #> attribute(s): #>           Min.  1st Qu.   Median     Mean  3rd Qu.     Max. #> mean  59.23541 61.07112 65.96675 68.91242 76.25445 83.18266 #> dimension(s): #>      from to #> band    1  6 if (FALSE) {  st_apply(x, \"band\", mean) # equivalent to the above  st_apply(x, 1:2, range) # min and max band value for each pixel  fn_ndvi1 = function(x) (x[4]-x[3])/(x[4]+x[3]) # ONE argument: will be called for each pixel  fn_ndvi2 = function(red,nir) (nir-red)/(nir+red) # n arguments: will be called only once  ndvi1 = st_apply(x, 1:2, fn_ndvi1)    # note that we can select bands 3 and 4 in the first argument:  ndvi2 = st_apply(x[,,,3:4], 1:2, fn_ndvi2)   all.equal(ndvi1, ndvi2)  # compute the (spatial) variance of each band; https://github.com/r-spatial/stars/issues/430  st_apply(x, 3, function(x) var(as.vector(x))) # as.vector is required!  # to get a progress bar also in non-interactive mode, specify:  if (require(pbapply)) { # install it, if FALSE    pboptions(type = \"timer\")  }  st_apply(x, 1:2, range) # dimension \"range\" is first; rearrange by:  st_apply(x, 1:2, range) %>% aperm(c(2,3,1)) }"},{"path":"/reference/st_as_sf.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert stars object into an sf object — st_as_sf","title":"Convert stars object into an sf object — st_as_sf","text":"Convert stars object sf object","code":""},{"path":"/reference/st_as_sf.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert stars object into an sf object — st_as_sf","text":"","code":"# S3 method for stars st_as_sfc(x, ..., as_points, which = seq_len(prod(dim(x)[1:2])))  # S3 method for stars st_as_sf(   x,   ...,   as_points = FALSE,   merge = FALSE,   na.rm = TRUE,   use_integer = is.logical(x[[1]]) || is.integer(x[[1]]),   long = FALSE,   connect8 = FALSE )  # S3 method for stars_proxy st_as_sf(x, ..., downsample = 0)"},{"path":"/reference/st_as_sf.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert stars object into an sf object — st_as_sf","text":"x object class stars ... ignored as_points logical; cells converted points polygons? See details. linear index cells keep (argument recommended used) merge logical; TRUE, cells identical values merged (using GDAL_Polygonize GDAL_FPolygonize); FALSE, polygon raster cell returned; see details na.rm logical; missing valued cells removed, also converted features? use_integer (relevant merge TRUE): TRUE, polygonizing values rounded 32-bits signed integer values (GDALPolygonize), otherwise converted 32-bit floating point values (GDALFPolygonize). long logical; TRUE, return long table form sf, geometries dimensions recycled connect8 logical; TRUE, use 8 connectedness. Otherwise 4 connectedness algorithm applied. downsample see st_as_stars","code":""},{"path":"/reference/st_as_sf.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Convert stars object into an sf object — st_as_sf","text":"merge TRUE, first attribute converted sf object. na.rm FALSE, areas NA values also written polygons. Note resulting polygons typically invalid, use st_make_valid create valid polygons .","code":""},{"path":"/reference/st_as_sf.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert stars object into an sf object — st_as_sf","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) x = x[,1:100,1:100,6] # subset of a band with lower values in it x[[1]][x[[1]] < 30] = NA # set lower values to NA x[[1]] = x[[1]] < 100 # make the rest binary x #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>  L7_ETMs.tif     #>  Mode :logical   #>  FALSE:525       #>  TRUE :7665      #>  NA's :1810      #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 100  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 100 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    6   6      NA    NA                         NA    NA     (p = st_as_sf(x)) # removes NA areas #> Simple feature collection with 8190 features and 1 field #> Geometry type: POLYGON #> Dimension:     XY #> Bounding box:  xmin: 288776.3 ymin: 9117911 xmax: 291626.3 ymax: 9120761 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #> First 10 features: #>      V1                       geometry #> 1  TRUE POLYGON ((288776.3 9120761,... #> 2  TRUE POLYGON ((288804.8 9120761,... #> 3  TRUE POLYGON ((288833.3 9120761,... #> 4  TRUE POLYGON ((288861.8 9120761,... #> 5  TRUE POLYGON ((288890.3 9120761,... #> 6  TRUE POLYGON ((288918.8 9120761,... #> 7  TRUE POLYGON ((288947.3 9120761,... #> 8  TRUE POLYGON ((288975.8 9120761,... #> 9  TRUE POLYGON ((289004.3 9120761,... #> 10 TRUE POLYGON ((289032.8 9120761,... (p = st_as_sf(x[,,,1], merge = TRUE)) # glues polygons together #> Simple feature collection with 155 features and 1 field #> Geometry type: POLYGON #> Dimension:     XY #> Bounding box:  xmin: 288776.3 ymin: 9117911 xmax: 291626.3 ymax: 9120761 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #> First 10 features: #>    L7_ETMs.tif                       geometry #> 1            0 POLYGON ((289517.3 9120761,... #> 2            0 POLYGON ((290144.3 9120761,... #> 3            0 POLYGON ((290315.3 9120761,... #> 4            0 POLYGON ((291113.3 9120761,... #> 5            0 POLYGON ((291341.3 9120761,... #> 6            1 POLYGON ((291455.3 9120761,... #> 7            1 POLYGON ((291569.3 9120761,... #> 8            0 POLYGON ((290372.3 9120732,... #> 9            1 POLYGON ((290628.8 9120732,... #> 10           1 POLYGON ((290771.3 9120732,... all(st_is_valid(p)) # not all valid, see details #> [1] TRUE plot(p, axes = TRUE)  (p = st_as_sf(x, na.rm = FALSE, merge = TRUE)) # includes polygons with NA values #> Simple feature collection with 380 features and 1 field #> Geometry type: POLYGON #> Dimension:     XY #> Bounding box:  xmin: 288776.3 ymin: 9117911 xmax: 291626.3 ymax: 9120761 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #> First 10 features: #>    L7_ETMs.tif                       geometry #> 1            0 POLYGON ((289517.3 9120761,... #> 2            0 POLYGON ((290144.3 9120761,... #> 3            0 POLYGON ((290315.3 9120761,... #> 4            0 POLYGON ((291113.3 9120761,... #> 5            0 POLYGON ((291341.3 9120761,... #> 6            1 POLYGON ((291455.3 9120761,... #> 7            1 POLYGON ((291569.3 9120761,... #> 8           NA POLYGON ((289745.3 9120732,... #> 9           NA POLYGON ((289830.8 9120732,... #> 10           0 POLYGON ((290372.3 9120732,... plot(p, axes = TRUE)"},{"path":"/reference/st_as_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"convert objects into a stars object — st_as_stars","title":"convert objects into a stars object — st_as_stars","text":"convert objects stars object","code":""},{"path":"/reference/st_as_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"convert objects into a stars object — st_as_stars","text":"","code":"# S3 method for cubble_df st_as_stars(.x, ..., check_times = FALSE)  # S3 method for ncdfgeom st_as_stars(.x, ..., sf_geometry = NA)  # S3 method for OpenStreetMap st_as_stars(.x, ..., as_col = FALSE)  # S3 method for stars_proxy st_as_stars(   .x,   ...,   downsample = 0,   url = attr(.x, \"url\"),   envir = parent.frame() )  # S3 method for data.frame st_as_stars(.x, ..., dims = coords, xy, y_decreasing = TRUE, coords = 1:2)  # S3 method for Raster st_as_stars(.x, ..., att = 1, ignore_file = FALSE)  # S3 method for SpatRaster st_as_stars(   .x,   ...,   ignore_file = FALSE,   as_attributes = all(terra::is.factor(.x)) )  # S3 method for sf st_as_stars(.x, ..., dims = attr(.x, \"sf_column\"))  st_as_stars(.x, ...)  # S3 method for list st_as_stars(.x, ..., dimensions = NULL)  # S3 method for default st_as_stars(.x = NULL, ..., raster = NULL)  # S3 method for stars st_as_stars(.x, ..., curvilinear = NULL, crs = st_crs(\"OGC:CRS84\"))  # S3 method for bbox st_as_stars(   .x,   ...,   nx,   ny,   dx = dy,   dy = dx,   xlim = .x[c(\"xmin\", \"xmax\")],   ylim = .x[c(\"ymin\", \"ymax\")],   values = 0,   n = 64800,   pretty = FALSE,   inside = FALSE,   nz,   proxy = FALSE )  # S3 method for xts st_as_stars(.x, ..., dimensions, name = \"attr\")"},{"path":"/reference/st_as_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"convert objects into a stars object — st_as_stars","text":".x object convert ... case .x class bbox, arguments passed  pretty. case .x class nc_proxy, arguments passed read_ncdf. check_times logical; check time stamps time series identical? sf_geometry sf data.frame geometry attributes added stars object. Must number rows timeseries instances. as_col logical; return rgb numbers (FALSE) (character) color values (TRUE)? downsample integer: larger 0, downsample rate (number pixels skip every row/column); length 2, specifies downsampling rate x y. url character; URL stars endpoint data reside envir environment resolve objects dims column names indices form cube dimensions xy x y raster dimension names indices; takes effect dims specified, see details y_decreasing logical; TRUE, (numeric) y values get negative delta (decrease increasing index) coords dims, symmetry st_as_sf att see factorValues; column RasterLayer's attribute table ignore_file logical; TRUE, ignore SpatRaster object file name as_attributes logical; TRUE .x one layer, load separate attributes rather band time dimension (implemented case ignore_file TRUE) dimensions object class dimensions raster character; names dimensions denote raster dimensions curvilinear creating curvilinear grids: named length 2 list holding longitude latitude matrices stars arrays, names corresponding attributes .x; names vector correspond raster dimensions matrices associated ; see Details. crs object class crs coordinate reference system values curvilinear; see details nx integer; number cells x direction; see details ny integer; number cells y direction; see details dx numeric object class units; cell size x direction; see details dy numeric object class units; cell size y direction; see details xlim length 2 numeric vector extent (min, max) x direction ylim length 2 numeric vector extent (min, max) y direction values value(s) populate raster values n (approximate) target number grid cells pretty logical; cell coordinates pretty values? inside logical; cells entirely fall inside bbox, potentially covering completely (TRUE), always cover bbox (FALSE), find good approximation (NA, default)? nz integer; number cells z direction; missing z-dimension created. proxy logical; stars_proxy object created? (requires gdal_create binary sf < 1.0-6) name character; attribute name array xts object","code":""},{"path":"/reference/st_as_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"convert objects into a stars object — st_as_stars","text":"ncdfgeom method: objects point-timeseries optional line polygon geometry timeseries specified sf_geometry parameter. See ncdfgeom NetCDF-based format geometry timeseries. xy specified first two dimensions dims numeric, set two dimensions. st_as_stars method sf objects without additional arguments returns one-dimensional data cube dimension simple features geometries, remaining attributes data cube attributes. used arguments, method data.frames called. curvilinear list stars objects longitude latitude values, coordinate reference system typically latitude longitude values. curvilinear contains names two arrays .x, removed returned object. bbox method: pretty TRUE, raster cells may extend coordinate range .x sides. addition nx ny, dx dy also missing, set single value computed sqrt(diff(xlim)*diff(ylim)/n). nx ny missing values matrix, number columns rows matrix taken. Otherwise, nx ny missing, computed (ceiling, floor, rounded integer value) ratio (x y) range divided (dx dy), depending value inside. Positive dy made negative. named arguments (...) passed pretty. dx dy units objects, value converted units st_crs(.x) (sf >= 1.0-7). xts methods, dimensions provided, time first dimension.","code":""},{"path":"/reference/st_as_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"convert objects into a stars object — st_as_stars","text":"","code":"if (require(plm, quietly = TRUE)) {  data(Produc, package = \"plm\")  st_as_stars(Produc) } #>  #> Attaching package: ‘plm’ #> The following objects are masked from ‘package:dplyr’: #>  #>     between, lag, lead #> stars object with 2 dimensions and 9 attributes #> attribute(s): #>     region         pcap              hwy            water         #>  5      :136   Min.   :  2627   Min.   : 1827   Min.   :  228.5   #>  8      :136   1st Qu.:  7097   1st Qu.: 3858   1st Qu.:  764.5   #>  4      :119   Median : 17572   Median : 7556   Median : 2266.5   #>  1      :102   Mean   : 25037   Mean   :10218   Mean   : 3618.8   #>  3      : 85   3rd Qu.: 27692   3rd Qu.:11267   3rd Qu.: 4318.7   #>  6      : 68   Max.   :140217   Max.   :47699   Max.   :24592.3   #>  (Other):170                                                      #>      util               pc               gsp              emp          #>  Min.   :  538.5   Min.   :  4053   Min.   :  4354   Min.   :  108.3   #>  1st Qu.: 2488.3   1st Qu.: 21651   1st Qu.: 16502   1st Qu.:  475.0   #>  Median : 7008.8   Median : 40671   Median : 39987   Median : 1164.8   #>  Mean   :11199.5   Mean   : 58188   Mean   : 61014   Mean   : 1747.1   #>  3rd Qu.:11598.5   3rd Qu.: 64796   3rd Qu.: 68126   3rd Qu.: 2114.1   #>  Max.   :80728.1   Max.   :375342   Max.   :464550   Max.   :11258.0   #>                                                                        #>      unemp        #>  Min.   : 2.800   #>  1st Qu.: 5.000   #>  Median : 6.200   #>  Mean   : 6.602   #>  3rd Qu.: 7.900   #>  Max.   :18.000   #>                   #> dimension(s): #>       from to offset delta              values #> state    1 48     NA    NA ALABAMA,...,WYOMING #> year     1 17   1970     1                NULL if (require(dplyr, quietly = TRUE)) {   # https://stackoverflow.com/questions/77368957/ spatial_dim <- st_sf(   ID = 1:3,   geometry = list(     st_polygon(list(       cbind(c(0, 1, 1, 0, 0), c(0, 0, 1, 1, 0))     )),     st_polygon(list(       cbind(c(1, 2, 2, 1, 1), c(0, 0, 1, 1, 0))     )),     st_polygon(list(       cbind(c(2, 3, 3, 2, 2), c(0, 0, 1, 1, 0))     ))   ) ) weekdays_dim <- data.frame(weekdays = c(\"Monday\", \"Tuesday\", \"Wednesday\",      \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\")) hours_dim <- data.frame(hours = c(\"8am\", \"11am\", \"4pm\", \"11pm\")) sf_dta <- spatial_dim |>   cross_join(weekdays_dim)|>   cross_join(hours_dim) |>   mutate(population = rnorm(n(), mean = 1000, sd = 200)) |>   select(everything(), geometry)  st_as_stars(sf_dta, dims = c(\"weekdays\", \"hours\", \"geometry\")) } #> stars object with 3 dimensions and 2 attributes #> attribute(s): #>                 Min.  1st Qu.   Median     Mean  3rd Qu.     Max. #> ID            1.0000   1.0000    2.000    2.000    3.000    3.000 #> population  594.2642 909.3489 1016.819 1010.279 1112.744 1324.842 #> dimension(s): #>          from to point #> weekdays    1  7    NA #> hours       1  4    NA #> geometry    1  3 FALSE #>                                                                 values #> weekdays                                             Monday,...,Sunday #> hours                                                     8am,...,11pm #> geometry POLYGON ((0 0, 1 0, 1 1, ...,...,POLYGON ((2 0, 3 0, 3 1, ... demo(nc, echo=FALSE,ask=FALSE) st_as_stars(nc) #> stars object with 1 dimensions and 14 attributes #> attribute(s): #>      AREA           PERIMETER         CNTY_         CNTY_ID     #>  Min.   :0.0420   Min.   :0.999   Min.   :1825   Min.   :1825   #>  1st Qu.:0.0910   1st Qu.:1.324   1st Qu.:1902   1st Qu.:1902   #>  Median :0.1205   Median :1.609   Median :1982   Median :1982   #>  Mean   :0.1263   Mean   :1.673   Mean   :1986   Mean   :1986   #>  3rd Qu.:0.1542   3rd Qu.:1.859   3rd Qu.:2067   3rd Qu.:2067   #>  Max.   :0.2410   Max.   :3.640   Max.   :2241   Max.   :2241   #>     NAME               FIPS               FIPSNO         CRESS_ID       #>  Length:100         Length:100         Min.   :37001   Min.   :  1.00   #>  Class :character   Class :character   1st Qu.:37050   1st Qu.: 25.75   #>  Mode  :character   Mode  :character   Median :37100   Median : 50.50   #>                                        Mean   :37100   Mean   : 50.50   #>                                        3rd Qu.:37150   3rd Qu.: 75.25   #>                                        Max.   :37199   Max.   :100.00   #>      BIR74           SID74          NWBIR74           BIR79       #>  Min.   :  248   Min.   : 0.00   Min.   :   1.0   Min.   :  319   #>  1st Qu.: 1077   1st Qu.: 2.00   1st Qu.: 190.0   1st Qu.: 1336   #>  Median : 2180   Median : 4.00   Median : 697.5   Median : 2636   #>  Mean   : 3300   Mean   : 6.67   Mean   :1050.8   Mean   : 4224   #>  3rd Qu.: 3936   3rd Qu.: 8.25   3rd Qu.:1168.5   3rd Qu.: 4889   #>  Max.   :21588   Max.   :44.00   Max.   :8027.0   Max.   :30757   #>      SID79          NWBIR79        #>  Min.   : 0.00   Min.   :    3.0   #>  1st Qu.: 2.00   1st Qu.:  250.5   #>  Median : 5.00   Median :  874.5   #>  Mean   : 8.36   Mean   : 1352.8   #>  3rd Qu.:10.25   3rd Qu.: 1406.8   #>  Max.   :57.00   Max.   :11631.0   #> dimension(s): #>      from  to refsys point #> geom    1 100  NAD27 FALSE #>                                                             values #> geom MULTIPOLYGON (((-81.47276...,...,MULTIPOLYGON (((-78.65572... st_as_stars(st_drop_geometry(nc), dims = \"NAME\") #> stars object with 1 dimensions and 13 attributes #> attribute(s): #>      AREA           PERIMETER         CNTY_         CNTY_ID     #>  Min.   :0.0420   Min.   :0.999   Min.   :1825   Min.   :1825   #>  1st Qu.:0.0910   1st Qu.:1.324   1st Qu.:1902   1st Qu.:1902   #>  Median :0.1205   Median :1.609   Median :1982   Median :1982   #>  Mean   :0.1263   Mean   :1.673   Mean   :1986   Mean   :1986   #>  3rd Qu.:0.1542   3rd Qu.:1.859   3rd Qu.:2067   3rd Qu.:2067   #>  Max.   :0.2410   Max.   :3.640   Max.   :2241   Max.   :2241   #>     FIPS               FIPSNO         CRESS_ID           BIR74       #>  Length:100         Min.   :37001   Min.   :  1.00   Min.   :  248   #>  Class :character   1st Qu.:37050   1st Qu.: 25.75   1st Qu.: 1077   #>  Mode  :character   Median :37100   Median : 50.50   Median : 2180   #>                     Mean   :37100   Mean   : 50.50   Mean   : 3300   #>                     3rd Qu.:37150   3rd Qu.: 75.25   3rd Qu.: 3936   #>                     Max.   :37199   Max.   :100.00   Max.   :21588   #>      SID74          NWBIR74           BIR79           SID79       #>  Min.   : 0.00   Min.   :   1.0   Min.   :  319   Min.   : 0.00   #>  1st Qu.: 2.00   1st Qu.: 190.0   1st Qu.: 1336   1st Qu.: 2.00   #>  Median : 4.00   Median : 697.5   Median : 2636   Median : 5.00   #>  Mean   : 6.67   Mean   :1050.8   Mean   : 4224   Mean   : 8.36   #>  3rd Qu.: 8.25   3rd Qu.:1168.5   3rd Qu.: 4889   3rd Qu.:10.25   #>  Max.   :44.00   Max.   :8027.0   Max.   :30757   Max.   :57.00   #>     NWBIR79        #>  Min.   :    3.0   #>  1st Qu.:  250.5   #>  Median :  874.5   #>  Mean   : 1352.8   #>  3rd Qu.: 1406.8   #>  Max.   :11631.0   #> dimension(s): #>      from  to             values #> NAME    1 100 Ashe,...,Brunswick data.frame(expand.grid(x=1:5, y = 1:5), z = rnorm(25)) |> st_as_stars() #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>         Min.  1st Qu.    Median       Mean   3rd Qu.     Max. #> z  -2.194688 -1.01616 -0.258447 -0.3639007 0.3655264 1.613714 #> dimension(s): #>   from to offset delta x/y #> x    1  5    0.5     1 [x] #> y    1  5    5.5    -1 [y] nc = st_read(system.file(\"gpkg/nc.gpkg\", package=\"sf\")) #> Reading layer `nc.gpkg' from data source  #>   `/home/runner/work/_temp/Library/sf/gpkg/nc.gpkg' using driver `GPKG' #> Simple feature collection with 100 features and 14 fields #> Geometry type: MULTIPOLYGON #> Dimension:     XY #> Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965 #> Geodetic CRS:  NAD27 st_as_stars(nc) #> stars object with 1 dimensions and 14 attributes #> attribute(s): #>      AREA           PERIMETER         CNTY_         CNTY_ID     #>  Min.   :0.0420   Min.   :0.999   Min.   :1825   Min.   :1825   #>  1st Qu.:0.0910   1st Qu.:1.324   1st Qu.:1902   1st Qu.:1902   #>  Median :0.1205   Median :1.609   Median :1982   Median :1982   #>  Mean   :0.1263   Mean   :1.673   Mean   :1986   Mean   :1986   #>  3rd Qu.:0.1542   3rd Qu.:1.859   3rd Qu.:2067   3rd Qu.:2067   #>  Max.   :0.2410   Max.   :3.640   Max.   :2241   Max.   :2241   #>     NAME               FIPS               FIPSNO         CRESS_ID       #>  Length:100         Length:100         Min.   :37001   Min.   :  1.00   #>  Class :character   Class :character   1st Qu.:37050   1st Qu.: 25.75   #>  Mode  :character   Mode  :character   Median :37100   Median : 50.50   #>                                        Mean   :37100   Mean   : 50.50   #>                                        3rd Qu.:37150   3rd Qu.: 75.25   #>                                        Max.   :37199   Max.   :100.00   #>      BIR74           SID74          NWBIR74           BIR79       #>  Min.   :  248   Min.   : 0.00   Min.   :   1.0   Min.   :  319   #>  1st Qu.: 1077   1st Qu.: 2.00   1st Qu.: 190.0   1st Qu.: 1336   #>  Median : 2180   Median : 4.00   Median : 697.5   Median : 2636   #>  Mean   : 3300   Mean   : 6.67   Mean   :1050.8   Mean   : 4224   #>  3rd Qu.: 3936   3rd Qu.: 8.25   3rd Qu.:1168.5   3rd Qu.: 4889   #>  Max.   :21588   Max.   :44.00   Max.   :8027.0   Max.   :30757   #>      SID79          NWBIR79        #>  Min.   : 0.00   Min.   :    3.0   #>  1st Qu.: 2.00   1st Qu.:  250.5   #>  Median : 5.00   Median :  874.5   #>  Mean   : 8.36   Mean   : 1352.8   #>  3rd Qu.:10.25   3rd Qu.: 1406.8   #>  Max.   :57.00   Max.   :11631.0   #> dimension(s): #>      from  to refsys point #> geom    1 100  NAD27 FALSE #>                                                             values #> geom MULTIPOLYGON (((-81.47276...,...,MULTIPOLYGON (((-78.65572..."},{"path":"/reference/st_cells.html","id":null,"dir":"Reference","previous_headings":"","what":"return the cell index corresponding to the location of a set of points — st_cells","title":"return the cell index corresponding to the location of a set of points — st_cells","text":"return cell index corresponding location set points","code":""},{"path":"/reference/st_cells.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"return the cell index corresponding to the location of a set of points — st_cells","text":"","code":"st_cells(x, sf)"},{"path":"/reference/st_cells.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"return the cell index corresponding to the location of a set of points — st_cells","text":"x object class stars sf object class sf sfc","code":""},{"path":"/reference/st_cells.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"return the cell index corresponding to the location of a set of points — st_cells","text":"","code":"set.seed(1345) st_bbox(L7_ETMs) |>    st_as_sfc() |>    st_sample(10) -> pts  (x <- st_cells(L7_ETMs, pts)) #>  [1] 102496 112324  74862  56976 112862 105242  75593  11784  91245  63885 # get the pixel values (first band only): st_as_stars(L7_ETMs)[[1]][x] #>  [1]  92  92  89  76  67  94  77  98 113  56 # get pixel values for all bands: st_as_stars(L7_ETMs) |> split() |> sapply(`[`, x) #>        X1 X2  X3 X4  X5  X6 #>  [1,]  92 81  60 14  14  11 #>  [2,]  92 83  59 13  13  12 #>  [3,]  89 83  88 66 113  92 #>  [4,]  76 63  66 61 108  78 #>  [5,]  67 55  50 65  69  38 #>  [6,]  94 81  92 60 125 105 #>  [7,]  77 63  65 58 114  93 #>  [8,]  98 85  88 57  93  80 #>  [9,] 113 98 104 66 110  94 #> [10,]  56 40  27 68  50  24 # compare with st_extract(): st_as_stars(L7_ETMs) |> split() |> st_extract(pts) #> Simple feature collection with 10 features and 6 fields #> Geometry type: POINT #> Dimension:     XY #> Bounding box:  xmin: 289267.4 ymin: 9111549 xmax: 297166.8 ymax: 9119794 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #>     X1 X2  X3 X4  X5  X6                 geometry #> 1   92 81  60 14  14  11 POINT (295582.2 9112406) #> 2   92 83  59 13  13  12 POINT (297166.8 9111599) #> 3   89 83  88 66 113  92 POINT (293775.8 9114659) #> 4   76 63  66 61 108  78 POINT (291294.7 9116093) #> 5   67 55  50 65  69  38 POINT (292609.8 9111549) #> 6   94 81  92 60 125 105 POINT (294276.2 9112159) #> 7   77 63  65 58 114  93   POINT (294731 9114598) #> 8   98 85  88 57  93  80 POINT (296360.6 9119794) #> 9  113 98 104 66 110  94 POINT (293206.5 9113313) #> 10  56 40  27 68  50  24 POINT (289267.4 9115521)"},{"path":"/reference/st_contour.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute or plot contour lines or sets — st_contour","title":"Compute or plot contour lines or sets — st_contour","text":"Compute contour lines sets","code":""},{"path":"/reference/st_contour.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute or plot contour lines or sets — st_contour","text":"","code":"st_contour(   x,   na.rm = TRUE,   contour_lines = FALSE,   breaks = classInt::classIntervals(na.omit(as.vector(x[[1]])))$brks )"},{"path":"/reference/st_contour.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compute or plot contour lines or sets — st_contour","text":"x object class stars na.rm logical; missing valued cells removed, also converted features? contour_lines logical; FALSE, polygons returned (contour sets), otherwise contour lines breaks numerical; values \"draw\" contour levels","code":""},{"path":"/reference/st_contour.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Compute or plot contour lines or sets — st_contour","text":"function requires GDAL >= 2.4.0","code":""},{"path":[]},{"path":"/reference/st_coordinates.html","id":null,"dir":"Reference","previous_headings":"","what":"retrieve coordinates for raster or vector cube cells — st_coordinates","title":"retrieve coordinates for raster or vector cube cells — st_coordinates","text":"retrieve coordinates raster vector cube cells","code":""},{"path":"/reference/st_coordinates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"retrieve coordinates for raster or vector cube cells — st_coordinates","text":"","code":"# S3 method for stars st_coordinates(x, ..., add_max = FALSE, center = TRUE)  # S3 method for stars as.data.frame(x, ..., add_max = FALSE, center = NA, add_coordinates = TRUE)  as_tibble.stars(.x, ..., add_max = FALSE, center = NA)"},{"path":"/reference/st_coordinates.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"retrieve coordinates for raster or vector cube cells — st_coordinates","text":"x object class stars ... ignored add_max logical; TRUE, dimensions given min (x) max (x_max) value center logical; (add_max FALSE): grid cell center coordinates returned (TRUE) offset values (FALSE)? center can named logical vector list specify values dimension. add_coordinates logical; `TRUE`, columns dimension values preceed array values,  otherwise omitted .x object converted tibble","code":""},{"path":"/reference/st_crop.html","id":null,"dir":"Reference","previous_headings":"","what":"crop a stars object — st_crop","title":"crop a stars object — st_crop","text":"crop stars object","code":""},{"path":"/reference/st_crop.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"crop a stars object — st_crop","text":"","code":"# S3 method for stars_proxy st_crop(   x,   y,   ...,   crop = TRUE,   epsilon = sqrt(.Machine$double.eps),   collect = TRUE )  # S3 method for stars st_crop(   x,   y,   ...,   crop = TRUE,   epsilon = sqrt(.Machine$double.eps),   as_points = all(st_dimension(y) == 2, na.rm = TRUE) )"},{"path":"/reference/st_crop.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"crop a stars object — st_crop","text":"x object class stars y object class sf, sfc bbox; see Details . ... ignored crop logical; TRUE, spatial extent returned object cropped still cover obj, FALSE, extent remains cells outside y given NA values. epsilon numeric; factor shrink bounding box y towards center cropping. collect logical; TRUE, repeat cropping stars object, .e. data read as_points logical; relevant y class sf sfc: FALSE, treat x set points, else set small polygons. Default: TRUE y two-dimensional, else FALSE; see Details","code":""},{"path":"/reference/st_crop.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"crop a stars object — st_crop","text":"raster x, st_crop selects cells intersect y.  intersection, raster cells interpreted points small polygons?  y class stars, x raster cells interpreted points; y class bbox, x cells interpreted cells (small polygons). Otherwise, as_points given, cells interpreted points y two-dimensional geometry.","code":""},{"path":"/reference/st_crop.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"crop a stars object — st_crop","text":"","code":"l7 = read_stars(system.file(\"tif/L7_ETMs.tif\", package = \"stars\")) d = st_dimensions(l7)  # area around cells 3:10 (x) and 4:11 (y): offset = c(d[[\"x\"]]$offset, d[[\"y\"]]$offset) res = c(d[[\"x\"]]$delta, d[[\"y\"]]$delta) bb = st_bbox(c(xmin = offset[1] + 2 * res[1],   ymin = offset[2] + 11 * res[2],   xmax = offset[1] + 10 * res[1],   ymax = offset[2] +  3 * res[2]), crs = st_crs(l7)) l7[bb] #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43   55.5 56.36979      65  111 #> dimension(s): #>      from to  offset delta                     refsys point x/y #> x       3 10  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       4 11 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6      NA    NA                         NA    NA     # equivalent: st_crop(l7, bb) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43   55.5 56.36979      65  111 #> dimension(s): #>      from to  offset delta                     refsys point x/y #> x       3 10  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       4 11 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6      NA    NA                         NA    NA      plot(l7[,1:13,1:13,1], reset = FALSE) image(l7[bb,,,1], add = TRUE, col = sf.colors()) plot(st_as_sfc(bb), add = TRUE, border = 'green', lwd = 2)   # slightly smaller bbox: bb = st_bbox(c(xmin = offset[1] + 2.1 * res[1],   ymin = offset[2] + 10.9 * res[2],   xmax = offset[1] +  9.9 * res[1],   ymax = offset[2] +  3.1 * res[2]), crs = st_crs(l7)) l7[bb] #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43   55.5 56.36979      65  111 #> dimension(s): #>      from to  offset delta                     refsys point x/y #> x       3 10  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       4 11 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6      NA    NA                         NA    NA      plot(l7[,1:13,1:13,1], reset = FALSE) image(l7[bb,,,1], add = TRUE, col = sf.colors()) plot(st_as_sfc(bb), add = TRUE, border = 'green', lwd = 2)   # slightly larger bbox: bb = st_bbox(c(xmin = offset[1] + 1.9 * res[1],   ymin = offset[2] + 11.1 * res[2],   xmax = offset[1] + 10.1 * res[1],   ymax = offset[2] +  2.9 * res[2]), crs = st_crs(l7)) l7[bb] #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43     55 56.11167      66  112 #> dimension(s): #>      from to  offset delta                     refsys point x/y #> x       2 11  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       3 12 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6      NA    NA                         NA    NA      plot(l7[,1:13,1:13,1], reset = FALSE) image(l7[bb,,,1], add = TRUE, col = sf.colors()) plot(st_as_sfc(bb), add = TRUE, border = 'green', lwd = 2)   # half a cell size larger bbox: bb = st_bbox(c(xmin = offset[1] + 1.49 * res[1],   ymin = offset[2] + 11.51 * res[2],   xmax = offset[1] + 10.51 * res[1],   ymax = offset[2] +  2.49 * res[2]), crs = st_crs(l7)) l7[bb] #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43     55 56.11167      66  112 #> dimension(s): #>      from to  offset delta                     refsys point x/y #> x       2 11  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       3 12 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6      NA    NA                         NA    NA      plot(l7[,1:13,1:13,1], reset = FALSE) image(l7[bb,,,1], add = TRUE, col = sf.colors()) plot(st_as_sfc(bb), add = TRUE, border = 'green', lwd = 2)"},{"path":"/reference/st_dim_to_attr.html","id":null,"dir":"Reference","previous_headings":"","what":"create an array with dimension values — st_dim_to_attr","title":"create an array with dimension values — st_dim_to_attr","text":"create array dimension values","code":""},{"path":"/reference/st_dim_to_attr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"create an array with dimension values — st_dim_to_attr","text":"","code":"st_dim_to_attr(x, which = seq_along(dim(x)))"},{"path":"/reference/st_dim_to_attr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"create an array with dimension values — st_dim_to_attr","text":"x object class stars integer; indices dimensions address (default: )","code":""},{"path":"/reference/st_dim_to_attr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"create an array with dimension values — st_dim_to_attr","text":"stars object dimension values attributes","code":""},{"path":"/reference/st_dim_to_attr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"create an array with dimension values — st_dim_to_attr","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x1 = read_stars(tif) (x = st_dim_to_attr(x1)) #> stars object with 3 dimensions and 3 attributes #> attribute(s): #>            Min. 1st Qu.    Median      Mean 3rd Qu.      Max. #> x      288790.5  291270  293749.5  293749.5  296229  298708.5 #> y     9110743.0 9113244 9115744.8 9115744.8 9118246 9120746.5 #> band        1.0       2       3.5       3.5       5       6.0 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     plot(x)  (x = st_dim_to_attr(x1, 2:3)) #> stars object with 3 dimensions and 2 attributes #> attribute(s): #>          Min. 1st Qu.    Median      Mean 3rd Qu.    Max. #> y     9110743 9113244 9115744.8 9115744.8 9118246 9120747 #> band        1       2       3.5       3.5       5       6 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     plot(x)  (x= st_dim_to_attr(x1, 3)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>       Min. 1st Qu. Median Mean 3rd Qu. Max. #> band     1       2    3.5  3.5       5    6 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     plot(x)"},{"path":"/reference/st_dimensions.html","id":null,"dir":"Reference","previous_headings":"","what":"get dimensions from stars object — st_dimensions","title":"get dimensions from stars object — st_dimensions","text":"get dimensions stars object","code":""},{"path":"/reference/st_dimensions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"get dimensions from stars object — st_dimensions","text":"","code":"st_dimensions(.x, ...)  # S3 method for stars st_dimensions(.x, ...)  st_dimensions(x) <- value  # S3 method for stars st_dimensions(x) <- value  # S3 method for stars_proxy st_dimensions(x) <- value  # S3 method for list st_dimensions(x) <- value  # S3 method for array st_dimensions(.x, ...)  # S3 method for default st_dimensions(   .x,   ...,   .raster,   affine = c(0, 0),   cell_midpoints = FALSE,   point = FALSE )  st_set_dimensions(   .x,   which,   values = NULL,   point = NULL,   names = NULL,   xy,   ... )  st_get_dimension_values(.x, which, ..., where = NA, max = FALSE, center = NA)"},{"path":"/reference/st_dimensions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"get dimensions from stars object — st_dimensions","text":".x object retrieve dimensions information ... arguments x object class dimensions value new object class dimensions, matching dimensions .raster length 2 character array names () raster dimensions affine numeric; specify parameters affine transformation cell_midpoints logical; TRUE dimension values strictly regular, values interpreted cell midpoint values rather cell offset values calculating offset (.e., half-cell-size correction applied); can value dimension, else recycled point logical; pixel value (measure) refer point (location) value pixel (area) summary value? integer character; index name dimension changed values values dimension (e.g. sfc list-column), length-1 dimensions object; setting special value NULL removes dimension values, instance remove curvilinear raster coordinates names character; vector new names dimensions, single new name dimension indicated xy length-2 character vector; (new) names x y raster dimensions character, one 'start', 'center' 'end'. Set NA (default) ignore use max center explictly.  argument provides convenient alternative setting max center. max logical; TRUE return end, rather beginning interval center logical; TRUE return center interval; NA return center raster dimensions, start intervals cases","code":""},{"path":"/reference/st_dimensions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"get dimensions from stars object — st_dimensions","text":"dimensions attribute x, class dimensions","code":""},{"path":"/reference/st_dimensions.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"get dimensions from stars object — st_dimensions","text":"dimensions can specified two ways. simplest pass vector numeric values numeric dimension, character values categorical dimension. Parameter cell_midpoints used specify whether numeric values refer offset (start) dimension interval (default), center; center case available regular dimensions. rectilinear numeric dimensions, one can specify either vector cell borders (start values), data.frame two columns named \"start\" \"end\", respective interval start end values. first case, end values computed start values assuming last two intervals equal width.","code":""},{"path":"/reference/st_dimensions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"get dimensions from stars object — st_dimensions","text":"","code":"x = read_stars(system.file(\"tif/L7_ETMs.tif\", package = \"stars\")) # Landsat 7 ETM+ band semantics: https://landsat.gsfc.nasa.gov/the-enhanced-thematic-mapper-plus/ # set bands to values 1,2,3,4,5,7: (x1 = st_set_dimensions(x, \"band\", values = c(1,2,3,4,5,7), names = \"band_number\", point = TRUE)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     1      54     69 68.91242      86  255 #> dimension(s): #>             from  to  offset delta                     refsys point  values x/y #> x              1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE    NULL [x] #> y              1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE    NULL [y] #> band_number    1   6      NA    NA                         NA  TRUE 1,...,7     # set band values as bandwidth rbind(c(0.45,0.515), c(0.525,0.605), c(0.63,0.69), c(0.775,0.90), c(1.55,1.75), c(2.08,2.35)) %>%   units::set_units(\"um\") -> bw # or: units::set_units(µm) -> bw # set bandwidth midpoint: (x2 = st_set_dimensions(x, \"band\", values = 0.5 * (bw[,1]+bw[,2]),     names = \"bandwidth_midpoint\", point = TRUE)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     1      54     69 68.91242      86  255 #> dimension(s): #>                    from  to  offset delta                     refsys point #> x                     1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE #> y                     1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE #> bandwidth_midpoint    1   6      NA    NA                    udunits  TRUE #>                                        values x/y #> x                                        NULL [x] #> y                                        NULL [y] #> bandwidth_midpoint 0.4825 [um],...,2.215 [um]     # set bandwidth intervals: (x3 = st_set_dimensions(x, \"band\", values = make_intervals(bw), names = \"bandwidth\")) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     1      54     69 68.91242      86  255 #> dimension(s): #>           from  to  offset delta                     refsys point #> x            1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE #> y            1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE #> bandwidth    1   6      NA    NA                    udunits    NA #>                                           values x/y #> x                                           NULL [x] #> y                                           NULL [y] #> bandwidth [0.45,0.515) [um],...,[2.08,2.35) [um]     m = matrix(1:20, nrow = 5, ncol = 4) dim(m) = c(x = 5, y = 4) # named dim (s = st_as_stars(m)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1     1    5.75   10.5 10.5   15.25   20 #> dimension(s): #>   from to offset delta point x/y #> x    1  5      0     1 FALSE [x] #> y    1  4      0     1 FALSE [y] st_get_dimension_values(s, 'x', where = \"start\") #> [1] 0 1 2 3 4 st_get_dimension_values(s, 'x', center = FALSE) #> [1] 0 1 2 3 4 st_get_dimension_values(s, 'x', where = \"center\") #> [1] 0.5 1.5 2.5 3.5 4.5 st_get_dimension_values(s, 'x', center = TRUE) #> [1] 0.5 1.5 2.5 3.5 4.5 st_get_dimension_values(s, 'x', where = \"end\") #> [1] 1 2 3 4 5 st_get_dimension_values(s, 'x', max = TRUE) #> [1] 1 2 3 4 5"},{"path":"/reference/st_downsample.html","id":null,"dir":"Reference","previous_headings":"","what":"downsample stars or stars_proxy objects — st_downsample","title":"downsample stars or stars_proxy objects — st_downsample","text":"downsample stars stars_proxy object either skipping rows, columns bands, computing single value (e.g. mean) sub-tiles involved","code":""},{"path":"/reference/st_downsample.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"downsample stars or stars_proxy objects — st_downsample","text":"","code":"st_downsample(x, n, ...)  # S3 method for stars st_downsample(x, n, ..., offset = 0, FUN)  # S3 method for stars_proxy st_downsample(x, n, ...)"},{"path":"/reference/st_downsample.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"downsample stars or stars_proxy objects — st_downsample","text":"x object class stars stars_proxy n integer; dimension number pixels/lines/bands etc skipped; see Details. ... arguments passed FUN (e.g., na.rm = TRUE ignore missing values FUN mean) offset integer; offset(s) downsampling, pixels, starting offset  dimension; smaller equal n FUN function; given, downsampling apply FUN subtiles","code":""},{"path":"/reference/st_downsample.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"downsample stars or stars_proxy objects — st_downsample","text":"n == 0, downsampling takes place; 1, every second row/column/band skipped, 2, every second+third row/column/band skipped, etc. Downsampling stars_proxy object returns stars object, equivalent calling st_as_stars(x, downsample = 2), downsamples first two (x y) dimensions. Downsampled regular rasters keep dimension offsets, cell size (delta) n[]+1 times larger, may result (slightly) different extent. Note terra's aggregate fact=2 corresponds st_downsample(x, n = 1, FUN = mean): fact one larger n.","code":""},{"path":"/reference/st_downsample.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"downsample stars or stars_proxy objects — st_downsample","text":"","code":"(m = matrix(1:121, 11, 11)) #>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] #>  [1,]    1   12   23   34   45   56   67   78   89   100   111 #>  [2,]    2   13   24   35   46   57   68   79   90   101   112 #>  [3,]    3   14   25   36   47   58   69   80   91   102   113 #>  [4,]    4   15   26   37   48   59   70   81   92   103   114 #>  [5,]    5   16   27   38   49   60   71   82   93   104   115 #>  [6,]    6   17   28   39   50   61   72   83   94   105   116 #>  [7,]    7   18   29   40   51   62   73   84   95   106   117 #>  [8,]    8   19   30   41   52   63   74   85   96   107   118 #>  [9,]    9   20   31   42   53   64   75   86   97   108   119 #> [10,]   10   21   32   43   54   65   76   87   98   109   120 #> [11,]   11   22   33   44   55   66   77   88   99   110   121 (s = st_as_stars(m)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1     1      31     61   61      91  121 #> dimension(s): #>    from to offset delta point x/y #> X1    1 11      0     1 FALSE [x] #> X2    1 11      0     1 FALSE [y] st_downsample(s, 1) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1     1    28.5     61   61    93.5  121 #> dimension(s): #>    from to offset delta point x/y #> X1    1  6      0     2 FALSE [x] #> X2    1  6      0     2 FALSE [y] st_downsample(s, 1)[[1]] #>      [,1] [,2] [,3] [,4] [,5] [,6] #> [1,]    1   23   45   67   89  111 #> [2,]    3   25   47   69   91  113 #> [3,]    5   27   49   71   93  115 #> [4,]    7   29   51   73   95  117 #> [5,]    9   31   53   75   97  119 #> [6,]   11   33   55   77   99  121 st_downsample(s, 1, offset = 1) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1    13      37     61   61      85  109 #> dimension(s): #>    from to offset delta point x/y #> X1    1  5      1     2 FALSE [x] #> X2    1  5      1     2 FALSE [y] st_downsample(s, 1, offset = 1)[[1]] #>      [,1] [,2] [,3] [,4] [,5] #> [1,]   13   35   57   79  101 #> [2,]   15   37   59   81  103 #> [3,]   17   39   61   83  105 #> [4,]   19   41   63   85  107 #> [5,]   21   43   65   87  109 st_downsample(s, 1, offset = c(0,1)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1    12    36.5     61   61    85.5  110 #> dimension(s): #>    from to offset delta point x/y #> X1    1  6      0     2 FALSE [x] #> X2    1  5      1     2 FALSE [y] st_downsample(s, 1, offset = c(0,1))[[1]] #>      [,1] [,2] [,3] [,4] [,5] #> [1,]   12   34   56   78  100 #> [2,]   14   36   58   80  102 #> [3,]   16   38   60   82  104 #> [4,]   18   40   62   84  106 #> [5,]   20   42   64   86  108 #> [6,]   22   44   66   88  110 st_downsample(s, 1, FUN = mean) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1     7      31     55   55      79  103 #> dimension(s): #>    from to offset delta point x/y #> X1    1  5      0     2 FALSE [x] #> X2    1  5      0     2 FALSE [y] st_downsample(s, 1, FUN = mean)[[1]] #>      [,1] [,2] [,3] [,4] [,5] #> [1,]    7   29   51   73   95 #> [2,]    9   31   53   75   97 #> [3,]   11   33   55   77   99 #> [4,]   13   35   57   79  101 #> [5,]   15   37   59   81  103 st_downsample(s, 1, offset = 1, FUN = mean) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1    19      43     67   67      91  115 #> dimension(s): #>    from to offset delta point x/y #> X1    1  5      1     2 FALSE [x] #> X2    1  5      1     2 FALSE [y] st_downsample(s, 1, offset = c(0,1), FUN = mean)[[1]] #>      [,1] [,2] [,3] [,4] [,5] #> [1,]   18   40   62   84  106 #> [2,]   20   42   64   86  108 #> [3,]   22   44   66   88  110 #> [4,]   24   46   68   90  112 #> [5,]   26   48   70   92  114"},{"path":"/reference/st_extract.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract cell values at point locations — st_extract","title":"Extract cell values at point locations — st_extract","text":"Extract cell values point locations","code":""},{"path":"/reference/st_extract.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract cell values at point locations — st_extract","text":"","code":"st_extract(x, ...)  # S3 method for stars st_extract(   x,   at,   ...,   bilinear = FALSE,   time_column = attr(at, \"time_column\") %||% attr(at, \"time_col\"),   interpolate_time = bilinear,   FUN = mean )"},{"path":"/reference/st_extract.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract cell values at point locations — st_extract","text":"x object class stars stars_proxy ... passed aggregate.stars geometries exclusively POINT geometries object class sf sfc geometries, two-column matrix coordinate points rows, indicating extract values x bilinear logical; use bilinear interpolation rather nearest neighbour? time_column character integer; name index column time date values matched values first temporal dimension (matching classes POSIXct, POSIXt, Date, PCICt), x, dimension reduced. useful extract data cube values along trajectory; see https://github.com/r-spatial/stars/issues/352 . interpolate_time logical; time interpolated? FALSE, time instances matched using coinciding last preceding time data cube. FUN function used aggregate pixel values geometries intersect one pixel","code":""},{"path":"/reference/st_extract.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract cell values at point locations — st_extract","text":"class matrix, matrix extracted values returned;  otherwise: x dimensions x y (raster),  object class stars POINT geometries replacing x y raster dimensions, case, object sf extracted values.","code":""},{"path":"/reference/st_extract.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract cell values at point locations — st_extract","text":"points outside raster returned NA values. large sets points extraction needed, passing matrix may much faster passing sf sfc object.","code":""},{"path":"/reference/st_extract.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract cell values at point locations — st_extract","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") r = read_stars(tif) pnt = st_sample(st_as_sfc(st_bbox(r)), 10) st_extract(r, pnt) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    12   60.75     74 72.51667      87  150 #> dimension(s): #>          from to                     refsys point #> geometry    1 10 SIRGAS 2000 / UTM zone 25S  TRUE #> band        1  6                         NA    NA #>                                                         values #> geometry POINT (298340.2 9114943),...,POINT (289531.4 9111471) #> band                                                      NULL st_extract(r, pnt) %>% st_as_sf() #> Simple feature collection with 10 features and 6 fields #> Geometry type: POINT #> Dimension:     XY #> Bounding box:  xmin: 288950.3 ymin: 9111189 xmax: 298340.2 ymax: 9119338 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #>    L7_ETMs.tif.V1 L7_ETMs.tif.V2 L7_ETMs.tif.V3 L7_ETMs.tif.V4 L7_ETMs.tif.V5 #> 1              97             88             67             14             13 #> 2              82             66             74             49            107 #> 3              66             54             46             73             79 #> 4              80             68             69             77            117 #> 5              87             85            104             87            120 #> 6              90             83             65             13             13 #> 7              63             46             38             65             83 #> 8             110            101            114             74            150 #> 9              80             68             74             54            110 #> 10             80             65             65             44             84 #>    L7_ETMs.tif.V6                 geometry #> 1              12 POINT (298340.2 9114943) #> 2              82 POINT (293918.4 9114415) #> 3              42 POINT (293485.2 9118749) #> 4              86 POINT (294440.9 9114839) #> 5              79   POINT (295209 9118813) #> 6              12 POINT (295048.9 9111189) #> 7              50 POINT (289649.4 9116888) #> 8             128 POINT (295730.3 9119338) #> 9              88 POINT (288950.3 9111816) #> 10             71 POINT (289531.4 9111471) st_extract(r[,,,1], pnt) #> Simple feature collection with 10 features and 1 field #> Geometry type: POINT #> Dimension:     XY #> Bounding box:  xmin: 288950.3 ymin: 9111189 xmax: 298340.2 ymax: 9119338 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #>    L7_ETMs.tif                 geometry #> 1           97 POINT (298340.2 9114943) #> 2           82 POINT (293918.4 9114415) #> 3           66 POINT (293485.2 9118749) #> 4           80 POINT (294440.9 9114839) #> 5           87   POINT (295209 9118813) #> 6           90 POINT (295048.9 9111189) #> 7           63 POINT (289649.4 9116888) #> 8          110 POINT (295730.3 9119338) #> 9           80 POINT (288950.3 9111816) #> 10          80 POINT (289531.4 9111471) st_extract(r, st_coordinates(pnt)) # \"at\" is a matrix: return a matrix #>       [,1] [,2] [,3] [,4] [,5] [,6] #>  [1,]   97   88   67   14   13   12 #>  [2,]   82   66   74   49  107   82 #>  [3,]   66   54   46   73   79   42 #>  [4,]   80   68   69   77  117   86 #>  [5,]   87   85  104   87  120   79 #>  [6,]   90   83   65   13   13   12 #>  [7,]   63   46   38   65   83   50 #>  [8,]  110  101  114   74  150  128 #>  [9,]   80   68   74   54  110   88 #> [10,]   80   65   65   44   84   71"},{"path":"/reference/st_geotransform.html","id":null,"dir":"Reference","previous_headings":"","what":"get or set the geotransform, or rotation matrix — st_geotransform","title":"get or set the geotransform, or rotation matrix — st_geotransform","text":"get set geotransform, rotation matrix","code":""},{"path":"/reference/st_geotransform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"get or set the geotransform, or rotation matrix — st_geotransform","text":"","code":"st_geotransform(x, ...)  st_geotransform(x) <- value  # S3 method for stars st_geotransform(x) <- value"},{"path":"/reference/st_geotransform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"get or set the geotransform, or rotation matrix — st_geotransform","text":"x object class stars dimensions ... ignored value length 6 numeric vector, 2 x 2 (scaled) rotation matrix","code":""},{"path":"/reference/st_geotransform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"get or set the geotransform, or rotation matrix — st_geotransform","text":"","code":"# using the \"classical\" rotation matrix, see https://en.wikipedia.org/wiki/Rotation_matrix : rot = function(theta, dxdy = c(1., -1.)) {    th = theta / 180 * pi    matrix(c(cos(th), sin(th), -sin(th), cos(th)), 2, 2) %*%         matrix(c(dxdy[2], 0, 0, dxdy[1]), 2, 2) } l = st_downsample(st_as_stars(L7_ETMs), 9) # save time in plotting st_geotransform(l) = rot(20, c(28.5, 28.5)) # clockwise, 20 degrees, scale by cell size plot(l[,,,1])   m = rot(20, c(1, 2)) g = expand.grid(x = 0:4, y = 0:4) plot(g[1:2], asp = 1) text(g[,1], g[,2], labels = seq_along(g[,1]), pos = 4) g = t(m %*% t(as.matrix(g))) points(g, col = 'red') text(g[,1], g[,2], labels = seq_along(g[,1]), pos = 4, col = 'red')   m = matrix(1:20, 4) s0 = st_as_stars(m) s = s0 # dy > 0, clockwise rotation: st_geotransform(s) = rot(10, c(1,1)) plot(s0, reset = FALSE) plot(s, add = TRUE)  # dy < 0, counter clockwise rotation, + expansion in x-direction: layout(1) s0 = st_as_stars(st_bbox(s0), dx = 1) s0$values = 1:20 s0 #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>         Min. 1st Qu. Median Mean 3rd Qu. Max. #> values     1    5.75   10.5 10.5   15.25   20 #> dimension(s): #>   from to offset delta x/y #> x    1  4      0     1 [x] #> y    1  5      5    -1 [y] plot(s0, reset = FALSE) s = s0 st_geotransform(s) = rot(10, c(2,1)) plot(s, add = TRUE)"},{"path":"/reference/st_intersects.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"spatial intersect predicate for stars and sfc object — st_intersects.stars","title":"spatial intersect predicate for stars and sfc object — st_intersects.stars","text":"spatial intersect predicate stars sfc object","code":""},{"path":"/reference/st_intersects.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"spatial intersect predicate for stars and sfc object — st_intersects.stars","text":"","code":"# S3 method for stars st_intersects(x, y, sparse = TRUE, ..., as_points = NA, transpose = FALSE)"},{"path":"/reference/st_intersects.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"spatial intersect predicate for stars and sfc object — st_intersects.stars","text":"x object class stars y object `st_geometry` method: class `sf` `sfc`, `stars` object `sfc` dimension sparse logical; TRUE, return sparse logical matrix (object class `sgbp`), FALSE, return logical matrix ... ignored, passed `st_intersects.sf` curvilinear grids as_points logical, grid cells considered points (TRUE) polygons (FALSE)? Default: FALSE warning emitted transpose logical; transpose `sgbp` object returned?","code":""},{"path":"/reference/st_intersects.stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"spatial intersect predicate for stars and sfc object — st_intersects.stars","text":"`sgbp` object sparse = TRUE, logical matrix otherwise","code":""},{"path":"/reference/st_intersects.stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"spatial intersect predicate for stars and sfc object — st_intersects.stars","text":"curvilinear grids always converted polygons, points grid boundaries may intersect two cells touched; grids cell boundary corner belongs one cell.","code":""},{"path":"/reference/st_join.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"Spatially join a stars and an `sf` object — st_join.stars","title":"Spatially join a stars and an `sf` object — st_join.stars","text":"Spatially join stars `sf` object","code":""},{"path":"/reference/st_join.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Spatially join a stars and an `sf` object — st_join.stars","text":"","code":"# S3 method for stars st_join(   x,   y,   join = st_intersects,   ...,   what = \"left1\",   as_points = NA,   warn = TRUE )"},{"path":"/reference/st_join.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Spatially join a stars and an `sf` object — st_join.stars","text":"x object class stars y object class sf, one can coerced st_as_sf join join function, return sgbp object; see details ... arguments passed join function \"left1\", \"right\" \"inner\"; see details as_points logical; controls whether grid cells x treated points, cell areas; st_intersects.stars method default derive x's metadata, else assume areas. warn logical; TRUE, warn 1--many matches \"left1\"","code":""},{"path":"/reference/st_join.stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Spatially join a stars and an `sf` object — st_join.stars","text":"\"left1\", object class stars (first) value y spatial instances x","code":""},{"path":"/reference/st_join.stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Spatially join a stars and an `sf` object — st_join.stars","text":"one match single x value, first matching record y taken (warn TRUE warning raised). \"inner\", object class sf matching records x y.","code":""},{"path":"/reference/st_mosaic.html","id":null,"dir":"Reference","previous_headings":"","what":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":"build mosaic (composite) several spatially disjoint stars objects","code":""},{"path":"/reference/st_mosaic.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":"","code":"st_mosaic(.x, ...)  # S3 method for stars st_mosaic(   .x,   ...,   dst = tempfile(fileext = file_ext),   options = c(\"-vrtnodata\", \"-9999\", \"-srcnodata\", \"nan\"),   file_ext = \".tif\" )  # S3 method for character st_mosaic(   .x,   ...,   dst = tempfile(fileext = file_ext),   options = c(\"-vrtnodata\", \"-9999\"),   file_ext = \".tif\" )  # S3 method for stars_proxy st_mosaic(   .x,   ...,   dst = tempfile(fileext = file_ext),   options = c(\"-vrtnodata\", \"-9999\"),   file_ext = \".tif\" )"},{"path":"/reference/st_mosaic.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":".x object class stars, character vector input dataset names ... input stars objects dst character; destination file name; VRT file references source file(s), see details options character; options gdalbuildvrt command file_ext character; file extension, determining format used write (\".tif\" implies GeoTIFF)","code":""},{"path":"/reference/st_mosaic.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":"stars method returns stars object composite input; character method returns file name file mosaic; see also GDAL documentation gdalbuildvrt","code":""},{"path":"/reference/st_mosaic.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":"gdal function buildvrt builds mosaic input images; input images can multi-band, higher-dimensional data cubes stars objects multiple attributes; note `stars` method, `dst` file may contain references temporary files going removed termination R session. uses gdal_utils internally call buildvrt; executables external R called.","code":""},{"path":"/reference/st_mosaic.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":"","code":"x = read_stars(system.file(\"tif/L7_ETMs.tif\", package = \"stars\")) x1 = x[,100:200,100:200,] x2 = x[,150:300,150:300,] plot(st_mosaic(x1, x2))"},{"path":"/reference/st_raster_type.html","id":null,"dir":"Reference","previous_headings":"","what":"get the raster type (if any) of a stars object — st_raster_type","title":"get the raster type (if any) of a stars object — st_raster_type","text":"get raster type () stars object","code":""},{"path":"/reference/st_raster_type.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"get the raster type (if any) of a stars object — st_raster_type","text":"","code":"st_raster_type(x, dimension = character(0))"},{"path":"/reference/st_raster_type.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"get the raster type (if any) of a stars object — st_raster_type","text":"x object class stars dimension optional: numbers names dimension(s) get per-dimension type","code":""},{"path":"/reference/st_raster_type.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"get the raster type (if any) of a stars object — st_raster_type","text":"dimension specified, return spatial raster type:  one NA (object raster dimensions),  \"curvilinear\", \"rectilinear\", \"affine\", \"regular\". case dimension(s) specified, return one \"regular\", \"rectilinear\" (irregular numeric), \"discrete\" (anything else).","code":""},{"path":"/reference/st_raster_type.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"get the raster type (if any) of a stars object — st_raster_type","text":"categories \"curvilinear\" \"affine\" refer relationship pair spatial (raster) dimensions.","code":""},{"path":"/reference/st_raster_type.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"get the raster type (if any) of a stars object — st_raster_type","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) st_raster_type(x) #> [1] \"regular\" st_raster_type(x, 1:3) #>          x          y       band  #>  \"regular\"  \"regular\" \"discrete\""},{"path":"/reference/st_rasterize.html","id":null,"dir":"Reference","previous_headings":"","what":"rasterize simple feature geometries — st_rasterize","title":"rasterize simple feature geometries — st_rasterize","text":"rasterize simple feature geometries","code":""},{"path":"/reference/st_rasterize.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"rasterize simple feature geometries — st_rasterize","text":"","code":"st_rasterize(   sf,   template = guess_raster(sf, ...) %||% st_as_stars(st_bbox(sf), values = NA_real_,     ...),   file = tempfile(),   driver = \"GTiff\",   options = character(0),   align = FALSE,   proxy = FALSE,   ... )"},{"path":"/reference/st_rasterize.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"rasterize simple feature geometries — st_rasterize","text":"sf object class sf template optional; stars object desired target geometry, target geometry alignment align=TRUE; see details file temporary file name driver driver temporary file options character; options vector GDALRasterize align logical; TRUE, template used geometry _alignment_,  informing target resolution offset proxy logical; proxy object returned? ... arguments passed st_as_stars","code":""},{"path":"/reference/st_rasterize.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"rasterize simple feature geometries — st_rasterize","text":"`template` `stars` object, non-NA cells covered `sf` receive value `template`; see also argument `align`.","code":""},{"path":"/reference/st_rasterize.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"rasterize simple feature geometries — st_rasterize","text":"","code":"demo(nc, echo = FALSE, ask = FALSE) (x = st_rasterize(nc)) # default grid: #> stars object with 2 dimensions and 12 attributes #> attribute(s): #>                 Min.   1st Qu.    Median         Mean   3rd Qu.      Max.  NA's #> AREA           0.042     0.108     0.142 1.451932e-01     0.181     0.241 30904 #> PERIMETER      0.999     1.461     1.716 1.786110e+00     2.004     3.640 30904 #> CNTY_       1825.000  1907.000  1989.000 1.998403e+03  2085.000  2241.000 30904 #> CNTY_ID     1825.000  1907.000  1989.000 1.998403e+03  2085.000  2241.000 30904 #> FIPSNO     37001.000 37049.000 37101.000 3.710042e+04 37153.000 37199.000 30904 #> CRESS_ID       1.000    25.000    51.000 5.071206e+01    77.000   100.000 30904 #> BIR74        248.000  1323.000  2648.000 3.791637e+03  4139.000 21588.000 30904 #> SID74          0.000     3.000     5.000 7.891985e+00    10.000    44.000 30904 #> NWBIR74        1.000   297.000   844.000 1.246210e+03  1396.000  8027.000 30904 #> BIR79        319.000  1606.000  3108.000 4.852046e+03  5400.000 30757.000 30904 #> SID79          0.000     3.000     6.000 9.584098e+00    13.000    57.000 30904 #> NWBIR79        3.000   360.000  1058.000 1.604642e+03  1524.000 11631.000 30904 #> dimension(s): #>   from  to offset    delta refsys point x/y #> x    1 461 -84.32  0.01925  NAD27 FALSE [x] #> y    1 141  36.59 -0.01925  NAD27 FALSE [y] plot(x, axes = TRUE)  # a bit more customized grid: (x = st_rasterize(nc, st_as_stars(st_bbox(nc), nx = 100, ny = 50, values = NA_real_))) #> stars object with 2 dimensions and 12 attributes #> attribute(s): #>                 Min.   1st Qu.    Median         Mean   3rd Qu.      Max. NA's #> AREA           0.042     0.108     0.142     0.145536     0.181     0.241 2373 #> PERIMETER      0.999     1.470     1.716     1.789032     2.004     3.640 2373 #> CNTY_       1825.000  1908.000  1989.000  1999.761325  2088.000  2241.000 2373 #> CNTY_ID     1825.000  1908.000  1989.000  1999.761325  2088.000  2241.000 2373 #> FIPSNO     37001.000 37049.000 37101.000 37100.327750 37151.000 37199.000 2373 #> CRESS_ID       1.000    25.000    51.000    50.663875    76.000   100.000 2373 #> BIR74        248.000  1323.500  2648.000  3790.530263  4139.000 21588.000 2373 #> SID74          0.000     3.000     5.000     7.905976    10.000    44.000 2373 #> NWBIR74        1.000   289.000   844.000  1246.116483  1396.000  8027.000 2373 #> BIR79        319.000  1606.000  3108.000  4848.231062  5386.000 30757.000 2373 #> SID79          0.000     3.000     6.000     9.574419    13.000    57.000 2373 #> NWBIR79        3.000   360.000  1058.000  1602.740769  1524.000 11631.000 2373 #> dimension(s): #>   from  to offset    delta refsys point x/y #> x    1 100 -84.32  0.08867  NAD27 FALSE [x] #> y    1  50  36.59 -0.05415  NAD27 FALSE [y] plot(x, axes = TRUE)  (ls = st_sf(a = 1:2, st_sfc(st_linestring(rbind(c(0.1, 0), c(1.1, 1))),    st_linestring(rbind(c(0, 0.05), c(1, 0.05)))))) #> Simple feature collection with 2 features and 1 field #> Geometry type: LINESTRING #> Dimension:     XY #> Bounding box:  xmin: 0 ymin: 0 xmax: 1.1 ymax: 1 #> CRS:           NA #>   a #> 1 1 #> 2 2 #>   c..st_sfc.st_linestring.rbind.c.0.1..0...c.1.1..1.....st_linestring.rbind.c.0..........0.05...c.1..0.05...... #> 1                                                                                     LINESTRING (0.1 0, 1.1 1) #> 2                                                                                   LINESTRING (0 0.05, 1 0.05) (grd = st_as_stars(st_bbox(ls), nx = 10, ny = 10, xlim = c(0, 1.0), ylim = c(0, 1),    values = NA_real_)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>         Min. 1st Qu. Median Mean 3rd Qu. Max. NA's #> values    NA      NA     NA  NaN      NA   NA  100 #> dimension(s): #>   from to offset delta x/y #> x    1 10      0   0.1 [x] #> y    1 10      1  -0.1 [y] # Only the left-top corner is part of the grid cell: sf_extSoftVersion()[\"GDAL\"] #>    GDAL  #> \"3.4.1\"  plot(st_rasterize(ls, grd), axes = TRUE, reset = FALSE) # ALL_TOUCHED=FALSE;  plot(ls, add = TRUE, col = \"red\")  plot(st_rasterize(ls, grd, options = \"ALL_TOUCHED=TRUE\"), axes = TRUE, reset = FALSE) plot(ls, add = TRUE, col = \"red\")  # add lines to existing 0 values, summing values in case of multiple lines: (grd = st_as_stars(st_bbox(ls), nx = 10, ny = 10, xlim = c(0, 1.0), ylim = c(0, 1), values = 0)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>         Min. 1st Qu. Median Mean 3rd Qu. Max. #> values     0       0      0    0       0    0 #> dimension(s): #>   from to offset delta x/y #> x    1 10      0   0.1 [x] #> y    1 10      1  -0.1 [y] r = st_rasterize(ls, grd, options = c(\"MERGE_ALG=ADD\", \"ALL_TOUCHED=TRUE\")) plot(r, axes = TRUE, reset = FALSE) plot(ls, add = TRUE, col = \"red\")"},{"path":"/reference/st_res.html","id":null,"dir":"Reference","previous_headings":"","what":"obtain (spatial) resolution of a stars object — st_res","title":"obtain (spatial) resolution of a stars object — st_res","text":"obtain resolution(s) stars object: default (absolute) x/y raster dimensions, optionally delta dimension parameters","code":""},{"path":"/reference/st_res.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"obtain (spatial) resolution of a stars object — st_res","text":"","code":"st_res(x, all = FALSE, absolute = !all)"},{"path":"/reference/st_res.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"obtain (spatial) resolution of a stars object — st_res","text":"x object class stars logical; FALSE return vector x/y raster resolution absolute logical; works = FALSE; TRUE return absolute resolution values, FALSE return delta values","code":""},{"path":"/reference/st_res.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"obtain (spatial) resolution of a stars object — st_res","text":"= FALSE vector x/y raster resolutions, otherwise list delta values","code":""},{"path":"/reference/st_res.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"obtain (spatial) resolution of a stars object — st_res","text":"","code":"st_res(L7_ETMs) #>    x    y  #> 28.5 28.5  st_res(L7_ETMs, absolute = FALSE) #>     x     y  #>  28.5 -28.5  st_res(L7_ETMs, all = TRUE) #> $x #> [1] 28.5 #>  #> $y #> [1] -28.5 #>  #> $band #> [1] NA #>  if (require(starsdata)) {   paste0(\"netcdf/\", c(\"avhrr-only-v2.19810901.nc\",      \"avhrr-only-v2.19810902.nc\",     \"avhrr-only-v2.19810903.nc\",     \"avhrr-only-v2.19810904.nc\")) |>   system.file(package = \"starsdata\") |>   read_stars(quiet = TRUE) -> x   st_res(x) |> print()   st_res(x, all = TRUE) |> print() } #> Loading required package: starsdata #>    x    y  #> 0.25 0.25  #> $x #> [1] 0.25 #>  #> $y #> [1] -0.25 #>  #> $zlev #> [1] NA #>  #> $time #> Time difference of 1 days #>"},{"path":"/reference/st_rgb.html","id":null,"dir":"Reference","previous_headings":"","what":"reduce dimension to rgb (alpha) hex values — st_rgb","title":"reduce dimension to rgb (alpha) hex values — st_rgb","text":"reduce dimension rgb (alpha) hex values","code":""},{"path":"/reference/st_rgb.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"reduce dimension to rgb (alpha) hex values — st_rgb","text":"","code":"st_rgb(   x,   dimension = 3,   use_alpha = dim(x)[dimension] == 4,   maxColorValue = 255L,   probs = c(0, 1),   stretch = NULL )"},{"path":"/reference/st_rgb.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"reduce dimension to rgb (alpha) hex values — st_rgb","text":"x object class stars dimension dimension name number reduce use_alpha logical; TRUE, fourth band used alpha values maxColorValue integer; maximum value colors probs probability values quantiles used stretching \"percent\". stretch logical character; TRUE \"percent\", band stretched 0 ... maxColorValue \"percent clip\" method using probs values. \"histogram\", \"histogram equalization\" performed (probs values ignored). stretch NULL FALSE, stretching performed. character values interpreted \"percent\" message printed.","code":""},{"path":"/reference/st_rgb.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"reduce dimension to rgb (alpha) hex values — st_rgb","text":"dimension's bands mapped red, green, blue, alpha; different ordering wanted, use [.stars reorder dimension, see examples. Alternatively, can use plot.stars rgb argument create three-band composition.","code":""},{"path":[]},{"path":"/reference/st_rgb.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"reduce dimension to rgb (alpha) hex values — st_rgb","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) st_rgb(x[,,,3:1]) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>  L7_ETMs.tif        #>  Length:122848      #>  Class :character   #>  Mode  :character   #> dimension(s): #>   from  to  offset delta                     refsys point x/y #> x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] r = st_rgb(x[,,,c(6,5,4,3)], 3, use_alpha=TRUE) # now R=6,G=5,B=4,alpha=3 if (require(ggplot2)) {  ggplot() + geom_stars(data = r) + scale_fill_identity() }  r = st_rgb(x[,,,3:1],        probs = c(0.01, 0.99),        stretch = \"percent\") plot(r) #> Error in image.stars(x, ..., axes = axes, breaks = breaks, col = col,     key.pos = key.pos, key.width = key.width, key.length = key.length,     main = NULL): rgb plotting not supported on this device r = st_rgb(x[,,,3:1],        probs = c(0.01, 0.99),        stretch = \"histogram\") plot(r) #> Error in image.stars(x, ..., axes = axes, breaks = breaks, col = col,     key.pos = key.pos, key.width = key.width, key.length = key.length,     main = NULL): rgb plotting not supported on this device"},{"path":"/reference/st_rotate.html","id":null,"dir":"Reference","previous_headings":"","what":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","title":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","text":"Transform rotated long/lat regular grid unrotated curvilinear grid","code":""},{"path":"/reference/st_rotate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","text":"","code":"# S3 method for stars st_rotate(.x, lon0, lat0, north = TRUE, ...)  # S3 method for sfc st_rotate(.x, lon0, lat0, north = TRUE, ...)  # S3 method for sf st_rotate(.x, lon0, lat0, north = TRUE, ...)"},{"path":"/reference/st_rotate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","text":".x object class stars lon0 longitude rotated pole degrees lat0 latitude rotated pole degrees north logical; TRUE pole refers North pole, otherwise South pole ... ignored","code":""},{"path":"/reference/st_rotate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","text":"curvilinear stars object coordinates regular long/lat (North pole lat=90)","code":""},{"path":"/reference/st_rotate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","text":"","code":"if (require(\"starsdata\") && require(\"maps\")) {   # data downloaded from https://esgf-data.dkrz.de/search/cosmo-rea/   nc = \"netcdf/ts_EUR-6km_ECMWF-ERAINT_REA6_r1i1p1f1_COSMO_v1_mon_201801-201812.nc\"   f = system.file(nc, package = \"starsdata\")   m = read_mdim(f, \"ts\")   print(m)   # NOTE this function is obsolete when reading m as   # m = read_mdim(f, \"ts\", curvilinear = c(\"longitude\", \"latitude\"))   if (require(RNetCDF)) {      x = open.nc(f)      lon = att.get.nc(x, \"rotated_latitude_longitude\", \"grid_north_pole_longitude\")      lat = att.get.nc(x, \"rotated_latitude_longitude\", \"grid_north_pole_latitude\")      close.nc(x)      print(c(lon = lon, lat = lat))   } else {      lon = -162      lat = 39.25   }    m1 = st_rotate(m, lon, lat)   print(m1)   h = function() maps::map(add = TRUE)   plot(m1, downsample = c(10, 10, 5), axes = TRUE, hook = h, mfrow = c(1, 2))      # curvilinear grid: downsample for plotting speed   m2 = st_warp(m1, crs = st_crs(\"OGC:CRS84\"), threshold = .1)   plot(m2, hook = h, mfrow = c(3, 4)) # regular grid: plots fast } #> Loading required package: maps #> stars object with 3 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>            Min.  1st Qu.   Median     Mean 3rd Qu.     Max. #> ts [K] 277.3233 284.7061 286.1046 286.5914 288.003 296.9786 #> dimension(s): #>      from  to offset delta refsys                    values x/y #> rlon    1 848 -28.43 0.055     NA                      NULL [x] #> rlat    1 824 -23.43 0.055     NA                      NULL [y] #> time    1  12     NA    NA   Date 2018-01-16,...,2018-12-16     #> Loading required package: RNetCDF #>     lon     lat  #> -162.00   39.25  #> stars object with 3 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>            Min.  1st Qu.   Median     Mean 3rd Qu.     Max. #> ts [K] 277.3233 284.7061 286.1046 286.5914 288.003 296.9786 #> dimension(s): #>      from  to refsys                     values x/y #> rlon    1 848 WGS 84 [848x824] -44.67,...,65.06 [x] #> rlat    1 824 WGS 84  [848x824] 21.95,...,72.61 [y] #> time    1  12   Date  2018-01-16,...,2018-12-16     #> curvilinear grid #> Warning: using Euclidean distance measures on geodetic coordinates #> downsample set to 5"},{"path":"/reference/st_set_bbox.html","id":null,"dir":"Reference","previous_headings":"","what":"set bounding box parameters of regular grid — st_set_bbox","title":"set bounding box parameters of regular grid — st_set_bbox","text":"set bounding box parameters regular grid","code":""},{"path":"/reference/st_set_bbox.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"set bounding box parameters of regular grid — st_set_bbox","text":"","code":"st_set_bbox(x, value, ...)"},{"path":"/reference/st_set_bbox.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"set bounding box parameters of regular grid — st_set_bbox","text":"x object class dimensions, stars stars_proxy value object class bbox ... ignored","code":""},{"path":"/reference/st_sfc2xy.html","id":null,"dir":"Reference","previous_headings":"","what":"replace POINT simple feature geometry list with an x y raster — st_sfc2xy","title":"replace POINT simple feature geometry list with an x y raster — st_sfc2xy","text":"replace POINT simple feature geometry list x y raster","code":""},{"path":"/reference/st_sfc2xy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"replace POINT simple feature geometry list with an x y raster — st_sfc2xy","text":"","code":"st_sfc2xy(x, ...)"},{"path":"/reference/st_sfc2xy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"replace POINT simple feature geometry list with an x y raster — st_sfc2xy","text":"x object class stars, class sf ... passed .data.frame.stars","code":""},{"path":"/reference/st_sfc2xy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"replace POINT simple feature geometry list with an x y raster — st_sfc2xy","text":"object class stars POINT list replaced x y raster dimensions. works points distributed regular rectilinear grid.","code":""},{"path":"/reference/st_tile.html","id":null,"dir":"Reference","previous_headings":"","what":"Specify parameters to load raster in blocks — st_tile","title":"Specify parameters to load raster in blocks — st_tile","text":"Helper function specifying block parameters (nXOff, nYOff, nXsize, nYSize) required RasterIO argument read_stars","code":""},{"path":"/reference/st_tile.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Specify parameters to load raster in blocks — st_tile","text":"","code":"st_tile(img_rows, img_cols, x_window, y_window, overlap = 0)"},{"path":"/reference/st_tile.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Specify parameters to load raster in blocks — st_tile","text":"img_rows number input raster rows (integer) img_cols number input raster columns (integer) x_window number rows block (integer) y_window number columns block (integer) overlap number overlapping pixels (integer)","code":""},{"path":"/reference/st_tile.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Specify parameters to load raster in blocks — st_tile","text":"matrix specified nXOff, nYOff, nXsize, nYSize parameters every block","code":""},{"path":"/reference/st_tile.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Specify parameters to load raster in blocks — st_tile","text":"","code":"if (FALSE) { tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") r = read_stars(tif, proxy = TRUE) tiles = st_tile(nrow(r), ncol(r), 256, 256) for (i in seq_len(nrow(tiles))) {   tile = read_stars(tif, proxy = FALSE, RasterIO = tiles[i, ])   # write tiles to separate files   write_stars(tile, dsn = paste0(i, \".tif\")) } }"},{"path":"/reference/st_transform.html","id":null,"dir":"Reference","previous_headings":"","what":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","title":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","text":"transform geometries stars objects new coordinate reference system, without warping","code":""},{"path":"/reference/st_transform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","text":"","code":"# S3 method for stars st_transform(x, crs, ...)  st_transform_proj.stars(x, crs, ...)"},{"path":"/reference/st_transform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","text":"x object class stars, either raster simple feature geometries crs object class crs target crs ... ignored","code":""},{"path":"/reference/st_transform.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","text":"simple feature dimensions, st_transform called, leading lossless transformation. gridded spatial data, curvilinear grid transformed grid cell (centers) returned, also lossless. convert regular grid new CRS, use st_warp (general lossy).","code":""},{"path":[]},{"path":"/reference/st_transform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","text":"","code":"geomatrix = system.file(\"tif/geomatrix.tif\", package = \"stars\") (x = read_stars(geomatrix)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>                Min. 1st Qu. Median    Mean 3rd Qu. Max. #> geomatrix.tif    74     107    123 126.765     132  255 #> dimension(s): #>   from to  offset delta                refsys point x/y #> x    1 20 1841002   1.5 WGS 84 / UTM zone 11N  TRUE [x] #> y    1 20 1144003  -1.5 WGS 84 / UTM zone 11N  TRUE [y] #> sheared raster with parameters: -5 -5  new = st_crs('OGC:CRS84') y = st_transform(x, new) plot(st_transform(st_as_sfc(st_bbox(x)), new), col = NA, border = 'red') plot(st_as_sfc(y, as_points=FALSE), col = NA, border = 'green', axes = TRUE, add = TRUE) image(y, col = heat.colors(12), add = TRUE) plot(st_as_sfc(y, as_points=TRUE), pch=3, cex=.5, col = 'blue', add = TRUE) plot(st_transform(st_as_sfc(x, as_points=FALSE), new), add = TRUE)"},{"path":"/reference/st_warp.html","id":null,"dir":"Reference","previous_headings":"","what":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","title":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","text":"Warp (resample) grids stars objects new grid, possibly new coordinate reference system","code":""},{"path":"/reference/st_warp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","text":"","code":"st_warp(   src,   dest,   ...,   crs = NA_crs_,   cellsize = NA_real_,   segments = 100,   use_gdal = FALSE,   options = character(0),   no_data_value = NA_real_,   debug = FALSE,   method = \"near\",   threshold = NA_real_ )"},{"path":"/reference/st_warp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","text":"src object class stars source raster dest object class stars target raster geometry ... ignored crs coordinate reference system destination grid, used dest missing cellsize length 1 2 numeric; cellsize target coordinate reference system units segments (total) number segments segmentizing bounding box transforming new crs use_gdal logical; TRUE, use gdal's warp warper, gdal_utils options character vector options, passed gdalwarp no_data_value value used gdalwarp no_data (NA) writing temporary file;  setting use_gdal TRUE leads warning debug logical; TRUE, remove temporary gdalwarp destination file, print name method character; see details options; methods near work use_gdal=TRUE threshold numeric; distance threshold warping curvilinear grids: new cells distances larger threshold assigned NA values.","code":""},{"path":"/reference/st_warp.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","text":"method one near, bilinear, cubic, cubicspline, lanczos, average, mode, max, min, med, q1 q3; see https://github.com/r-spatial/stars/issues/109 gridded spatial data (dimensions x y), see figure; existing grid transformed regular grid defined dest, possibly new coordinate reference system. dest specified, crs , procedure used choose target grid similar projectRaster. entails: () envelope (bounding box polygon) transformed new crs, possibly segmentation (red box); (ii) grid formed new crs, touching transformed envelope East North side, (cellsize given) cellsize similar cell size src, extent least covers x; (iii) cell center new grid, matching grid cell x used; match, NA value used.","code":""},{"path":"/reference/st_warp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","text":"","code":"geomatrix = system.file(\"tif/geomatrix.tif\", package = \"stars\") (x = read_stars(geomatrix)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>                Min. 1st Qu. Median    Mean 3rd Qu. Max. #> geomatrix.tif    74     107    123 126.765     132  255 #> dimension(s): #>   from to  offset delta                refsys point x/y #> x    1 20 1841002   1.5 WGS 84 / UTM zone 11N  TRUE [x] #> y    1 20 1144003  -1.5 WGS 84 / UTM zone 11N  TRUE [y] #> sheared raster with parameters: -5 -5  new_crs = st_crs('OGC:CRS84') y = st_warp(x, crs = new_crs) plot(st_transform(st_as_sfc(st_bbox(x)), new_crs), col = NA, border = 'red') plot(st_as_sfc(y, as_points=FALSE), col = NA, border = 'green', axes = TRUE, add = TRUE) image(y, add = TRUE, nbreaks = 6) plot(st_as_sfc(y, as_points=TRUE), pch=3, cex=.5, col = 'blue', add = TRUE) plot(st_transform(st_as_sfc(x, as_points=FALSE), new_crs), add = TRUE)  # warp 0-360 raster to -180-180 raster: r = read_stars(system.file(\"nc/reduced.nc\", package = \"stars\")) #> sst, anom, err, ice,  r %>% st_set_crs('OGC:CRS84') %>% st_warp(st_as_stars(st_bbox(), dx = 2)) -> s plot(r, axes = TRUE) # no CRS set, so no degree symbols in labels  plot(s, axes = TRUE)  # downsample raster (90 to 270 m) r = read_stars(system.file(\"tif/olinda_dem_utm25s.tif\", package = \"stars\")) r270 = st_as_stars(st_bbox(r), dx = 270) r270 = st_warp(r, r270)"},{"path":"/reference/st_xy2sfc.html","id":null,"dir":"Reference","previous_headings":"","what":"replace x y raster dimensions with simple feature geometry list (points, or polygons = rasterize) — st_xy2sfc","title":"replace x y raster dimensions with simple feature geometry list (points, or polygons = rasterize) — st_xy2sfc","text":"replace x y raster dimensions simple feature geometry list (points, polygons = rasterize)","code":""},{"path":"/reference/st_xy2sfc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"replace x y raster dimensions with simple feature geometry list (points, or polygons = rasterize) — st_xy2sfc","text":"","code":"st_xy2sfc(x, as_points, ..., na.rm = TRUE)"},{"path":"/reference/st_xy2sfc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"replace x y raster dimensions with simple feature geometry list (points, or polygons = rasterize) — st_xy2sfc","text":"x object class stars as_points logical; TRUE, generate points cell centers, else generate polygons ... arguments passed st_as_sfc na.rm logical; omit (remove) cells entirely missing valued (across dimensions)?","code":""},{"path":"/reference/st_xy2sfc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"replace x y raster dimensions with simple feature geometry list (points, or polygons = rasterize) — st_xy2sfc","text":"object class stars x y raster dimensions replaced single sfc geometry list column containing either points, polygons. Adjacent cells identical values merged; see st_rasterize .","code":""},{"path":"/reference/stars_sentinel2.html","id":null,"dir":"Reference","previous_headings":"","what":"Sentinel-2 sample tile — stars_sentinel2","title":"Sentinel-2 sample tile — stars_sentinel2","text":"Sentinel-2 sample tile, downloaded  reads four 10-m bands: B2 (490 nm), B3 (560 nm), B4 (665 nm) B8 (842 nm)","code":""},{"path":"/reference/stars_sentinel2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sentinel-2 sample tile — stars_sentinel2","text":"","code":"stars_sentinel2"},{"path":"/reference/stars_sentinel2.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Sentinel-2 sample tile — stars_sentinel2","text":"object class stars_proxy (inherits stars) dimension 10980 x 10980 x 4.","code":""},{"path":"/reference/stars_subset.html","id":null,"dir":"Reference","previous_headings":"","what":"subset stars objects — stars_subset","title":"subset stars objects — stars_subset","text":"subset stars objects","code":""},{"path":"/reference/stars_subset.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"subset stars objects — stars_subset","text":"","code":"# S3 method for stars_proxy [(x, i, downsample = 0) <- value  # S3 method for stars [(x, i = TRUE, ..., drop = FALSE, crop = !is_curvilinear(x))  # S3 method for stars [(x, i) <- value  st_flip(x, which = 1)"},{"path":"/reference/stars_subset.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"subset stars objects — stars_subset","text":"x object class stars first selector: integer, logical character vector indicating attributes select, object class sf, sfc, bbox, stars used spatial selector; see details downsample downsampling rate used case stars_proxy object value array dimensions equal x, vector value recycled array ... (logical integer vector) selectors, matched order, select individual dimensions drop logical; TRUE, degenerate dimensions (one value) dropped crop logical; TRUE parameter spatial geometry (sf sfc) object, extent (bounding box) result cropped match extent using st_crop. Cropping curvilinear grids supported. character integer; dimension(s) flipped","code":""},{"path":"/reference/stars_subset.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"subset stars objects — stars_subset","text":"st_flip flips (reverts) array values along chosen dimension  without(s) changing dimension properties","code":""},{"path":"/reference/stars_subset.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"subset stars objects — stars_subset","text":"object class sf, sfc bbox, spatial subset covering geometry selected, possibly followed cropping extent. Array values cell centre inside geometry assigned NA. class stars, attributes logical, cells x corresponding NA FALSE cells assigned NA. Dimension ranges containing negative values NA may partially supported. assignment (replacement form, [<-), argument needs either () stars object logical attribute(s) dimensions matching (possibly recycling) x, case TRUE cells replaced /value recycled dimensions arrays x, (ii) length-one integer character vector indicating array replace, case value may stars object vector array (recycled).","code":""},{"path":"/reference/stars_subset.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"subset stars objects — stars_subset","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) x[,,,1:3] # select bands #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    21      58     70 70.36041      83  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   3      NA    NA                         NA    NA     x[,1:100,100:200,] # select x and y by range #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    13      54     65 67.21531      77  252 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 100  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y     100 200 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x[\"L7_ETMs.tif\"] # select attribute #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     1      54     69 68.91242      86  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     xy = structure(list(x = c(293253.999046018, 296400.196497684), y = c(9113801.64775462, 9111328.49619133)), .Names = c(\"x\", \"y\")) pts = st_as_sf(data.frame(do.call(cbind, xy)), coords = c(\"x\", \"y\"), crs = st_crs(x)) image(x, axes = TRUE) plot(st_as_sfc(st_bbox(pts)), col = NA, add = TRUE)  bb = st_bbox(pts) (xx = x[bb]) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     3      56     73 70.87303      89  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x     158 268  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y     245 331 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     image(xx) plot(st_as_sfc(bb), add = TRUE, col = NA)  image(x) pt = st_point(c(x = 290462.103109179, y = 9114202.32594085)) buf = st_buffer(st_sfc(pt, crs = st_crs(x)), 1500) plot(buf, add = TRUE)   buf = st_sfc(st_polygon(list(st_buffer(pt, 1500)[[1]], st_buffer(pt, 1000)[[1]])),    crs = st_crs(x)) image(x[buf]) plot(buf, add = TRUE, col = NA)  image(x[buf, crop=FALSE]) plot(buf, add = TRUE, col = NA)  # with i of class stars: x[x > 75] # generates lots of NA's; pattern for each band #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max.   NA's #> L7_ETMs.tif    76      82     90 94.40052     101  255 443210 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x[x[,,,1] > 75] # recycles a single band template for all bands #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max.   NA's #> L7_ETMs.tif     1      63     79 74.98075      93  255 318960 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x = read_stars(tif) # replace, using a logical stars selector: cuts all values above 90 to 90 x[x > 90] = 90 # replace a single attribute when there are more than one: s = split(x) names(s) = paste0(\"band\", 1:6) # rescale only band 1: s[1] = s[1] * 0.75  # rescale only attribute named \"band2\": s[\"band2\"] = s[\"band2\"] * 0.85  # create a new attribute from a numeric vector: s[\"rnorm\"] = rnorm(prod(dim(s)))  s #> stars object with 2 dimensions and 7 attributes #> attribute(s): #>             Min.    1st Qu.       Median         Mean    3rd Qu.      Max. #> band1  35.250000 50.2500000 58.500000000 57.878219426 66.7500000 67.500000 #> band2  27.200000 46.7500000 56.100000000 56.776205555 67.1500000 76.500000 #> band3  21.000000 49.0000000 63.000000000 62.777008987 77.0000000 90.000000 #> band4   9.000000 52.0000000 63.000000000 58.940544413 75.0000000 90.000000 #> band5   1.000000 63.0000000 89.000000000 71.285092146 90.0000000 90.000000 #> band6   1.000000 32.0000000 60.000000000 56.662127182 88.0000000 90.000000 #> rnorm  -5.096659 -0.6759559 -0.004252816 -0.003659307  0.6699726  4.216072 #> dimension(s): #>   from  to  offset delta                     refsys point x/y #> x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] lc = read_stars(system.file(\"tif/lc.tif\", package = \"stars\")) x = c(orig = lc,        flip_x = st_flip(lc, \"x\"),        flip_y = st_flip(lc, \"y\"),        flip_xy = st_flip(lc, c(\"x\", \"y\")),        along = 3) plot(x)"},{"path":"/reference/write_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"write stars object to gdal dataset (typically: to file) — write_stars","title":"write stars object to gdal dataset (typically: to file) — write_stars","text":"write stars object gdal dataset (typically: file)","code":""},{"path":"/reference/write_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"write stars object to gdal dataset (typically: to file) — write_stars","text":"","code":"write_stars(obj, dsn, layer, ...)  # S3 method for stars write_stars(   obj,   dsn,   layer = 1,   ...,   driver = detect.driver(dsn),   options = character(0),   type = if (is.factor(obj[[1]]) && length(levels(obj[[1]])) < 256) \"Byte\" else \"Float32\",   NA_value = NA_real_,   update = FALSE,   normalize_path = TRUE,   scale_offset = c(1, 0) )  # S3 method for stars_proxy write_stars(   obj,   dsn,   layer = 1,   ...,   driver = detect.driver(dsn),   options = character(0),   scale_offset = c(1, 0),   type = \"Float32\",   NA_value = NA_real_,   chunk_size = c(dim(obj)[1], floor(2.5e+07/dim(obj)[1])),   progress = TRUE )  detect.driver(filename)"},{"path":"/reference/write_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"write stars object to gdal dataset (typically: to file) — write_stars","text":"obj object class stars dsn gdal dataset (file) name layer attribute name; missing, first attribute written ... passed gdal_write driver driver driver name; see st_drivers options character vector dataset creation options, passed GDAL type character; output binary type, one : Byte eight bit unsigned integer, UInt16 sixteen bit unsigned integer, Int16 sixteen bit signed integer, UInt32 thirty two bit unsigned integer, Int32 thirty two bit signed integer, Float32 thirty two bit floating point, Float64 sixty four bit floating point. NA_value non-NA value represent R's NA value target raster file; set NA, ignored. update logical; TRUE, existing file updated normalize_path logical; see read_stars scale_offset length 2 numeric vector scale, offset values: raw values computed raw = (value - offset) / scale written dsn; scale offset values written dsn else warning raised chunk_size length two integer vector number pixels (x, y) used read/write loop; see details. progress logical; TRUE, progress bar shown filename character; used guessing driver short name based file  extension; see examples","code":""},{"path":"/reference/write_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"write stars object to gdal dataset (typically: to file) — write_stars","text":"write_stars first creates target file, updates sequentially writing blocks chunk_size. case obj multi-file stars_proxy object, files written layers output file dsn","code":""},{"path":"/reference/write_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"write stars object to gdal dataset (typically: to file) — write_stars","text":"","code":"detect.driver(\"L7_ETMs.tif\") #> [1] \"GTiff\""},{"path":"/news/index.html","id":"version-06-6","dir":"Changelog","previous_headings":"","what":"version 0.6-6","title":"version 0.6-6","text":"constrain reading full GEOLOCATION arrays case 2-D; #678","code":""},{"path":"/news/index.html","id":"version-06-5","dir":"Changelog","previous_headings":"","what":"version 0.6-5","title":"version 0.6-5","text":"CRAN release: 2024-04-04 fix st_as_stars.Spatial() Spatial gridded objects non-square grid cells, see https://github.com/r-spatial/gstat/issues/123 add prcomp() methods stars stars_proxy objects, working attributes last dimension st_rasterize() align=TRUE returns NA values data; #668 read_mdim() reads tables composity type, returning data.frame case; #659 st_rotate() transforms rotated grid back curvilinear grid unrotated coordinates. aggregate.stars() deals functions return one number, putting new dimension like st_apply() st_as_stars.data.frame() st_as_stars.sf() better handle non-raster data cubes plot.stars() resets layout needed (one sub-plot, key present) fixed st_as_stars.im(); #648 st_crs<-.stars() less critical existing CRS class crs c.stars() single (valid) argument along specified adds dimension; #646 st_join.stars() keeps attributes x complete; #643 st_as_stars.list() requires named list, set names array dimensions present","code":""},{"path":"/news/index.html","id":"version-06-4","dir":"Changelog","previous_headings":"","what":"version 0.6-4","title":"version 0.6-4","text":"CRAN release: 2023-09-11 plot.stars() fill argument shifts unused plotting space sub-maps bottom right side plotting area plot.stars(), key.width default sensitive par(\"ps\"), pointsize graphics parameter plot.stars() image.stars() sensitive cex.axis, axes key (requires sf >= 1.0-14); #642 move lwgeom dependency Suggests; using st_transform_proj() vector data cubes requires loading lwgeom first","code":""},{"path":"/news/index.html","id":"version-06-3","dir":"Changelog","previous_headings":"","what":"version 0.6-3","title":"version 0.6-3","text":"CRAN release: 2023-08-11 st_downsample() argument offset pixel-shift downsampled images st_downsample() argument FUN compute sub-tile aggregates; #604 st_as_stars.bbox() retains factor values; #640 fix CRAN error test script st_crop() works (warns) case crop area overlap area object; #638","code":""},{"path":"/news/index.html","id":"version-06-2","dir":"Changelog","previous_headings":"","what":"version 0.6-2","title":"version 0.6-2","text":"CRAN release: 2023-07-12 split.stars() accepts stars objects multiple attributes; #635 [.stars() supports NA values dimension ranges vector geometry (sfc) dimensions, resulting empty geometries st_extract() supports extracting points values curvilinear grids (proxy); #632 read_mdim() reads curvilinear rasters (geolocation arrays), far full extent/resolution st_as_stars.stars() accepts curvilinear argument lon/lat array names present .x consistently use OGC:CRS84 instead EPSG:4326 setting values = NULL st_set_dimensions() removes dimension values gracefully handle plotting global coverage curvilinear grids; #632 image.stars() plots images (e.g. cross sections) x /y singular absent; #628 st_as_stars.cubble_df() adds conversion cubble; cubble::as_cubble() methods converts back [<-.stars() accepts indicator (numeric length character) array replaced; #626 plot.stars() gains argument key.lab set legend key label (requires sf >= 1.0-13)","code":""},{"path":"/news/index.html","id":"version-06-1","dir":"Changelog","previous_headings":"","what":"version 0.6-1","title":"version 0.6-1","text":"CRAN release: 2023-04-06 remove rgdal dependency read_stars() fixes combining bands different block sizes; #623 st_warp() gets (proper) default value threshold; #618 read_mdim() reads “raster” single pixel (point) [.stars(), r[x] allows x logical stars object [<-.stars_proxy() clones environment, r[r > 100] = NA don’t get infinite recursion realizing r read_stars() avoids reading raster twice determine choose proxy; proxy can now set (defaults ) number cells (bands * rows * columns) data read memory returned stars_proxy object; #609 fix using RasterIO read_stars() proxy=TRUE; #608 plot.stars() hook function can handle arguments row, col, nrow, ncol, nr, value bbox; #600 fix handling categorical rasters colors without category labels; #595, fallout #565 fix subsetting proxy objects time range; #596","code":""},{"path":"/news/index.html","id":"version-06-0","dir":"Changelog","previous_headings":"","what":"version 0.6-0","title":"version 0.6-0","text":"CRAN release: 2022-11-21 write_stars() writes scaled /shifted values using argument scale_offset; #589 aggregate.stars_proxy() implements aggregation non-spatial objects (lazily) fix [.stars_proxy() selecting dimension 3 higher; #561 plot.stars(), col can also palette function st_res() returns spatial resolutions, optionally dimension resolutions; #557 thanks Krzysztof Dyba read_stars() shortens band array names contain common start ending, unless names become empty shorten=FALSE set; e.g. shorten=\"B\" puts B shortened array names printing stars dimension tables omits fields NULL NA values, unless print(..., = TRUE) given improve reading categorical rasters, now avoids calling factor(); #565 thanks Krzysztof Dyba read_mdim() read bounds arrays coordinates using bounds attribute, accepts bounds argument specify attribute missing time() returns time stamps time dimension st_cells() returns cell index set point coordinates, provided sf sfc object; #558 reading & writing vector data cubes: read_mdim() reads CF compliant vector geometries, reconstructs sfc dimension; write_mdim() writes . write_mdim() uses GDAL multidimensional array API; read_mdim() uses arguments offset, count step read sub-arrays strided arrays (requires sf >= 1.0-9)","code":""},{"path":"/news/index.html","id":"version-05-6","dir":"Changelog","previous_headings":"","what":"version 0.5-6","title":"version 0.5-6","text":"CRAN release: 2022-07-21 export read_mdim(), reader using GDAL’s multidimensional array API (sf <= 1.0-8) remove tos_O1_2001-2002.nc packaged datasets keep source package size 5 Mb .POSIXct.stars() converts PCICt dimensions POSIXct values. improve handling PCICt 360 365 day calendars; read read_mdim (requires sf >= 1.0-9) read_stars() reads factor levels better attribute table; #484 thanks @ailich read_stars() puts band names band_meta DESCRIPTION= tags values; improve handling categorical rasters, exchange terra; #484 plot() handles auto colors better factor arrays read_ncdf() handles units formally setting crs; #533 print message dimensions proxy objects reflect unevaluated operations; #530 passing na.action = na.omit geom_stars() removes NA values; #532 read_stars() detects curvilinear grids automatically; #513 st_warp() warps curvilinear grids (using Euclidean distances coordinates); #513 Ops.stars() errors (common) dimension identical; #506 guess_raster() accepts empty rows/columns sparse grids; #509 speed rgb plotting; #503 Added new helper function st_tile() specify block parameters (nXOff, nYOff, nXsize, nYSize) required RasterIO argument read_stars(); #492 thanks Krzysztof Dyba","code":""},{"path":"/news/index.html","id":"version-05-5","dir":"Changelog","previous_headings":"","what":"version 0.5-5","title":"version 0.5-5","text":"CRAN release: 2021-12-19 st_as_stars.bbox() creates empy raster file proxy = TRUE; #489 st_rasterize() option align = TRUE use template aligning new raster ; #489 adrop.stars() missing dimensions longer drops x/y raster dimensions; #485 aggregate.stars() propagates units arrays; #477","code":""},{"path":"/news/index.html","id":"version-05-4","dir":"Changelog","previous_headings":"","what":"version 0.5-4","title":"version 0.5-4","text":"CRAN release: 2021-11-19 c.stars() fails tries merge arrays different units; #475 NetCDF files, read_stars() uses long_name array name; #475 add rename() method; #470 refresh CRS packaged L7_ETMs.tif; #466 .data.frame.stars() works mixed regular rectilinear dimension; #458 plot.stars() plots curvilinear rasters color table, without table col argument passed; #456 st_extract() accepts matrix points argument, performance important; see e.g. https://github.com/rspatial/terra/issues/341 fix bug st_crop() cropping area larger grid; #455 export st_downsample(), e.g. used tmap; https://github.com/r-tmap/tmap/issues/597 argument downsample plot.stars() st_as_stars.stars_proxy() st_downsample() effect (removed one-offset ). st_redimension() works curvilinear grids; #441 downsample propagated subexpressions like r[r < 50] = NA predict.stars() obtains argument drop_dimensions , TRUE, drops dimensions prediction data.frame; #362 extend options st_rgb(), #432, Gabo Gaona allow subsetting [ using labels, e.g. band names.","code":""},{"path":"/news/index.html","id":"version-05-3","dir":"Changelog","previous_headings":"","what":"version 0.5-3","title":"version 0.5-3","text":"CRAN release: 2021-06-08 read_stars() accepts function (list functions) first argument, allowing saving stars objects read package directories resolving platform-dependent paths run-time handle categorical rasters starting value 0 (adding 1, warning); #428 add %% method; #424 read_stars() gains argument tolerance control tolerance dimension value comparisons; #414 binary Ops (like +, -, * etc.) work stars_proxy objects; #390 st_rasterize() rasterizes multiple attributes, handles factors (sf >= 0.9-9) write_stars() deals better stars_proxy objects; #404 fix regression reading stars_proxy objects; #379 add [<- (partially) .na methods stars_proxy objects; #402 add replace_na() methods; #402","code":""},{"path":"/news/index.html","id":"version-05-2","dir":"Changelog","previous_headings":"","what":"version 0.5-2","title":"version 0.5-2","text":"CRAN release: 2021-03-17 read write factor levels GDAL category names; write color table; #392 handle normalize_path choosing proxy; #391 ignore units different units across bands subdataset speed st_rgb() using faster st_apply() approach; #315, #390 improve handling crs Spatial objects (avoid loss wkt comments) correctly write band subsets smaller proxy objects; #291 write arbitrarily cropped proxy objects; #291 speed st_apply() function provided works chunks time; #390 warn breaks = “quantile” results single class; #388 fix [ bug selecting bands proxy objects; #388 stars_proxy objects, write_stars() writes objects multi-layer file; #385 multi-file proxy objects can st_warp()ed use_gdal = TRUE; #385","code":""},{"path":"/news/index.html","id":"version-05-1","dir":"Changelog","previous_headings":"","what":"version 0.5-1","title":"version 0.5-1","text":"CRAN release: 2021-01-25 fix weird GDAL-related bug stars2 vignette read_ncdf() take time mid-points regular intervals, starting points; #378","code":""},{"path":"/news/index.html","id":"version-05-0","dir":"Changelog","previous_headings":"","what":"version 0.5-0","title":"version 0.5-0","text":"CRAN release: 2021-01-19 fix handling rasters color tables; #375 st_apply() methods stars_proxy objects handle … ; #374 add st_bbox(), st_crs() methods terra’s SpatVector objects; https://github.com/r-tmap/tmap/issues/536 add st_bbox(), st_crs() st_as_stars() methods terra’s SpatRaster objects; https://github.com/r-tmap/tmap/issues/536 allow multi-resolution attributes stars_proxy objects (e.g., gray scale sentinel-2 bands); see vignettes 2 7 examples. plot() defaults categorical color scale plotting factor variable; https://github.com/r-tmap/tmap/issues/526 st_extract() extracts space-time points time_column specified, handles time intervals; #352 add [[<-.stars method, now called $<-.stars, array names can set programmatically add transmute() methods plot.stars() calls droplevels factor array NA levels; #339 read_stars() reads NaNs NA; #333 improve st_extract() method stars stars_proxy objects; interpolation options reduced bilinear; #322, #279, #290 better handle categorical rasters start value 1; #329 plot layout can controlled mfrow = c(nr, nc) argument stars_proxy objects normalized path; #331 cropping selecting bbox treats cells always small polygons; #330 add faster st_extract() method stars objects; #322 added vignette: “raster functions map stars functions”, Sebastien Rochette; #122, #325 fix bug dimension values field downsampling; #324 write_stars() also writes band names; #323 add rgdal Suggests: call_list entry stars_proxy object carries proper calling environment; #309 st_as_sf.stars() copes zero attribute (empty) stars objects add st_set_bbox() generic, set raster extent, motivated #315 set tic, great help @pat-s, #313 get rid proj4strings representing coordinate reference systems; #312 (x, “Spatial”) correctly handles dimension values different one read_stars() now sets BANDNAME GDAL metadata item, else band’s GetDescription() band’s dimension values st_as_stars.data.frame() reads simple tables (non-raster data) dims length less 2 band descriptions band dimension values dimension tables simpler, shown properly Rstudio st_rgb() gains probs argument, cut stretch based quantiles (x, \"Raster\") merges multiple attributes converting raster brick","code":""},{"path":"/news/index.html","id":"version-04-3","dir":"Changelog","previous_headings":"","what":"version 0.4-3","title":"version 0.4-3","text":"CRAN release: 2020-07-08 fix bug st_as_stars.Raster; set crs one assigned raster; https://github.com/r-tmap/tmap/issues/471 add s2 Suggests: new function st_rgb() collapses (reduces) dimension rgb hex value; #302","code":""},{"path":"/news/index.html","id":"version-04-2","dir":"Changelog","previous_headings":"","what":"version 0.4-2","title":"version 0.4-2","text":"CRAN release: 2020-07-01 aggregate.stars() handles arrays NA values now correctly; brought #299 Thorsten Simon aggregate.stars() gains argument exact , TRUE, calls exactextractr polygonal aggregation; #289 read_stars() reads subdatasets dimensions equal first, warns ignoring others; #296 make copying dimensions somewhat easier; #295 st_as_stars.Raster() tries read file raster object -memory object. write_stars() normalizes path, read_stars already ; #293 merge() proxy objects acts, longer lazy; #290 st_as_stars.Raster() returns proxy object raster layer disk add st_extract() extract e.g. time series grids point locations; #279; #290 read_stars() chooses value proxy depends data dimensions; #281 x/y range subsetting stars_proxy objects now reads range, similar crop already . st_warp() preserves levels colors; https://github.com/r-tmap/tmap/issues/429 st_crop() works bounding boxes larger downsampled bounding box; #276 st_crop() non-zero default epsilon (bounding box shrinkage) exclude cells touching crop bounding box; #275 image.stars() (hence plot.stars) gains extent argument setting extent plot; https://github.com/r-spatial/sf/issues/1193","code":""},{"path":"/news/index.html","id":"version-04-1","dir":"Changelog","previous_headings":"","what":"version 0.4-1","title":"version 0.4-1","text":"CRAN release: 2020-04-07 st_warp() (stars native) flips longitudes full cycle; #256, #264, #269 handle axis order st_transform (requires sf >= 0.9-1) depend sf 0.9-0 adapt cubelyr split-dplyr; add cubelyr Suggests:; https://github.com/hadley/cubelyr/issues/2 add droplevels() method handle color tables, category tables raster attribute tables read GDAL; #128, #245; https://github.com/r-spatial/mapview/issues/208 handle dimension crs specially, proxy objects now. handle new-style crs objects upcoming sf, moving away proj4strings handle full crs objects refsys element spatial dimensions, rather proj4string st_raster_type(x) reveals raster type x; #248, https://github.com/r-tmap/tmap/issues/368 add st_as_stars.OpenStreetMap() method; #241 @mtennekes add st_flip() flip arrays along one dimensions without changing dimension properties add .owin() method convert (2D raster) stars objects spatstat owin; https://github.com/r-spatial/sf/issues/1233 temporal aggregation, aggregate.stars now also takes arguments like “week”, “month”, “5 days” add st_as_stars() method xts objects; improve .xts stars objects skip tests solaris","code":""},{"path":"/news/index.html","id":"version-04-0","dir":"Changelog","previous_headings":"","what":"version 0.4-0","title":"version 0.4-0","text":"CRAN release: 2019-10-10 plot() now uses data figure breaks, order also find extremes; #216 st_mosaic() creates mosaics spatially disjoint rasters; #210 #205 large refactoring read_ncdf, David Blodgett Mike Sumner, affecting #199, #89, #30, #86, #175 allow funny units like m s**-1; #201 add contour() method stars objects; #196 plot uses rasterImage default available; #194 x y raster dimensions can set unset xy argument st_set_dimensions; #190 retain factor levels dimension values set st_set_dimensions; #188 add conversion stars_proxy Raster: #193 make plotting multiple curvilinear grids work plot default cell borders case curvilinear, rotated sheared grids robustify handling units allow read_ncdf() ignore bounds scale applied wrongly multi-band images; #189, requires sf >= 0.7-5 .nc now recognized correctly write_stars write NetCDF file; #186 [ subset now works correctly negative logical indices; #184, #185 NA values float32 grids now correctly detected; #182, requires sf >= 0.7-5 cropping stars_proxy object now works; #179 st_apply() can now loop Raster layers; examples #176","code":""},{"path":"/news/index.html","id":"version-03-1","dir":"Changelog","previous_headings":"","what":"version 0.3-1","title":"version 0.3-1","text":"CRAN release: 2019-04-23 st_as_stars.bbox now ncells pretty argument, better choose default raster dimensions geom_stars now works stars_proxy objects, needs downsample set; #21 NA values Float32 rasters now read correctly read_stars; #182 handle bounds, given, read_ncdf provide time parsing (POSIXct, PCICt) read_ncdf; #115","code":""},{"path":"/news/index.html","id":"version-03-0","dir":"Changelog","previous_headings":"","what":"version 0.3-0","title":"version 0.3-0","text":"CRAN release: 2019-02-24 add st_area method return raster grid cell sizes; #99 fix st_warp use_gdal=TRUE, allowing multi-band warps add st_get_dimension_values get values particular dimension (meaningful); #100 allow setting intervals dimension values; see examples st_dimensions add st_contour, clean st_as_sf; #99 experimental color table support; https://github.com/r-spatial/mapview/issues/208 rewrote vignettes, added vignettes; #99 deprecate st_write.stars write_stars; #96 use “native” R array-factor support support PCICt 360- 365-day calendars; #29 remove import ncdf4 favor RNetCDF, now line practice ncmeta package. Thanks David Blodgett motivation testing (see #87, #94). st_as_sf uses date/time column names appropriate allow missing trailing comma’s subsetting: [1,,] [1,] now . move rlang Imports: ; rewrite [ subset using rlang. add conversion Spatial* classes, including gridded ones, taking care factor variables depend sf 0.7-2 add logz support log-scale keys plot image","code":""},{"path":"/news/index.html","id":"version-02-0","dir":"Changelog","previous_headings":"","what":"version 0.2-0","title":"version 0.2-0","text":"CRAN release: 2018-10-25 vignettes now use external package, starsdata, larger dataset examples support [<-.stars e.g. mask values; support .na.stars replace NA masks support cut methods factor arrays (plot, subset); #56 add st_rasterize, uses GDALRasterize rasterize sf object; #13 st_as_sf.stars now uses GDAL(F)Polygonize give regular sheared grid grid cells points, returns contour bands using GDALContourGenerateEx (requiring GDAL 2.4.0) case cells points; #13 support curvilinear grids; see #54 data_model vignette add vignette stars_proxy objects work stars_proxy objects defer processing st_apply jobs subsampling; #50 allow reading sections raster, raster lower resolution, selected bands; #48 allow reading vectors (arrays) 2^31 elements; #48 fold higher dimensions third dimension coercing Raster; #40","code":""},{"path":"/news/index.html","id":"version-01-1","dir":"Changelog","previous_headings":"","what":"version 0.1-1","title":"version 0.1-1","text":"CRAN release: 2018-07-25 add meta data reader read_stars","code":""},{"path":"/news/index.html","id":"version-01-0","dir":"Changelog","previous_headings":"","what":"version 0.1-0","title":"version 0.1-0","text":"add merge (merge attributes array dimension) split (split dimension attributes) interface sf, raster spacetime improve plotting handle logical arrays plot add st_apply, analogous apply add cropping/masking used x[buf] buf sf, sfc bbox object; masking x[buf, crop = FALSE] add Ops (+,-,/ etc) Math (sqrt, pow, sin etc) methods add dimnames dimnames<- methods stars objects downsample large grids plot pixels actually shown can plot rectilinear grids (plot rgb images regular grids) rgb argument image works [ array-like subsetting works; first index attribute selector","code":""},{"path":"/news/index.html","id":"version-00","dir":"Changelog","previous_headings":"","what":"version 0.0","title":"version 0.0","text":"interface 9 C++ gdal utils gdal_utils() (now part sf)","code":""}]
+[{"path":"/PROPOSAL.html","id":null,"dir":"","previous_headings":"","what":"Scalable, spatiotemporal Tidy Arrays for R","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"Edzer Pebesma, Michael Sumner, Etienne Racine","code":""},{"path":"/PROPOSAL.html","id":"summary","dir":"","previous_headings":"","what":"Summary","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"lot spatiotemporal data takes form dense, multidimensional arrays. Examples population counts region, year age group weather data variable, time step sensor location satellite imagery, e.g. energy spectral band, location (pixel) time collection climate model data, e.g. surface temperature location, time climate scenario. financial data, e.g. share price company time Although data can represented long tables, larger datasets array form beneficial replicate dimension indexes, array form provides faster access implicitly indexed. R’s native arrays number limitations, handle heterogeneous data records (e.g. consisting numeric, logical Date) like typically data.frame’s, can deal -memory data, handle spatial temporal array dimensions. project () implement flexible generic multidimensional array model heterogeneous records (ii) handles strong spatial temporal referencing array indexes, (iii) scales moderately sized - memory data, large -disk data, massive data held remote servers, using unified user interface follows tidy tools manifesto.","code":""},{"path":"/PROPOSAL.html","id":"the-problem","dir":"","previous_headings":"","what":"The Problem","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"handle analyze large amounts spatially referenced time series data R? handle satellite imagery don’t fit local disc R, need small cluster finish computation within acceptable time? can quickly easily develop analysis testing small portion spatiotemporal datasets, deploying massive data set? can use pipe-based workflows dplyr-verbs data sets? can visually explore high-dimensional raster data? Today, people use R large spatiotemporal data, hit limits related usability, user interface, scalability. r-sig-geo mailing list documents many cases. Now simple features R project largely modernized handling analysis vector data (points, lines, polygons) R tidyverse-friendly fashion, time raster data catch . proposal aims spatiotemporal raster data, well time series feature data.","code":""},{"path":"/PROPOSAL.html","id":"existing-work","dir":"","previous_headings":"The Problem","what":"Existing work","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"Base R supports n-dimensional homogeneous arrays basic types (double, integer, logical, logical), -memory. Package ff supports --memory data structures, held local disc, spatial temporal references dimensions. Spatial packages include rgdal, lets read write raster data, possibly piece--piece, one 142 different file formats. Package raster allows users work raster maps stacks , stack can either refer different bands (color) different time steps, . Package raster can iterate functions large files disc, takes care caching, using either rgdal ncdf4. Another package reading writing NetCDF RNetCDF. Packages dedicated single data source type include include RStoolbox, MODIS, landsat, hsdar; relies raster rgdal file-based /O. CRAN package spacetime provides heterogeneous records, using data.frame attributes. keeps indexes record spatial geometry (grid cell/point/polygon) time instance period; keeps data memory builds xts temporal, sp spatial reference. support R Consortium, Distributed Computing Working Group started develop API distributed computing; initial version available package ddR. aims generic R data structures, works towards relieving users worrying data distributed. Relevant work outside R includes GDAL, particular gdal virtual tiles building arbitrary large grid data sets many individual files, SciDB, open source array database spatial temporal capabilities, strongly scalable architecture, extremely flexible array manipulation methods SciDB4geo, SciDB Plugin Managing Spatial Temporal Reference Information Arrays, SciDB4gdal, GDAL driver SciDB arrays, two activities make SciDB databases aware space time PostGIS Raster, raster data extension PostGIS Rasdaman, array database dedicate images, partially open source. Since definite trend downloading Earth observation data longer feasible, work towards solutions data accessed web service interface. Cloud services AWS starting give access large remote sensing imagery archives e.g. Landsat, MODIS Sentinel satellites.","code":""},{"path":"/PROPOSAL.html","id":"the-plan","dir":"","previous_headings":"","what":"The Plan:","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"develop R package container infrastructure supports dense, n-dimensional arrays heterogeneous records, supports flexible reference array dimensions space, space can gridded (2D/3D raster) set simple features (1D, irregular) supports flexible reference array dimensions time (POSIXct, Date) supports regular arrays (fixed cell size / time step) well irregular arrays allows working memory, local disc, remote computer (using web service interface), allows R functions passed web service back-end, executed parallel, uses -memory proxies large arrays, allowing work first n records computations carried full arrays (similar dplyr ) allows pipe-based workflows, using data.frames, dplyr-style verbs. document software provide tutorials reproducible data analysis examples using locally downloaded imagery, well scalable examples accessing larger (> 1 Tb) datasets using docker container images. document RESTful API connects R client web service holding (processing) big Earth observation data. also develop discuss migration path raster package (43K lines R, C C++ code), functionality, new infrastructure. publish resulting products open access form, R journal, also journal (conference) directed Earth observation community. Timeline: Month 1-2: work design, decide web service technology, basic web service API design Month 3-6: programming R package, testing smaller data sets Month 7-8: testing larger datasets, develop test cases, deploy docker containers Month 9-12: write tutorials, develop teaching material reproducible examples Month 9-12: experiment different back-ends: file-based, database SciDB Failure modes: can’t get RESTful API work properly; solution path: ask rOpenSci community help (Scott Chamberlain, Jeroen Ooms) downloading large image sets cumbersome (slow) larger tutorial examples; solution path: deploy test server teaching/experimenting purposes Amazon cloud, Landsat Sentinel imagery readily available","code":""},{"path":"/PROPOSAL.html","id":"how-can-the-isc-help","dir":"","previous_headings":"","what":"How Can The ISC Help:","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"use funding develop R package web service API. Total costs 10,000 USD, breaks : workshop: travel costs Etienne Racine Michael Sumner visit Muenster, another venue can meet (USD 2500). Programming, project communication: (USD 7000). Cloud deployment Amazon cloud (USD 500).","code":""},{"path":"/PROPOSAL.html","id":"dissemination","dir":"","previous_headings":"","what":"Dissemination:","title":"Scalable, spatiotemporal Tidy Arrays for R","text":"regularly post blogs project r-spatial.org, use twitter, post r-sig-geo, stackoverflow, communicate github issues gitter discussion. project live GitHub, r-spatial organisation. work permissive open source license, probably LGPL-2.1. Pull requests encouraged. R consortium blogs provided start end. Publications R Journal scientific outlets foreseen.","code":""},{"path":"/articles/stars1.html","id":"reading-a-satellite-image","dir":"Articles","previous_headings":"","what":"Reading a satellite image","title":"1. introduction","text":"can read satellite image GDAL, e.g. GeoTIFF file package:  see image geographically referenced (coordinate values along axes), object returned (x) three dimensions called x, y band, one attribute: dimension name; meaning fields single dimension : means index (starting \\(=1\\)) along certain dimension, corresponding dimension value (coordinate, time) \\(\\mbox{offset} + (-1) \\times \\mbox{delta}\\). value refers start (edge) cell interval; order get interval middle cell centre, one needs add half offset. Dimension band simple sequence 1 6. Since bands refer colors, one put wavelength values values field. particular dataset (raster datasets), see delta dimension y negative: means consecutive array values decreasing \\(y\\) values: cell indexes increase top bottom, direction opposite \\(y\\) axis. read_stars reads bands raster dataset, optionally subset raster datasets, single stars array structure. , raster values (often UINT8 UINT16) converted double (numeric) values, scaled back original values needed file encodes scaling parameters. data structure stars generalization tbl_cube found cubelyr; can convert cause loss certain properties (cell size, reference system, vector geometries)","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) plot(x, axes = TRUE) x ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif     1      54     69 68.91242      86  255 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA library(cubelyr) as.tbl_cube(x) ## Source: local array [737,088 x 3] ## D: x [dbl, 349] ## D: y [dbl, 352] ## D: band [int, 6] ## M: L7_ETMs.tif [dbl[,352,6]]"},{"path":"/articles/stars1.html","id":"switching-attributes-to-dimensions-and-back","dir":"Articles","previous_headings":"Reading a satellite image","what":"Switching attributes to dimensions and back","title":"1. introduction","text":"see newly created dimension lost name, single attribute got default name. can set attribute names setNames, dimension names values st_set_dimensions:","code":"(x.spl = split(x, \"band\")) ## stars object with 2 dimensions and 6 attributes ## attribute(s): ##     Min. 1st Qu. Median     Mean 3rd Qu. Max. ## X1    47      67     78 79.14772      89  255 ## X2    32      55     66 67.57465      79  255 ## X3    21      49     63 64.35886      77  255 ## X4     9      52     63 59.23541      75  255 ## X5     1      63     89 83.18266     112  255 ## X6     1      32     60 59.97521      88  255 ## dimension(s): ##   from  to  offset delta                     refsys point x/y ## x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] merge(x.spl) ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##                    Min. 1st Qu. Median     Mean 3rd Qu. Max. ## X1.X2.X3.X4.X5.X6     1      54     69 68.91242      86  255 ## dimension(s): ##            from  to  offset delta                     refsys point    values ## x             1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE      NULL ## y             1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE      NULL ## attributes    1   6      NA    NA                         NA    NA X1,...,X6 ##            x/y ## x          [x] ## y          [y] ## attributes merge(x.spl) |>   setNames(names(x)) |>    st_set_dimensions(3, values = paste0(\"band\", 1:6)) |>   st_set_dimensions(names = c(\"x\", \"y\", \"band\")) ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif     1      54     69 68.91242      86  255 ## dimension(s): ##      from  to  offset delta                     refsys point          values ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE            NULL ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE            NULL ## band    1   6      NA    NA                         NA    NA band1,...,band6 ##      x/y ## x    [x] ## y    [y] ## band"},{"path":"/articles/stars1.html","id":"subsetting","dir":"Articles","previous_headings":"Reading a satellite image","what":"Subsetting","title":"1. introduction","text":"Besides tidyverse subsetting selection operators explained vignette, can also use [ [[. Since stars objects list arrays metadata table describing dimensions, list extraction (assignment) works expected: level, can work array objects directly. stars subset operator [ works bit different: first argument selects attributes second argument selects first dimension third argument selects second dimension, etc Thus, selects second attribute, first 10 columns (x-coordinate), rows, bands 2-4. Alternatively, [ given single argument class sf, sfc bbox, [ work crop operator:","code":"class(x[[1]]) ## [1] \"array\" dim(x[[1]]) ##    x    y band  ##  349  352    6 x$two = 2 * x[[1]] x ## stars object with 3 dimensions and 2 attributes ## attribute(s): ##              Min. 1st Qu. Median      Mean 3rd Qu. Max. ## L7_ETMs.tif     1      54     69  68.91242      86  255 ## two             2     108    138 137.82484     172  510 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA x[\"two\", 1:10, , 2:4] ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##      Min. 1st Qu. Median     Mean 3rd Qu. Max. ## two    36     100    116 119.7326     136  470 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1  10  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    2   4      NA    NA                         NA    NA circle = st_sfc(st_buffer(st_point(c(293749.5, 9115745)), 400), crs = st_crs(x)) plot(x[circle][, , , 1], reset = FALSE) plot(circle, col = NA, border = 'red', add = TRUE, lwd = 2)"},{"path":"/articles/stars1.html","id":"overviews","dir":"Articles","previous_headings":"Reading a satellite image","what":"Overviews","title":"1. introduction","text":"can read rasters lower resolution contain -called overviews. GeoTIFF file, created gdaladdo utility, particular adds coarse resolution versions using average resampling method compute values based blocks pixels. can read ","code":"gdaladdo -r average L7_ETMs.tif  2 4 8 16 x1 = read_stars(tif, options = c(\"OVERVIEW_LEVEL=1\")) x2 = read_stars(tif, options = c(\"OVERVIEW_LEVEL=2\")) x3 = read_stars(tif, options = c(\"OVERVIEW_LEVEL=3\")) dim(x1) ##    x    y band  ##   88   88    6 dim(x2) ##    x    y band  ##   44   44    6 dim(x3) ##    x    y band  ##   22   22    6 par(mfrow = c(1, 3), mar = rep(0.2, 4)) image(x1[,,,1]) image(x2[,,,1]) image(x3[,,,1])"},{"path":"/articles/stars1.html","id":"reading-a-raster-time-series-netcdf","dir":"Articles","previous_headings":"","what":"Reading a raster time series: NetCDF","title":"1. introduction","text":"Another example read raster time series model outputs NetCDF file, e.g. see dataset can see variables units associated (wrong unit, C assigned temperature) time now dimension, proper units time steps Alternatively, dataset can read using read_ncdf, difference read_ncdf read_stars NetCDF files former uses package RNetCDF directly read NetCDF file, latter uses GDAL driver NetCDF files.","code":"system.file(\"nc/bcsd_obs_1999.nc\", package = \"stars\") |>     read_stars() -> w ## pr, tas, w ## stars object with 3 dimensions and 2 attributes ## attribute(s): ##                 Min.   1st Qu.   Median      Mean   3rd Qu.      Max. NA's ## pr [mm/m]  0.5900000 56.139999 81.88000 101.26433 121.07250 848.54999 7116 ## tas [C]   -0.4209678  8.898887 15.65763  15.48932  21.77979  29.38581 7116 ## dimension(s): ##      from to offset  delta  refsys                    values x/y ## x       1 81    -85  0.125      NA                      NULL [x] ## y       1 33  37.12 -0.125      NA                      NULL [y] ## time    1 12     NA     NA POSIXct 1999-01-31,...,1999-12-31 system.file(\"nc/bcsd_obs_1999.nc\", package = \"stars\") |>     read_ncdf() ## no 'var' specified, using pr, tas ## other available variables: ##  latitude, longitude, time ## Will return stars object with 32076 cells. ## No projection information found in nc file.  ##  Coordinate variable units found to be degrees,  ##  assuming WGS84 Lat/Lon. ## stars object with 3 dimensions and 2 attributes ## attribute(s): ##                 Min.   1st Qu.   Median      Mean   3rd Qu.      Max. NA's ## pr [mm/m]  0.5900000 56.139999 81.88000 101.26433 121.07250 848.54999 7116 ## tas [C]   -0.4209678  8.898887 15.65763  15.48932  21.77979  29.38581 7116 ## dimension(s): ##           from to offset delta  refsys                    values x/y ## longitude    1 81    -85 0.125  WGS 84                      NULL [x] ## latitude     1 33     33 0.125  WGS 84                      NULL [y] ## time         1 12     NA    NA POSIXct 1999-01-31,...,1999-12-31"},{"path":"/articles/stars1.html","id":"reading-datasets-from-multiple-files","dir":"Articles","previous_headings":"Reading a raster time series: NetCDF","what":"Reading datasets from multiple files","title":"1. introduction","text":"Model data often spread across many files. example 0.25 degree grid, global daily sea surface temperature product found ; subset 1981 used downloaded NOAA ftp site longer available form. (ftp site used eclipse.ncdc.noaa.gov/pub/OI-daily-v2/NetCDF/1981/AVHRR/). read data giving read_stars vector character names: Next, select sea surface temperature (sst), drop singular zlev (depth) dimension using adrop: can now graph sea surface temperature (SST) using ggplot, needs data long table form, without units:","code":"x = c( \"avhrr-only-v2.19810901.nc\", \"avhrr-only-v2.19810902.nc\", \"avhrr-only-v2.19810903.nc\", \"avhrr-only-v2.19810904.nc\", \"avhrr-only-v2.19810905.nc\", \"avhrr-only-v2.19810906.nc\", \"avhrr-only-v2.19810907.nc\", \"avhrr-only-v2.19810908.nc\", \"avhrr-only-v2.19810909.nc\" ) # see the second vignette: # install.packages(\"starsdata\", repos = \"http://pebesma.staff.ifgi.de\", type = \"source\") file_list = system.file(paste0(\"netcdf/\", x), package = \"starsdata\") (y = read_stars(file_list, quiet = TRUE)) ## stars object with 4 dimensions and 4 attributes ## attribute(s), summary of first 1e+05 cells: ##                Min. 1st Qu. Median       Mean 3rd Qu. Max.  NA's ## sst [°*C]     -1.80   -1.19  -1.05 -0.3201670   -0.20 9.36 13360 ## anom [°*C]    -4.69   -0.06   0.52  0.2299385    0.71 3.70 13360 ## err [°*C]      0.11    0.30   0.30  0.2949421    0.30 0.48 13360 ## ice [percent]  0.01    0.73   0.83  0.7657695    0.87 1.00 27377 ## dimension(s): ##      from   to         offset  delta  refsys x/y ## x       1 1440              0   0.25      NA [x] ## y       1  720             90  -0.25      NA [y] ## zlev    1    1          0 [m]     NA      NA     ## time    1    9 1981-09-01 UTC 1 days POSIXct library(dplyr) ##  ## Attaching package: 'dplyr' ## The following objects are masked from 'package:stats': ##  ##     filter, lag ## The following objects are masked from 'package:base': ##  ##     intersect, setdiff, setequal, union library(abind) z <- y |> select(sst) |> adrop() # convert POSIXct time to character, to please ggplot's facet_wrap() z1 = st_set_dimensions(z, 3, values = as.character(st_get_dimension_values(z, 3))) library(ggplot2) library(viridis) ## Loading required package: viridisLite library(ggthemes) ggplot() +     geom_stars(data = z1[1], alpha = 0.8, downsample = c(10, 10, 1)) +    facet_wrap(\"time\") +   scale_fill_viridis() +   coord_equal() +   theme_map() +   theme(legend.position = \"bottom\") +   theme(legend.key.width = unit(2, \"cm\"))"},{"path":"/articles/stars1.html","id":"writing-stars-objects-to-disk","dir":"Articles","previous_headings":"","what":"Writing stars objects to disk","title":"1. introduction","text":"can write stars object disk using write_stars; used GDAL write engine. Writing NetCDF files without going GDAL interface currently supported. write_stars currently writes single attribute: See explanation merge see multiple attributes can merged (folded) dimension.","code":"write_stars(adrop(y[1]), \"sst.tif\")"},{"path":"/articles/stars1.html","id":"cropping-a-rasters-extent","dir":"Articles","previous_headings":"","what":"Cropping a raster’s extent","title":"1. introduction","text":"Using curvilinear grid, taken example read_ncdf:  can now crop grid cells falling  selection prec_slice[nc] essentially calls st_crop(prec_slice, nc) get cropped selection. happened cells intersecting North Carolina (sea) set NA values. regular grids, extent resulting stars object also reduced (cropped) default; can controlled crop parameter st_crop [.stars.","code":"prec_file = system.file(\"nc/test_stageiv_xyt.nc\", package = \"stars\") prec = read_ncdf(prec_file, curvilinear = c(\"lon\", \"lat\")) ## no 'var' specified, using Total_precipitation_surface_1_Hour_Accumulation ## other available variables: ##  lat, lon, time ## Will return stars object with 236118 cells. ## No projection information found in nc file.  ##  Coordinate variable units found to be degrees,  ##  assuming WGS84 Lat/Lon. ##plot(prec) ## gives error about unique breaks ## remove NAs, zeros, and give a large number ## of breaks (used for validating in detail) qu_0_omit = function(x, ..., n = 22) {   if (inherits(x, \"units\"))     x = units::drop_units(na.omit(x))   c(0, quantile(x[x > 0], seq(0, 1, length.out = n))) } library(dplyr) # loads slice generic prec_slice = slice(prec, index = 17, along = \"time\") plot(prec_slice, border = NA, breaks = qu_0_omit(prec_slice[[1]]), reset = FALSE) nc = sf::read_sf(system.file(\"gpkg/nc.gpkg\", package = \"sf\"), \"nc.gpkg\") plot(st_geometry(nc), add = TRUE, reset = FALSE, col = NA, border = 'red') nc = st_transform(nc, st_crs(prec_slice)) # datum transformation plot(prec_slice[nc], border = NA, breaks = qu_0_omit(prec_slice[[1]]), reset = FALSE) plot(st_geometry(nc), add = TRUE, reset = FALSE, col = NA, border = 'red')"},{"path":"/articles/stars1.html","id":"vector-data-cube-example","dir":"Articles","previous_headings":"","what":"Vector data cube example","title":"1. introduction","text":"Like tbl_cube, stars arrays limits number dimensions handle. example origin-destination (OD) matrix, time travel mode.","code":""},{"path":"/articles/stars1.html","id":"od-space-x-space-x-travel-mode-x-time-x-time","dir":"Articles","previous_headings":"Vector data cube example","what":"OD: space x space x travel mode x time x time","title":"1. introduction","text":"create 5-dimensional matrix traffic regions, day, time day, travel mode. day time day dimension advantage want compute patterns day, certain period. array contains simple feature geometries origin destination can directly plot every slice without additional table joins. want represent array tbl_cube, simple feature geometry dimensions need replaced indexes: following demonstrates can use dplyr filter travel mode bike, compute mean bike traffic hour day:","code":"nc = st_read(system.file(\"gpkg/nc.gpkg\", package=\"sf\"))  ## Reading layer `nc.gpkg' from data source  ##   `/home/runner/work/_temp/Library/sf/gpkg/nc.gpkg' using driver `GPKG' ## Simple feature collection with 100 features and 14 fields ## Geometry type: MULTIPOLYGON ## Dimension:     XY ## Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965 ## Geodetic CRS:  NAD27 to = from = st_geometry(nc) # 100 polygons: O and D regions mode = c(\"car\", \"bike\", \"foot\") # travel mode day = 1:100 # arbitrary library(units) ## udunits database from /usr/share/xml/udunits/udunits2.xml units(day) = as_units(\"days since 2015-01-01\") hour = set_units(0:23, h) # hour of day dims = st_dimensions(origin = from, destination = to, mode = mode, day = day, hour = hour) (n = dim(dims)) ##      origin destination        mode         day        hour  ##         100         100           3         100          24 traffic = array(rpois(prod(n), 10), dim = n) # simulated traffic counts (st = st_as_stars(list(traffic = traffic),  dimensions = dims)) ## stars object with 5 dimensions and 1 attribute ## attribute(s), summary of first 1e+05 cells: ##          Min. 1st Qu. Median    Mean 3rd Qu. Max. ## traffic     0       8     10 9.99961      12   26 ## dimension(s): ##             from  to                      offset                       delta ## origin         1 100                          NA                          NA ## destination    1 100                          NA                          NA ## mode           1   3                          NA                          NA ## day            1 100 1 [(days since 2015-01-01)] 1 [(days since 2015-01-01)] ## hour           1  24                       0 [h]                       1 [h] ##              refsys point ## origin        NAD27 FALSE ## destination   NAD27 FALSE ## mode             NA FALSE ## day         udunits FALSE ## hour        udunits FALSE ##                                                                    values ## origin      MULTIPOLYGON (((-81.47276...,...,MULTIPOLYGON (((-78.65572... ## destination MULTIPOLYGON (((-81.47276...,...,MULTIPOLYGON (((-78.65572... ## mode                                                     car , bike, foot ## day                                                                  NULL ## hour                                                                 NULL st |> as.tbl_cube() ## Source: local array [72,000,000 x 5] ## D: origin [int, 100] ## D: destination [int, 100] ## D: mode [chr, 3] ## D: day [[(days since 2015-01-01)], 100] ## D: hour [[h], 24] ## M: traffic [int[,100,3,100,24]] b <- st |>    as.tbl_cube() |>    filter(mode == \"bike\") |>    group_by(hour) |>   summarise(traffic = mean(traffic)) |>    as.data.frame() require(ggforce) # for plotting a units variable ## Loading required package: ggforce ggplot() +     geom_line(data = b, aes(x = hour, y = traffic)) ## Warning: The `scale_name` argument of `continuous_scale()` is deprecated as of ggplot2 ## 3.5.0. ## This warning is displayed once every 8 hours. ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was ## generated."},{"path":"/articles/stars1.html","id":"extracting-at-point-locations-aggregating-over-polygons","dir":"Articles","previous_headings":"","what":"Extracting at point locations, aggregating over polygons","title":"1. introduction","text":"Data cube values point location can extracted st_extract, example found vignette 7 Aggregates, mean, maximum modal values can obtained aggregate. example use categorical raster, try find modal (frequent) class within two circular polygons:  find modal value, need function gives back label corresponding class frequent, using table: can call aggregate raster map, set two circular polygons pol1 pol2, pass function f:","code":"s = system.file(\"tif/lc.tif\", package = \"stars\") r = read_stars(s, proxy = FALSE) |> droplevels() levels(r[[1]]) = abbreviate(levels(r[[1]]), 10) # shorten text labels st_point(c(3190631, 3125)) |> st_sfc(crs = st_crs(r)) |> st_buffer(25000) -> pol1 st_point(c(3233847, 21027)) |> st_sfc(crs = st_crs(r)) |> st_buffer(10000) -> pol2 if (isTRUE(dev.capabilities()$rasterImage == \"yes\")) {   plot(r, reset = FALSE, key.pos = 4)   plot(c(pol1, pol2), col = NA, border = c('yellow', 'green'), lwd = 2, add = TRUE) } f = function(x) { tb = table(x); names(tb)[which.max(tb)] } aggregate(r, c(pol1, pol2), f) |> st_as_sf() ## Simple feature collection with 2 features and 1 field ## Geometry type: POLYGON ## Dimension:     XY ## Bounding box:  xmin: 3165631 ymin: -21875 xmax: 3243847 ymax: 31027 ## Projected CRS: Albers Conical Equal Area ##       lc.tif                       geometry ## 1 EvrgrnFrst POLYGON ((3215631 3125, 321... ## 2 Dvlpd,MdmI POLYGON ((3243847 21027, 32..."},{"path":"/articles/stars2.html","id":"preamble-the-starsdata-package","dir":"Articles","previous_headings":"","what":"Preamble: the starsdata package","title":"2. stars proxy objects","text":"run examples vignette, must install package datasets large (1 Gb) held stars package. drat repo, installation done ","code":"install.packages(\"starsdata\", repos = \"http://gis-bigdata.uni-muenster.de/pebesma\", type = \"source\")  # possibly after: options(timeout = 100) # or from an alternative repository: # install.packages(\"starsdata\", repos = \"http://pebesma.staff.ifgi.de\", type = \"source\")"},{"path":"/articles/stars2.html","id":"reading-chunks-change-resolution-select-bands","dir":"Articles","previous_headings":"","what":"Reading chunks, change resolution, select bands","title":"2. stars proxy objects","text":"read_stars argument called RasterIO controls GDAL dataset read. default, pixels bands read memory. can consume lot time require lot memory. Remember file may compressed, pixel values represented file bytes converted 8-byte doubles R. reason using RasterIO parameters use directly mapped GDAL RasterIO function used (adapting 1-based offset index R 0-based offset C++).","code":""},{"path":"/articles/stars2.html","id":"reading-a-particular-chunk","dir":"Articles","previous_headings":"Reading chunks, change resolution, select bands","what":"Reading a particular chunk","title":"2. stars proxy objects","text":"example using RasterIO Compare see delta values remain , offset (x/y coordinates origin) grid remain reflect new area, relate new delta values dim(x) reflects new size, three bands read","code":"library(stars) ## Loading required package: abind ## Loading required package: sf ## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") rasterio = list(nXOff = 6, nYOff = 6, nXSize = 100, nYSize = 100, bands = c(1, 3, 4)) (x = read_stars(tif, RasterIO = rasterio)) ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif    23      54     63 62.05977   73.25  235 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       6 105  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       6 105 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   3      NA    NA                         NA    NA dim(x) ##    x    y band  ##  100  100    3 st_dimensions(read_stars(tif)) ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA"},{"path":"/articles/stars2.html","id":"reading-at-a-different-resolution","dir":"Articles","previous_headings":"Reading chunks, change resolution, select bands","what":"Reading at a different resolution","title":"2. stars proxy objects","text":"Reading datasets lower (also higher!) resolution can done setting nBufXSize nBufYSize see addition: delta (raster cell size) values increased factor 5, nBufXSize nBufYSize set values factor 5 smaller nXSize nYSize offset coordinates grid still reflect new area, relate new delta cell size values can also read higher resolution; read 3 x 3 area blow 100 x 100:  reason “see” three grid cells default sampling method “nearest neighbour”. can modify  following methods allowed parameter resample: methods implemented GDAL; methods exactly , refer GDAL documentation source code.","code":"rasterio = list(nXOff = 6, nYOff = 6, nXSize = 100, nYSize = 100,                 nBufXSize = 20, nBufYSize = 20, bands = c(1, 3, 4)) (x = read_stars(tif, RasterIO = rasterio)) ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif    27      53     63 62.09417      74  151 ## dimension(s): ##      from to  offset  delta                     refsys point x/y ## x       2 21  288776  142.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       2 21 9120761 -142.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1  3      NA     NA                         NA    NA rasterio = list(nXOff = 6, nYOff = 6, nXSize = 3, nYSize = 3,    nBufXSize = 100, nBufYSize = 100, bands = 1) x = read_stars(tif, RasterIO = rasterio) dim(x) ##   x   y  ## 100 100 plot(x) rasterio = list(nXOff = 6, nYOff = 6, nXSize = 3, nYSize = 3,    nBufXSize = 100, nBufYSize = 100, bands = 1, resample = \"cubic_spline\") x = read_stars(tif, RasterIO = rasterio) dim(x) ##   x   y  ## 100 100 plot(x)"},{"path":"/articles/stars2.html","id":"stars-proxy-objects","dir":"Articles","previous_headings":"","what":"Stars proxy objects","title":"2. stars proxy objects","text":"Stars proxy objects take another approach: upon creation contain data , pointers data can read. Data read needed, much needed: plot proxy objects, data read resolution pixels screen, rather native resolution, e.g. 10000 x 10000 Sentinel 2 (level 1C) image, can open happens instantly, data read. plot object,  takes around 1 second, since pixels read can seen plot. read entire image memory first, reading take minute, require 5 Gb memory.","code":"granule = system.file(\"sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip\", package = \"starsdata\") s2 = paste0(\"SENTINEL2_L1C:/vsizip/\", granule, \"/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/MTD_MSIL1C.xml:10m:EPSG_32632\") (p = read_stars(s2, proxy = TRUE)) ## stars_proxy object with 1 attribute in 1 file(s): ## $EPSG_32632 ## [1] \"[...]/MTD_MSIL1C.xml:10m:EPSG_32632\" ##  ## dimension(s): ##      from    to offset delta                refsys    values x/y ## x       1 10980  3e+05    10 WGS 84 / UTM zone 32N      NULL [x] ## y       1 10980  6e+06   -10 WGS 84 / UTM zone 32N      NULL [y] ## band    1     4     NA    NA                    NA B4,...,B8 system.time(plot(p)) ## downsample set to 18 ##    user  system elapsed  ##   0.982   0.189   0.677 p = read_stars(s2, proxy = FALSE)"},{"path":"/articles/stars2.html","id":"methods-for-stars-proxy-objects","dir":"Articles","previous_headings":"Stars proxy objects","what":"Methods for stars proxy objects","title":"2. stars proxy objects","text":"","code":"methods(class = \"stars_proxy\") ##  [1] [               [[<-            [<-             adrop           ##  [5] aggregate       aperm           as.data.frame   c               ##  [9] coerce          dim             droplevels      hist            ## [13] image           initialize      is.na           Math            ## [17] merge           Ops             plot            prcomp          ## [21] predict         print           show            slotsFromS3     ## [25] split           st_apply        st_as_sf        st_as_stars     ## [29] st_crop         st_dimensions<- st_downsample   st_mosaic       ## [33] st_normalize    st_redimension  st_sample       st_set_bbox     ## [37] write_stars     ## see '?methods' for accessing help and source code"},{"path":"/articles/stars2.html","id":"select-attributes","dir":"Articles","previous_headings":"Stars proxy objects","what":"Select attributes","title":"2. stars proxy objects","text":"can select attributes regular stars objects, using first argument [: Note selection limits reading 4 1 subdataset 9 NetCDF files.","code":"x = c(\"avhrr-only-v2.19810901.nc\", \"avhrr-only-v2.19810902.nc\", \"avhrr-only-v2.19810903.nc\", \"avhrr-only-v2.19810904.nc\", \"avhrr-only-v2.19810905.nc\", \"avhrr-only-v2.19810906.nc\", \"avhrr-only-v2.19810907.nc\", \"avhrr-only-v2.19810908.nc\", \"avhrr-only-v2.19810909.nc\") file_list = system.file(paste0(\"netcdf/\", x), package = \"starsdata\") y = read_stars(file_list, quiet = TRUE, proxy = TRUE) names(y) ## [1] \"sst\"  \"anom\" \"err\"  \"ice\" y[\"sst\"] ## stars_proxy object with 1 attribute in 9 file(s): ## $sst ## [1] \"[...]/avhrr-only-v2.19810901.nc:sst\" \"[...]/avhrr-only-v2.19810902.nc:sst\" ## [3] \"[...]/avhrr-only-v2.19810903.nc:sst\" \"[...]/avhrr-only-v2.19810904.nc:sst\" ## [5] \"[...]/avhrr-only-v2.19810905.nc:sst\" \"[...]/avhrr-only-v2.19810906.nc:sst\" ## [7] \"[...]/avhrr-only-v2.19810907.nc:sst\" \"[...]/avhrr-only-v2.19810908.nc:sst\" ## [9] \"[...]/avhrr-only-v2.19810909.nc:sst\" ##  ## dimension(s): ##      from   to         offset  delta  refsys x/y ## x       1 1440              0   0.25      NA [x] ## y       1  720             90  -0.25      NA [y] ## zlev    1    1          0 [m]     NA      NA     ## time    1    9 1981-09-01 UTC 1 days POSIXct"},{"path":"/articles/stars2.html","id":"select-an-area","dir":"Articles","previous_headings":"Stars proxy objects","what":"Select an area","title":"2. stars proxy objects","text":"Another possibility crop, select rectangular region based spatial object. can done passing bbox object, sf, sfc stars object bounding box taken. example:","code":"bb = st_bbox(c(xmin = 10.125, ymin = 0.125, xmax = 70.125, ymax = 70.125)) ysub = y[bb] st_dimensions(ysub) ##      from  to         offset  delta  refsys x/y ## x      41 281              0   0.25      NA [x] ## y      80 360             90  -0.25      NA [y] ## zlev    1   1          0 [m]     NA      NA     ## time    1   9 1981-09-01 UTC 1 days POSIXct class(ysub) # still no data here!! ## [1] \"stars_proxy\" \"stars\" plot(ysub, reset = FALSE) # plot reads the data, at resolution that is relevant plot(st_as_sfc(bb), add = TRUE, lwd = .5, border = 'red')"},{"path":"/articles/stars2.html","id":"lazy-evaluation-changing-evaluation-order","dir":"Articles","previous_headings":"Stars proxy objects","what":"Lazy evaluation, changing evaluation order","title":"2. stars proxy objects","text":"actions can carried stars_proxy objects, effect delayed data actually needed (plot, write_stars). instance, range selections dimensions shown first need data, can carried . functions added object, attribute called call_list: allows optimizing order operations done. example, st_apply, reading can done sequentially dimensions function applied: example function applied band (: compute band quantiles), bands can read sequentially, discarded quantiles computed. time series function applied pixel time series result plotted map, time series function evaluated pixels actually plotted. means e.g. order evaluation reversed: plot knows pixels going shown, controls x downsampled st_apply carried subset.","code":"yy = adrop(y) yyy = yy[,1:10,1:10,] class(yyy) # still no data ## [1] \"stars_proxy\" \"stars\" st_dimensions(yyy) # and dimensions not adjusted ##      from   to         offset  delta  refsys x/y ## x       1 1440              0   0.25      NA [x] ## y       1  720             90  -0.25      NA [y] ## zlev    1    1          0 [m]     NA      NA     ## time    1    9 1981-09-01 UTC 1 days POSIXct attr(yyy, \"call_list\") # the name of object in the call (y) is replaced with x: ## [[1]] ## adrop(x = x, drop = drop) ## attr(,\".Environment\") ##  ##  ## [[2]] ## x[i = i, 1:10, 1:10, , drop = drop, crop = crop] ## attr(,\".Environment\") ##  plot(st_apply(x, c(\"x\", \"y\"), range))"},{"path":"/articles/stars2.html","id":"fetching-the-data","dir":"Articles","previous_headings":"Stars proxy objects > Lazy evaluation, changing evaluation order","what":"Fetching the data","title":"2. stars proxy objects","text":"Fetching data now involves reading whole array evaluating call_list , sequentially:","code":"(x = st_as_stars(yyy)) # read, adrop, subset ## stars object with 3 dimensions and 4 attributes ## attribute(s): ##                Min. 1st Qu. Median       Mean 3rd Qu.  Max. ## sst [°*C]     -1.28   -1.17  -1.11 -1.1163555   -1.06 -0.95 ## anom [°*C]     0.48    0.62   0.69  0.6649555    0.72  0.77 ## err [°*C]      0.30    0.30   0.30  0.3000000    0.30  0.30 ## ice [percent]  0.76    0.79   0.81  0.8062889    0.82  0.85 ## dimension(s): ##      from to         offset  delta  refsys x/y ## x       1 10              0   0.25      NA [x] ## y       1 10             90  -0.25      NA [y] ## time    1  9 1981-09-01 UTC 1 days POSIXct"},{"path":"/articles/stars2.html","id":"plotting-with-changed-evaluation-order","dir":"Articles","previous_headings":"Stars proxy objects > Lazy evaluation, changing evaluation order","what":"Plotting with changed evaluation order","title":"2. stars proxy objects","text":"Sentinel 2 data, band 4 represents NIR band 1 red, can compute NDVI ","code":"# S2 10m: band 4: near infrared, band 1: red. #ndvi = function(x) (x[4] - x[1])/(x[4] + x[1]) ndvi = function(x1, x2, x3, x4) (x4 - x1)/(x4 + x1) rm(x) (s2.ndvi = st_apply(p, c(\"x\", \"y\"), ndvi)) ## stars_proxy object with 1 attribute in 1 file(s): ## $EPSG_32632 ## [1] \"[...]/MTD_MSIL1C.xml:10m:EPSG_32632\" ##  ## dimension(s): ##      from    to offset delta                refsys    values x/y ## x       1 10980  3e+05    10 WGS 84 / UTM zone 32N      NULL [x] ## y       1 10980  6e+06   -10 WGS 84 / UTM zone 32N      NULL [y] ## band    1     4     NA    NA                    NA B4,...,B8     ## call_list: ## [[1]] ## st_apply(X = X, MARGIN = MARGIN, FUN = FUN, CLUSTER = CLUSTER,  ##     PROGRESS = PROGRESS, FUTURE = FUTURE, rename = rename, .fname = .fname) ## attr(,\".Environment\") ##  ##  ## This object has pending lazy operations: dimensions as printed may not reflect this. system.time(plot(s2.ndvi)) # read - compute ndvi - plot  ## downsample set to 18 ##    user  system elapsed  ##   0.675   0.173   0.369"},{"path":"/articles/stars2.html","id":"multi-resolution-proxy-objects","dir":"Articles","previous_headings":"","what":"Multi-resolution proxy objects","title":"2. stars proxy objects","text":"sections shows examples stars_proxy objects deal situation different maps dissimilar resolution. assumptions : maps need origin coordinates (typically upper-left corner) CRS. first map determines “working” resolution, e.g. native downsampled resolutions refer ’ll create four maps cells size 1, 2 3:    created three rasters identical cell values dimensions, different cell sizes, hence extents. bind single proxy object, see multi-resolution mentioned printed summary. converting stars object, secondary rasters resampled cellsize + extent first:  sub-range, defined object resolutions, get:  now create four maps, region ([0,4] x [0,4]), different resolutions (cell size 1, 1/2 1/3):      Finally, example first raster higher resolution:","code":"s1 = st_as_stars(matrix(1:16, 4)) s2 = st_as_stars(matrix(1:16, 4)) s3 = st_as_stars(matrix(1:16, 4)) attr(s1, \"dimensions\")$X1$offset = 0 attr(s1, \"dimensions\")$X2$offset = 4 attr(s2, \"dimensions\")$X1$offset = 0 attr(s2, \"dimensions\")$X2$offset = 4 attr(s3, \"dimensions\")$X1$offset = 0 attr(s3, \"dimensions\")$X2$offset = 4 attr(s1, \"dimensions\")$X1$delta =  1 attr(s1, \"dimensions\")$X2$delta = -1 attr(s2, \"dimensions\")$X1$delta =  2 attr(s2, \"dimensions\")$X2$delta = -2 attr(s3, \"dimensions\")$X1$delta =  3 attr(s3, \"dimensions\")$X2$delta = -3 plot(s1, axes = TRUE, text_values = TRUE, text_color = 'orange') plot(s2, axes = TRUE, text_values = TRUE, text_color = 'orange') plot(s3, axes = TRUE, text_values = TRUE, text_color = 'orange') fn1 = paste0(tempdir(), .Platform$file.sep, \"img1.tif\") fn2 = paste0(tempdir(), .Platform$file.sep, \"img2.tif\") fn3 = paste0(tempdir(), .Platform$file.sep, \"img3.tif\") write_stars(s1, fn1) write_stars(s2, fn2) write_stars(s3, fn3)  (r1 = read_stars(c(fn1, fn2, fn3), proxy = TRUE)) ## multi-resolution stars_proxy object with 3 attributes in 3 file(s): ## $`1` ## [1] \"[...]/img1.tif\" ##  ## $`2` ## [1] \"[...]/img2.tif\" ##  ## $`3` ## [1] \"[...]/img3.tif\" ##  ## dimension(s): ##   from to offset delta x/y ## x    1  4      0     1 [x] ## y    1  4      4    -1 [y] st_as_stars(r1) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE) st_as_stars(r1[,2:4,2:4]) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE) s4 = st_as_stars(matrix(1: 16, 4)) s5 = st_as_stars(matrix(1: 64, 8)) s6 = st_as_stars(matrix(1:144,12)) attr(s4, \"dimensions\")$X1$offset = 0 attr(s4, \"dimensions\")$X2$offset = 4 attr(s5, \"dimensions\")$X1$offset = 0 attr(s5, \"dimensions\")$X2$offset = 4 attr(s6, \"dimensions\")$X1$offset = 0 attr(s6, \"dimensions\")$X2$offset = 4 attr(s4, \"dimensions\")$X1$delta =  1 attr(s4, \"dimensions\")$X2$delta = -1 attr(s5, \"dimensions\")$X1$delta =  1/2 attr(s5, \"dimensions\")$X2$delta = -1/2 attr(s6, \"dimensions\")$X1$delta =  1/3 attr(s6, \"dimensions\")$X2$delta = -1/3 plot(s4, axes = TRUE, text_values = TRUE, text_color = 'orange') plot(s5, axes = TRUE, text_values = TRUE, text_color = 'orange') plot(s6, axes = TRUE, text_values = TRUE, text_color = 'orange') fn4 = paste0(tempdir(), .Platform$file.sep, \"img4.tif\") fn5 = paste0(tempdir(), .Platform$file.sep, \"img5.tif\") fn6 = paste0(tempdir(), .Platform$file.sep, \"img6.tif\") write_stars(s4, fn4) write_stars(s5, fn5) write_stars(s6, fn6)  (r2 = read_stars(c(fn4, fn5, fn6), proxy = TRUE)) ## multi-resolution stars_proxy object with 3 attributes in 3 file(s): ## $`4` ## [1] \"[...]/img4.tif\" ##  ## $`5` ## [1] \"[...]/img5.tif\" ##  ## $`6` ## [1] \"[...]/img6.tif\" ##  ## dimension(s): ##   from to offset delta x/y ## x    1  4      0     1 [x] ## y    1  4      4    -1 [y] st_as_stars(r2) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE) st_as_stars(r2[,2:4,2:4]) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE) (r3 = read_stars(c(fn6, fn5, fn4), proxy = TRUE)) ## multi-resolution stars_proxy object with 3 attributes in 3 file(s): ## $`6` ## [1] \"[...]/img6.tif\" ##  ## $`5` ## [1] \"[...]/img5.tif\" ##  ## $`4` ## [1] \"[...]/img4.tif\" ##  ## dimension(s): ##   from to offset   delta x/y ## x    1 12      0  0.3333 [x] ## y    1 12      4 -0.3333 [y] st_as_stars(r3) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE) st_as_stars(r3[,2:6,3:6]) %>%   merge() %>%   plot(breaks = \"equal\", text_values = TRUE, text_color = 'orange', axes = TRUE)"},{"path":"/articles/stars3.html","id":"slice","dir":"Articles","previous_headings":"","what":"slice","title":"3. stars tidyverse methods","text":"slice slices sub-array cube; done specifying dimension act, slice number. returns lower-dimensional array single element selected along slice dimension.","code":"x %>% slice(band, 6) -> x6 x6 ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif     1      32     60 59.97521      88  255 ## dimension(s): ##   from  to  offset delta                     refsys point x/y ## x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y]"},{"path":"/articles/stars3.html","id":"filter","dir":"Articles","previous_headings":"","what":"filter","title":"3. stars tidyverse methods","text":"Similar slice, filter selects dimensions evaluates values rather index: subarray created based x coordinate values. Note filter converts object tbl_cube, uses dplyr filter method tbl_cube objects. limitation stars objects rectilinear, curvilinear simple feature geometries handled. objects, using regular [ selection using st_crop may alternative.","code":"x %>% filter(x > 289000, x < 291000, band > 3) -> x7 x7 ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif     5      54     70 71.79194      88  252 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1  70  289004  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   3       4     1                         NA    NA"},{"path":"/articles/stars3.html","id":"pull","dir":"Articles","previous_headings":"","what":"pull","title":"3. stars tidyverse methods","text":"pull pulls array stars object:","code":"x %>% pull(1) -> x8 class(x8) ## [1] \"array\" dim(x8) ##    x    y band  ##  349  352    6"},{"path":"/articles/stars3.html","id":"mutate","dir":"Articles","previous_headings":"","what":"mutate","title":"3. stars tidyverse methods","text":"","code":"x %>% mutate(band2 = 2 * L7_ETMs.tif) -> x2  x2 ## stars object with 3 dimensions and 2 attributes ## attribute(s): ##              Min. 1st Qu. Median      Mean 3rd Qu. Max. ## L7_ETMs.tif     1      54     69  68.91242      86  255 ## band2           2     108    138 137.82484     172  510 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA"},{"path":"/articles/stars3.html","id":"select","dir":"Articles","previous_headings":"","what":"select","title":"3. stars tidyverse methods","text":"select selects attribute, set attributes:","code":"x2 %>% select(band2) -> x9 x9 ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##        Min. 1st Qu. Median     Mean 3rd Qu. Max. ## band2     2     108    138 137.8248     172  510 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA"},{"path":"/articles/stars3.html","id":"geom_stars","dir":"Articles","previous_headings":"","what":"geom_stars","title":"3. stars tidyverse methods","text":"geom_raster ggplot2 geom function accepts stars objects data argument sets raster vector spatial coordinates plot dimensions, first attribute fill variable allows downsampling (without choosing suitable downsampling level) chooses using geom_raster, geom_rect geom_sf depending whether geometry regular, rectilinear vector geometries example use ","code":"library(ggplot2) library(viridis) ## Loading required package: viridisLite ggplot() +    geom_stars(data = x) +   coord_equal() +   facet_wrap(~band) +   theme_void() +   scale_fill_viridis() +   scale_x_discrete(expand = c(0, 0)) +   scale_y_discrete(expand = c(0, 0))"},{"path":"/articles/stars4.html","id":"stars-objects","dir":"Articles","previous_headings":"","what":"Stars objects","title":"4. stars data model","text":"stars objects consist (possibly empty) named list arrays, named dimensions (dim) attribute attribute called dimensions class dimensions carries dimension metadata class name includes stars dimensions object named list dimension elements, describing semantics dimension data arrays (space, time, type etc). addition , dimensions object attribute called raster class stars_raster, named list three elements: dimensions length 2 character; dimension names constitute spatial raster (NA) affine length 2 numeric; two affine parameters geotransform (NA) curvilinear boolean indicating whether raster curvilinear raster (NA) affine curvilinear values relevant case raster data, indicated dimensions non-NA values. dimension object describes single dimension; list named elements : (numeric length 1): start index array : (numeric length 1): end index array offset: (numeric length 1): start coordinate (time) value first pixel (.e., pixel/cell boundary) delta: (numeric length 1): increment, cell size refsys: (character, crs): object describing reference system; e.g. PROJ string, string POSIXct PCICt (360 365 days/year calendars), object class crs (containing EPSG code proj4string) point: (logical length 1): boolean indicating whether cells/pixels refer areas/periods, points/instances (may NA) NULL (missing), vector coordinate values (numeric, POSIXct, PCICt, sfc), object class intervals (list two vectors, start end, interval start- end-values), matrix longitudes latitudes cells (case curvilinear grids) usually 1 dimension size, may larger 1 case sub-grid got selected (cropped). offset delta apply regularly discretized dimensions, NA case. NA, dimension values may held values field. Rectilinear curvilinear grids need grid values values can either: rectilinear grids: irregularly spaced coordinate values, coordinate intervals irregular width (rectilinear grid can one dimension regular), curvilinear grids: matrix grid cell centre values row/col combinations (usually longitude latitude). Alternatively, values can contains set spatial geometries encoded sfc vector (“list-column”), case vector data cube.","code":""},{"path":[]},{"path":"/articles/stars4.html","id":"regular-grids","dir":"Articles","previous_headings":"Grid type","what":"Regular grids","title":"4. stars data model","text":"simple file created \\(4 \\times 5\\) matrix see rows (5) mapped first dimension, x-coordinate columns (4) mapped second dimension, y-coordinate fields dimension define range corresponds array dimension: offset delta specify increasing row column index maps x y coordinate values respectively. plot object, using image method stars objects,  see \\((0,0)\\) origin grid (grid corner), \\(1\\) coordinate value increase one index (row, col) next. means consecutive matrix columns represent grid lines, going south north. Grids defined way regular: grid cell size constant everywhere. Many actual grid datasets y coordinates (grid rows) going North South (top bottom); realised negative value delta. see grid origin \\((0,0)\\) change:  example GeoTIFF carried package, , probably data sources read GDAL, negative delta y-coordinate:","code":"suppressPackageStartupMessages(library(stars)) m = matrix(1:20, nrow = 5, ncol = 4) dim(m) = c(x = 5, y = 4) # named dim (s = st_as_stars(m)) ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##     Min. 1st Qu. Median Mean 3rd Qu. Max. ## A1     1    5.75   10.5 10.5   15.25   20 ## dimension(s): ##   from to offset delta point x/y ## x    1  5      0     1 FALSE [x] ## y    1  4      0     1 FALSE [y] dim(s[[1]]) ## x y  ## 5 4 image(s, text_values = TRUE, axes = TRUE) attr(s, \"dimensions\")[[2]]$delta = -1 image(s, text_values = TRUE, axes = TRUE) tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") st_dimensions(read_stars(tif))[\"y\"] ##   from  to  offset delta                     refsys point ## y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE"},{"path":"/articles/stars4.html","id":"raster-attributes-rotated-and-sheared-grids","dir":"Articles","previous_headings":"Grid type","what":"Raster attributes, rotated and sheared grids","title":"4. stars data model","text":"Dimension tables stars objects carry raster attribute: list holds dimensions: character, names raster dimensions (), opposed e.g. spectral, temporal dimensions affine: numeric, affine parameters curvilinear: logical indicating whether raster curvilinear fields needed level, describe properties array higher level individual dimensions : pair dimensions forms raster, affine curvilinear describe x y pair derived grid indexes (see ) done per-dimension basis. two affine parameters \\(a_1\\) \\(a_2\\), \\(x\\) \\(y\\) coordinates derived (1-based) grid indexes \\(\\) \\(j\\), grid offset values \\(o_x\\) \\(o_y\\), grid cell sizes \\(d_x\\) \\(d_y\\) \\[x = o_x + (-1) d_x + (j-1) a_1\\] \\[y = o_y + (-1) a_2 + (j-1) d_y\\] Clearly, \\(a_1=a_2=0\\), \\(x\\) \\(y\\) entirely derived respective index, offset cellsize. Note integer indexes, coordinates starting edge grid cell; get grid cell center top left grid cell (case negative \\(d_y\\)), use \\(=1.5\\) \\(j=1.5\\). can rotate grids setting \\(a_1\\) \\(a_2\\) non-zero value:  rotation angle, degrees, Sheared grids obtained two rotation coefficients, \\(a_1\\) \\(a_2\\), unequal:  Now, y-axis x-axis different rotation degrees respectively","code":"str(attr(st_dimensions(s), \"raster\")) ## List of 4 ##  $ affine     : num [1:2] 0 0 ##  $ dimensions : chr [1:2] \"x\" \"y\" ##  $ curvilinear: logi FALSE ##  $ blocksizes : NULL ##  - attr(*, \"class\")= chr \"stars_raster\" attr(attr(s, \"dimensions\"), \"raster\")$affine = c(0.1, 0.1) plot(st_as_sf(s, as_points = FALSE), axes = TRUE, nbreaks = 20) atan2(0.1, 1) * 180 / pi ## [1] 5.710593 attr(attr(s, \"dimensions\"), \"raster\")$affine = c(0.1, 0.2) plot(st_as_sf(s, as_points = FALSE), axes = TRUE, nbreaks = 20) atan2(c(0.1, 0.2), 1) * 180 / pi ## [1]  5.710593 11.309932"},{"path":"/articles/stars4.html","id":"rectilinear-grids","dir":"Articles","previous_headings":"","what":"Rectilinear grids","title":"4. stars data model","text":"Rectilinear grids orthogonal axes, congruent (equally sized shaped) cells: axis irregular subdivision. can define rectilinear grid specifying cell boundaries, meaning every dimension specify one value dimension size:  leave last value, stars may come different cell boundary last cell, now derived width one--last cell: problematic cells constant width, case boundaries reduced offset delta value, irrespective whether upper boundary given: Alternatively, one can also set cell midpoints specifying arguments cell_midpoints st_dimensions call: dimension regular, results offset shifted back half delta, else intervals derived distances cell centers. obviously done cell boundaries specified.","code":"x = c(0, 0.5, 1, 2, 4, 5)  # 6 numbers: boundaries! y = c(0.3, 0.5, 1, 2, 2.2) # 5 numbers: boundaries! (r = st_as_stars(list(m = m), dimensions = st_dimensions(x = x, y = y))) ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##    Min. 1st Qu. Median Mean 3rd Qu. Max. ## m     1    5.75   10.5 10.5   15.25   20 ## dimension(s): ##   from to point                values x/y ## x    1  5 FALSE     [0,0.5),...,[4,5) [x] ## y    1  4 FALSE [0.3,0.5),...,[2,2.2) [y] st_bbox(r) ## xmin ymin xmax ymax  ##  0.0  0.3  5.0  2.2 image(r, axes = TRUE, col = grey((1:20)/20)) x = c(0, 0.5, 1, 2, 4)  # 5 numbers: offsets only! y = c(0.3, 0.5, 1, 2)   # 4 numbers: offsets only! (r = st_as_stars(list(m = m), dimensions = st_dimensions(x = x, y = y))) ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##    Min. 1st Qu. Median Mean 3rd Qu. Max. ## m     1    5.75   10.5 10.5   15.25   20 ## dimension(s): ##   from to point              values x/y ## x    1  5 FALSE   [0,0.5),...,[4,6) [x] ## y    1  4 FALSE [0.3,0.5),...,[2,3) [y] st_bbox(r) ## xmin ymin xmax ymax  ##  0.0  0.3  6.0  3.0 x = c(0, 1, 2, 3, 4)  # 5 numbers: offsets only! y = c(0.5, 1, 1.5, 2)   # 4 numbers: offsets only! (r = st_as_stars(list(m = m), dimensions = st_dimensions(x = x, y = y))) ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##    Min. 1st Qu. Median Mean 3rd Qu. Max. ## m     1    5.75   10.5 10.5   15.25   20 ## dimension(s): ##   from to offset delta point x/y ## x    1  5      0     1 FALSE [x] ## y    1  4    0.5   0.5 FALSE [y] st_bbox(r) ## xmin ymin xmax ymax  ##  0.0  0.5  5.0  2.5 x = st_as_stars(matrix(1:9, 3, 3),                  st_dimensions(x = c(1, 2, 3), y = c(2, 3, 10), cell_midpoints = TRUE))"},{"path":"/articles/stars4.html","id":"curvilinear-grids","dir":"Articles","previous_headings":"","what":"Curvilinear grids","title":"4. stars data model","text":"Curvilinear grids grids whose grid lines straight. Rather describing curvature parametrically, typical (HDF5 NetCDF) files found two raster layers longitudes latitudes every corresponding pixel remaining layers. example, use Sentinel 5P dataset available package starsdata; package can installed dataset found : can construct curvilinear stars raster calling read_stars right sub-array: array, can see GDAL metadata item GEOLOCATION: reveals , dataset, longitude latitude arrays kept. curvilinear array actual arrays (raster layers, matrices) longitude latitude values read dimension table. can plot file:   can downsample data  doesn’t look nice, plotting cells polygons looks better:  Another approach warp curvilinear grid regular grid, e.g. ","code":"install.packages(\"starsdata\", repos = \"http://pebesma.staff.ifgi.de\", type = \"source\") (s5p = system.file(\"sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc\", package = \"starsdata\")) ## [1] \"/home/runner/work/_temp/Library/starsdata/sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc\" subs = gdal_subdatasets(s5p) subs[[6]] ## [1] \"NETCDF:\\\"/home/runner/work/_temp/Library/starsdata/sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc\\\":/PRODUCT/nitrogendioxide_tropospheric_column\" gdal_metadata(subs[[6]], \"GEOLOCATION\") ## $LINE_OFFSET ## [1] \"0\" ##  ## $LINE_STEP ## [1] \"1\" ##  ## $PIXEL_OFFSET ## [1] \"0\" ##  ## $PIXEL_STEP ## [1] \"1\" ##  ## $SRS ## [1] \"GEOGCS[\\\"WGS 84\\\",DATUM[\\\"WGS_1984\\\",SPHEROID[\\\"WGS 84\\\",6378137,298.257223563,AUTHORITY[\\\"EPSG\\\",\\\"7030\\\"]],AUTHORITY[\\\"EPSG\\\",\\\"6326\\\"]],PRIMEM[\\\"Greenwich\\\",0,AUTHORITY[\\\"EPSG\\\",\\\"8901\\\"]],UNIT[\\\"degree\\\",0.0174532925199433,AUTHORITY[\\\"EPSG\\\",\\\"9122\\\"]],AXIS[\\\"Latitude\\\",NORTH],AXIS[\\\"Longitude\\\",EAST],AUTHORITY[\\\"EPSG\\\",\\\"4326\\\"]]\" ##  ## $X_BAND ## [1] \"1\" ##  ## $X_DATASET ## [1] \"NETCDF:\\\"/home/runner/work/_temp/Library/starsdata/sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc\\\":/PRODUCT/longitude\" ##  ## $Y_BAND ## [1] \"1\" ##  ## $Y_DATASET ## [1] \"NETCDF:\\\"/home/runner/work/_temp/Library/starsdata/sentinel5p/S5P_NRTI_L2__NO2____20180717T120113_20180717T120613_03932_01_010002_20180717T125231.nc\\\":/PRODUCT/latitude\" ##  ## attr(,\"class\") ## [1] \"gdal_metadata\" nit.c = read_stars(subs[[6]])  ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. ## Warning in CPL_read_gdal(as.character(x), as.character(options), ## as.character(driver), : GDAL Message 1: The dataset has several variables that ## could be identified as vector fields, but not all share the same primary ## dimension. Consequently they will be ignored. threshold = units::set_units(9e+36, mol/m^2) nit.c[[1]][nit.c[[1]] > threshold] = NA nit.c ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##                                                   Min.      1st Qu. ## nitrogendioxide_tropospheri... [mol/m^2] -3.301083e-05 1.868205e-05 ##                                                Median         Mean      3rd Qu. ## nitrogendioxide_tropospheri... [mol/m^2] 2.622178e-05 2.898976e-05 3.629641e-05 ##                                                  Max. NA's ## nitrogendioxide_tropospheri... [mol/m^2] 0.0003924858  330 ## dimension(s): ##      from  to         offset  refsys                             values x/y ## x       1 450             NA  WGS 84 [450x278] -5.811 [°],...,30.95 [°] [x] ## y       1 278             NA  WGS 84  [450x278] 28.36 [°],...,51.47 [°] [y] ## time    1   1 2018-07-17 UTC POSIXct                               NULL     ## curvilinear grid plot(nit.c, breaks = \"equal\", reset = FALSE, axes = TRUE, as_points = TRUE,           pch = 16,  logz = TRUE, key.length = 1) ## Warning in NextMethod(): NaNs produced ## Warning in plot.sf(x, pal = col, ...): NaNs produced maps::map('world', add = TRUE, col = 'red') plot(nit.c, breaks = \"equal\", reset = FALSE, axes = TRUE, as_points = FALSE,           border = NA, logz = TRUE, key.length = 1) ## Warning in NextMethod(): NaNs produced ## Warning in plot.sf(x, pal = col, ...): NaNs produced maps::map('world', add = TRUE, col = 'red') (nit.c_ds = stars:::st_downsample(nit.c, 8)) ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##                                                   Min.     1st Qu.       Median ## nitrogendioxide_tropospheri... [mol/m^2] -1.847503e-05 1.85778e-05 2.700901e-05 ##                                                Mean      3rd Qu.         Max. ## nitrogendioxide_tropospheri... [mol/m^2] 2.9113e-05 3.642568e-05 0.0001363282 ##                                          NA's ## nitrogendioxide_tropospheri... [mol/m^2]   32 ## dimension(s): ##      from to         offset  refsys                           values x/y ## x       1 50             NA  WGS 84 [50x31] -5.811 [°],...,30.14 [°] [x] ## y       1 31             NA  WGS 84  [50x31] 28.78 [°],...,51.47 [°] [y] ## time    1  1 2018-07-17 UTC POSIXct                             NULL     ## curvilinear grid plot(nit.c_ds, breaks = \"equal\", reset = FALSE, axes = TRUE, as_points = TRUE,           pch = 16, logz = TRUE, key.length = 1) ## Warning in NextMethod(): NaNs produced ## Warning in plot.sf(x, pal = col, ...): NaNs produced maps::map('world', add = TRUE, col = 'red') plot(nit.c_ds, breaks = \"equal\", reset = FALSE, axes = TRUE, as_points = FALSE,           border = NA, logz = TRUE, key.length = 1) ## Warning in NextMethod(): NaNs produced ## Warning in plot.sf(x, pal = col, ...): NaNs produced maps::map('world', add = TRUE, col = 'red') w = st_warp(nit.c, crs = 4326, cellsize = 0.25) ## Warning in transform_grid_grid(st_as_stars(src), st_dimensions(dest), ## threshold): using Euclidean distance measures on geodetic coordinates ## threshold set to 0.108545 : set a larger value if you see missing values where there shouldn't be plot(w)"},{"path":"/articles/stars5.html","id":"rasterizing-an-sf-vector-object","dir":"Articles","previous_headings":"","what":"Rasterizing an sf vector object","title":"5. vector-raster conversions, reprojection, warping","text":"algorithm used GDAL rasterize utility, options utility can passed st_rasterize. geometry final raster can controlled passing target bounding box either raster dimensions nx ny, pixel size dx dy parameters.","code":"library(stars) ## Loading required package: abind system.file(\"gpkg/nc.gpkg\", package = \"sf\") %>%   read_sf() %>%   st_transform(32119) -> nc nc$dens = nc$BIR79 / units::set_units(st_area(nc), km^2) (nc.st = st_rasterize(nc[\"dens\"], dx = 5000, dy = 5000)) ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##                    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. NA's ## dens [1/km^2] 0.2545072 1.225631 1.932222 3.345918 3.825745 21.24828 4808 ## dimension(s): ##   from  to offset delta                 refsys point x/y ## x    1 162 123829  5000 NAD83 / North Carolina FALSE [x] ## y    1  61 318260 -5000 NAD83 / North Carolina FALSE [y] plot(nc.st)"},{"path":"/articles/stars5.html","id":"vectorizing-a-raster-object-to-an-sf-object","dir":"Articles","previous_headings":"","what":"Vectorizing a raster object to an sf object","title":"5. vector-raster conversions, reprojection, warping","text":"stars objects can converted sf object using st_as_sf. number options, depending whether pixels represent point value pixel center, small square polygons single value. work landsat-7 6-band image, select first band round values:","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif)[, 1:50, 1:50, 1:2] x[[1]] = round(x[[1]]/5)"},{"path":"/articles/stars5.html","id":"polygonizing","dir":"Articles","previous_headings":"Vectorizing a raster object to an sf object","what":"Polygonizing","title":"5. vector-raster conversions, reprojection, warping","text":"case raster cells reflect point values want get vector representation whole field, can draw contour lines export contour sets (available GDAL version least 2.4.0):","code":"l =  st_contour(x, contour_lines = TRUE, breaks = 11:15) plot(l[1], key.pos = 1, pal = sf.colors, lwd = 2, key.length = 0.8)"},{"path":"/articles/stars5.html","id":"exporting-to-points","dir":"Articles","previous_headings":"Vectorizing a raster object to an sf object","what":"Exporting to points","title":"5. vector-raster conversions, reprojection, warping","text":"Alternatively, can simply export pixels points, get either wide table bands per point, replicated POINT geometries: long table single attribute points replicated: can see, additional attribute band now indicates band concerned.","code":"st_as_sf(x, as_points = TRUE, merge = FALSE) ## Simple feature collection with 2500 features and 2 fields ## Geometry type: POINT ## Dimension:     XY ## Bounding box:  xmin: 288790.5 ymin: 9119350 xmax: 290187 ymax: 9120747 ## Projected CRS: SIRGAS 2000 / UTM zone 25S ## First 10 features: ##    L7_ETMs.tif.V1 L7_ETMs.tif.V2                 geometry ## 1              14             11 POINT (288790.5 9120747) ## 2              14             11   POINT (288819 9120747) ## 3              13             10 POINT (288847.5 9120747) ## 4              12              9   POINT (288876 9120747) ## 5              12             10 POINT (288904.5 9120747) ## 6              12             10   POINT (288933 9120747) ## 7              12             10 POINT (288961.5 9120747) ## 8              12             10   POINT (288990 9120747) ## 9              13             10 POINT (289018.5 9120747) ## 10             13             10   POINT (289047 9120747) st_as_sf(x, as_points = TRUE, merge = FALSE, long = TRUE) ## Simple feature collection with 5000 features and 2 fields ## Geometry type: POINT ## Dimension:     XY ## Bounding box:  xmin: 288790.5 ymin: 9119350 xmax: 290187 ymax: 9120747 ## Projected CRS: SIRGAS 2000 / UTM zone 25S ## First 10 features: ##    band L7_ETMs.tif                 geometry ## 1     1          14 POINT (288790.5 9120747) ## 2     1          14   POINT (288819 9120747) ## 3     1          13 POINT (288847.5 9120747) ## 4     1          12   POINT (288876 9120747) ## 5     1          12 POINT (288904.5 9120747) ## 6     1          12   POINT (288933 9120747) ## 7     1          12 POINT (288961.5 9120747) ## 8     1          12   POINT (288990 9120747) ## 9     1          13 POINT (289018.5 9120747) ## 10    1          13   POINT (289047 9120747)"},{"path":"/articles/stars5.html","id":"exporting-to-polygons","dir":"Articles","previous_headings":"Vectorizing a raster object to an sf object","what":"Exporting to polygons","title":"5. vector-raster conversions, reprojection, warping","text":"Alternatively, can export polygons either get single polygon per pixel, merge polygons identical pixel values; plotted boundaries, see resolved boundaries areas pixel value:  option connect8 can set TRUE use 8 connectedness, rather default 4 connectedness algorithm. cases, polygons returned often invalid according simple feature standard, can made valid using lwgeom::st_make_valid.","code":"st_as_sf(x[1], as_points = FALSE, merge = FALSE) ## Simple feature collection with 2500 features and 2 fields ## Geometry type: POLYGON ## Dimension:     XY ## Bounding box:  xmin: 288776.3 ymin: 9119336 xmax: 290201.3 ymax: 9120761 ## Projected CRS: SIRGAS 2000 / UTM zone 25S ## First 10 features: ##    L7_ETMs.tif.V1 L7_ETMs.tif.V2                       geometry ## 1              14             11 POLYGON ((288776.3 9120761,... ## 2              14             11 POLYGON ((288804.8 9120761,... ## 3              13             10 POLYGON ((288833.3 9120761,... ## 4              12              9 POLYGON ((288861.8 9120761,... ## 5              12             10 POLYGON ((288890.3 9120761,... ## 6              12             10 POLYGON ((288918.8 9120761,... ## 7              12             10 POLYGON ((288947.3 9120761,... ## 8              12             10 POLYGON ((288975.8 9120761,... ## 9              13             10 POLYGON ((289004.3 9120761,... ## 10             13             10 POLYGON ((289032.8 9120761,... p = st_as_sf(x, as_points = FALSE, merge = TRUE) plot(p)"},{"path":"/articles/stars5.html","id":"switching-between-vector-and-raster-in-stars-objects","dir":"Articles","previous_headings":"","what":"Switching between vector and raster in stars objects","title":"5. vector-raster conversions, reprojection, warping","text":"can convert raster dimension vector dimension keeping dimensions stars object also requires setting as_points arguments st_as_sf.","code":"x.sf = st_xy2sfc(x, as_points = TRUE) x.sf ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median    Mean 3rd Qu. Max. ## L7_ETMs.tif     7       9     11 11.2548      12   28 ## dimension(s): ##          from   to                     refsys point ## geometry    1 2500 SIRGAS 2000 / UTM zone 25S  TRUE ## band        1    2                         NA    NA ##                                                       values ## geometry POINT (288790.5 9120747),...,POINT (290187 9119350) ## band                                                    NULL"},{"path":"/articles/stars5.html","id":"reprojecting-a-raster","dir":"Articles","previous_headings":"","what":"Reprojecting a raster","title":"5. vector-raster conversions, reprojection, warping","text":"accept curvilinear rasters rasters , regular rectilinear grids special cases curvilinear grids, reprojecting raster longer “problem”, just recomputes new coordinates every raster cell, generally results curvilinear grid (sometimes can brought back regular rectilinear grid). curvilinear grid cells represented coordinates cell center, actual shape grid cell gets lost, may larger effect grid cells large transformation stronger non-linear. example reprojection grid created  noted dimensionality grid didn’t change: set raster cells replotted new CRS, now curvilinear grid.","code":"nc.st %>% st_transform(\"+proj=laea +lat_0=34 +lon_0=-60\") -> nc.curv nc.curv ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##                    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. NA's ## dens [1/km^2] 0.2545072 1.225631 1.932222 3.345918 3.825745 21.24828 4808 ## dimension(s): ##   from  to                       refsys point                         values ## x    1 162 +proj=laea +lat_0=34 +lon... FALSE [162x61] -2210936,...,-1371611 ## y    1  61 +proj=laea +lat_0=34 +lon... FALSE      [162x61] 90650,...,538204 ##   x/y ## x [x] ## y [y] ## curvilinear grid plot(nc.curv, border = NA, graticule = TRUE)"},{"path":"/articles/stars5.html","id":"warping-a-raster","dir":"Articles","previous_headings":"","what":"Warping a raster","title":"5. vector-raster conversions, reprojection, warping","text":"Warping raster means creating new regular grid new CRS, based (usually regular) grid another CRS. can transformation previous section first creating target grid: warping old raster new  new object regular grid new CRS, aligned new x- y-axes.","code":"nc %>% st_transform(\"+proj=laea +lat_0=34 +lon_0=-60\") %>% st_bbox() %>%     st_as_stars() -> newgrid nc.st %>% st_warp(newgrid) -> nc.new nc.new  ## stars object with 2 dimensions and 1 attribute ## attribute(s): ##                    Min.  1st Qu.   Median     Mean  3rd Qu.     Max.  NA's ## dens [1/km^2] 0.2545072 1.225631 1.932222 3.344805 3.825745 21.24828 36155 ## dimension(s): ##   from  to   offset delta                       refsys x/y ## x    1 380 -2188110  2098 +proj=laea +lat_0=34 +lon... [x] ## y    1 171   494924 -2098 +proj=laea +lat_0=34 +lon... [y] plot(nc.new)"},{"path":"/articles/stars6.html","id":"comment-legend","dir":"Articles","previous_headings":"","what":"COMMENT LEGEND","title":"6. How `raster` functions map to `stars` functions","text":"? = sure / unknown * = present, low priority # = present, high priority NA = available design","code":""},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":[]},{"path":"/articles/stars6.html","id":"computing-row-column-cell-numbers-and-coordinates","dir":"Articles","previous_headings":"","what":"Computing row, column, cell numbers and coordinates","title":"6. How `raster` functions map to `stars` functions","text":"format table follows raster-package entry raster manual, found https://cran.r-project.org/web/packages/raster/raster.pdf.","code":""},{"path":"/articles/stars7.html","id":"training-and-prediction-with-stars-objects","dir":"Articles","previous_headings":"","what":"Training and prediction with stars objects","title":"7. Statistical modelling with stars objects","text":"usual way statistical modelling R uses data.frames (tibbles), proceeds like model function like lm, glm, randomForest etc. returns classed object, predict generic can choose right prediction function based class. formula looks like y ~ x1+x2 specifies dependent variable (y) predictors (x1, x2), found columns data. newdata needs predictors columns, returns predicted values y values predictors.","code":"m = model(formula, data) pr = predict(m, newdata)"},{"path":"/articles/stars7.html","id":"stars-objects-as-data-frames","dir":"Articles","previous_headings":"Training and prediction with stars objects","what":"stars objects as data.frames","title":"7. Statistical modelling with stars objects","text":"analogy stars objects data.frame : attribute (array) becomes single column dimensions become added (index) columns see works 6-band example dataset, consider : see get one single variable object (array) name, added columns dimension values (x, y, band). typical case, like six bands distributed six variables, single observation (row) x/y pair. , use e.g. utils::unstack dplyr::pivot_wider data.frame, efficient way use dedicated split method stars objects, resolves dimension splits attributes, one dimension value: reason split efficient mentioned alternatives () split match records based dimensions (x/y), (ii) works --memory (stars_proxy) arrays, chunked process/write loop write_stars(). ### Predict stars objects pattern obtain predictions pixels stars objects : use full dataset sample train model, using .data.frame() (possibly split) use predict(star_object, model) predict pixels stars_object, using stars-wrapper predict method model. predict method model, provide one (see kmeans example ) works stars objects (-memory) stars_proxy objects (-memory). plotting stars_proxy objects, downsampling done prediction (predicting pixels shown), full rasters can written disk write_stars(), carry predictions chunks read written.","code":"library(stars) ## Loading required package: abind ## Loading required package: sf ## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE l7 = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") %>%   read_stars() l7 ## stars object with 3 dimensions and 1 attribute ## attribute(s): ##              Min. 1st Qu. Median     Mean 3rd Qu. Max. ## L7_ETMs.tif     1      54     69 68.91242      86  255 ## dimension(s): ##      from  to  offset delta                     refsys point x/y ## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] ## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] ## band    1   6      NA    NA                         NA    NA as.data.frame(l7) %>% head() ##          x       y band L7_ETMs.tif ## 1 288790.5 9120747    1          69 ## 2 288819.0 9120747    1          69 ## 3 288847.5 9120747    1          63 ## 4 288876.0 9120747    1          60 ## 5 288904.5 9120747    1          61 ## 6 288933.0 9120747    1          61 l7 %>% split(\"band\") %>%   as.data.frame() %>%    head() ##          x       y X1 X2 X3 X4 X5 X6 ## 1 288790.5 9120747 69 56 46 79 86 46 ## 2 288819.0 9120747 69 57 49 75 88 49 ## 3 288847.5 9120747 63 52 45 66 75 41 ## 4 288876.0 9120747 60 45 35 66 69 38 ## 5 288904.5 9120747 61 52 44 76 92 60 ## 6 288933.0 9120747 61 50 37 78 74 38"},{"path":"/articles/stars7.html","id":"models-fitted-for-every-pixel","dir":"Articles","previous_headings":"","what":"models fitted for every pixel","title":"7. Statistical modelling with stars objects","text":"can run models many different ways array data. One way run single model pixels, model operates e.g. spectral (band) temporal dimension. example given vignette 2, NDVI computed red near infrared band. NDVI involve estimating parameters, reducing two bands one. example fit model every pixel fit time series model pixel time series, output one model coefficients pixel; shown next.","code":""},{"path":"/articles/stars7.html","id":"linear-regression-on-pixel-time-series","dir":"Articles","previous_headings":"models fitted for every pixel","what":"Linear regression on pixel time series","title":"7. Statistical modelling with stars objects","text":"can read avhrr dataset, containing 9 days: use function computes slope regression line temperature time. get temperatures vector first argument function supplied st_apply, t already defined. function look like optimize bit, using anyNA lm.fit rather lm: result lazily defined (adrop drops singular dimension) computed following command, computations restricted pixels plotted:  interesting pattern appears (despite short time series!): SST reveals main signal colder getting equator, changes SST show much fine grained structures areas going , others going . diverging color ramp better choice , distinguish positive negative trends.","code":"library(stars) x = c(\"avhrr-only-v2.19810901.nc\", \"avhrr-only-v2.19810902.nc\", \"avhrr-only-v2.19810903.nc\", \"avhrr-only-v2.19810904.nc\", \"avhrr-only-v2.19810905.nc\", \"avhrr-only-v2.19810906.nc\", \"avhrr-only-v2.19810907.nc\", \"avhrr-only-v2.19810908.nc\", \"avhrr-only-v2.19810909.nc\") file_list = system.file(paste0(\"netcdf/\", x), package = \"starsdata\") y = read_stars(file_list, sub = \"sst\", quiet = TRUE, proxy = TRUE) (t = st_get_dimension_values(y, 4)) ## [1] \"1981-09-01 UTC\" \"1981-09-02 UTC\" \"1981-09-03 UTC\" \"1981-09-04 UTC\" ## [5] \"1981-09-05 UTC\" \"1981-09-06 UTC\" \"1981-09-07 UTC\" \"1981-09-08 UTC\" ## [9] \"1981-09-09 UTC\" slope = function(x) {   if (any(is.na(x)))     NA_real_   else     coeffients(lm(x~t))[2] } slope = function(x) {   if (anyNA(x))     NA_real_   else     lm.fit(cbind(1, t), x)$coefficients[2] } out = st_apply(adrop(y), c(1,2), slope) plot(out, breaks = \"equal\", main = \"9-day time trend (slope)\") ## downsample set to 1"},{"path":[]},{"path":"/articles/stars7.html","id":"principal-components","dir":"Articles","previous_headings":"Unsupervised learners","what":"Principal components","title":"7. Statistical modelling with stars objects","text":"first example, build principal components entire dataset, rather small.  see, amongst others, PC1 picks difference sea (dark) land, PC2 3 structures sea coastal waters. second example, build principal components sample entire dataset, entire dataset rather large. apply , using predict, pixels shown plot (.e. reduced rather full resolution) plotting , ’ll add country borders delineate sea, obtained mapdata package: plot results independent color ranges, every PC stretched entire grey scale.  suggests PC1 picks difference cloud signal (difference clouds non-clouds), PC2 difference sea land areas, PC4 sensor artefacts (striping swath direction). compute full resolution (10000 x 10000 pixels) results write file, use","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") r = split(read_stars(tif)) pc = prcomp(as.data.frame(r)[,-(1:2)]) # based on all data out = predict(r, pc) plot(merge(out), breaks = \"equal\", join_zlim = FALSE) granule = system.file(\"sentinel/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.zip\",     package = \"starsdata\") s2 = paste0(\"SENTINEL2_L1C:/vsizip/\", granule,  \"/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/MTD_MSIL1C.xml:10m:EPSG_32632\") p = read_stars(s2, proxy = TRUE, NA_value = 0) %>%     split() r = st_sample(p, 1000) pc = prcomp(na.omit(as.data.frame(r))[,-(1:2)]) # based on all data out = predict(p, pc) bb = st_bbox(p) %>%    st_as_sfc() %>%   st_transform(4326) %>%   st_bbox() library(maps) library(mapdata) m = map(\"worldHires\", xlim = bb[c(1,3)], ylim = bb[c(2,4)], plot=F,fill=TRUE) %>%   st_as_sfc() %>%   st_transform(st_crs(r)) plt_boundary = function() plot(m, border = 'orange', add = TRUE) plot(merge(out), hook = plt_boundary, join_zlim = FALSE) ## downsample set to 18 write_stars(merge(out), \"out.tif\")"},{"path":"/articles/stars7.html","id":"k-means-clustering","dir":"Articles","previous_headings":"Unsupervised learners","what":"K-means clustering","title":"7. Statistical modelling with stars objects","text":"small dataset:  seems pick fair number land cover classes: water (5), rural (3), densely populated (1, 2). large(r) dataset:  see class 1 3 identify unclouded area, 3 land, classes seem mainly catch aspects cloud signal.","code":"library(clue) predict.kmeans = function(object, newdata, ...) {     unclass(clue::cl_predict(object, newdata[, -c(1:2)], ...)) } tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") i = read_stars(tif, proxy = TRUE) %>%     split() nclus = 5  sam = st_sample(i, 1000) k = kmeans(na.omit(as.data.frame(sam)[, -c(1:2)]), nclus) out = predict(i, k) plot(out, col = sf.colors(nclus, categorical=TRUE)) i = read_stars(s2, proxy = TRUE, NA_value = 0) %>%     split() sam = st_sample(i, 1000) k = kmeans(na.omit(as.data.frame(sam)[, -c(1:2)]), nclus) out = predict(i, k) plot(out, col = sf.colors(nclus, categorical=TRUE), reset = FALSE) ## downsample set to 18 plot(m, add = TRUE)"},{"path":[]},{"path":"/articles/stars7.html","id":"random-forest-land-use-classification","dir":"Articles","previous_headings":"Supervised learners","what":"Random Forest land use classification","title":"7. Statistical modelling with stars objects","text":"following example purely educational purposes; classified “land use” just rough approximation seems easily visible image: sea, land, areas partially covered clouds. opted therefore four classes: sea, land, clouds sea, clouds land. polygon areas land use classified, residing GeoPackage file. (file created using QGIS, using instructions found .)  Next, need points, sampled inside polygons, need extract satellite spectral data  comes rather trivial finding land sea can well predicted clouds, less trivial finding can reasonably distinguished patchy clouds kind. Note predictions kind pure pixel-based: prediction spectral bands pixel considered, instance neighboring pixels.","code":"# for all, multi-resolution, use: bands = c(\"B04\", \"B03\", \"B02\", \"B08\", \"B01\", \"B05\", \"B06\", \"B07\", \"B8A\", \"B09\", \"B10\", \"B11\", \"B12\") # bands = c(\"B04\", \"B03\", \"B02\", \"B08\") s2 = paste0(\"/vsizip/\", granule,  \"/S2A_MSIL1C_20180220T105051_N0206_R051_T32ULE_20180221T134037.SAFE/GRANULE/L1C_T32ULE_A013919_20180220T105539/IMG_DATA/T32ULE_20180220T105051_\", bands, \".jp2\") r = read_stars(s2, proxy = TRUE, NA_value = 0) %>%     setNames(bands)  cl = read_sf(system.file(\"gpkg/s2.gpkg\", package = \"stars\")) %>%   st_transform(st_crs(r)) plot(r, reset = FALSE) ## downsample set to 8 plot(cl, add = TRUE) plot(m, add = TRUE, border = 'orange') pts = st_sample(cl, 1000, \"regular\") %>%     st_as_sf() %>%     st_intersection(cl) ## Warning: attribute variables are assumed to be spatially constant throughout ## all geometries train = st_extract(r, pts) train$use = as.factor(pts$use) # no need for join, since the order did not change train ## Simple feature collection with 1000 features and 14 fields ## Geometry type: POINT ## Dimension:     XY ## Bounding box:  xmin: 328195.1 ymin: 5909563 xmax: 407928.8 ymax: 5970391 ## Projected CRS: WGS 84 / UTM zone 32N ## First 10 features: ##     B04  B03  B02  B08  B01  B05  B06  B07  B8A  B09 B10  B11  B12 ## 1   921 1139 1396 2375 1744 1180 1860 2099 2396 1006  15 1458  779 ## 2   879 1136 1366 2935 1728 1246 2148 2537 2814  994  14 1669  887 ## 3   870 1029 1338 1872 1694 1076 1567 1765 2042  824  14 1629  856 ## 4  1016 1228 1439 3054 1789 1477 2655 3057 3427 1207  15 2220 1210 ## 5  1010 1145 1449 2039 1782 1302 1724 1975 2144  860  10 1795  999 ## 6  1344 1213 1475 1943 1770 1427 1684 1901 2143  863  14 2276 1365 ## 7  1067 1204 1472 2348 1778 1369 2057 2306 2685 1032  17 2010 1179 ## 8  1035 1144 1437 2289 1760 1299 1891 2246 2637 1042  11 1788  920 ## 9   854 1047 1371 1902 1715 1146 1815 1941 2133  782  16 1568  949 ## 10  941 1155 1379 2802 1689 1380 2268 2595 2976 1058  15 2012 1086 ##                           x  use ## 1  POINT (394518.2 5940525) land ## 2  POINT (390045.1 5931738) land ## 3  POINT (390340.9 5929888) land ## 4    POINT (391254 5938829) land ## 5  POINT (391997.7 5937843) land ## 6  POINT (395680.9 5933296) land ## 7  POINT (388792.2 5934807) land ## 8  POINT (392185.2 5940074) land ## 9  POINT (387142.8 5936359) land ## 10 POINT (390877.6 5927178) land library(randomForest) ## randomForest 4.7-1.1 ## Type rfNews() to see new features/changes/bug fixes. ##  ## Attaching package: 'randomForest' ## The following object is masked from 'package:dplyr': ##  ##     combine train = as.data.frame(train) train$x = NULL # remove geometry rf = randomForest(use ~ ., train) # ~ . : use all other attributes pr = predict(r, rf) plot(pr, reset = FALSE, key.pos = 1) ## downsample set to 8 # add country outline: plot(m, add = TRUE)"},{"path":"/articles/stars7.html","id":"parallel-processing","dir":"Articles","previous_headings":"","what":"Parallel processing","title":"7. Statistical modelling with stars objects","text":"machine learning models support multithreading default (e.g., ranger xgboost), rule. R single-threaded, using appropriate packages can easily parallelize calculations, reduce data processing time. example tutorial showing step--step unsupervised classification using multithreading can found R-Spatial blog.","code":""},{"path":"/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Edzer Pebesma. Author, maintainer. Michael Sumner. Contributor. Etienne Racine. Contributor. Adriano Fantini. Contributor. David Blodgett. Contributor. Krzysztof Dyba. Contributor.","code":""},{"path":"/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Pebesma E, Bivand R (2023). Spatial Data Science: applications R. Chapman Hall/CRC, London. doi:10.1201/9780429459016, https://r-spatial.org/book/.","code":"@Book{,   title = {{Spatial Data Science: With applications in R}},   author = {Edzer Pebesma and Roger Bivand},   year = {2023},   publisher = {Chapman and Hall/CRC},   address = {London},   url = {https://r-spatial.org/book/},   pages = {352},   doi = {10.1201/9780429459016}, }"},{"path":"/index.html","id":"spatiotemporal-arrays-raster-and-vector-datacubes","dir":"","previous_headings":"","what":"Spatiotemporal Arrays, Raster and Vector Data Cubes","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"Spatiotemporal data often comes form dense arrays, space time array dimensions. Examples include socio-economic demographic data, environmental variables monitored fixed stations, raster maps time series satellite images multiple spectral bands, spatial simulations, climate weather model output. R package provides classes methods reading, manipulating, plotting writing data cubes, extent proper formats .","code":""},{"path":"/index.html","id":"raster-and-vector-data-cubes","dir":"","previous_headings":"","what":"Raster and vector data cubes","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"canonical data cube us mind two dimensions represent spatial raster dimensions, third time (band), e.g. shown :  data cubes however also consider higher-dimensional cubes (hypercubes) five-dimensional cube addition time, spectral band sensor form dimensions:  lower-dimensional cubes raster image:  Raster data need regular aligned North/East, package stars supports besides regular also rotated, sheared, rectilinear curvilinear rasters:  Vector data cubes arise two regularly discretized spatial dimensions, single dimension points distinct spatial feature geometries, polygons (e.g. denoting administrative regions):  points (e.g. denoting sensor locations):  NetCDF’s CF-convention calls discrete axis.","code":"suppressPackageStartupMessages(library(dplyr)) library(stars) # Loading required package: abind # Loading required package: sf # Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") read_stars(tif) |>   slice(index = 1, along = \"band\") |>   plot()"},{"path":"/index.html","id":"netcdf-gdal","dir":"","previous_headings":"","what":"NetCDF, GDAL","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"stars provides two functions read data: read_ncdf read_stars, latter reads GDAL. (future, integrated read_stars.) reading NetCDF files, package RNetCDF used, reading GDAL, package sf provides binary linking GDAL. vector raster operations, stars uses much possible routines available GDAL PROJ (e.g. st_transform, rasterize, polygonize, warp). Read vignette vector-raster conversions, reprojection, warping.","code":""},{"path":"/index.html","id":"out-of-memory-on-disk-rasters","dir":"","previous_headings":"","what":"Out-of-memory (on-disk) rasters","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"Package stars provides stars_proxy objects (currently read GDAL), contain dimensions metadata pointers files disk. objects work lazily: reading processing data postponed moment pixels really needed (plot time, writing disk), done lowest spatial resolution possible still fulfills resolution graphics device. details found stars proxy vignette. following methods currently available stars_proxy objects:","code":"methods(class = \"stars_proxy\") #  [1] [               [[<-            [<-             adrop           #  [5] aggregate       aperm           as.data.frame   c               #  [9] coerce          dim             droplevels      filter          # [13] hist            image           initialize      is.na           # [17] Math            merge           mutate          Ops             # [21] plot            predict         print           pull            # [25] rename          select          show            slice           # [29] slotsFromS3     split           st_apply        st_as_sf        # [33] st_as_stars     st_crop         st_dimensions<- st_downsample   # [37] st_mosaic       st_normalize    st_redimension  st_sample       # [41] st_set_bbox     transmute       write_stars     # see '?methods' for accessing help and source code"},{"path":"/index.html","id":"raster-and-vector-time-series-analysis-example","dir":"","previous_headings":"","what":"Raster and vector time series analysis example","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"following, curvilinear grid hourly precipitation values hurricane imported first 12 time steps plotted:  next, intersected counties North Carolina, maximum precipitation intensity obtained per county, plotted:  can integrate (reduce) time, instance find maximum precipitation occurred. following code finds time index, corresponding time value:  package cubble, can make glyph map see magnitude timings county maximum precipitation:","code":"prec_file = system.file(\"nc/test_stageiv_xyt.nc\", package = \"stars\") (prec = read_stars(gdal_subdatasets(prec_file)[[1]])) # stars object with 3 dimensions and 1 attribute # attribute(s): #                                         Min. 1st Qu. Median     Mean 3rd Qu. # Total_precipitation_surface... [kg/m^2]    0       0   0.75 4.143009    4.63 #                                           Max. # Total_precipitation_surface... [kg/m^2] 163.75 # dimension(s): #      from  to                  offset   delta         refsys # x       1  87                      NA      NA WGS 84 (CRS84) # y       1 118                      NA      NA WGS 84 (CRS84) # time    1  23 2018-09-13 19:00:00 UTC 1 hours        POSIXct #                                  values x/y # x    [87x118] -80.61 [°],...,-74.88 [°] [x] # y      [87x118] 32.44 [°],...,37.62 [°] [y] # time                               NULL     # curvilinear grid # or: (prec = read_ncdf(prec_file, curvilinear = c(\"lon\", \"lat\"), ignore_bounds = TRUE)) sf::read_sf(system.file(\"gpkg/nc.gpkg\", package = \"sf\"), \"nc.gpkg\") |>    st_transform(st_crs(prec)) -> nc # transform from NAD27 to WGS84 nc_outline = st_union(st_geometry(nc)) plot_hook = function() plot(nc_outline, border = 'red', add = TRUE) prec |>   slice(index = 1:12, along = \"time\") |>   plot(downsample = c(3, 3, 1), hook = plot_hook) a = aggregate(prec, by = nc, FUN = max) plot(a, max.plot = 23, border = 'grey', lwd = .5) index_max = function(x) ifelse(all(is.na(x)), NA, which.max(x)) b = st_apply(a, \"geom\", index_max) b |>  mutate(when = st_get_dimension_values(a, \"time\")[b$index_max]) |>   select(when) |>   plot(key.pos = 1, main = \"time of maximum precipitation\") library(cubble) #  # Attaching package: 'cubble' # The following object is masked from 'package:stats': #  #     filter library(ggplot2) a |> setNames(\"precip\") |>   st_set_dimensions(2, name = \"tm\") |>   units::drop_units() |>   as_cubble(key = id, index = tm) |>   suppressWarnings() -> a.cb a.cb |>   face_temporal() |>   unfold(long, lat) |>   mutate(tm = as.numeric(tm)) |>   ggplot(aes(x_major = long, x_minor = tm, y_major = lat, y_minor = precip)) +   geom_sf(data = nc, inherit.aes = FALSE) +   geom_glyph_box(width = 0.3, height = 0.1) +   geom_glyph(width = 0.3, height = 0.1) # Warning: There were 84 warnings in `dplyr::mutate()`. # The first warning was: # ℹ In argument: `y = .data$y_major + rescale11(.data$y_minor) * .data$height/2`. # ℹ In group 12: `group = 12`. # Caused by warning in `min()`: # ! no non-missing arguments to min; returning Inf # ℹ Run `dplyr::last_dplyr_warnings()` to see the 83 remaining warnings. # Warning: Removed 966 rows containing missing values or values outside the scale range # (`geom_glyph_box()`). # Warning: Removed 966 rows containing missing values or values outside the scale range # (`geom_glyph()`)."},{"path":[]},{"path":"/index.html","id":"gdalcubes","dir":"","previous_headings":"Other packages for data cubes","what":"gdalcubes","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"Package gdalcubes can used create data cubes (functions ) image collections, sets multi-band images varying spatial resolution spatial extent coordinate reference systems (e.g., spread multiple UTM zones) observation times resampling /aggregating space /time. reuses GDAL VRT’s gdalwarp spatial resampling /warping, handles temporal resampling aggregation .","code":""},{"path":"/index.html","id":"ncdfgeom","dir":"","previous_headings":"Other packages for data cubes","what":"ncdfgeom","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"ncdfgeom reads writes vector data cubes netcdf files standards-compliant way.","code":""},{"path":"/index.html","id":"raster-and-terra","dir":"","previous_headings":"Other packages for data cubes","what":"raster and terra","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"Packages raster successor, terra powerful packages handling raster maps stacks raster maps memory disk, address non-raster time series, multi-attribute rasters time series rasters mixed type attributes (e.g., numeric, logical, factor, POSIXct) rectilinear curvilinear rasters list stars commands matching existing raster commands found wiki. list translations opposite direction (stars raster terra) still needs made. comment differences stars terra found .","code":""},{"path":"/index.html","id":"other-stars-resources","dir":"","previous_headings":"","what":"Other stars resources:","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"blog posts: first, second, third, newer blog posts vignettes original R Consortium proposal.","code":""},{"path":"/index.html","id":"acknowledgment","dir":"","previous_headings":"Other stars resources:","what":"Acknowledgment","title":"Spatiotemporal Arrays, Raster and Vector Data Cubes","text":"project realized financial support ","code":""},{"path":"/reference/L7_ETMs.html","id":null,"dir":"Reference","previous_headings":"","what":"Landsat-7 bands for a selected region around Olinda, BR — L7_ETMs","title":"Landsat-7 bands for a selected region around Olinda, BR — L7_ETMs","text":"Probably containing six 30 m bands: Band 1 Visible (0.45 - 0.52 µm) 30 m Band 2 Visible (0.52 - 0.60 µm) 30 m Band 3 Visible (0.63 - 0.69 µm) 30 m Band 4 Near-Infrared (0.77 - 0.90 µm) 30 m Band 5 Short-wave Infrared (1.55 - 1.75 µm) 30 m Band 7 Mid-Infrared (2.08 - 2.35 µm) 30 m","code":""},{"path":"/reference/L7_ETMs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Landsat-7 bands for a selected region around Olinda, BR — L7_ETMs","text":"","code":"L7_ETMs"},{"path":"/reference/L7_ETMs.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Landsat-7 bands for a selected region around Olinda, BR — L7_ETMs","text":"object class stars_proxy (inherits stars) dimension 349 x 352 x 6.","code":""},{"path":"/reference/aggregate.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"spatially or temporally aggregate stars object — aggregate.stars","title":"spatially or temporally aggregate stars object — aggregate.stars","text":"spatially temporally aggregate stars object, returning data cube lower spatial temporal resolution","code":""},{"path":"/reference/aggregate.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"spatially or temporally aggregate stars object — aggregate.stars","text":"","code":"# S3 method for stars aggregate(   x,   by,   FUN,   ...,   drop = FALSE,   join = st_intersects,   as_points = any(st_dimension(by) == 2, na.rm = TRUE),   rightmost.closed = FALSE,   left.open = FALSE,   exact = FALSE )"},{"path":"/reference/aggregate.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"spatially or temporally aggregate stars object — aggregate.stars","text":"x object class stars information aggregated object class sf sfc spatial aggregation, temporal aggregation vector time values (Date, POSIXct, PCICt) interpreted sequence left-closed, right-open time intervals string like \"months\", \"5 days\" like (see cut.POSIXt), function cuts time intervals; object class stars, converted sfc st_as_sfc(, as_points = FALSE) thus ignoring time component. Note: pixel assigned single group (order groups occur) non-overlapping spatial features temporal windows recommended. FUN aggregation function, mean ... arguments passed FUN, na.rm=TRUE drop logical; ignored join function; function used find matches x as_points see st_as_sf: shall raster pixels taken points, small square polygons? rightmost.closed see findInterval left.open logical; used time intervals, see findInterval cut.POSIXt exact logical; TRUE, use coverage_fraction compute exact overlap fractions polygons raster cells","code":""},{"path":[]},{"path":"/reference/aggregate.stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"spatially or temporally aggregate stars object — aggregate.stars","text":"","code":"# aggregate time dimension in format Date tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") t1 = as.Date(\"2018-07-31\") x = read_stars(c(tif, tif, tif, tif), along = list(time = c(t1, t1+1, t1+2, t1+3)))[,1:30,1:30] st_get_dimension_values(x, \"time\") #> [1] \"2018-07-31\" \"2018-08-01\" \"2018-08-02\" \"2018-08-03\" x_agg_time = aggregate(x, by = t1 + c(0, 2, 4), FUN = max)   # aggregate time dimension in format Date - interval by_t = \"2 days\" x_agg_time2 = aggregate(x, by = by_t, FUN = max)  st_get_dimension_values(x_agg_time2, \"time\") #> [1] \"2018-07-31\" \"2018-08-02\" #TBD: #x_agg_time - x_agg_time2  # aggregate time dimension in format POSIXct x = st_set_dimensions(x, 4, values = as.POSIXct(c(\"2018-07-31\",                                                    \"2018-08-01\",                                                    \"2018-08-02\",                                                    \"2018-08-03\")),                        names = \"time\") by_t = as.POSIXct(c(\"2018-07-31\", \"2018-08-02\")) x_agg_posix = aggregate(x, by = by_t, FUN = max) st_get_dimension_values(x_agg_posix, \"time\") #> [1] \"2018-07-31 UTC\" \"2018-08-02 UTC\" #TBD: # x_agg_time - x_agg_posix aggregate(x, \"2 days\", mean) #> stars object with 4 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43     58 57.58796      70  145 #> dimension(s): #>      from to         offset  delta                     refsys point x/y #> time    1  2 2018-07-31 UTC 2 days                    POSIXct    NA     #> x       1 30         288776   28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 30        9120761  -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6             NA     NA                         NA    NA     if (require(ncmeta, quietly = TRUE)) {  # Spatial aggregation, see https://github.com/r-spatial/stars/issues/299  prec_file = system.file(\"nc/test_stageiv_xyt.nc\", package = \"stars\")  prec = read_ncdf(prec_file, curvilinear = c(\"lon\", \"lat\"))  prec_slice = dplyr::slice(prec, index = 17, along = \"time\")  nc = sf::read_sf(system.file(\"gpkg/nc.gpkg\", package = \"sf\"), \"nc.gpkg\")  nc = st_transform(nc, st_crs(prec_slice))  agg = aggregate(prec_slice, st_geometry(nc), mean)  plot(agg) } #> no 'var' specified, using Total_precipitation_surface_1_Hour_Accumulation #> other available variables: #>  lat, lon, time #> Will return stars object with 236118 cells. #> No projection information found in nc file.  #>  Coordinate variable units found to be degrees,  #>  assuming WGS84 Lat/Lon.   # example of using a function for \"by\": aggregate by month-of-year d = c(10, 10, 150) a = array(rnorm(prod(d)), d) # pure noise times = Sys.Date() + seq(1, 2000, length.out = d[3]) m = as.numeric(format(times, \"%m\")) signal = rep(sin(m / 12 * pi), each = prod(d[1:2])) # yearly period s = (st_as_stars(a) + signal) %>%       st_set_dimensions(3, values = times) f = function(x, format = \"%B\") {     months = format(as.Date(paste0(\"01-\", 1:12, \"-1970\")), format)     factor(format(x, format), levels = months) } agg = aggregate(s, f, mean) plot(agg)"},{"path":"/reference/bcsd_obs.html","id":null,"dir":"Reference","previous_headings":"","what":"Monthly Gridded Meteorological Observations — bcsd_obs","title":"Monthly Gridded Meteorological Observations — bcsd_obs","text":"monthly observational data used BCSD downscaling. See:  information.\" ; \"Atmospheric Temperature, Air Temperature Atmosphere, Precipitation, Rain, Maximum Daily Temperature, Minimum  Daily Temperature\" ;","code":""},{"path":"/reference/bcsd_obs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Monthly Gridded Meteorological Observations — bcsd_obs","text":"","code":"bcsd_obs"},{"path":"/reference/bcsd_obs.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Monthly Gridded Meteorological Observations — bcsd_obs","text":"object class stars_proxy (inherits stars) dimension 81 x 33 x 12.","code":""},{"path":"/reference/c.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"combine multiple stars objects, combine multiple attributes single stars object single array","code":""},{"path":"/reference/c.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"","code":"# S3 method for stars_proxy c(   ...,   along = NA_integer_,   along_crs = FALSE,   try_hard = FALSE,   nms = names(list(...)),   tolerance = sqrt(.Machine$double.eps) )  # S3 method for stars c(   ...,   along = NA_integer_,   try_hard = FALSE,   nms = names(list(...)),   tolerance = sqrt(.Machine$double.eps) )"},{"path":"/reference/c.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"... object(s) class star: case multiple arguments, combined single stars object, case single argument, attributes combined single attribute. case multiple objects, objects dimensionality. along integer; see read_stars along_crs logical; TRUE, combine arrays along CRS dimension try_hard logical; TRUE arrays different dimensions, combine dimensions matching first array nms character; vector array names tolerance numeric; values used .equal compare dimension values combine dimensions matching first array","code":""},{"path":"/reference/c.stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"single stars object merged (binded) arrays.","code":""},{"path":"/reference/c.stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"error raised attempting combine arrays different measurement units single array. intentded, drop_units  can used remove units stars object merging.","code":""},{"path":"/reference/c.stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"combine multiple stars objects, or combine multiple attributes in a single stars object into a single array — c.stars","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) (new = c(x, x)) #> stars object with 3 dimensions and 2 attributes #> attribute(s): #>                Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif       1      54     69 68.91242      86  255 #> L7_ETMs.tif.1     1      54     69 68.91242      86  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     c(new) # collapses two arrays into one with an additional dimension #> stars object with 3 dimensions and 2 attributes #> attribute(s): #>                Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif       1      54     69 68.91242      86  255 #> L7_ETMs.tif.1     1      54     69 68.91242      86  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     c(x, x, along = 3) #> stars object with 3 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>              Min. 1st Qu. Median    Mean 3rd Qu. Max. #> L7_ETMs.tif    47      65     76 77.3419      87  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  12      NA    NA                         NA    NA"},{"path":"/reference/coerce-methods.html","id":null,"dir":"Reference","previous_headings":"","what":"Coerce stars object into a Raster raster or brick — as","title":"Coerce stars object into a Raster raster or brick — as","text":"Coerce stars object Raster raster brick Coerce stars object terra SpatRaster","code":""},{"path":"/reference/coerce-methods.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Coerce stars object into a Raster raster or brick — as","text":"object coerce","code":""},{"path":"/reference/coerce-methods.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Coerce stars object into a Raster raster or brick — as","text":"RasterLayer RasterBrick SpatRaster","code":""},{"path":"/reference/coerce-methods.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Coerce stars object into a Raster raster or brick — as","text":"stars object three dimensions, dimensions higher third collapsed third dimensions. stars object x/y raster multiple attributes, merged first, put raster brick. stars object three dimensions, dimensions higher third collapsed third dimensions. stars object x/y raster multiple attributes, merged first, put SpatRaster.","code":""},{"path":"/reference/contour.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"plot contours of a stars object — contour.stars","title":"plot contours of a stars object — contour.stars","text":"plot contours stars object","code":""},{"path":"/reference/contour.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"plot contours of a stars object — contour.stars","text":"","code":"# S3 method for stars contour(x, ...)"},{"path":"/reference/contour.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"plot contours of a stars object — contour.stars","text":"x object class stars ... parameters passed contour","code":""},{"path":"/reference/contour.stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"plot contours of a stars object — contour.stars","text":"uses R internal contour algorithm, (default) plots contours; st_contour uses GDAL contour algorithm returns contours simple features.","code":""},{"path":"/reference/contour.stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"plot contours of a stars object — contour.stars","text":"","code":"d = st_dimensions(x = 1:ncol(volcano), y = 1:nrow(volcano)) r = st_as_stars(t(volcano)) r = st_set_dimensions(r, 1, offset = 0, delta = 1) r = st_set_dimensions(r, 2, offset = 0, delta = -1) plot(r, reset = FALSE) contour(r, add = TRUE)"},{"path":"/reference/cut_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"cut methods for stars objects — cut_stars","title":"cut methods for stars objects — cut_stars","text":"cut methods stars objects","code":""},{"path":"/reference/cut_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"cut methods for stars objects — cut_stars","text":"","code":"# S3 method for array cut(x, breaks, ...)  # S3 method for matrix cut(x, breaks, ...)  # S3 method for stars cut(x, breaks, ...)"},{"path":"/reference/cut_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"cut methods for stars objects — cut_stars","text":"x see cut breaks see cut ... see cut","code":""},{"path":"/reference/cut_stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"cut methods for stars objects — cut_stars","text":"array matrix levels attribute; see details","code":""},{"path":"/reference/cut_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"cut methods for stars objects — cut_stars","text":"R's factor works vectors, arrays matrices. work-around (hack?) keep factor levels generated cut use plots.","code":""},{"path":"/reference/cut_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"cut methods for stars objects — cut_stars","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) cut(x, c(0, 50, 100, 255)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>     L7_ETMs.tif     #>  (0,50]   :156060   #>  (50,100] :503764   #>  (100,255]: 77264   #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     cut(x[,,,1], c(0, 50, 100, 255)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>     L7_ETMs.tif     #>  (0,50]   :     1   #>  (50,100] :117134   #>  (100,255]:  5713   #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   1      NA    NA                         NA    NA     plot(cut(x[,,,1], c(0, 50, 100, 255)))  tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x1 = read_stars(tif) (x1_cut = cut(x1, breaks = c(0, 50, 100, Inf)))  # shows factor in summary #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>     L7_ETMs.tif     #>  (0,50]   :156060   #>  (50,100] :503764   #>  (100,Inf]: 77264   #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     plot(x1_cut[,,,c(3,6)]) # propagates through [ and plot"},{"path":"/reference/dplyr.html","id":null,"dir":"Reference","previous_headings":"","what":"dplyr verbs for stars objects — dplyr","title":"dplyr verbs for stars objects — dplyr","text":"dplyr verbs stars objects; package dplyr needs loaded methods can used stars objects.","code":""},{"path":"/reference/dplyr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"dplyr verbs for stars objects — dplyr","text":"","code":"filter.stars(.data, ...)  filter.stars_proxy(.data, ...)  mutate.stars(.data, ...)  mutate.stars_proxy(.data, ...)  transmute.stars(.data, ...)  transmute.stars_proxy(.data, ...)  select.stars(.data, ...)  select.stars_proxy(.data, ...)  rename.stars(.data, ...)  rename.stars_proxy(.data, ...)  pull.stars(.data, var = -1)  pull.stars_proxy(.data, ...)  as.tbl_cube.stars(x, ...)  slice.stars(.data, along, index, ..., drop = length(index) == 1)  slice.stars_proxy(.data, along, index, ...)  replace_na.stars(data, replace, ...)  replace_na.stars_proxy(data, ...)"},{"path":"/reference/dplyr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"dplyr verbs for stars objects — dplyr","text":".data object class stars ... see filter var see pull x object class stars along name index dimension slice applied index integer value(s) index drop logical; drop dimensions single index? data data set work replace see replace_na: list variable=value pairs, value replacement value NA's","code":""},{"path":"/reference/dplyr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"dplyr verbs for stars objects — dplyr","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x1 = read_stars(tif) if (require(dplyr, quietly = TRUE)) {  x1 %>% slice(\"band\", 2:3)  x1 %>% slice(\"x\", 50:100) } #>  #> Attaching package: ‘dplyr’ #> The following objects are masked from ‘package:stats’: #>  #>     filter, lag #> The following objects are masked from ‘package:base’: #>  #>     intersect, setdiff, setequal, union #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    11      56     68 70.50099      82  252 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x      50 100  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA"},{"path":"/reference/expand_dimensions.html","id":null,"dir":"Reference","previous_headings":"","what":"expand the dimension values into a list — expand_dimensions","title":"expand the dimension values into a list — expand_dimensions","text":"expand dimension values list","code":""},{"path":"/reference/expand_dimensions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"expand the dimension values into a list — expand_dimensions","text":"","code":"expand_dimensions(x, ...)  # S3 method for dimensions expand_dimensions(x, ..., max = FALSE, center = NA)"},{"path":"/reference/expand_dimensions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"expand the dimension values into a list — expand_dimensions","text":"x object class `stars` `dimensions` ... ignored max logical; `TRUE` return max (end) values dimensions intervals center logical; `TRUE` return center values intervals, otherwise return offset (start) intervals; `NA` (default) return centers x/y dimensions, offsets others","code":""},{"path":"/reference/geom_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"ggplot geom for stars objects — geom_stars","title":"ggplot geom for stars objects — geom_stars","text":"ggplot geom stars objects","code":""},{"path":"/reference/geom_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ggplot geom for stars objects — geom_stars","text":"","code":"geom_stars(   mapping = NULL,   data = NULL,   ...,   downsample = 0,   sf = FALSE,   na.action = na.pass )  theme_stars(...)"},{"path":"/reference/geom_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"ggplot geom for stars objects — geom_stars","text":"mapping see geom_raster data see geom_raster ... see geom_raster downsample downsampling rate: e.g. 3 keeps rows cols 1, 4, 7, 10 etc.; value 0 downsample; can specified dimension, e.g. c(5,5,0) downsample first two dimensions third. sf logical; TRUE rasters converted polygons plotted using geom_sf. na.action function; NA values need removed plotting use value na.omit (applies objects raster dimensions)","code":""},{"path":"/reference/geom_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"ggplot geom for stars objects — geom_stars","text":"geom_stars returns (call ) either geom_raster, geom_tile, geom_sf, depending raster vector geometry; first , aes call constructed raster dimension names first array fill variable. calls coord_equal facet_wrap needed control aspect ratio layers plotted; see examples. stars array contains hex color values, fill parameter given, color values used fill color; see example . visual artefacts occur (Moiré-Effekt), see details section plot.stars","code":""},{"path":"/reference/geom_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"ggplot geom for stars objects — geom_stars","text":"","code":"system.file(\"tif/L7_ETMs.tif\", package = \"stars\") %>% read_stars() -> x if (require(ggplot2, quietly = TRUE)) {   ggplot() + geom_stars(data = x) +     coord_equal() +     facet_wrap(~band) +     theme_void() +     scale_x_discrete(expand=c(0,0))+     scale_y_discrete(expand=c(0,0))   # plot rgb composite:   st_as_stars(L7_ETMs)[,,,1:3] |> st_rgb() -> x # x contains colors as pixel values   ggplot() + geom_stars(data = x) }"},{"path":"/reference/in-methods.html","id":null,"dir":"Reference","previous_headings":"","what":"evaluate whether cube values are in a given set — %in%,stars-method","title":"evaluate whether cube values are in a given set — %in%,stars-method","text":"evaluate whether cube values given set","code":""},{"path":"/reference/in-methods.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"evaluate whether cube values are in a given set — %in%,stars-method","text":"","code":"# S4 method for stars %in%(x, table)"},{"path":"/reference/in-methods.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"evaluate whether cube values are in a given set — %in%,stars-method","text":"x data cube value table values set","code":""},{"path":"/reference/make_intervals.html","id":null,"dir":"Reference","previous_headings":"","what":"create an intervals object — make_intervals","title":"create an intervals object — make_intervals","text":"create intervals object, assuming left-closed right-open intervals","code":""},{"path":"/reference/make_intervals.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"create an intervals object — make_intervals","text":"","code":"make_intervals(start, end)"},{"path":"/reference/make_intervals.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"create an intervals object — make_intervals","text":"start vector start values, 2-column matrix start end values column 1 2, respectively end vector end values","code":""},{"path":"/reference/mdim.html","id":null,"dir":"Reference","previous_headings":"","what":"Read or write data using GDAL's multidimensional array API — mdim","title":"Read or write data using GDAL's multidimensional array API — mdim","text":"Read write data using GDAL's multidimensional array API","code":""},{"path":"/reference/mdim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read or write data using GDAL's multidimensional array API — mdim","text":"","code":"read_mdim(   filename,   variable = character(0),   ...,   options = character(0),   raster = NULL,   offset = integer(0),   count = integer(0),   step = integer(0),   proxy = FALSE,   debug = FALSE,   bounds = TRUE,   curvilinear = NA )  write_mdim(   x,   filename,   driver = detect.driver(filename),   ...,   root_group_options = character(0),   options = character(0),   as_float = TRUE )"},{"path":"/reference/mdim.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read or write data using GDAL's multidimensional array API — mdim","text":"filename name source destination file data source variable name array read; `\"?\"`, list array names returned, group name list element names. ... ignored options character; driver specific options regarding opening (read_mdim) creation (write_mdim) dataset raster names raster variables (default: first two dimensions) offset integer; offset dimension (pixels) sub-array read, defaults 0 dimension(requires sf >= 1.0-9) count integer; size dimension (pixels) sub-array read (default: read ); value NA read corresponding dimension entirely; counts relative step size (requires sf >= 1.0-9) step integer; step size dimension (pixels) sub-array read; defaults 1 dimension (requires sf >= 1.0-9) proxy logical; return proxy object? (functional yet) debug logical; print debug info? bounds logical character: TRUE tries infer \"bounds\" attribute; character,  named vector form c(longitude=\"lon_bnds\", latitude=\"lat_bnds\") names dimension names curvilinear control reading curvilinear (geolocation) coordinate arrays; NA try reading x/y dimension names; character, defines arrays read; FALSE try; see also read_stars x stars object driver character; driver name root_group_options character; driver specific options regarding creation root group as_float logical; TRUE write 4-byte floating point numbers, FALSE write 8-byte doubles","code":""},{"path":"/reference/mdim.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Read or write data using GDAL's multidimensional array API — mdim","text":"assumed first two dimensions easting northing","code":""},{"path":[]},{"path":"/reference/mdim.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read or write data using GDAL's multidimensional array API — mdim","text":"","code":"set.seed(135) m = matrix(runif(10), 2, 5) names(dim(m)) = c(\"stations\", \"time\") times = as.Date(\"2022-05-01\") + 1:5 pts = st_as_sfc(c(\"POINT(0 1)\", \"POINT(3 5)\")) s = st_as_stars(list(Precipitation = m)) |>  st_set_dimensions(1, values = pts) |>  st_set_dimensions(2, values = times) nc = tempfile(fileext=\".nc\") if (compareVersion(sf_extSoftVersion()[\"GDAL\"], \"3.4.0\") > -1) {   write_mdim(s, nc)   # try ncdump on the generated file   print(read_mdim(nc)) } #> Warning: GDAL Error 6: SetIndexingVariable() not implemented #> Warning: GDAL Error 6: SetIndexingVariable() not implemented #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>                      Min.   1st Qu.    Median      Mean  3rd Qu.      Max. #> Precipitation  0.03524588 0.3224987 0.3772574 0.4289465 0.511113 0.9204841 #> dimension(s): #>          from to     offset  delta refsys point                   values #> stations    1  2         NA     NA     NA  TRUE POINT (0 1), POINT (3 5) #> time        1  5 2022-05-02 1 days   Date    NA                     NULL"},{"path":"/reference/merge.html","id":null,"dir":"Reference","previous_headings":"","what":"merge or split stars object — merge","title":"merge or split stars object — merge","text":"merge attributes dimension, split dimension attributes","code":""},{"path":"/reference/merge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"merge or split stars object — merge","text":"","code":"# S3 method for stars split(x, f = length(dim(x)), drop = TRUE, ...)  # S3 method for stars merge(x, y, ..., name = \"attributes\")"},{"path":"/reference/merge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"merge or split stars object — merge","text":"x object class stars f name index dimension split; default last dimension drop ignored ... defined, first unnamed argument used dimension values, defined, attribute names used dimension values y needs missing name name new dimension","code":""},{"path":"/reference/merge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"merge or split stars object — merge","text":"merge merges attributes stars object new dimension; split splits dimension attributes","code":""},{"path":"/reference/merge.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"merge or split stars object — merge","text":"split.stars works first attribute, give error one attribute present","code":""},{"path":"/reference/ops_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"S3 Ops Group Generic Functions for stars objects — ops_stars","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"Ops functions stars objects, including comparison, product divide, add, subtract","code":""},{"path":"/reference/ops_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"","code":"# S3 method for stars Ops(e1, e2)  # S3 method for stars Math(x, ...)  # S3 method for stars_proxy Ops(e1, e2)  # S3 method for stars_proxy Math(x, ...)"},{"path":"/reference/ops_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"e1 object class stars e2 object class stars x object class stars ... parameters passed Math functions","code":""},{"path":"/reference/ops_stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"object class stars","code":""},{"path":"/reference/ops_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"e1 e2 numeric vector, e2 less smaller dimensions e1, e2 recycled fits e1, using usual R array recycling rules. user needs make sure sensible; may needed use aperm permutate dimensions first.","code":""},{"path":"/reference/ops_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"S3 Ops Group Generic Functions for stars objects — ops_stars","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) x * x #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median    Mean 3rd Qu.  Max. #> L7_ETMs.tif     1    2916   4761 5512.41    7396 65025 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x / x #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median Mean 3rd Qu. Max. #> L7_ETMs.tif     1       1      1    1       1    1 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x + x #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     2     108    138 137.8248     172  510 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x + 10 #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    11      64     79 78.91242      96  265 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     all.equal(x * 10, 10 * x) #> [1] TRUE tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) a = sqrt(x) b = log(x, base = 10)"},{"path":"/reference/plot.html","id":null,"dir":"Reference","previous_headings":"","what":"plot stars object, with subplots for each level of first non-spatial dimension — plot","title":"plot stars object, with subplots for each level of first non-spatial dimension — plot","text":"plot stars object, subplots level first non-spatial dimension, customization legend key","code":""},{"path":"/reference/plot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"plot stars object, with subplots for each level of first non-spatial dimension — plot","text":"","code":"# S3 method for nc_proxy plot(x, y, ..., downsample = get_downsample(dim(x)), max_times = 16)  # S3 method for stars plot(   x,   y,   ...,   join_zlim = TRUE,   main = make_label(x, 1),   axes = FALSE,   downsample = TRUE,   nbreaks = 11,   breaks = \"quantile\",   col = grey(1:(nbreaks - 1)/nbreaks),   key.pos = get_key_pos(x, ...),   key.width = kw_dflt(x, key.pos),   key.length = 0.618,   key.lab = main,   reset = TRUE,   box_col = NA,   center_time = FALSE,   hook = NULL,   mfrow = NULL,   compact = TRUE )  # S3 method for stars image(   x,   ...,   band = 1,   attr = 1,   asp = NULL,   rgb = NULL,   maxColorValue = ifelse(inherits(rgb, \"data.frame\"), 255, max(x[[attr]], na.rm = TRUE)),   xlab = if (!axes) \"\" else names(d)[1],   ylab = if (!axes) \"\" else names(d)[2],   xlim = st_bbox(extent)$xlim,   ylim = st_bbox(extent)$ylim,   text_values = FALSE,   text_color = \"black\",   axes = FALSE,   interpolate = FALSE,   as_points = FALSE,   key.pos = NULL,   logz = FALSE,   key.width = kw_dflt(x, key.pos),   key.length = 0.618,   add.geom = NULL,   border = NA,   useRaster = isTRUE(dev.capabilities()$rasterImage == \"yes\"),   extent = x )  # S3 method for stars_proxy plot(x, y, ..., downsample = get_downsample(dim(x)))"},{"path":"/reference/plot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"plot stars object, with subplots for each level of first non-spatial dimension — plot","text":"x object class stars y ignored ... arguments: plot, passed image.stars; image, passed image.default rasterImage. downsample logical numeric; TRUE try plot many pixels actually visible, FALSE, downsampling takes place, numeric, number pixels/lines/bands etc skipped; see Details. max_times integer; maximum number time steps attempt plot. join_zlim logical; TRUE, compute single, joint zlim (color scale) subplots x main character; subplot title prefix; use \"\" get time, use NULL suppress subplot titles axes logical; axes box added plot? nbreaks number color breaks; one number colors. missing col specified, derived . breaks numeric vector actual color breaks, style name used classIntervals. col colors use grid cells, color palette function key.pos numeric; side plot color key: 1 bottom, 2 left, 3 top, 4 right; set NULL omit key. Ignored multiple columns plotted single function call. Default depends plot size, map aspect, , set, parameter asp. length 2, second value, ranging 0 1, determines key placed available space (default: 0.5, center). key.width amount space reserved width key (labels); relative absolute (using lcm) key.length amount space reserved length key (labels); relative absolute (using lcm) key.lab character; label color key case multiple subplots, use \"\" suppress reset logical; FALSE, keep plot mode allows adding map elements; TRUE restore original mode plotting box_col color box around sub-plots; use NA suppress plotting boxes around sub-plots. center_time logical; TRUE, sub-plot titles show center time intervals, otherwise start hook NULL function; hook function called every sub-plot; see examples. mfrow length-2 integer vector nrows, ncolumns composite plot, override default layout compact logical; place facets compactly (TRUE), spread plotting device area? band integer; band (dimension) plot attr integer; attribute plot asp numeric; aspect ratio image rgb integer; specify three bands form rgb composite. Experimental: rgb color table; see Details. maxColorValue numeric; passed rgb xlab character; x axis label ylab character; y axis label xlim x axis limits ylim y axis limits text_values logical; print values text image? text_color character; color printed text values interpolate logical; using rasterImage (rgb), pixels interpolated? as_points logical; curvilinear sheared grids: parameter passed st_as_sf, determining whether raster cells plotted symbols (fast, approximate) small polygons (slow, exact) logz logical; TRUE, use log10-scale attribute variable. case, breaks need given log10-values; see examples. add.geom object class sfc, list arguments plot, added image sub-image border color used cell borders (case x curvilinear rotated/sheared grid) useRaster logical; use rasterImage capabilities graphics device? extent object st_bbox method; sets plotting extent","code":""},{"path":"/reference/plot.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"plot stars object, with subplots for each level of first non-spatial dimension — plot","text":"plotting subsetted stars_proxy object, default value argument downsample computed correctly, set manually. Downsampling: value downsample 0: downsampling, 1: every dimension value (pixel/line/band), one value skipped (half original resolution), 2: every dimension value, 2 values skipped (one third original resolution), etc. downsample TRUE length 1 numeric vector, downsampling applied raster [x] [y] dimensions. remove unused classes categorical raster, use droplevels function. bitmaps show visual artefacts (Moiré effects), make sure device png used rather ragg::agg_png latter uses antialiasing filled polygons causes ; see also https://github.com/r-spatial/stars/issues/573 . use rgb color table experimental; see https://github.com/r-spatial/mapview/issues/208 plotting subsetted stars_proxy object, default value argument downsample computed correctly, set manually.","code":""},{"path":"/reference/plot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"plot stars object, with subplots for each level of first non-spatial dimension — plot","text":"","code":"st_bbox(L7_ETMs) |> st_as_sfc() |> st_centroid() |> st_coordinates() -> pt hook1 = function() {     text(pt[,\"X\"], pt[,\"Y\"], \"foo\", col = 'orange', cex = 2) } plot(L7_ETMs, hook = hook1)  x = st_set_dimensions(L7_ETMs, 3, paste0(\"B_\", 1:6)) hook2 = function(..., row, col, nr, nrow, ncol, value, bbox) {    str = paste0(\"row \", row, \"/\", nrow, \", col \", col, \"/\", ncol, \"\\nnr: \", nr, \" value: \", value)    bbox |> st_as_sfc() |> st_centroid() |> st_coordinates() -> pt    text(pt[,\"X\"], pt[,\"Y\"], str, col = 'red', cex = 2) } plot(x, hook = hook2, col = grey(c(.2,.25,.3,.35)))  if (isTRUE(dev.capabilities()$rasterImage == \"yes\")) {   lc = read_stars(system.file(\"tif/lc.tif\", package = \"stars\"))   levels(lc[[1]]) = abbreviate(levels(lc[[1]]), 6) # so it's not only legend   plot(lc, key.pos=4) } tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) image(x, col = grey((3:9)/10))  if (isTRUE(dev.capabilities()$rasterImage == \"yes\")) {   image(x, rgb = c(1,3,5)) # false color composite }"},{"path":"/reference/prcomp.html","id":null,"dir":"Reference","previous_headings":"","what":"Principle components of stars object — prcomp","title":"Principle components of stars object — prcomp","text":"Compute principle components stars object","code":""},{"path":"/reference/prcomp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Principle components of stars object — prcomp","text":"","code":"# S3 method for stars_proxy prcomp(x, ..., downsample = 0)  # S3 method for stars prcomp(x, ..., quiet = FALSE)"},{"path":"/reference/prcomp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Principle components of stars object — prcomp","text":"x object class `stars` `stars_proxy` ... see prcomp downsample see st_as_stars quiet logical; `TRUE`, suppress message PCs computed last dimension; see details","code":""},{"path":"/reference/prcomp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Principle components of stars object — prcomp","text":"object class `prcomp`, see prcomp","code":""},{"path":"/reference/prcomp.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Principle components of stars object — prcomp","text":"`x` one attribute, principle components computed space last dimension `x` predict PC scores `stars` object, use predict.stars; see example ","code":""},{"path":"/reference/prcomp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Principle components of stars object — prcomp","text":"","code":"l7 = split(st_as_stars(L7_ETMs), 3) # use bands as features l7 |> prcomp() |> plot()  l7 |> prcomp() |> predict(l7, model = _) |> merge() |> plot() #> downsample set to 1"},{"path":"/reference/predict.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict values, given a model object, for a stars or stars_proxy object — predict.stars","title":"Predict values, given a model object, for a stars or stars_proxy object — predict.stars","text":"Predict values, given model object, stars stars_proxy object","code":""},{"path":"/reference/predict.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict values, given a model object, for a stars or stars_proxy object — predict.stars","text":"","code":"# S3 method for stars_proxy predict(object, model, ...)  # S3 method for stars predict(object, model, ..., drop_dimensions = FALSE)"},{"path":"/reference/predict.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict values, given a model object, for a stars or stars_proxy object — predict.stars","text":"object object class `stars` model model object class predict method; check `methods(class = class(object))` ... arguments passed predict method drop_dimensions logical; `TRUE`, remove dimensions (coordinates etc) `data.frame` predictors","code":""},{"path":"/reference/predict.stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Predict values, given a model object, for a stars or stars_proxy object — predict.stars","text":"separate predictors object need separate attributes object;  case e.g. band dimension, use `split(object)`","code":""},{"path":"/reference/print_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"print stars or dimensions object — print_stars","title":"print stars or dimensions object — print_stars","text":"print stars dimensions object","code":""},{"path":"/reference/print_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"print stars or dimensions object — print_stars","text":"","code":"# S3 method for dimensions as.data.frame(   x,   ...,   digits = max(3, getOption(\"digits\") - 3),   usetz = TRUE,   stars_crs = getOption(\"stars.crs\") %||% 28,   all = FALSE )  # S3 method for dimensions print(x, ...)  # S3 method for stars print(x, ..., n = 1e+05, abbrev = 30)"},{"path":"/reference/print_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"print stars or dimensions object — print_stars","text":"x object class stars class dimensions ... passed .data.frame.dimensions digits number digits print numbers usetz logical; used format PCICt POSIXct values stars_crs maximum width string CRS objects logical; TRUE print also fields entirely filled NA NULL n prod(dim(x)) > 10 * n, first n cells used attribute summary statistics abbrev number characters abbreviate attribute names ","code":""},{"path":"/reference/read_ncdf.html","id":null,"dir":"Reference","previous_headings":"","what":"Read NetCDF into stars object — read_ncdf","title":"Read NetCDF into stars object — read_ncdf","text":"Read data file (source) using NetCDF library directly.","code":""},{"path":"/reference/read_ncdf.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read NetCDF into stars object — read_ncdf","text":"","code":"read_ncdf(   .x,   ...,   var = NULL,   ncsub = NULL,   curvilinear = character(0),   eps = sqrt(.Machine$double.eps),   ignore_bounds = FALSE,   make_time = TRUE,   make_units = TRUE,   proxy = NULL,   downsample = 0 )"},{"path":"/reference/read_ncdf.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read NetCDF into stars object — read_ncdf","text":".x NetCDF file source character vector nc_proxy object. ... ignored var variable name names (must matching grids) ncsub matrix start, count columns (see Details) curvilinear length two character named vector names variables holding longitude latitude values raster cells. `stars` attempts figure appropriate curvilinear coordinates supplied. eps numeric; dimension value increases considered identical differ less eps ignore_bounds logical; bounds values dimensions, present, ignored? make_time TRUE (default), attempt made provide date-time class \"time\" variable make_units TRUE (default), attempt made set units property variable proxy logical; TRUE, object class stars_proxy read contains array metadata ; FALSE full array data read memory. set, defaults TRUE number cells read larger options(stars.n_proxy), 1e8 option set. downsample integer; number cells omit samples along dimension.  e.g. c(1,1,2) return every cell x y every third cell third dimension (z t). 0, downsampling applied. Note transformation applied NetCDF data read using st_downsample. , proxy=TRUE,  option ignored.","code":""},{"path":"/reference/read_ncdf.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Read NetCDF into stars object — read_ncdf","text":"following logic applied coordinates. coordinate axes regularly spaced coordinate variables reduced offset/delta form 'affine = c(0, 0)', otherwise values coordinates stored used define rectilinear grid. data two dimensions first two regular nominated 'raster' plotting. curvilinear argument used specifies 2D arrays containing coordinate values first two dimensions data read. currently assumed coordinates 2D relate first two dimensions order. var set first set variables shared grid used. start count columns ncsub must correspond variable dimension (nrows) valid index using var.get.nc convention (start 1-based). count value NA steps included. Axis order must match variable/s read.","code":""},{"path":"/reference/read_ncdf.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read NetCDF into stars object — read_ncdf","text":"","code":"f <- system.file(\"nc/reduced.nc\", package = \"stars\") if (require(ncmeta, quietly = TRUE)) {  read_ncdf(f)  read_ncdf(f, var = c(\"anom\"))  read_ncdf(f, ncsub = cbind(start = c(1, 1, 1, 1), count = c(10, 12, 1, 1))) } #> no 'var' specified, using sst, anom, err, ice #> other available variables: #>  lon, lat, zlev, time #> 0-360 longitude crossing the international date line encountered. #> Longitude coordinates will be 0-360 in output. #> Will return stars object with 16200 cells. #> No projection information found in nc file.  #>  Coordinate variable units found to be degrees,  #>  assuming WGS84 Lat/Lon. #> 0-360 longitude crossing the international date line encountered. #> Longitude coordinates will be 0-360 in output. #> Will return stars object with 16200 cells. #> No projection information found in nc file.  #>  Coordinate variable units found to be degrees,  #>  assuming WGS84 Lat/Lon. #> no 'var' specified, using sst, anom, err, ice #> other available variables: #>  lon, lat, zlev, time #> Will return stars object with 120 cells. #> No projection information found in nc file.  #>  Coordinate variable units found to be degrees,  #>  assuming WGS84 Lat/Lon. #> stars object with 4 dimensions and 4 attributes #> attribute(s): #>                Min. 1st Qu. Median        Mean 3rd Qu. Max. NA's #> sst [°C]      -1.39 -0.7200 -0.515 -0.53399999  -0.275 0.03   90 #> anom [°C]     -1.07 -0.3625  0.195  0.05866667   0.555 0.92   90 #> err [°C]       0.30  0.3000  0.300  0.30299999   0.300 0.32   90 #> ice [percent]  0.01  0.1100  0.170  0.20937500   0.255 0.52  104 #> dimension(s): #>      from to offset delta  refsys         values x/y #> lon     1 10     -1     2  WGS 84           NULL [x] #> lat     1 12    -90     2  WGS 84           NULL [y] #> zlev    1  1     NA    NA      NA              0     #> time    1  1     NA    NA POSIXct 1981-12-31 UTC      if (require(ncmeta, quietly = TRUE)) {  #' precipitation data in a curvilinear NetCDF  prec_file = system.file(\"nc/test_stageiv_xyt.nc\", package = \"stars\")  prec = read_ncdf(prec_file, curvilinear = c(\"lon\", \"lat\"), ignore_bounds = TRUE) } #> no 'var' specified, using Total_precipitation_surface_1_Hour_Accumulation #> other available variables: #>  lat, lon, time #> Will return stars object with 236118 cells. #> No projection information found in nc file.  #>  Coordinate variable units found to be degrees,  #>  assuming WGS84 Lat/Lon.  ##plot(prec) ## gives error about unique breaks ## remove NAs, zeros, and give a large number ## of breaks (used for validating in detail) qu_0_omit = function(x, ..., n = 22) {   x = units::drop_units(na.omit(x))   c(0, quantile(x[x > 0], seq(0, 1, length.out = n))) } if (require(dplyr, quietly = TRUE)) {   prec_slice = slice(prec, index = 17, along = \"time\")   plot(prec_slice, border = NA, breaks = qu_0_omit(prec_slice[[1]]), reset = FALSE)   nc = sf::read_sf(system.file(\"gpkg/nc.gpkg\", package = \"sf\"), \"nc.gpkg\")   plot(st_geometry(nc), add = TRUE, reset = FALSE, col = NA) }"},{"path":"/reference/read_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"read raster/array dataset from file or connection — read_stars","title":"read raster/array dataset from file or connection — read_stars","text":"read raster/array dataset file connection","code":""},{"path":"/reference/read_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"read raster/array dataset from file or connection — read_stars","text":"","code":"read_stars(   .x,   sub = TRUE,   ...,   options = character(0),   driver = character(0),   quiet = FALSE,   NA_value = NA_real_,   along = NA_integer_,   RasterIO = list(),   proxy = getOption(\"stars.n_proxy\") %||% 1e+08,   curvilinear = character(0),   normalize_path = TRUE,   RAT = character(0),   tolerance = 1e-10,   exclude = \"\",   shorten = TRUE )"},{"path":"/reference/read_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"read raster/array dataset from file or connection — read_stars","text":".x character vector name(s) file(s) data source(s) read, function returns vector sub character, integer logical; name, index indicator sub-dataset(s) read ... passed st_as_stars curvilinear set options character; opening options driver character; driver use opening file. override fixing subdatasets autodetect well, use NULL. quiet logical; print progress output? NA_value numeric value used conversion NA values; default read input file along length-one character integer, list; determines several arrays combined, see Details. RasterIO list named parameters GDAL's RasterIO, control extent, resolution bands read data source; see details. proxy logical; TRUE, object class stars_proxy read contains array metadata ; FALSE full array data read memory. Always FALSE curvilinear girds. set number, defaults TRUE number cells read larger number. curvilinear length two character vector names subdatasets holding longitude latitude values raster cells, named length 2 list holding longitude latitude matrices; names list correspond raster dimensions referred normalize_path logical; FALSE, suppress call normalizePath .x RAT character; raster attribute table column name use factor levels tolerance numeric; passed .equal comparing dimension parameters. exclude character; vector category value(s) exclude shorten logical character; TRUE length(.x) > 1, remove common start end parts array names; character new prefix","code":""},{"path":"/reference/read_stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"read raster/array dataset from file or connection — read_stars","text":"object class stars","code":""},{"path":"/reference/read_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"read raster/array dataset from file or connection — read_stars","text":"case .x contains multiple files, read combined c.stars. Along dimension, objects merged? along set NA merge arrays new attributes objects identical dimensions, else try merge along time dimension called time indicates different time stamps. single name (positive value) along merge along dimension, create new one already exist. arrays arranged along one dimensions values (e.g. time stamps), named list can passed along specify ; see example. RasterIO list zero following named arguments: nXOff, nYOff (1-based: first row/col offset value 1), nXSize, nYSize, nBufXSize, nBufYSize, bands, resample. See https://gdal.org/doxygen/classGDALDataset.html meaning; bands integer vector containing band numbers read (1-based: first band 1). Note nBufXSize nBufYSize specified downsampling image, resulting adjusted geotransform. resample reflects resampling method one : \"nearest_neighbour\" (default), \"bilinear\", \"cubic\", \"cubic_spline\", \"lanczos\", \"average\", \"mode\", \"Gauss\". Data read memory (proxy=FALSE) read numeric (double) array, except categorical variables read numeric (integer) array class factor.","code":""},{"path":"/reference/read_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"read raster/array dataset from file or connection — read_stars","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") (x1 = read_stars(tif)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     1      54     69 68.91242      86  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     (x2 = read_stars(c(tif, tif))) #> stars object with 3 dimensions and 2 attributes #> attribute(s): #>                Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif       1      54     69 68.91242      86  255 #> L7_ETMs.tif.1     1      54     69 68.91242      86  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     (x3 = read_stars(c(tif, tif), along = \"band\")) #> stars object with 3 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>              Min. 1st Qu. Median    Mean 3rd Qu. Max. #> L7_ETMs.tif    47      65     76 77.3419      87  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  12      NA    NA                         NA    NA     (x4 = read_stars(c(tif, tif), along = \"new_dimensions\")) # create 4-dimensional array #> stars object with 4 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>              Min. 1st Qu. Median    Mean 3rd Qu. Max. #> L7_ETMs.tif    47      65     76 77.3419      87  255 #> dimension(s): #>                from  to  offset delta                     refsys point x/y #> x                 1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y                 1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band              1   6      NA    NA                         NA    NA     #> new_dimensions    1   2      NA    NA                         NA    NA     x1o = read_stars(tif, options = \"OVERVIEW_LEVEL=1\") t1 = as.Date(\"2018-07-31\") # along is a named list indicating two dimensions: read_stars(c(tif, tif, tif, tif), along = list(foo = c(\"bar1\", \"bar2\"), time = c(t1, t1+2))) #> stars object with 5 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>              Min. 1st Qu. Median    Mean 3rd Qu. Max. #> L7_ETMs.tif    47      65     76 77.3419      87  255 #> dimension(s): #>      from  to     offset  delta                     refsys point     values x/y #> x       1 349     288776   28.5 SIRGAS 2000 / UTM zone 25S FALSE       NULL [x] #> y       1 352    9120761  -28.5 SIRGAS 2000 / UTM zone 25S FALSE       NULL [y] #> band    1   6         NA     NA                         NA    NA       NULL     #> foo     1   2         NA     NA                         NA    NA bar1, bar2     #> time    1   2 2018-07-31 2 days                       Date    NA       NULL      m = matrix(1:120, nrow = 12, ncol = 10) dim(m) = c(x = 10, y = 12) # named dim st = st_as_stars(m) attr(st, \"dimensions\")$y$delta = -1 attr(st, \"dimensions\")$y$offset = 12 st #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1     1   30.75   60.5 60.5   90.25  120 #> dimension(s): #>   from to offset delta point x/y #> x    1 10      0     1 FALSE [x] #> y    1 12     12    -1 FALSE [y] tmp = tempfile(fileext = \".tif\") write_stars(st, tmp) (red <- read_stars(tmp)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>                       Min. 1st Qu. Median Mean 3rd Qu. Max. #> file21d014e9bb37.tif     1   30.75   60.5 60.5   90.25  120 #> dimension(s): #>   from to offset delta x/y #> x    1 10      0     1 [x] #> y    1 12     12    -1 [y] read_stars(tmp, RasterIO = list(nXOff = 1, nYOff = 1, nXSize = 10, nYSize = 12,    nBufXSize = 2, nBufYSize = 2))[[1]] #>      [,1] [,2] #> [1,]   33   93 #> [2,]   38   98 (red <- read_stars(tmp, RasterIO = list(nXOff = 1, nYOff = 1, nXSize = 10, nYSize = 12,    nBufXSize = 2, nBufYSize = 2))) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>                       Min. 1st Qu. Median Mean 3rd Qu. Max. #> file21d014e9bb37.tif    33   36.75   65.5 65.5   94.25   98 #> dimension(s): #>   from to offset delta x/y #> x    1  2      0     5 [x] #> y    1  2     12    -6 [y] red[[1]] # cell values of subsample grid: #>      [,1] [,2] #> [1,]   33   93 #> [2,]   38   98 if (FALSE) {   plot(st, reset = FALSE, axes = TRUE, ylim = c(-.1,12.1), xlim = c(-.1,10.1),     main = \"nBufXSize & nBufYSize demo\", text_values = TRUE)   plot(st_as_sfc(red, as_points = TRUE), add = TRUE, col = 'red', pch = 16)   plot(st_as_sfc(st_as_stars(st), as_points = FALSE), add = TRUE, border = 'grey')   plot(st_as_sfc(red, as_points = FALSE), add = TRUE, border = 'green', lwd = 2) } file.remove(tmp) #> [1] TRUE"},{"path":"/reference/redimension.html","id":null,"dir":"Reference","previous_headings":"","what":"redimension array, or collapse attributes into a new dimension — redimension","title":"redimension array, or collapse attributes into a new dimension — redimension","text":"redimension array, collapse attributes new dimension","code":""},{"path":"/reference/redimension.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"redimension array, or collapse attributes into a new dimension — redimension","text":"","code":"# S3 method for stars_proxy st_redimension(   x,   new_dims = st_dimensions(x),   along = list(new_dim = names(x)),   ... )  st_redimension(x, new_dims, along, ...)  # S3 method for stars st_redimension(   x,   new_dims = st_dimensions(x),   along = setNames(list(names(x)), name),   ...,   name = \"new_dim\" )"},{"path":"/reference/redimension.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"redimension array, or collapse attributes into a new dimension — redimension","text":"x object class stars new_dims target dimensions: either `dimensions` object integer vector dimensions' sizes along named list new dimension name values ... ignored name character name new dimension","code":""},{"path":"/reference/st_apply.html","id":null,"dir":"Reference","previous_headings":"","what":"st_apply apply a function to one or more array dimensions — st_apply","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"st_apply apply function array dimensions: aggregate space, time, something else","code":""},{"path":"/reference/st_apply.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"","code":"# S3 method for stars st_apply(   X,   MARGIN,   FUN,   ...,   CLUSTER = NULL,   PROGRESS = FALSE,   FUTURE = FALSE,   rename = TRUE,   .fname,   single_arg = has_single_arg(FUN, list(...)) || can_single_arg(FUN),   keep = FALSE )"},{"path":"/reference/st_apply.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"X object class stars MARGIN see apply; index number(s) name(s) dimensions FUN applied FUN see apply see Details. ... arguments passed FUN CLUSTER cluster use parallel apply; see makeCluster PROGRESS logical; TRUE, use pbapply::pbapply show progress bar FUTURE logical;TRUE, use future.apply::future_apply rename logical; TRUE X one attribute  FUN simple function name, rename attribute returned object  function name .fname function name new attribute name (one  dimensions reduced) new dimension (new dimension created);  missing, name FUN used single_arg logical; TRUE, FUN takes single argument (like fn_ndvi1 ),  FALSE FUN takes multiple arguments (like fn_ndvi2 ). keep logical; TRUE, preserve dimension metadata (e.g. time stamps)","code":""},{"path":"/reference/st_apply.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"object class stars accordingly reduced number dimensions;  case FUN returns one value, new dimension created carrying  name function used; see examples. Following logic  apply, new dimension put dimensions; use aperm rearrange , see last example.","code":""},{"path":"/reference/st_apply.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"FUN function either operates single object,  data iteration step dimensions MARGIN, function  many arguments elements object. See NDVI  examples . second form can much faster e.g. trivial  function called every pixel, (example). heuristics default single_arg work often, always; try setting right value st_apply gives error.","code":""},{"path":"/reference/st_apply.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"st_apply apply a function to one or more array dimensions — st_apply","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) st_apply(x, 1:2, mean) # mean band value for each pixel #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>       Min.  1st Qu.   Median     Mean 3rd Qu. Max. #> mean  25.5 53.33333 68.33333 68.91242      82  255 #> dimension(s): #>   from  to  offset delta                     refsys point x/y #> x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] st_apply(x, c(\"x\", \"y\"), mean) # equivalent to the above #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>       Min.  1st Qu.   Median     Mean 3rd Qu. Max. #> mean  25.5 53.33333 68.33333 68.91242      82  255 #> dimension(s): #>   from  to  offset delta                     refsys point x/y #> x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] st_apply(x, 3, mean)   # mean of all pixels for each band #> stars object with 1 dimensions and 1 attribute #> attribute(s): #>           Min.  1st Qu.   Median     Mean  3rd Qu.     Max. #> mean  59.23541 61.07112 65.96675 68.91242 76.25445 83.18266 #> dimension(s): #>      from to #> band    1  6 if (FALSE) {  st_apply(x, \"band\", mean) # equivalent to the above  st_apply(x, 1:2, range) # min and max band value for each pixel  fn_ndvi1 = function(x) (x[4]-x[3])/(x[4]+x[3]) # ONE argument: will be called for each pixel  fn_ndvi2 = function(red,nir) (nir-red)/(nir+red) # n arguments: will be called only once  ndvi1 = st_apply(x, 1:2, fn_ndvi1)    # note that we can select bands 3 and 4 in the first argument:  ndvi2 = st_apply(x[,,,3:4], 1:2, fn_ndvi2)   all.equal(ndvi1, ndvi2)  # compute the (spatial) variance of each band; https://github.com/r-spatial/stars/issues/430  st_apply(x, 3, function(x) var(as.vector(x))) # as.vector is required!  # to get a progress bar also in non-interactive mode, specify:  if (require(pbapply)) { # install it, if FALSE    pboptions(type = \"timer\")  }  st_apply(x, 1:2, range) # dimension \"range\" is first; rearrange by:  st_apply(x, 1:2, range) %>% aperm(c(2,3,1)) }"},{"path":"/reference/st_as_sf.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert stars object into an sf object — st_as_sf","title":"Convert stars object into an sf object — st_as_sf","text":"Convert stars object sf object","code":""},{"path":"/reference/st_as_sf.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert stars object into an sf object — st_as_sf","text":"","code":"# S3 method for stars st_as_sfc(x, ..., as_points, which = seq_len(prod(dim(x)[1:2])))  # S3 method for stars st_as_sf(   x,   ...,   as_points = FALSE,   merge = FALSE,   na.rm = TRUE,   use_integer = is.logical(x[[1]]) || is.integer(x[[1]]),   long = FALSE,   connect8 = FALSE )  # S3 method for stars_proxy st_as_sf(x, ..., downsample = 0)"},{"path":"/reference/st_as_sf.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert stars object into an sf object — st_as_sf","text":"x object class stars ... ignored as_points logical; cells converted points polygons? See details. linear index cells keep (argument recommended used) merge logical; TRUE, cells identical values merged (using GDAL_Polygonize GDAL_FPolygonize); FALSE, polygon raster cell returned; see details na.rm logical; missing valued cells removed, also converted features? use_integer (relevant merge TRUE): TRUE, polygonizing values rounded 32-bits signed integer values (GDALPolygonize), otherwise converted 32-bit floating point values (GDALFPolygonize). long logical; TRUE, return long table form sf, geometries dimensions recycled connect8 logical; TRUE, use 8 connectedness. Otherwise 4 connectedness algorithm applied. downsample see st_as_stars","code":""},{"path":"/reference/st_as_sf.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Convert stars object into an sf object — st_as_sf","text":"merge TRUE, first attribute converted sf object. na.rm FALSE, areas NA values also written polygons. Note resulting polygons typically invalid, use st_make_valid create valid polygons .","code":""},{"path":"/reference/st_as_sf.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert stars object into an sf object — st_as_sf","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) x = x[,1:100,1:100,6] # subset of a band with lower values in it x[[1]][x[[1]] < 30] = NA # set lower values to NA x[[1]] = x[[1]] < 100 # make the rest binary x #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>  L7_ETMs.tif     #>  Mode :logical   #>  FALSE:525       #>  TRUE :7665      #>  NA's :1810      #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 100  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 100 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    6   6      NA    NA                         NA    NA     (p = st_as_sf(x)) # removes NA areas #> Simple feature collection with 8190 features and 1 field #> Geometry type: POLYGON #> Dimension:     XY #> Bounding box:  xmin: 288776.3 ymin: 9117911 xmax: 291626.3 ymax: 9120761 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #> First 10 features: #>      V1                       geometry #> 1  TRUE POLYGON ((288776.3 9120761,... #> 2  TRUE POLYGON ((288804.8 9120761,... #> 3  TRUE POLYGON ((288833.3 9120761,... #> 4  TRUE POLYGON ((288861.8 9120761,... #> 5  TRUE POLYGON ((288890.3 9120761,... #> 6  TRUE POLYGON ((288918.8 9120761,... #> 7  TRUE POLYGON ((288947.3 9120761,... #> 8  TRUE POLYGON ((288975.8 9120761,... #> 9  TRUE POLYGON ((289004.3 9120761,... #> 10 TRUE POLYGON ((289032.8 9120761,... (p = st_as_sf(x[,,,1], merge = TRUE)) # glues polygons together #> Simple feature collection with 155 features and 1 field #> Geometry type: POLYGON #> Dimension:     XY #> Bounding box:  xmin: 288776.3 ymin: 9117911 xmax: 291626.3 ymax: 9120761 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #> First 10 features: #>    L7_ETMs.tif                       geometry #> 1            0 POLYGON ((289517.3 9120761,... #> 2            0 POLYGON ((290144.3 9120761,... #> 3            0 POLYGON ((290315.3 9120761,... #> 4            0 POLYGON ((291113.3 9120761,... #> 5            0 POLYGON ((291341.3 9120761,... #> 6            1 POLYGON ((291455.3 9120761,... #> 7            1 POLYGON ((291569.3 9120761,... #> 8            0 POLYGON ((290372.3 9120732,... #> 9            1 POLYGON ((290628.8 9120732,... #> 10           1 POLYGON ((290771.3 9120732,... all(st_is_valid(p)) # not all valid, see details #> [1] TRUE plot(p, axes = TRUE)  (p = st_as_sf(x, na.rm = FALSE, merge = TRUE)) # includes polygons with NA values #> Simple feature collection with 380 features and 1 field #> Geometry type: POLYGON #> Dimension:     XY #> Bounding box:  xmin: 288776.3 ymin: 9117911 xmax: 291626.3 ymax: 9120761 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #> First 10 features: #>    L7_ETMs.tif                       geometry #> 1            0 POLYGON ((289517.3 9120761,... #> 2            0 POLYGON ((290144.3 9120761,... #> 3            0 POLYGON ((290315.3 9120761,... #> 4            0 POLYGON ((291113.3 9120761,... #> 5            0 POLYGON ((291341.3 9120761,... #> 6            1 POLYGON ((291455.3 9120761,... #> 7            1 POLYGON ((291569.3 9120761,... #> 8           NA POLYGON ((289745.3 9120732,... #> 9           NA POLYGON ((289830.8 9120732,... #> 10           0 POLYGON ((290372.3 9120732,... plot(p, axes = TRUE)"},{"path":"/reference/st_as_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"convert objects into a stars object — st_as_stars","title":"convert objects into a stars object — st_as_stars","text":"convert objects stars object","code":""},{"path":"/reference/st_as_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"convert objects into a stars object — st_as_stars","text":"","code":"# S3 method for cubble_df st_as_stars(.x, ..., check_times = FALSE)  # S3 method for ncdfgeom st_as_stars(.x, ..., sf_geometry = NA)  # S3 method for OpenStreetMap st_as_stars(.x, ..., as_col = FALSE)  # S3 method for stars_proxy st_as_stars(   .x,   ...,   downsample = 0,   url = attr(.x, \"url\"),   envir = parent.frame() )  # S3 method for data.frame st_as_stars(.x, ..., dims = coords, xy, y_decreasing = TRUE, coords = 1:2)  # S3 method for Raster st_as_stars(.x, ..., att = 1, ignore_file = FALSE)  # S3 method for SpatRaster st_as_stars(   .x,   ...,   ignore_file = FALSE,   as_attributes = all(terra::is.factor(.x)) )  # S3 method for sf st_as_stars(.x, ..., dims = attr(.x, \"sf_column\"))  st_as_stars(.x, ...)  # S3 method for list st_as_stars(.x, ..., dimensions = NULL)  # S3 method for default st_as_stars(.x = NULL, ..., raster = NULL)  # S3 method for stars st_as_stars(.x, ..., curvilinear = NULL, crs = st_crs(\"OGC:CRS84\"))  # S3 method for bbox st_as_stars(   .x,   ...,   nx,   ny,   dx = dy,   dy = dx,   xlim = .x[c(\"xmin\", \"xmax\")],   ylim = .x[c(\"ymin\", \"ymax\")],   values = 0,   n = 64800,   pretty = FALSE,   inside = FALSE,   nz,   proxy = FALSE )  # S3 method for xts st_as_stars(.x, ..., dimensions, name = \"attr\")"},{"path":"/reference/st_as_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"convert objects into a stars object — st_as_stars","text":".x object convert ... case .x class bbox, arguments passed  pretty. case .x class nc_proxy, arguments passed read_ncdf. check_times logical; check time stamps time series identical? sf_geometry sf data.frame geometry attributes added stars object. Must number rows timeseries instances. as_col logical; return rgb numbers (FALSE) (character) color values (TRUE)? downsample integer: larger 0, downsample rate (number pixels skip every row/column); length 2, specifies downsampling rate x y. url character; URL stars endpoint data reside envir environment resolve objects dims column names indices form cube dimensions xy x y raster dimension names indices; takes effect dims specified, see details y_decreasing logical; TRUE, (numeric) y values get negative delta (decrease increasing index) coords dims, symmetry st_as_sf att see factorValues; column RasterLayer's attribute table ignore_file logical; TRUE, ignore SpatRaster object file name as_attributes logical; TRUE .x one layer, load separate attributes rather band time dimension (implemented case ignore_file TRUE) dimensions object class dimensions raster character; names dimensions denote raster dimensions curvilinear creating curvilinear grids: named length 2 list holding longitude latitude matrices stars arrays, names corresponding attributes .x; names vector correspond raster dimensions matrices associated ; see Details. crs object class crs coordinate reference system values curvilinear; see details nx integer; number cells x direction; see details ny integer; number cells y direction; see details dx numeric object class units; cell size x direction; see details dy numeric object class units; cell size y direction; see details xlim length 2 numeric vector extent (min, max) x direction ylim length 2 numeric vector extent (min, max) y direction values value(s) populate raster values n (approximate) target number grid cells pretty logical; cell coordinates pretty values? inside logical; cells entirely fall inside bbox, potentially covering completely (TRUE), always cover bbox (FALSE), find good approximation (NA, default)? nz integer; number cells z direction; missing z-dimension created. proxy logical; stars_proxy object created? (requires gdal_create binary sf < 1.0-6) name character; attribute name array xts object","code":""},{"path":"/reference/st_as_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"convert objects into a stars object — st_as_stars","text":"ncdfgeom method: objects point-timeseries optional line polygon geometry timeseries specified sf_geometry parameter. See ncdfgeom NetCDF-based format geometry timeseries. xy specified first two dimensions dims numeric, set two dimensions. st_as_stars method sf objects without additional arguments returns one-dimensional data cube dimension simple features geometries, remaining attributes data cube attributes. used arguments, method data.frames called. curvilinear list stars objects longitude latitude values, coordinate reference system typically latitude longitude values. curvilinear contains names two arrays .x, removed returned object. bbox method: pretty TRUE, raster cells may extend coordinate range .x sides. addition nx ny, dx dy also missing, set single value computed sqrt(diff(xlim)*diff(ylim)/n). nx ny missing values matrix, number columns rows matrix taken. Otherwise, nx ny missing, computed (ceiling, floor, rounded integer value) ratio (x y) range divided (dx dy), depending value inside. Positive dy made negative. named arguments (...) passed pretty. dx dy units objects, value converted units st_crs(.x) (sf >= 1.0-7). xts methods, dimensions provided, time first dimension.","code":""},{"path":"/reference/st_as_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"convert objects into a stars object — st_as_stars","text":"","code":"if (require(plm, quietly = TRUE)) {  data(Produc, package = \"plm\")  st_as_stars(Produc) } #>  #> Attaching package: ‘plm’ #> The following objects are masked from ‘package:dplyr’: #>  #>     between, lag, lead #> stars object with 2 dimensions and 9 attributes #> attribute(s): #>     region         pcap              hwy            water         #>  5      :136   Min.   :  2627   Min.   : 1827   Min.   :  228.5   #>  8      :136   1st Qu.:  7097   1st Qu.: 3858   1st Qu.:  764.5   #>  4      :119   Median : 17572   Median : 7556   Median : 2266.5   #>  1      :102   Mean   : 25037   Mean   :10218   Mean   : 3618.8   #>  3      : 85   3rd Qu.: 27692   3rd Qu.:11267   3rd Qu.: 4318.7   #>  6      : 68   Max.   :140217   Max.   :47699   Max.   :24592.3   #>  (Other):170                                                      #>      util               pc               gsp              emp          #>  Min.   :  538.5   Min.   :  4053   Min.   :  4354   Min.   :  108.3   #>  1st Qu.: 2488.3   1st Qu.: 21651   1st Qu.: 16502   1st Qu.:  475.0   #>  Median : 7008.8   Median : 40671   Median : 39987   Median : 1164.8   #>  Mean   :11199.5   Mean   : 58188   Mean   : 61014   Mean   : 1747.1   #>  3rd Qu.:11598.5   3rd Qu.: 64796   3rd Qu.: 68126   3rd Qu.: 2114.1   #>  Max.   :80728.1   Max.   :375342   Max.   :464550   Max.   :11258.0   #>                                                                        #>      unemp        #>  Min.   : 2.800   #>  1st Qu.: 5.000   #>  Median : 6.200   #>  Mean   : 6.602   #>  3rd Qu.: 7.900   #>  Max.   :18.000   #>                   #> dimension(s): #>       from to offset delta              values #> state    1 48     NA    NA ALABAMA,...,WYOMING #> year     1 17   1970     1                NULL if (require(dplyr, quietly = TRUE)) {   # https://stackoverflow.com/questions/77368957/ spatial_dim <- st_sf(   ID = 1:3,   geometry = list(     st_polygon(list(       cbind(c(0, 1, 1, 0, 0), c(0, 0, 1, 1, 0))     )),     st_polygon(list(       cbind(c(1, 2, 2, 1, 1), c(0, 0, 1, 1, 0))     )),     st_polygon(list(       cbind(c(2, 3, 3, 2, 2), c(0, 0, 1, 1, 0))     ))   ) ) weekdays_dim <- data.frame(weekdays = c(\"Monday\", \"Tuesday\", \"Wednesday\",      \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\")) hours_dim <- data.frame(hours = c(\"8am\", \"11am\", \"4pm\", \"11pm\")) sf_dta <- spatial_dim |>   cross_join(weekdays_dim)|>   cross_join(hours_dim) |>   mutate(population = rnorm(n(), mean = 1000, sd = 200)) |>   select(everything(), geometry)  st_as_stars(sf_dta, dims = c(\"weekdays\", \"hours\", \"geometry\")) } #> stars object with 3 dimensions and 2 attributes #> attribute(s): #>                 Min.  1st Qu.   Median     Mean  3rd Qu.     Max. #> ID            1.0000   1.0000    2.000    2.000    3.000    3.000 #> population  594.2642 909.3489 1016.819 1010.279 1112.744 1324.842 #> dimension(s): #>          from to point #> weekdays    1  7    NA #> hours       1  4    NA #> geometry    1  3 FALSE #>                                                                 values #> weekdays                                             Monday,...,Sunday #> hours                                                     8am,...,11pm #> geometry POLYGON ((0 0, 1 0, 1 1, ...,...,POLYGON ((2 0, 3 0, 3 1, ... demo(nc, echo=FALSE,ask=FALSE) st_as_stars(nc) #> stars object with 1 dimensions and 14 attributes #> attribute(s): #>      AREA           PERIMETER         CNTY_         CNTY_ID     #>  Min.   :0.0420   Min.   :0.999   Min.   :1825   Min.   :1825   #>  1st Qu.:0.0910   1st Qu.:1.324   1st Qu.:1902   1st Qu.:1902   #>  Median :0.1205   Median :1.609   Median :1982   Median :1982   #>  Mean   :0.1263   Mean   :1.673   Mean   :1986   Mean   :1986   #>  3rd Qu.:0.1542   3rd Qu.:1.859   3rd Qu.:2067   3rd Qu.:2067   #>  Max.   :0.2410   Max.   :3.640   Max.   :2241   Max.   :2241   #>     NAME               FIPS               FIPSNO         CRESS_ID       #>  Length:100         Length:100         Min.   :37001   Min.   :  1.00   #>  Class :character   Class :character   1st Qu.:37050   1st Qu.: 25.75   #>  Mode  :character   Mode  :character   Median :37100   Median : 50.50   #>                                        Mean   :37100   Mean   : 50.50   #>                                        3rd Qu.:37150   3rd Qu.: 75.25   #>                                        Max.   :37199   Max.   :100.00   #>      BIR74           SID74          NWBIR74           BIR79       #>  Min.   :  248   Min.   : 0.00   Min.   :   1.0   Min.   :  319   #>  1st Qu.: 1077   1st Qu.: 2.00   1st Qu.: 190.0   1st Qu.: 1336   #>  Median : 2180   Median : 4.00   Median : 697.5   Median : 2636   #>  Mean   : 3300   Mean   : 6.67   Mean   :1050.8   Mean   : 4224   #>  3rd Qu.: 3936   3rd Qu.: 8.25   3rd Qu.:1168.5   3rd Qu.: 4889   #>  Max.   :21588   Max.   :44.00   Max.   :8027.0   Max.   :30757   #>      SID79          NWBIR79        #>  Min.   : 0.00   Min.   :    3.0   #>  1st Qu.: 2.00   1st Qu.:  250.5   #>  Median : 5.00   Median :  874.5   #>  Mean   : 8.36   Mean   : 1352.8   #>  3rd Qu.:10.25   3rd Qu.: 1406.8   #>  Max.   :57.00   Max.   :11631.0   #> dimension(s): #>      from  to refsys point #> geom    1 100  NAD27 FALSE #>                                                             values #> geom MULTIPOLYGON (((-81.47276...,...,MULTIPOLYGON (((-78.65572... st_as_stars(st_drop_geometry(nc), dims = \"NAME\") #> stars object with 1 dimensions and 13 attributes #> attribute(s): #>      AREA           PERIMETER         CNTY_         CNTY_ID     #>  Min.   :0.0420   Min.   :0.999   Min.   :1825   Min.   :1825   #>  1st Qu.:0.0910   1st Qu.:1.324   1st Qu.:1902   1st Qu.:1902   #>  Median :0.1205   Median :1.609   Median :1982   Median :1982   #>  Mean   :0.1263   Mean   :1.673   Mean   :1986   Mean   :1986   #>  3rd Qu.:0.1542   3rd Qu.:1.859   3rd Qu.:2067   3rd Qu.:2067   #>  Max.   :0.2410   Max.   :3.640   Max.   :2241   Max.   :2241   #>     FIPS               FIPSNO         CRESS_ID           BIR74       #>  Length:100         Min.   :37001   Min.   :  1.00   Min.   :  248   #>  Class :character   1st Qu.:37050   1st Qu.: 25.75   1st Qu.: 1077   #>  Mode  :character   Median :37100   Median : 50.50   Median : 2180   #>                     Mean   :37100   Mean   : 50.50   Mean   : 3300   #>                     3rd Qu.:37150   3rd Qu.: 75.25   3rd Qu.: 3936   #>                     Max.   :37199   Max.   :100.00   Max.   :21588   #>      SID74          NWBIR74           BIR79           SID79       #>  Min.   : 0.00   Min.   :   1.0   Min.   :  319   Min.   : 0.00   #>  1st Qu.: 2.00   1st Qu.: 190.0   1st Qu.: 1336   1st Qu.: 2.00   #>  Median : 4.00   Median : 697.5   Median : 2636   Median : 5.00   #>  Mean   : 6.67   Mean   :1050.8   Mean   : 4224   Mean   : 8.36   #>  3rd Qu.: 8.25   3rd Qu.:1168.5   3rd Qu.: 4889   3rd Qu.:10.25   #>  Max.   :44.00   Max.   :8027.0   Max.   :30757   Max.   :57.00   #>     NWBIR79        #>  Min.   :    3.0   #>  1st Qu.:  250.5   #>  Median :  874.5   #>  Mean   : 1352.8   #>  3rd Qu.: 1406.8   #>  Max.   :11631.0   #> dimension(s): #>      from  to             values #> NAME    1 100 Ashe,...,Brunswick data.frame(expand.grid(x=1:5, y = 1:5), z = rnorm(25)) |> st_as_stars() #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>         Min.  1st Qu.    Median       Mean   3rd Qu.     Max. #> z  -2.194688 -1.01616 -0.258447 -0.3639007 0.3655264 1.613714 #> dimension(s): #>   from to offset delta x/y #> x    1  5    0.5     1 [x] #> y    1  5    5.5    -1 [y] nc = st_read(system.file(\"gpkg/nc.gpkg\", package=\"sf\")) #> Reading layer `nc.gpkg' from data source  #>   `/home/runner/work/_temp/Library/sf/gpkg/nc.gpkg' using driver `GPKG' #> Simple feature collection with 100 features and 14 fields #> Geometry type: MULTIPOLYGON #> Dimension:     XY #> Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965 #> Geodetic CRS:  NAD27 st_as_stars(nc) #> stars object with 1 dimensions and 14 attributes #> attribute(s): #>      AREA           PERIMETER         CNTY_         CNTY_ID     #>  Min.   :0.0420   Min.   :0.999   Min.   :1825   Min.   :1825   #>  1st Qu.:0.0910   1st Qu.:1.324   1st Qu.:1902   1st Qu.:1902   #>  Median :0.1205   Median :1.609   Median :1982   Median :1982   #>  Mean   :0.1263   Mean   :1.673   Mean   :1986   Mean   :1986   #>  3rd Qu.:0.1542   3rd Qu.:1.859   3rd Qu.:2067   3rd Qu.:2067   #>  Max.   :0.2410   Max.   :3.640   Max.   :2241   Max.   :2241   #>     NAME               FIPS               FIPSNO         CRESS_ID       #>  Length:100         Length:100         Min.   :37001   Min.   :  1.00   #>  Class :character   Class :character   1st Qu.:37050   1st Qu.: 25.75   #>  Mode  :character   Mode  :character   Median :37100   Median : 50.50   #>                                        Mean   :37100   Mean   : 50.50   #>                                        3rd Qu.:37150   3rd Qu.: 75.25   #>                                        Max.   :37199   Max.   :100.00   #>      BIR74           SID74          NWBIR74           BIR79       #>  Min.   :  248   Min.   : 0.00   Min.   :   1.0   Min.   :  319   #>  1st Qu.: 1077   1st Qu.: 2.00   1st Qu.: 190.0   1st Qu.: 1336   #>  Median : 2180   Median : 4.00   Median : 697.5   Median : 2636   #>  Mean   : 3300   Mean   : 6.67   Mean   :1050.8   Mean   : 4224   #>  3rd Qu.: 3936   3rd Qu.: 8.25   3rd Qu.:1168.5   3rd Qu.: 4889   #>  Max.   :21588   Max.   :44.00   Max.   :8027.0   Max.   :30757   #>      SID79          NWBIR79        #>  Min.   : 0.00   Min.   :    3.0   #>  1st Qu.: 2.00   1st Qu.:  250.5   #>  Median : 5.00   Median :  874.5   #>  Mean   : 8.36   Mean   : 1352.8   #>  3rd Qu.:10.25   3rd Qu.: 1406.8   #>  Max.   :57.00   Max.   :11631.0   #> dimension(s): #>      from  to refsys point #> geom    1 100  NAD27 FALSE #>                                                             values #> geom MULTIPOLYGON (((-81.47276...,...,MULTIPOLYGON (((-78.65572..."},{"path":"/reference/st_cells.html","id":null,"dir":"Reference","previous_headings":"","what":"return the cell index corresponding to the location of a set of points — st_cells","title":"return the cell index corresponding to the location of a set of points — st_cells","text":"object cropped without normalization, indices return relative original uncropped extent.  See st_crop","code":""},{"path":"/reference/st_cells.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"return the cell index corresponding to the location of a set of points — st_cells","text":"","code":"st_cells(x, sf)"},{"path":"/reference/st_cells.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"return the cell index corresponding to the location of a set of points — st_cells","text":"x object class stars sf object class sf sfc","code":""},{"path":"/reference/st_cells.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"return the cell index corresponding to the location of a set of points — st_cells","text":"","code":"set.seed(1345) st_bbox(L7_ETMs) |>    st_as_sfc() |>    st_sample(10) -> pts  (x <- st_cells(L7_ETMs, pts)) #>  [1] 102496 112324  74862  56976 112862 105242  75593  11784  91245  63885 # get the pixel values (first band only): st_as_stars(L7_ETMs)[[1]][x] #>  [1]  92  92  89  76  67  94  77  98 113  56 # get pixel values for all bands: st_as_stars(L7_ETMs) |> split() |> sapply(`[`, x) #>        X1 X2  X3 X4  X5  X6 #>  [1,]  92 81  60 14  14  11 #>  [2,]  92 83  59 13  13  12 #>  [3,]  89 83  88 66 113  92 #>  [4,]  76 63  66 61 108  78 #>  [5,]  67 55  50 65  69  38 #>  [6,]  94 81  92 60 125 105 #>  [7,]  77 63  65 58 114  93 #>  [8,]  98 85  88 57  93  80 #>  [9,] 113 98 104 66 110  94 #> [10,]  56 40  27 68  50  24 # compare with st_extract(): st_as_stars(L7_ETMs) |> split() |> st_extract(pts) #> Simple feature collection with 10 features and 6 fields #> Geometry type: POINT #> Dimension:     XY #> Bounding box:  xmin: 289267.4 ymin: 9111549 xmax: 297166.8 ymax: 9119794 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #>     X1 X2  X3 X4  X5  X6                 geometry #> 1   92 81  60 14  14  11 POINT (295582.2 9112406) #> 2   92 83  59 13  13  12 POINT (297166.8 9111599) #> 3   89 83  88 66 113  92 POINT (293775.8 9114659) #> 4   76 63  66 61 108  78 POINT (291294.7 9116093) #> 5   67 55  50 65  69  38 POINT (292609.8 9111549) #> 6   94 81  92 60 125 105 POINT (294276.2 9112159) #> 7   77 63  65 58 114  93   POINT (294731 9114598) #> 8   98 85  88 57  93  80 POINT (296360.6 9119794) #> 9  113 98 104 66 110  94 POINT (293206.5 9113313) #> 10  56 40  27 68  50  24 POINT (289267.4 9115521)"},{"path":"/reference/st_contour.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute or plot contour lines or sets — st_contour","title":"Compute or plot contour lines or sets — st_contour","text":"Compute contour lines sets","code":""},{"path":"/reference/st_contour.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute or plot contour lines or sets — st_contour","text":"","code":"st_contour(   x,   na.rm = TRUE,   contour_lines = FALSE,   breaks = classInt::classIntervals(na.omit(as.vector(x[[1]])))$brks )"},{"path":"/reference/st_contour.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compute or plot contour lines or sets — st_contour","text":"x object class stars na.rm logical; missing valued cells removed, also converted features? contour_lines logical; FALSE, polygons returned (contour sets), otherwise contour lines breaks numerical; values \"draw\" contour levels","code":""},{"path":"/reference/st_contour.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Compute or plot contour lines or sets — st_contour","text":"function requires GDAL >= 2.4.0","code":""},{"path":[]},{"path":"/reference/st_coordinates.html","id":null,"dir":"Reference","previous_headings":"","what":"retrieve coordinates for raster or vector cube cells — st_coordinates","title":"retrieve coordinates for raster or vector cube cells — st_coordinates","text":"retrieve coordinates raster vector cube cells","code":""},{"path":"/reference/st_coordinates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"retrieve coordinates for raster or vector cube cells — st_coordinates","text":"","code":"# S3 method for stars st_coordinates(x, ..., add_max = FALSE, center = TRUE)  # S3 method for stars as.data.frame(x, ..., add_max = FALSE, center = NA, add_coordinates = TRUE)  as_tibble.stars(.x, ..., add_max = FALSE, center = NA)"},{"path":"/reference/st_coordinates.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"retrieve coordinates for raster or vector cube cells — st_coordinates","text":"x object class stars ... ignored add_max logical; TRUE, dimensions given min (x) max (x_max) value center logical; (add_max FALSE): grid cell center coordinates returned (TRUE) offset values (FALSE)? center can named logical vector list specify values dimension. add_coordinates logical; `TRUE`, columns dimension values preceed array values,  otherwise omitted .x object converted tibble","code":""},{"path":"/reference/st_crop.html","id":null,"dir":"Reference","previous_headings":"","what":"crop a stars object — st_crop","title":"crop a stars object — st_crop","text":"crop stars object","code":""},{"path":"/reference/st_crop.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"crop a stars object — st_crop","text":"","code":"# S3 method for stars_proxy st_crop(   x,   y,   ...,   crop = TRUE,   epsilon = sqrt(.Machine$double.eps),   collect = TRUE )  # S3 method for stars st_crop(   x,   y,   ...,   crop = TRUE,   epsilon = sqrt(.Machine$double.eps),   as_points = all(st_dimension(y) == 2, na.rm = TRUE),   normalize = FALSE )"},{"path":"/reference/st_crop.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"crop a stars object — st_crop","text":"x object class stars y object class sf, sfc bbox; see Details . ... ignored crop logical; TRUE, spatial extent returned object cropped still cover obj, FALSE, extent remains cells outside y given NA values. epsilon numeric; factor shrink bounding box y towards center cropping. collect logical; TRUE, repeat cropping stars object, .e. data read as_points logical; relevant y class sf sfc: FALSE, treat x set points, else set small polygons. Default: TRUE y two-dimensional, else FALSE; see Details normalize logical; TRUE pass cropped object st_normalize returning.","code":""},{"path":"/reference/st_crop.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"crop a stars object — st_crop","text":"raster x, st_crop selects cells intersect y.  intersection, raster cells interpreted points small polygons?  y class stars, x raster cells interpreted points; y class bbox, x cells interpreted cells (small polygons). Otherwise, as_points given, cells interpreted points y two-dimensional geometry.","code":""},{"path":"/reference/st_crop.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"crop a stars object — st_crop","text":"","code":"l7 = read_stars(system.file(\"tif/L7_ETMs.tif\", package = \"stars\")) d = st_dimensions(l7)  # area around cells 3:10 (x) and 4:11 (y): offset = c(d[[\"x\"]]$offset, d[[\"y\"]]$offset) res = c(d[[\"x\"]]$delta, d[[\"y\"]]$delta) bb = st_bbox(c(xmin = offset[1] + 2 * res[1],   ymin = offset[2] + 11 * res[2],   xmax = offset[1] + 10 * res[1],   ymax = offset[2] +  3 * res[2]), crs = st_crs(l7)) l7[bb] #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43   55.5 56.36979      65  111 #> dimension(s): #>      from to  offset delta                     refsys point x/y #> x       3 10  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       4 11 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6      NA    NA                         NA    NA     # equivalent: st_crop(l7, bb) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43   55.5 56.36979      65  111 #> dimension(s): #>      from to  offset delta                     refsys point x/y #> x       3 10  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       4 11 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6      NA    NA                         NA    NA      plot(l7[,1:13,1:13,1], reset = FALSE) image(l7[bb,,,1], add = TRUE, col = sf.colors()) plot(st_as_sfc(bb), add = TRUE, border = 'green', lwd = 2)   # slightly smaller bbox: bb = st_bbox(c(xmin = offset[1] + 2.1 * res[1],   ymin = offset[2] + 10.9 * res[2],   xmax = offset[1] +  9.9 * res[1],   ymax = offset[2] +  3.1 * res[2]), crs = st_crs(l7)) l7[bb] #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43   55.5 56.36979      65  111 #> dimension(s): #>      from to  offset delta                     refsys point x/y #> x       3 10  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       4 11 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6      NA    NA                         NA    NA      plot(l7[,1:13,1:13,1], reset = FALSE) image(l7[bb,,,1], add = TRUE, col = sf.colors()) plot(st_as_sfc(bb), add = TRUE, border = 'green', lwd = 2)   # slightly larger bbox: bb = st_bbox(c(xmin = offset[1] + 1.9 * res[1],   ymin = offset[2] + 11.1 * res[2],   xmax = offset[1] + 10.1 * res[1],   ymax = offset[2] +  2.9 * res[2]), crs = st_crs(l7)) l7[bb] #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43     55 56.11167      66  112 #> dimension(s): #>      from to  offset delta                     refsys point x/y #> x       2 11  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       3 12 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6      NA    NA                         NA    NA      plot(l7[,1:13,1:13,1], reset = FALSE) image(l7[bb,,,1], add = TRUE, col = sf.colors()) plot(st_as_sfc(bb), add = TRUE, border = 'green', lwd = 2)   # half a cell size larger bbox: bb = st_bbox(c(xmin = offset[1] + 1.49 * res[1],   ymin = offset[2] + 11.51 * res[2],   xmax = offset[1] + 10.51 * res[1],   ymax = offset[2] +  2.49 * res[2]), crs = st_crs(l7)) l7[bb] #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    17      43     55 56.11167      66  112 #> dimension(s): #>      from to  offset delta                     refsys point x/y #> x       2 11  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       3 12 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1  6      NA    NA                         NA    NA      plot(l7[,1:13,1:13,1], reset = FALSE) image(l7[bb,,,1], add = TRUE, col = sf.colors()) plot(st_as_sfc(bb), add = TRUE, border = 'green', lwd = 2)"},{"path":"/reference/st_dim_to_attr.html","id":null,"dir":"Reference","previous_headings":"","what":"create an array with dimension values — st_dim_to_attr","title":"create an array with dimension values — st_dim_to_attr","text":"create array dimension values","code":""},{"path":"/reference/st_dim_to_attr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"create an array with dimension values — st_dim_to_attr","text":"","code":"st_dim_to_attr(x, which = seq_along(dim(x)))"},{"path":"/reference/st_dim_to_attr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"create an array with dimension values — st_dim_to_attr","text":"x object class stars integer; indices dimensions address (default: )","code":""},{"path":"/reference/st_dim_to_attr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"create an array with dimension values — st_dim_to_attr","text":"stars object dimension values attributes","code":""},{"path":"/reference/st_dim_to_attr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"create an array with dimension values — st_dim_to_attr","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x1 = read_stars(tif) (x = st_dim_to_attr(x1)) #> stars object with 3 dimensions and 3 attributes #> attribute(s): #>            Min. 1st Qu.    Median      Mean 3rd Qu.      Max. #> x      288790.5  291270  293749.5  293749.5  296229  298708.5 #> y     9110743.0 9113244 9115744.8 9115744.8 9118246 9120746.5 #> band        1.0       2       3.5       3.5       5       6.0 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     plot(x)  (x = st_dim_to_attr(x1, 2:3)) #> stars object with 3 dimensions and 2 attributes #> attribute(s): #>          Min. 1st Qu.    Median      Mean 3rd Qu.    Max. #> y     9110743 9113244 9115744.8 9115744.8 9118246 9120747 #> band        1       2       3.5       3.5       5       6 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     plot(x)  (x= st_dim_to_attr(x1, 3)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>       Min. 1st Qu. Median Mean 3rd Qu. Max. #> band     1       2    3.5  3.5       5    6 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     plot(x)"},{"path":"/reference/st_dimensions.html","id":null,"dir":"Reference","previous_headings":"","what":"get dimensions from stars object — st_dimensions","title":"get dimensions from stars object — st_dimensions","text":"get dimensions stars object","code":""},{"path":"/reference/st_dimensions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"get dimensions from stars object — st_dimensions","text":"","code":"st_dimensions(.x, ...)  # S3 method for stars st_dimensions(.x, ...)  st_dimensions(x) <- value  # S3 method for stars st_dimensions(x) <- value  # S3 method for stars_proxy st_dimensions(x) <- value  # S3 method for list st_dimensions(x) <- value  # S3 method for array st_dimensions(.x, ...)  # S3 method for default st_dimensions(   .x,   ...,   .raster,   affine = c(0, 0),   cell_midpoints = FALSE,   point = FALSE )  st_set_dimensions(   .x,   which,   values = NULL,   point = NULL,   names = NULL,   xy,   ... )  st_get_dimension_values(.x, which, ..., where = NA, max = FALSE, center = NA)"},{"path":"/reference/st_dimensions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"get dimensions from stars object — st_dimensions","text":".x object retrieve dimensions information ... arguments x object class dimensions value new object class dimensions, matching dimensions .raster length 2 character array names () raster dimensions affine numeric; specify parameters affine transformation cell_midpoints logical; TRUE dimension values strictly regular, values interpreted cell midpoint values rather cell offset values calculating offset (.e., half-cell-size correction applied); can value dimension, else recycled point logical; pixel value (measure) refer point (location) value pixel (area) summary value? integer character; index name dimension changed values values dimension (e.g. sfc list-column), length-1 dimensions object; setting special value NULL removes dimension values, instance remove curvilinear raster coordinates names character; vector new names dimensions, single new name dimension indicated xy length-2 character vector; (new) names x y raster dimensions character, one 'start', 'center' 'end'. Set NA (default) ignore use max center explictly.  argument provides convenient alternative setting max center. max logical; TRUE return end, rather beginning interval center logical; TRUE return center interval; NA return center raster dimensions, start intervals cases","code":""},{"path":"/reference/st_dimensions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"get dimensions from stars object — st_dimensions","text":"dimensions attribute x, class dimensions","code":""},{"path":"/reference/st_dimensions.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"get dimensions from stars object — st_dimensions","text":"dimensions can specified two ways. simplest pass vector numeric values numeric dimension, character values categorical dimension. Parameter cell_midpoints used specify whether numeric values refer offset (start) dimension interval (default), center; center case available regular dimensions. rectilinear numeric dimensions, one can specify either vector cell borders (start values), data.frame two columns named \"start\" \"end\", respective interval start end values. first case, end values computed start values assuming last two intervals equal width.","code":""},{"path":"/reference/st_dimensions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"get dimensions from stars object — st_dimensions","text":"","code":"x = read_stars(system.file(\"tif/L7_ETMs.tif\", package = \"stars\")) # Landsat 7 ETM+ band semantics: https://landsat.gsfc.nasa.gov/the-enhanced-thematic-mapper-plus/ # set bands to values 1,2,3,4,5,7: (x1 = st_set_dimensions(x, \"band\", values = c(1,2,3,4,5,7), names = \"band_number\", point = TRUE)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     1      54     69 68.91242      86  255 #> dimension(s): #>             from  to  offset delta                     refsys point  values x/y #> x              1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE    NULL [x] #> y              1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE    NULL [y] #> band_number    1   6      NA    NA                         NA  TRUE 1,...,7     # set band values as bandwidth rbind(c(0.45,0.515), c(0.525,0.605), c(0.63,0.69), c(0.775,0.90), c(1.55,1.75), c(2.08,2.35)) %>%   units::set_units(\"um\") -> bw # or: units::set_units(µm) -> bw # set bandwidth midpoint: (x2 = st_set_dimensions(x, \"band\", values = 0.5 * (bw[,1]+bw[,2]),     names = \"bandwidth_midpoint\", point = TRUE)) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     1      54     69 68.91242      86  255 #> dimension(s): #>                    from  to  offset delta                     refsys point #> x                     1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE #> y                     1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE #> bandwidth_midpoint    1   6      NA    NA                    udunits  TRUE #>                                        values x/y #> x                                        NULL [x] #> y                                        NULL [y] #> bandwidth_midpoint 0.4825 [um],...,2.215 [um]     # set bandwidth intervals: (x3 = st_set_dimensions(x, \"band\", values = make_intervals(bw), names = \"bandwidth\")) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     1      54     69 68.91242      86  255 #> dimension(s): #>           from  to  offset delta                     refsys point #> x            1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE #> y            1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE #> bandwidth    1   6      NA    NA                    udunits    NA #>                                           values x/y #> x                                           NULL [x] #> y                                           NULL [y] #> bandwidth [0.45,0.515) [um],...,[2.08,2.35) [um]     m = matrix(1:20, nrow = 5, ncol = 4) dim(m) = c(x = 5, y = 4) # named dim (s = st_as_stars(m)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1     1    5.75   10.5 10.5   15.25   20 #> dimension(s): #>   from to offset delta point x/y #> x    1  5      0     1 FALSE [x] #> y    1  4      0     1 FALSE [y] st_get_dimension_values(s, 'x', where = \"start\") #> [1] 0 1 2 3 4 st_get_dimension_values(s, 'x', center = FALSE) #> [1] 0 1 2 3 4 st_get_dimension_values(s, 'x', where = \"center\") #> [1] 0.5 1.5 2.5 3.5 4.5 st_get_dimension_values(s, 'x', center = TRUE) #> [1] 0.5 1.5 2.5 3.5 4.5 st_get_dimension_values(s, 'x', where = \"end\") #> [1] 1 2 3 4 5 st_get_dimension_values(s, 'x', max = TRUE) #> [1] 1 2 3 4 5"},{"path":"/reference/st_downsample.html","id":null,"dir":"Reference","previous_headings":"","what":"downsample stars or stars_proxy objects — st_downsample","title":"downsample stars or stars_proxy objects — st_downsample","text":"downsample stars stars_proxy object either skipping rows, columns bands, computing single value (e.g. mean) sub-tiles involved","code":""},{"path":"/reference/st_downsample.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"downsample stars or stars_proxy objects — st_downsample","text":"","code":"st_downsample(x, n, ...)  # S3 method for stars st_downsample(x, n, ..., offset = 0, FUN)  # S3 method for stars_proxy st_downsample(x, n, ...)"},{"path":"/reference/st_downsample.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"downsample stars or stars_proxy objects — st_downsample","text":"x object class stars stars_proxy n integer; dimension number pixels/lines/bands etc skipped; see Details. ... arguments passed FUN (e.g., na.rm = TRUE ignore missing values FUN mean) offset integer; offset(s) downsampling, pixels, starting offset  dimension; smaller equal n FUN function; given, downsampling apply FUN subtiles","code":""},{"path":"/reference/st_downsample.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"downsample stars or stars_proxy objects — st_downsample","text":"n == 0, downsampling takes place; 1, every second row/column/band skipped, 2, every second+third row/column/band skipped, etc. Downsampling stars_proxy object returns stars object, equivalent calling st_as_stars(x, downsample = 2), downsamples first two (x y) dimensions. Downsampled regular rasters keep dimension offsets, cell size (delta) n[]+1 times larger, may result (slightly) different extent. Note terra's aggregate fact=2 corresponds st_downsample(x, n = 1, FUN = mean): fact one larger n.","code":""},{"path":"/reference/st_downsample.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"downsample stars or stars_proxy objects — st_downsample","text":"","code":"(m = matrix(1:121, 11, 11)) #>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] #>  [1,]    1   12   23   34   45   56   67   78   89   100   111 #>  [2,]    2   13   24   35   46   57   68   79   90   101   112 #>  [3,]    3   14   25   36   47   58   69   80   91   102   113 #>  [4,]    4   15   26   37   48   59   70   81   92   103   114 #>  [5,]    5   16   27   38   49   60   71   82   93   104   115 #>  [6,]    6   17   28   39   50   61   72   83   94   105   116 #>  [7,]    7   18   29   40   51   62   73   84   95   106   117 #>  [8,]    8   19   30   41   52   63   74   85   96   107   118 #>  [9,]    9   20   31   42   53   64   75   86   97   108   119 #> [10,]   10   21   32   43   54   65   76   87   98   109   120 #> [11,]   11   22   33   44   55   66   77   88   99   110   121 (s = st_as_stars(m)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1     1      31     61   61      91  121 #> dimension(s): #>    from to offset delta point x/y #> X1    1 11      0     1 FALSE [x] #> X2    1 11      0     1 FALSE [y] st_downsample(s, 1) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1     1    28.5     61   61    93.5  121 #> dimension(s): #>    from to offset delta point x/y #> X1    1  6      0     2 FALSE [x] #> X2    1  6      0     2 FALSE [y] st_downsample(s, 1)[[1]] #>      [,1] [,2] [,3] [,4] [,5] [,6] #> [1,]    1   23   45   67   89  111 #> [2,]    3   25   47   69   91  113 #> [3,]    5   27   49   71   93  115 #> [4,]    7   29   51   73   95  117 #> [5,]    9   31   53   75   97  119 #> [6,]   11   33   55   77   99  121 st_downsample(s, 1, offset = 1) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1    13      37     61   61      85  109 #> dimension(s): #>    from to offset delta point x/y #> X1    1  5      1     2 FALSE [x] #> X2    1  5      1     2 FALSE [y] st_downsample(s, 1, offset = 1)[[1]] #>      [,1] [,2] [,3] [,4] [,5] #> [1,]   13   35   57   79  101 #> [2,]   15   37   59   81  103 #> [3,]   17   39   61   83  105 #> [4,]   19   41   63   85  107 #> [5,]   21   43   65   87  109 st_downsample(s, 1, offset = c(0,1)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1    12    36.5     61   61    85.5  110 #> dimension(s): #>    from to offset delta point x/y #> X1    1  6      0     2 FALSE [x] #> X2    1  5      1     2 FALSE [y] st_downsample(s, 1, offset = c(0,1))[[1]] #>      [,1] [,2] [,3] [,4] [,5] #> [1,]   12   34   56   78  100 #> [2,]   14   36   58   80  102 #> [3,]   16   38   60   82  104 #> [4,]   18   40   62   84  106 #> [5,]   20   42   64   86  108 #> [6,]   22   44   66   88  110 st_downsample(s, 1, FUN = mean) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1     7      31     55   55      79  103 #> dimension(s): #>    from to offset delta point x/y #> X1    1  5      0     2 FALSE [x] #> X2    1  5      0     2 FALSE [y] st_downsample(s, 1, FUN = mean)[[1]] #>      [,1] [,2] [,3] [,4] [,5] #> [1,]    7   29   51   73   95 #> [2,]    9   31   53   75   97 #> [3,]   11   33   55   77   99 #> [4,]   13   35   57   79  101 #> [5,]   15   37   59   81  103 st_downsample(s, 1, offset = 1, FUN = mean) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>     Min. 1st Qu. Median Mean 3rd Qu. Max. #> A1    19      43     67   67      91  115 #> dimension(s): #>    from to offset delta point x/y #> X1    1  5      1     2 FALSE [x] #> X2    1  5      1     2 FALSE [y] st_downsample(s, 1, offset = c(0,1), FUN = mean)[[1]] #>      [,1] [,2] [,3] [,4] [,5] #> [1,]   18   40   62   84  106 #> [2,]   20   42   64   86  108 #> [3,]   22   44   66   88  110 #> [4,]   24   46   68   90  112 #> [5,]   26   48   70   92  114"},{"path":"/reference/st_extract.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract cell values at point locations — st_extract","title":"Extract cell values at point locations — st_extract","text":"Extract cell values point locations","code":""},{"path":"/reference/st_extract.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract cell values at point locations — st_extract","text":"","code":"st_extract(x, ...)  # S3 method for stars st_extract(   x,   at,   ...,   bilinear = FALSE,   time_column = attr(at, \"time_column\") %||% attr(at, \"time_col\"),   interpolate_time = bilinear,   FUN = mean )"},{"path":"/reference/st_extract.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract cell values at point locations — st_extract","text":"x object class stars stars_proxy ... passed aggregate.stars geometries exclusively POINT geometries object class sf sfc geometries, two-column matrix coordinate points rows, indicating extract values x bilinear logical; use bilinear interpolation rather nearest neighbour? time_column character integer; name index column time date values matched values first temporal dimension (matching classes POSIXct, POSIXt, Date, PCICt), x, dimension reduced. useful extract data cube values along trajectory; see https://github.com/r-spatial/stars/issues/352 . interpolate_time logical; time interpolated? FALSE, time instances matched using coinciding last preceding time data cube. FUN function used aggregate pixel values geometries intersect one pixel","code":""},{"path":"/reference/st_extract.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract cell values at point locations — st_extract","text":"class matrix, matrix extracted values returned;  otherwise: x dimensions x y (raster),  object class stars POINT geometries replacing x y raster dimensions, case, object sf extracted values.","code":""},{"path":"/reference/st_extract.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract cell values at point locations — st_extract","text":"points outside raster returned NA values. large sets points extraction needed, passing matrix may much faster passing sf sfc object.","code":""},{"path":"/reference/st_extract.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract cell values at point locations — st_extract","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") r = read_stars(tif) pnt = st_sample(st_as_sfc(st_bbox(r)), 10) st_extract(r, pnt) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    12   60.75     74 72.51667      87  150 #> dimension(s): #>          from to                     refsys point #> geometry    1 10 SIRGAS 2000 / UTM zone 25S  TRUE #> band        1  6                         NA    NA #>                                                         values #> geometry POINT (298340.2 9114943),...,POINT (289531.4 9111471) #> band                                                      NULL st_extract(r, pnt) %>% st_as_sf() #> Simple feature collection with 10 features and 6 fields #> Geometry type: POINT #> Dimension:     XY #> Bounding box:  xmin: 288950.3 ymin: 9111189 xmax: 298340.2 ymax: 9119338 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #>    L7_ETMs.tif.V1 L7_ETMs.tif.V2 L7_ETMs.tif.V3 L7_ETMs.tif.V4 L7_ETMs.tif.V5 #> 1              97             88             67             14             13 #> 2              82             66             74             49            107 #> 3              66             54             46             73             79 #> 4              80             68             69             77            117 #> 5              87             85            104             87            120 #> 6              90             83             65             13             13 #> 7              63             46             38             65             83 #> 8             110            101            114             74            150 #> 9              80             68             74             54            110 #> 10             80             65             65             44             84 #>    L7_ETMs.tif.V6                 geometry #> 1              12 POINT (298340.2 9114943) #> 2              82 POINT (293918.4 9114415) #> 3              42 POINT (293485.2 9118749) #> 4              86 POINT (294440.9 9114839) #> 5              79   POINT (295209 9118813) #> 6              12 POINT (295048.9 9111189) #> 7              50 POINT (289649.4 9116888) #> 8             128 POINT (295730.3 9119338) #> 9              88 POINT (288950.3 9111816) #> 10             71 POINT (289531.4 9111471) st_extract(r[,,,1], pnt) #> Simple feature collection with 10 features and 1 field #> Geometry type: POINT #> Dimension:     XY #> Bounding box:  xmin: 288950.3 ymin: 9111189 xmax: 298340.2 ymax: 9119338 #> Projected CRS: SIRGAS 2000 / UTM zone 25S #>    L7_ETMs.tif                 geometry #> 1           97 POINT (298340.2 9114943) #> 2           82 POINT (293918.4 9114415) #> 3           66 POINT (293485.2 9118749) #> 4           80 POINT (294440.9 9114839) #> 5           87   POINT (295209 9118813) #> 6           90 POINT (295048.9 9111189) #> 7           63 POINT (289649.4 9116888) #> 8          110 POINT (295730.3 9119338) #> 9           80 POINT (288950.3 9111816) #> 10          80 POINT (289531.4 9111471) st_extract(r, st_coordinates(pnt)) # \"at\" is a matrix: return a matrix #>       [,1] [,2] [,3] [,4] [,5] [,6] #>  [1,]   97   88   67   14   13   12 #>  [2,]   82   66   74   49  107   82 #>  [3,]   66   54   46   73   79   42 #>  [4,]   80   68   69   77  117   86 #>  [5,]   87   85  104   87  120   79 #>  [6,]   90   83   65   13   13   12 #>  [7,]   63   46   38   65   83   50 #>  [8,]  110  101  114   74  150  128 #>  [9,]   80   68   74   54  110   88 #> [10,]   80   65   65   44   84   71"},{"path":"/reference/st_geotransform.html","id":null,"dir":"Reference","previous_headings":"","what":"get or set the geotransform, or rotation matrix — st_geotransform","title":"get or set the geotransform, or rotation matrix — st_geotransform","text":"get set geotransform, rotation matrix","code":""},{"path":"/reference/st_geotransform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"get or set the geotransform, or rotation matrix — st_geotransform","text":"","code":"st_geotransform(x, ...)  st_geotransform(x) <- value  # S3 method for stars st_geotransform(x) <- value"},{"path":"/reference/st_geotransform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"get or set the geotransform, or rotation matrix — st_geotransform","text":"x object class stars dimensions ... ignored value length 6 numeric vector, 2 x 2 (scaled) rotation matrix","code":""},{"path":"/reference/st_geotransform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"get or set the geotransform, or rotation matrix — st_geotransform","text":"","code":"# using the \"classical\" rotation matrix, see https://en.wikipedia.org/wiki/Rotation_matrix : rot = function(theta, dxdy = c(1., -1.)) {    th = theta / 180 * pi    matrix(c(cos(th), sin(th), -sin(th), cos(th)), 2, 2) %*%         matrix(c(dxdy[2], 0, 0, dxdy[1]), 2, 2) } l = st_downsample(st_as_stars(L7_ETMs), 9) # save time in plotting st_geotransform(l) = rot(20, c(28.5, 28.5)) # clockwise, 20 degrees, scale by cell size plot(l[,,,1])   m = rot(20, c(1, 2)) g = expand.grid(x = 0:4, y = 0:4) plot(g[1:2], asp = 1) text(g[,1], g[,2], labels = seq_along(g[,1]), pos = 4) g = t(m %*% t(as.matrix(g))) points(g, col = 'red') text(g[,1], g[,2], labels = seq_along(g[,1]), pos = 4, col = 'red')   m = matrix(1:20, 4) s0 = st_as_stars(m) s = s0 # dy > 0, clockwise rotation: st_geotransform(s) = rot(10, c(1,1)) plot(s0, reset = FALSE) plot(s, add = TRUE)  # dy < 0, counter clockwise rotation, + expansion in x-direction: layout(1) s0 = st_as_stars(st_bbox(s0), dx = 1) s0$values = 1:20 s0 #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>         Min. 1st Qu. Median Mean 3rd Qu. Max. #> values     1    5.75   10.5 10.5   15.25   20 #> dimension(s): #>   from to offset delta x/y #> x    1  4      0     1 [x] #> y    1  5      5    -1 [y] plot(s0, reset = FALSE) s = s0 st_geotransform(s) = rot(10, c(2,1)) plot(s, add = TRUE)"},{"path":"/reference/st_intersects.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"spatial intersect predicate for stars and sfc object — st_intersects.stars","title":"spatial intersect predicate for stars and sfc object — st_intersects.stars","text":"spatial intersect predicate stars sfc object","code":""},{"path":"/reference/st_intersects.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"spatial intersect predicate for stars and sfc object — st_intersects.stars","text":"","code":"# S3 method for stars st_intersects(x, y, sparse = TRUE, ..., as_points = NA, transpose = FALSE)"},{"path":"/reference/st_intersects.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"spatial intersect predicate for stars and sfc object — st_intersects.stars","text":"x object class stars y object `st_geometry` method: class `sf` `sfc`, `stars` object `sfc` dimension sparse logical; TRUE, return sparse logical matrix (object class `sgbp`), FALSE, return logical matrix ... ignored, passed `st_intersects.sf` curvilinear grids as_points logical, grid cells considered points (TRUE) polygons (FALSE)? Default: FALSE warning emitted transpose logical; transpose `sgbp` object returned?","code":""},{"path":"/reference/st_intersects.stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"spatial intersect predicate for stars and sfc object — st_intersects.stars","text":"`sgbp` object sparse = TRUE, logical matrix otherwise","code":""},{"path":"/reference/st_intersects.stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"spatial intersect predicate for stars and sfc object — st_intersects.stars","text":"curvilinear grids always converted polygons, points grid boundaries may intersect two cells touched; grids cell boundary corner belongs one cell.","code":""},{"path":"/reference/st_join.stars.html","id":null,"dir":"Reference","previous_headings":"","what":"Spatially join a stars and an `sf` object — st_join.stars","title":"Spatially join a stars and an `sf` object — st_join.stars","text":"Spatially join stars `sf` object","code":""},{"path":"/reference/st_join.stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Spatially join a stars and an `sf` object — st_join.stars","text":"","code":"# S3 method for stars st_join(   x,   y,   join = st_intersects,   ...,   what = \"left1\",   as_points = NA,   warn = TRUE )"},{"path":"/reference/st_join.stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Spatially join a stars and an `sf` object — st_join.stars","text":"x object class stars y object class sf, one can coerced st_as_sf join join function, return sgbp object; see details ... arguments passed join function \"left1\", \"right\" \"inner\"; see details as_points logical; controls whether grid cells x treated points, cell areas; st_intersects.stars method default derive x's metadata, else assume areas. warn logical; TRUE, warn 1--many matches \"left1\"","code":""},{"path":"/reference/st_join.stars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Spatially join a stars and an `sf` object — st_join.stars","text":"\"left1\", object class stars (first) value y spatial instances x","code":""},{"path":"/reference/st_join.stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Spatially join a stars and an `sf` object — st_join.stars","text":"one match single x value, first matching record y taken (warn TRUE warning raised). \"inner\", object class sf matching records x y.","code":""},{"path":"/reference/st_mosaic.html","id":null,"dir":"Reference","previous_headings":"","what":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":"build mosaic (composite) several spatially disjoint stars objects","code":""},{"path":"/reference/st_mosaic.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":"","code":"st_mosaic(.x, ...)  # S3 method for stars st_mosaic(   .x,   ...,   dst = tempfile(fileext = file_ext),   options = c(\"-vrtnodata\", \"-9999\", \"-srcnodata\", \"nan\"),   file_ext = \".tif\" )  # S3 method for character st_mosaic(   .x,   ...,   dst = tempfile(fileext = file_ext),   options = c(\"-vrtnodata\", \"-9999\"),   file_ext = \".tif\" )  # S3 method for stars_proxy st_mosaic(   .x,   ...,   dst = tempfile(fileext = file_ext),   options = c(\"-vrtnodata\", \"-9999\"),   file_ext = \".tif\" )"},{"path":"/reference/st_mosaic.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":".x object class stars, character vector input dataset names ... input stars objects dst character; destination file name; VRT file references source file(s), see details options character; options gdalbuildvrt command file_ext character; file extension, determining format used write (\".tif\" implies GeoTIFF)","code":""},{"path":"/reference/st_mosaic.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":"stars method returns stars object composite input; character method returns file name file mosaic; see also GDAL documentation gdalbuildvrt","code":""},{"path":"/reference/st_mosaic.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":"gdal function buildvrt builds mosaic input images; input images can multi-band, higher-dimensional data cubes stars objects multiple attributes; note `stars` method, `dst` file may contain references temporary files going removed termination R session. uses gdal_utils internally call buildvrt; executables external R called.","code":""},{"path":"/reference/st_mosaic.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"build mosaic (composite) of several spatially disjoint stars objects — st_mosaic","text":"","code":"x = read_stars(system.file(\"tif/L7_ETMs.tif\", package = \"stars\")) x1 = x[,100:200,100:200,] x2 = x[,150:300,150:300,] plot(st_mosaic(x1, x2))"},{"path":"/reference/st_raster_type.html","id":null,"dir":"Reference","previous_headings":"","what":"get the raster type (if any) of a stars object — st_raster_type","title":"get the raster type (if any) of a stars object — st_raster_type","text":"get raster type () stars object","code":""},{"path":"/reference/st_raster_type.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"get the raster type (if any) of a stars object — st_raster_type","text":"","code":"st_raster_type(x, dimension = character(0))"},{"path":"/reference/st_raster_type.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"get the raster type (if any) of a stars object — st_raster_type","text":"x object class stars dimension optional: numbers names dimension(s) get per-dimension type","code":""},{"path":"/reference/st_raster_type.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"get the raster type (if any) of a stars object — st_raster_type","text":"dimension specified, return spatial raster type:  one NA (object raster dimensions),  \"curvilinear\", \"rectilinear\", \"affine\", \"regular\". case dimension(s) specified, return one \"regular\", \"rectilinear\" (irregular numeric), \"discrete\" (anything else).","code":""},{"path":"/reference/st_raster_type.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"get the raster type (if any) of a stars object — st_raster_type","text":"categories \"curvilinear\" \"affine\" refer relationship pair spatial (raster) dimensions.","code":""},{"path":"/reference/st_raster_type.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"get the raster type (if any) of a stars object — st_raster_type","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) st_raster_type(x) #> [1] \"regular\" st_raster_type(x, 1:3) #>          x          y       band  #>  \"regular\"  \"regular\" \"discrete\""},{"path":"/reference/st_rasterize.html","id":null,"dir":"Reference","previous_headings":"","what":"rasterize simple feature geometries — st_rasterize","title":"rasterize simple feature geometries — st_rasterize","text":"rasterize simple feature geometries","code":""},{"path":"/reference/st_rasterize.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"rasterize simple feature geometries — st_rasterize","text":"","code":"st_rasterize(   sf,   template = guess_raster(sf, ...) %||% st_as_stars(st_bbox(sf), values = NA_real_,     ...),   file = tempfile(),   driver = \"GTiff\",   options = character(0),   align = FALSE,   proxy = FALSE,   ... )"},{"path":"/reference/st_rasterize.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"rasterize simple feature geometries — st_rasterize","text":"sf object class sf template optional; stars object desired target geometry, target geometry alignment align=TRUE; see details file temporary file name driver driver temporary file options character; options vector GDALRasterize align logical; TRUE, template used geometry _alignment_,  informing target resolution offset proxy logical; proxy object returned? ... arguments passed st_as_stars","code":""},{"path":"/reference/st_rasterize.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"rasterize simple feature geometries — st_rasterize","text":"`template` `stars` object, non-NA cells covered `sf` receive value `template`; see also argument `align`.","code":""},{"path":"/reference/st_rasterize.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"rasterize simple feature geometries — st_rasterize","text":"","code":"demo(nc, echo = FALSE, ask = FALSE) (x = st_rasterize(nc)) # default grid: #> stars object with 2 dimensions and 12 attributes #> attribute(s): #>                 Min.   1st Qu.    Median         Mean   3rd Qu.      Max.  NA's #> AREA           0.042     0.108     0.142 1.451932e-01     0.181     0.241 30904 #> PERIMETER      0.999     1.461     1.716 1.786110e+00     2.004     3.640 30904 #> CNTY_       1825.000  1907.000  1989.000 1.998403e+03  2085.000  2241.000 30904 #> CNTY_ID     1825.000  1907.000  1989.000 1.998403e+03  2085.000  2241.000 30904 #> FIPSNO     37001.000 37049.000 37101.000 3.710042e+04 37153.000 37199.000 30904 #> CRESS_ID       1.000    25.000    51.000 5.071206e+01    77.000   100.000 30904 #> BIR74        248.000  1323.000  2648.000 3.791637e+03  4139.000 21588.000 30904 #> SID74          0.000     3.000     5.000 7.891985e+00    10.000    44.000 30904 #> NWBIR74        1.000   297.000   844.000 1.246210e+03  1396.000  8027.000 30904 #> BIR79        319.000  1606.000  3108.000 4.852046e+03  5400.000 30757.000 30904 #> SID79          0.000     3.000     6.000 9.584098e+00    13.000    57.000 30904 #> NWBIR79        3.000   360.000  1058.000 1.604642e+03  1524.000 11631.000 30904 #> dimension(s): #>   from  to offset    delta refsys point x/y #> x    1 461 -84.32  0.01925  NAD27 FALSE [x] #> y    1 141  36.59 -0.01925  NAD27 FALSE [y] plot(x, axes = TRUE)  # a bit more customized grid: (x = st_rasterize(nc, st_as_stars(st_bbox(nc), nx = 100, ny = 50, values = NA_real_))) #> stars object with 2 dimensions and 12 attributes #> attribute(s): #>                 Min.   1st Qu.    Median         Mean   3rd Qu.      Max. NA's #> AREA           0.042     0.108     0.142     0.145536     0.181     0.241 2373 #> PERIMETER      0.999     1.470     1.716     1.789032     2.004     3.640 2373 #> CNTY_       1825.000  1908.000  1989.000  1999.761325  2088.000  2241.000 2373 #> CNTY_ID     1825.000  1908.000  1989.000  1999.761325  2088.000  2241.000 2373 #> FIPSNO     37001.000 37049.000 37101.000 37100.327750 37151.000 37199.000 2373 #> CRESS_ID       1.000    25.000    51.000    50.663875    76.000   100.000 2373 #> BIR74        248.000  1323.500  2648.000  3790.530263  4139.000 21588.000 2373 #> SID74          0.000     3.000     5.000     7.905976    10.000    44.000 2373 #> NWBIR74        1.000   289.000   844.000  1246.116483  1396.000  8027.000 2373 #> BIR79        319.000  1606.000  3108.000  4848.231062  5386.000 30757.000 2373 #> SID79          0.000     3.000     6.000     9.574419    13.000    57.000 2373 #> NWBIR79        3.000   360.000  1058.000  1602.740769  1524.000 11631.000 2373 #> dimension(s): #>   from  to offset    delta refsys point x/y #> x    1 100 -84.32  0.08867  NAD27 FALSE [x] #> y    1  50  36.59 -0.05415  NAD27 FALSE [y] plot(x, axes = TRUE)  (ls = st_sf(a = 1:2, st_sfc(st_linestring(rbind(c(0.1, 0), c(1.1, 1))),    st_linestring(rbind(c(0, 0.05), c(1, 0.05)))))) #> Simple feature collection with 2 features and 1 field #> Geometry type: LINESTRING #> Dimension:     XY #> Bounding box:  xmin: 0 ymin: 0 xmax: 1.1 ymax: 1 #> CRS:           NA #>   a #> 1 1 #> 2 2 #>   c..st_sfc.st_linestring.rbind.c.0.1..0...c.1.1..1.....st_linestring.rbind.c.0..........0.05...c.1..0.05...... #> 1                                                                                     LINESTRING (0.1 0, 1.1 1) #> 2                                                                                   LINESTRING (0 0.05, 1 0.05) (grd = st_as_stars(st_bbox(ls), nx = 10, ny = 10, xlim = c(0, 1.0), ylim = c(0, 1),    values = NA_real_)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>         Min. 1st Qu. Median Mean 3rd Qu. Max. NA's #> values    NA      NA     NA  NaN      NA   NA  100 #> dimension(s): #>   from to offset delta x/y #> x    1 10      0   0.1 [x] #> y    1 10      1  -0.1 [y] # Only the left-top corner is part of the grid cell: sf_extSoftVersion()[\"GDAL\"] #>    GDAL  #> \"3.4.1\"  plot(st_rasterize(ls, grd), axes = TRUE, reset = FALSE) # ALL_TOUCHED=FALSE;  plot(ls, add = TRUE, col = \"red\")  plot(st_rasterize(ls, grd, options = \"ALL_TOUCHED=TRUE\"), axes = TRUE, reset = FALSE) plot(ls, add = TRUE, col = \"red\")  # add lines to existing 0 values, summing values in case of multiple lines: (grd = st_as_stars(st_bbox(ls), nx = 10, ny = 10, xlim = c(0, 1.0), ylim = c(0, 1), values = 0)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>         Min. 1st Qu. Median Mean 3rd Qu. Max. #> values     0       0      0    0       0    0 #> dimension(s): #>   from to offset delta x/y #> x    1 10      0   0.1 [x] #> y    1 10      1  -0.1 [y] r = st_rasterize(ls, grd, options = c(\"MERGE_ALG=ADD\", \"ALL_TOUCHED=TRUE\")) plot(r, axes = TRUE, reset = FALSE) plot(ls, add = TRUE, col = \"red\")"},{"path":"/reference/st_res.html","id":null,"dir":"Reference","previous_headings":"","what":"obtain (spatial) resolution of a stars object — st_res","title":"obtain (spatial) resolution of a stars object — st_res","text":"obtain resolution(s) stars object: default (absolute) x/y raster dimensions, optionally delta dimension parameters","code":""},{"path":"/reference/st_res.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"obtain (spatial) resolution of a stars object — st_res","text":"","code":"st_res(x, all = FALSE, absolute = !all)"},{"path":"/reference/st_res.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"obtain (spatial) resolution of a stars object — st_res","text":"x object class stars logical; FALSE return vector x/y raster resolution absolute logical; works = FALSE; TRUE return absolute resolution values, FALSE return delta values","code":""},{"path":"/reference/st_res.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"obtain (spatial) resolution of a stars object — st_res","text":"= FALSE vector x/y raster resolutions, otherwise list delta values","code":""},{"path":"/reference/st_res.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"obtain (spatial) resolution of a stars object — st_res","text":"","code":"st_res(L7_ETMs) #>    x    y  #> 28.5 28.5  st_res(L7_ETMs, absolute = FALSE) #>     x     y  #>  28.5 -28.5  st_res(L7_ETMs, all = TRUE) #> $x #> [1] 28.5 #>  #> $y #> [1] -28.5 #>  #> $band #> [1] NA #>  if (require(starsdata)) {   paste0(\"netcdf/\", c(\"avhrr-only-v2.19810901.nc\",      \"avhrr-only-v2.19810902.nc\",     \"avhrr-only-v2.19810903.nc\",     \"avhrr-only-v2.19810904.nc\")) |>   system.file(package = \"starsdata\") |>   read_stars(quiet = TRUE) -> x   st_res(x) |> print()   st_res(x, all = TRUE) |> print() } #> Loading required package: starsdata #>    x    y  #> 0.25 0.25  #> $x #> [1] 0.25 #>  #> $y #> [1] -0.25 #>  #> $zlev #> [1] NA #>  #> $time #> Time difference of 1 days #>"},{"path":"/reference/st_rgb.html","id":null,"dir":"Reference","previous_headings":"","what":"reduce dimension to rgb (alpha) hex values — st_rgb","title":"reduce dimension to rgb (alpha) hex values — st_rgb","text":"reduce dimension rgb (alpha) hex values","code":""},{"path":"/reference/st_rgb.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"reduce dimension to rgb (alpha) hex values — st_rgb","text":"","code":"st_rgb(   x,   dimension = 3,   use_alpha = dim(x)[dimension] == 4,   maxColorValue = 255L,   probs = c(0, 1),   stretch = NULL )"},{"path":"/reference/st_rgb.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"reduce dimension to rgb (alpha) hex values — st_rgb","text":"x object class stars dimension dimension name number reduce use_alpha logical; TRUE, fourth band used alpha values maxColorValue integer; maximum value colors probs probability values quantiles used stretching \"percent\". stretch logical character; TRUE \"percent\", band stretched 0 ... maxColorValue \"percent clip\" method using probs values. \"histogram\", \"histogram equalization\" performed (probs values ignored). stretch NULL FALSE, stretching performed. character values interpreted \"percent\" message printed.","code":""},{"path":"/reference/st_rgb.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"reduce dimension to rgb (alpha) hex values — st_rgb","text":"dimension's bands mapped red, green, blue, alpha; different ordering wanted, use [.stars reorder dimension, see examples. Alternatively, can use plot.stars rgb argument create three-band composition.","code":""},{"path":[]},{"path":"/reference/st_rgb.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"reduce dimension to rgb (alpha) hex values — st_rgb","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) st_rgb(x[,,,3:1]) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>  L7_ETMs.tif        #>  Length:122848      #>  Class :character   #>  Mode  :character   #> dimension(s): #>   from  to  offset delta                     refsys point x/y #> x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] r = st_rgb(x[,,,c(6,5,4,3)], 3, use_alpha=TRUE) # now R=6,G=5,B=4,alpha=3 if (require(ggplot2)) {  ggplot() + geom_stars(data = r) + scale_fill_identity() }  r = st_rgb(x[,,,3:1],        probs = c(0.01, 0.99),        stretch = \"percent\") plot(r) #> Error in image.stars(x, ..., axes = axes, breaks = breaks, col = col,     key.pos = key.pos, key.width = key.width, key.length = key.length,     main = NULL): rgb plotting not supported on this device r = st_rgb(x[,,,3:1],        probs = c(0.01, 0.99),        stretch = \"histogram\") plot(r) #> Error in image.stars(x, ..., axes = axes, breaks = breaks, col = col,     key.pos = key.pos, key.width = key.width, key.length = key.length,     main = NULL): rgb plotting not supported on this device"},{"path":"/reference/st_rotate.html","id":null,"dir":"Reference","previous_headings":"","what":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","title":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","text":"Transform rotated long/lat regular grid unrotated curvilinear grid","code":""},{"path":"/reference/st_rotate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","text":"","code":"# S3 method for stars st_rotate(.x, lon0, lat0, north = TRUE, ...)  # S3 method for sfc st_rotate(.x, lon0, lat0, north = TRUE, ...)  # S3 method for sf st_rotate(.x, lon0, lat0, north = TRUE, ...)"},{"path":"/reference/st_rotate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","text":".x object class stars lon0 longitude rotated pole degrees lat0 latitude rotated pole degrees north logical; TRUE pole refers North pole, otherwise South pole ... ignored","code":""},{"path":"/reference/st_rotate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","text":"curvilinear stars object coordinates regular long/lat (North pole lat=90)","code":""},{"path":"/reference/st_rotate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Transform rotated pole long/lat regular grid to unrotated curvilinear grid — st_rotate","text":"","code":"if (require(\"starsdata\") && require(\"maps\")) {   # data downloaded from https://esgf-data.dkrz.de/search/cosmo-rea/   nc = \"netcdf/ts_EUR-6km_ECMWF-ERAINT_REA6_r1i1p1f1_COSMO_v1_mon_201801-201812.nc\"   f = system.file(nc, package = \"starsdata\")   m = read_mdim(f, \"ts\")   print(m)   # NOTE this function is obsolete when reading m as   # m = read_mdim(f, \"ts\", curvilinear = c(\"longitude\", \"latitude\"))   if (require(RNetCDF)) {      x = open.nc(f)      lon = att.get.nc(x, \"rotated_latitude_longitude\", \"grid_north_pole_longitude\")      lat = att.get.nc(x, \"rotated_latitude_longitude\", \"grid_north_pole_latitude\")      close.nc(x)      print(c(lon = lon, lat = lat))   } else {      lon = -162      lat = 39.25   }    m1 = st_rotate(m, lon, lat)   print(m1)   h = function() maps::map(add = TRUE)   plot(m1, downsample = c(10, 10, 5), axes = TRUE, hook = h, mfrow = c(1, 2))      # curvilinear grid: downsample for plotting speed   m2 = st_warp(m1, crs = st_crs(\"OGC:CRS84\"), threshold = .1)   plot(m2, hook = h, mfrow = c(3, 4)) # regular grid: plots fast } #> Loading required package: maps #> stars object with 3 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>            Min.  1st Qu.   Median     Mean 3rd Qu.     Max. #> ts [K] 277.3233 284.7061 286.1046 286.5914 288.003 296.9786 #> dimension(s): #>      from  to offset delta refsys                    values x/y #> rlon    1 848 -28.43 0.055     NA                      NULL [x] #> rlat    1 824 -23.43 0.055     NA                      NULL [y] #> time    1  12     NA    NA   Date 2018-01-16,...,2018-12-16     #> Loading required package: RNetCDF #>     lon     lat  #> -162.00   39.25  #> stars object with 3 dimensions and 1 attribute #> attribute(s), summary of first 1e+05 cells: #>            Min.  1st Qu.   Median     Mean 3rd Qu.     Max. #> ts [K] 277.3233 284.7061 286.1046 286.5914 288.003 296.9786 #> dimension(s): #>      from  to refsys                     values x/y #> rlon    1 848 WGS 84 [848x824] -44.67,...,65.06 [x] #> rlat    1 824 WGS 84  [848x824] 21.95,...,72.61 [y] #> time    1  12   Date  2018-01-16,...,2018-12-16     #> curvilinear grid #> Warning: using Euclidean distance measures on geodetic coordinates #> downsample set to 5"},{"path":"/reference/st_set_bbox.html","id":null,"dir":"Reference","previous_headings":"","what":"set bounding box parameters of regular grid — st_set_bbox","title":"set bounding box parameters of regular grid — st_set_bbox","text":"set bounding box parameters regular grid","code":""},{"path":"/reference/st_set_bbox.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"set bounding box parameters of regular grid — st_set_bbox","text":"","code":"st_set_bbox(x, value, ...)"},{"path":"/reference/st_set_bbox.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"set bounding box parameters of regular grid — st_set_bbox","text":"x object class dimensions, stars stars_proxy value object class bbox ... ignored","code":""},{"path":"/reference/st_sfc2xy.html","id":null,"dir":"Reference","previous_headings":"","what":"replace POINT simple feature geometry list with an x y raster — st_sfc2xy","title":"replace POINT simple feature geometry list with an x y raster — st_sfc2xy","text":"replace POINT simple feature geometry list x y raster","code":""},{"path":"/reference/st_sfc2xy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"replace POINT simple feature geometry list with an x y raster — st_sfc2xy","text":"","code":"st_sfc2xy(x, ...)"},{"path":"/reference/st_sfc2xy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"replace POINT simple feature geometry list with an x y raster — st_sfc2xy","text":"x object class stars, class sf ... passed .data.frame.stars","code":""},{"path":"/reference/st_sfc2xy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"replace POINT simple feature geometry list with an x y raster — st_sfc2xy","text":"object class stars POINT list replaced x y raster dimensions. works points distributed regular rectilinear grid.","code":""},{"path":"/reference/st_tile.html","id":null,"dir":"Reference","previous_headings":"","what":"Specify parameters to load raster in blocks — st_tile","title":"Specify parameters to load raster in blocks — st_tile","text":"Helper function specifying block parameters (nXOff, nYOff, nXsize, nYSize) required RasterIO argument read_stars","code":""},{"path":"/reference/st_tile.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Specify parameters to load raster in blocks — st_tile","text":"","code":"st_tile(img_rows, img_cols, x_window, y_window, overlap = 0)"},{"path":"/reference/st_tile.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Specify parameters to load raster in blocks — st_tile","text":"img_rows number input raster rows (integer) img_cols number input raster columns (integer) x_window number rows block (integer) y_window number columns block (integer) overlap number overlapping pixels (integer)","code":""},{"path":"/reference/st_tile.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Specify parameters to load raster in blocks — st_tile","text":"matrix specified nXOff, nYOff, nXsize, nYSize parameters every block","code":""},{"path":"/reference/st_tile.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Specify parameters to load raster in blocks — st_tile","text":"","code":"if (FALSE) { tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") r = read_stars(tif, proxy = TRUE) tiles = st_tile(nrow(r), ncol(r), 256, 256) for (i in seq_len(nrow(tiles))) {   tile = read_stars(tif, proxy = FALSE, RasterIO = tiles[i, ])   # write tiles to separate files   write_stars(tile, dsn = paste0(i, \".tif\")) } }"},{"path":"/reference/st_transform.html","id":null,"dir":"Reference","previous_headings":"","what":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","title":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","text":"transform geometries stars objects new coordinate reference system, without warping","code":""},{"path":"/reference/st_transform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","text":"","code":"# S3 method for stars st_transform(x, crs, ...)  st_transform_proj.stars(x, crs, ...)"},{"path":"/reference/st_transform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","text":"x object class stars, either raster simple feature geometries crs object class crs target crs ... ignored","code":""},{"path":"/reference/st_transform.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","text":"simple feature dimensions, st_transform called, leading lossless transformation. gridded spatial data, curvilinear grid transformed grid cell (centers) returned, also lossless. convert regular grid new CRS, use st_warp (general lossy).","code":""},{"path":[]},{"path":"/reference/st_transform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"transform geometries in stars objects to a new coordinate reference system, without warping — st_transform","text":"","code":"geomatrix = system.file(\"tif/geomatrix.tif\", package = \"stars\") (x = read_stars(geomatrix)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>                Min. 1st Qu. Median    Mean 3rd Qu. Max. #> geomatrix.tif    74     107    123 126.765     132  255 #> dimension(s): #>   from to  offset delta                refsys point x/y #> x    1 20 1841002   1.5 WGS 84 / UTM zone 11N  TRUE [x] #> y    1 20 1144003  -1.5 WGS 84 / UTM zone 11N  TRUE [y] #> sheared raster with parameters: -5 -5  new = st_crs('OGC:CRS84') y = st_transform(x, new) plot(st_transform(st_as_sfc(st_bbox(x)), new), col = NA, border = 'red') plot(st_as_sfc(y, as_points=FALSE), col = NA, border = 'green', axes = TRUE, add = TRUE) image(y, col = heat.colors(12), add = TRUE) plot(st_as_sfc(y, as_points=TRUE), pch=3, cex=.5, col = 'blue', add = TRUE) plot(st_transform(st_as_sfc(x, as_points=FALSE), new), add = TRUE)"},{"path":"/reference/st_warp.html","id":null,"dir":"Reference","previous_headings":"","what":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","title":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","text":"Warp (resample) grids stars objects new grid, possibly new coordinate reference system","code":""},{"path":"/reference/st_warp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","text":"","code":"st_warp(   src,   dest,   ...,   crs = NA_crs_,   cellsize = NA_real_,   segments = 100,   use_gdal = FALSE,   options = character(0),   no_data_value = NA_real_,   debug = FALSE,   method = \"near\",   threshold = NA_real_ )"},{"path":"/reference/st_warp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","text":"src object class stars source raster dest object class stars target raster geometry ... ignored crs coordinate reference system destination grid, used dest missing cellsize length 1 2 numeric; cellsize target coordinate reference system units segments (total) number segments segmentizing bounding box transforming new crs use_gdal logical; TRUE, use gdal's warp warper, gdal_utils options character vector options, passed gdalwarp no_data_value value used gdalwarp no_data (NA) writing temporary file;  setting use_gdal TRUE leads warning debug logical; TRUE, remove temporary gdalwarp destination file, print name method character; see details options; methods near work use_gdal=TRUE threshold numeric; distance threshold warping curvilinear grids: new cells distances larger threshold assigned NA values.","code":""},{"path":"/reference/st_warp.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","text":"method one near, bilinear, cubic, cubicspline, lanczos, average, mode, max, min, med, q1 q3; see https://github.com/r-spatial/stars/issues/109 gridded spatial data (dimensions x y), see figure; existing grid transformed regular grid defined dest, possibly new coordinate reference system. dest specified, crs , procedure used choose target grid similar projectRaster. entails: () envelope (bounding box polygon) transformed new crs, possibly segmentation (red box); (ii) grid formed new crs, touching transformed envelope East North side, (cellsize given) cellsize similar cell size src, extent least covers x; (iii) cell center new grid, matching grid cell x used; match, NA value used.","code":""},{"path":"/reference/st_warp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Warp (resample) grids in stars objects to a new grid, possibly in an new coordinate reference system — st_warp","text":"","code":"geomatrix = system.file(\"tif/geomatrix.tif\", package = \"stars\") (x = read_stars(geomatrix)) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #>                Min. 1st Qu. Median    Mean 3rd Qu. Max. #> geomatrix.tif    74     107    123 126.765     132  255 #> dimension(s): #>   from to  offset delta                refsys point x/y #> x    1 20 1841002   1.5 WGS 84 / UTM zone 11N  TRUE [x] #> y    1 20 1144003  -1.5 WGS 84 / UTM zone 11N  TRUE [y] #> sheared raster with parameters: -5 -5  new_crs = st_crs('OGC:CRS84') y = st_warp(x, crs = new_crs) plot(st_transform(st_as_sfc(st_bbox(x)), new_crs), col = NA, border = 'red') plot(st_as_sfc(y, as_points=FALSE), col = NA, border = 'green', axes = TRUE, add = TRUE) image(y, add = TRUE, nbreaks = 6) plot(st_as_sfc(y, as_points=TRUE), pch=3, cex=.5, col = 'blue', add = TRUE) plot(st_transform(st_as_sfc(x, as_points=FALSE), new_crs), add = TRUE)  # warp 0-360 raster to -180-180 raster: r = read_stars(system.file(\"nc/reduced.nc\", package = \"stars\")) #> sst, anom, err, ice,  r %>% st_set_crs('OGC:CRS84') %>% st_warp(st_as_stars(st_bbox(), dx = 2)) -> s plot(r, axes = TRUE) # no CRS set, so no degree symbols in labels  plot(s, axes = TRUE)  # downsample raster (90 to 270 m) r = read_stars(system.file(\"tif/olinda_dem_utm25s.tif\", package = \"stars\")) r270 = st_as_stars(st_bbox(r), dx = 270) r270 = st_warp(r, r270)"},{"path":"/reference/st_xy2sfc.html","id":null,"dir":"Reference","previous_headings":"","what":"replace x y raster dimensions with simple feature geometry list (points, or polygons = rasterize) — st_xy2sfc","title":"replace x y raster dimensions with simple feature geometry list (points, or polygons = rasterize) — st_xy2sfc","text":"replace x y raster dimensions simple feature geometry list (points, polygons = rasterize)","code":""},{"path":"/reference/st_xy2sfc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"replace x y raster dimensions with simple feature geometry list (points, or polygons = rasterize) — st_xy2sfc","text":"","code":"st_xy2sfc(x, as_points, ..., na.rm = TRUE)"},{"path":"/reference/st_xy2sfc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"replace x y raster dimensions with simple feature geometry list (points, or polygons = rasterize) — st_xy2sfc","text":"x object class stars as_points logical; TRUE, generate points cell centers, else generate polygons ... arguments passed st_as_sfc na.rm logical; omit (remove) cells entirely missing valued (across dimensions)?","code":""},{"path":"/reference/st_xy2sfc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"replace x y raster dimensions with simple feature geometry list (points, or polygons = rasterize) — st_xy2sfc","text":"object class stars x y raster dimensions replaced single sfc geometry list column containing either points, polygons. Adjacent cells identical values merged; see st_rasterize .","code":""},{"path":"/reference/stars_sentinel2.html","id":null,"dir":"Reference","previous_headings":"","what":"Sentinel-2 sample tile — stars_sentinel2","title":"Sentinel-2 sample tile — stars_sentinel2","text":"Sentinel-2 sample tile, downloaded  reads four 10-m bands: B2 (490 nm), B3 (560 nm), B4 (665 nm) B8 (842 nm)","code":""},{"path":"/reference/stars_sentinel2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sentinel-2 sample tile — stars_sentinel2","text":"","code":"stars_sentinel2"},{"path":"/reference/stars_sentinel2.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Sentinel-2 sample tile — stars_sentinel2","text":"object class stars_proxy (inherits stars) dimension 10980 x 10980 x 4.","code":""},{"path":"/reference/stars_subset.html","id":null,"dir":"Reference","previous_headings":"","what":"subset stars objects — stars_subset","title":"subset stars objects — stars_subset","text":"subset stars objects","code":""},{"path":"/reference/stars_subset.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"subset stars objects — stars_subset","text":"","code":"# S3 method for stars_proxy [(x, i, downsample = 0) <- value  # S3 method for stars [(x, i = TRUE, ..., drop = FALSE, crop = !is_curvilinear(x))  # S3 method for stars [(x, i) <- value  st_flip(x, which = 1)"},{"path":"/reference/stars_subset.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"subset stars objects — stars_subset","text":"x object class stars first selector: integer, logical character vector indicating attributes select, object class sf, sfc, bbox, stars used spatial selector; see details downsample downsampling rate used case stars_proxy object value array dimensions equal x, vector value recycled array ... (logical integer vector) selectors, matched order, select individual dimensions drop logical; TRUE, degenerate dimensions (one value) dropped crop logical; TRUE parameter spatial geometry (sf sfc) object, extent (bounding box) result cropped match extent using st_crop. Cropping curvilinear grids supported. character integer; dimension(s) flipped","code":""},{"path":"/reference/stars_subset.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"subset stars objects — stars_subset","text":"st_flip flips (reverts) array values along chosen dimension  without(s) changing dimension properties","code":""},{"path":"/reference/stars_subset.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"subset stars objects — stars_subset","text":"object class sf, sfc bbox, spatial subset covering geometry selected, possibly followed cropping extent. Array values cell centre inside geometry assigned NA. class stars, attributes logical, cells x corresponding NA FALSE cells assigned NA. Dimension ranges containing negative values NA may partially supported. assignment (replacement form, [<-), argument needs either () stars object logical attribute(s) dimensions matching (possibly recycling) x, case TRUE cells replaced /value recycled dimensions arrays x, (ii) length-one integer character vector indicating array replace, case value may stars object vector array (recycled).","code":""},{"path":"/reference/stars_subset.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"subset stars objects — stars_subset","text":"","code":"tif = system.file(\"tif/L7_ETMs.tif\", package = \"stars\") x = read_stars(tif) x[,,,1:3] # select bands #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    21      58     70 70.36041      83  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   3      NA    NA                         NA    NA     x[,1:100,100:200,] # select x and y by range #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif    13      54     65 67.21531      77  252 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 100  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y     100 200 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x[\"L7_ETMs.tif\"] # select attribute #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     1      54     69 68.91242      86  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     xy = structure(list(x = c(293253.999046018, 296400.196497684), y = c(9113801.64775462, 9111328.49619133)), .Names = c(\"x\", \"y\")) pts = st_as_sf(data.frame(do.call(cbind, xy)), coords = c(\"x\", \"y\"), crs = st_crs(x)) image(x, axes = TRUE) plot(st_as_sfc(st_bbox(pts)), col = NA, add = TRUE)  bb = st_bbox(pts) (xx = x[bb]) #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max. #> L7_ETMs.tif     3      56     73 70.87303      89  255 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x     158 268  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y     245 331 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     image(xx) plot(st_as_sfc(bb), add = TRUE, col = NA)  image(x) pt = st_point(c(x = 290462.103109179, y = 9114202.32594085)) buf = st_buffer(st_sfc(pt, crs = st_crs(x)), 1500) plot(buf, add = TRUE)   buf = st_sfc(st_polygon(list(st_buffer(pt, 1500)[[1]], st_buffer(pt, 1000)[[1]])),    crs = st_crs(x)) image(x[buf]) plot(buf, add = TRUE, col = NA)  image(x[buf, crop=FALSE]) plot(buf, add = TRUE, col = NA)  # with i of class stars: x[x > 75] # generates lots of NA's; pattern for each band #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max.   NA's #> L7_ETMs.tif    76      82     90 94.40052     101  255 443210 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x[x[,,,1] > 75] # recycles a single band template for all bands #> stars object with 3 dimensions and 1 attribute #> attribute(s): #>              Min. 1st Qu. Median     Mean 3rd Qu. Max.   NA's #> L7_ETMs.tif     1      63     79 74.98075      93  255 318960 #> dimension(s): #>      from  to  offset delta                     refsys point x/y #> x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] #> band    1   6      NA    NA                         NA    NA     x = read_stars(tif) # replace, using a logical stars selector: cuts all values above 90 to 90 x[x > 90] = 90 # replace a single attribute when there are more than one: s = split(x) names(s) = paste0(\"band\", 1:6) # rescale only band 1: s[1] = s[1] * 0.75  # rescale only attribute named \"band2\": s[\"band2\"] = s[\"band2\"] * 0.85  # create a new attribute from a numeric vector: s[\"rnorm\"] = rnorm(prod(dim(s)))  s #> stars object with 2 dimensions and 7 attributes #> attribute(s): #>             Min.    1st Qu.       Median         Mean    3rd Qu.      Max. #> band1  35.250000 50.2500000 58.500000000 57.878219426 66.7500000 67.500000 #> band2  27.200000 46.7500000 56.100000000 56.776205555 67.1500000 76.500000 #> band3  21.000000 49.0000000 63.000000000 62.777008987 77.0000000 90.000000 #> band4   9.000000 52.0000000 63.000000000 58.940544413 75.0000000 90.000000 #> band5   1.000000 63.0000000 89.000000000 71.285092146 90.0000000 90.000000 #> band6   1.000000 32.0000000 60.000000000 56.662127182 88.0000000 90.000000 #> rnorm  -5.096659 -0.6759559 -0.004252816 -0.003659307  0.6699726  4.216072 #> dimension(s): #>   from  to  offset delta                     refsys point x/y #> x    1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] #> y    1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] lc = read_stars(system.file(\"tif/lc.tif\", package = \"stars\")) x = c(orig = lc,        flip_x = st_flip(lc, \"x\"),        flip_y = st_flip(lc, \"y\"),        flip_xy = st_flip(lc, c(\"x\", \"y\")),        along = 3) plot(x)"},{"path":"/reference/write_stars.html","id":null,"dir":"Reference","previous_headings":"","what":"write stars object to gdal dataset (typically: to file) — write_stars","title":"write stars object to gdal dataset (typically: to file) — write_stars","text":"write stars object gdal dataset (typically: file)","code":""},{"path":"/reference/write_stars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"write stars object to gdal dataset (typically: to file) — write_stars","text":"","code":"write_stars(obj, dsn, layer, ...)  # S3 method for stars write_stars(   obj,   dsn,   layer = 1,   ...,   driver = detect.driver(dsn),   options = character(0),   type = if (is.factor(obj[[1]]) && length(levels(obj[[1]])) < 256) \"Byte\" else \"Float32\",   NA_value = NA_real_,   update = FALSE,   normalize_path = TRUE,   scale_offset = c(1, 0) )  # S3 method for stars_proxy write_stars(   obj,   dsn,   layer = 1,   ...,   driver = detect.driver(dsn),   options = character(0),   scale_offset = c(1, 0),   type = \"Float32\",   NA_value = NA_real_,   chunk_size = c(dim(obj)[1], floor(2.5e+07/dim(obj)[1])),   progress = TRUE )  detect.driver(filename)"},{"path":"/reference/write_stars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"write stars object to gdal dataset (typically: to file) — write_stars","text":"obj object class stars dsn gdal dataset (file) name layer attribute name; missing, first attribute written ... passed gdal_write driver driver driver name; see st_drivers options character vector dataset creation options, passed GDAL type character; output binary type, one : Byte eight bit unsigned integer, UInt16 sixteen bit unsigned integer, Int16 sixteen bit signed integer, UInt32 thirty two bit unsigned integer, Int32 thirty two bit signed integer, Float32 thirty two bit floating point, Float64 sixty four bit floating point. NA_value non-NA value represent R's NA value target raster file; set NA, ignored. update logical; TRUE, existing file updated normalize_path logical; see read_stars scale_offset length 2 numeric vector scale, offset values: raw values computed raw = (value - offset) / scale written dsn; scale offset values written dsn else warning raised chunk_size length two integer vector number pixels (x, y) used read/write loop; see details. progress logical; TRUE, progress bar shown filename character; used guessing driver short name based file  extension; see examples","code":""},{"path":"/reference/write_stars.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"write stars object to gdal dataset (typically: to file) — write_stars","text":"write_stars first creates target file, updates sequentially writing blocks chunk_size. case obj multi-file stars_proxy object, files written layers output file dsn","code":""},{"path":"/reference/write_stars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"write stars object to gdal dataset (typically: to file) — write_stars","text":"","code":"detect.driver(\"L7_ETMs.tif\") #> [1] \"GTiff\""},{"path":"/news/index.html","id":"version-06-6","dir":"Changelog","previous_headings":"","what":"version 0.6-6","title":"version 0.6-6","text":"constrain reading full GEOLOCATION arrays case 2-D; #678","code":""},{"path":"/news/index.html","id":"version-06-5","dir":"Changelog","previous_headings":"","what":"version 0.6-5","title":"version 0.6-5","text":"CRAN release: 2024-04-04 fix st_as_stars.Spatial() Spatial gridded objects non-square grid cells, see https://github.com/r-spatial/gstat/issues/123 add prcomp() methods stars stars_proxy objects, working attributes last dimension st_rasterize() align=TRUE returns NA values data; #668 read_mdim() reads tables composity type, returning data.frame case; #659 st_rotate() transforms rotated grid back curvilinear grid unrotated coordinates. aggregate.stars() deals functions return one number, putting new dimension like st_apply() st_as_stars.data.frame() st_as_stars.sf() better handle non-raster data cubes plot.stars() resets layout needed (one sub-plot, key present) fixed st_as_stars.im(); #648 st_crs<-.stars() less critical existing CRS class crs c.stars() single (valid) argument along specified adds dimension; #646 st_join.stars() keeps attributes x complete; #643 st_as_stars.list() requires named list, set names array dimensions present","code":""},{"path":"/news/index.html","id":"version-06-4","dir":"Changelog","previous_headings":"","what":"version 0.6-4","title":"version 0.6-4","text":"CRAN release: 2023-09-11 plot.stars() fill argument shifts unused plotting space sub-maps bottom right side plotting area plot.stars(), key.width default sensitive par(\"ps\"), pointsize graphics parameter plot.stars() image.stars() sensitive cex.axis, axes key (requires sf >= 1.0-14); #642 move lwgeom dependency Suggests; using st_transform_proj() vector data cubes requires loading lwgeom first","code":""},{"path":"/news/index.html","id":"version-06-3","dir":"Changelog","previous_headings":"","what":"version 0.6-3","title":"version 0.6-3","text":"CRAN release: 2023-08-11 st_downsample() argument offset pixel-shift downsampled images st_downsample() argument FUN compute sub-tile aggregates; #604 st_as_stars.bbox() retains factor values; #640 fix CRAN error test script st_crop() works (warns) case crop area overlap area object; #638","code":""},{"path":"/news/index.html","id":"version-06-2","dir":"Changelog","previous_headings":"","what":"version 0.6-2","title":"version 0.6-2","text":"CRAN release: 2023-07-12 split.stars() accepts stars objects multiple attributes; #635 [.stars() supports NA values dimension ranges vector geometry (sfc) dimensions, resulting empty geometries st_extract() supports extracting points values curvilinear grids (proxy); #632 read_mdim() reads curvilinear rasters (geolocation arrays), far full extent/resolution st_as_stars.stars() accepts curvilinear argument lon/lat array names present .x consistently use OGC:CRS84 instead EPSG:4326 setting values = NULL st_set_dimensions() removes dimension values gracefully handle plotting global coverage curvilinear grids; #632 image.stars() plots images (e.g. cross sections) x /y singular absent; #628 st_as_stars.cubble_df() adds conversion cubble; cubble::as_cubble() methods converts back [<-.stars() accepts indicator (numeric length character) array replaced; #626 plot.stars() gains argument key.lab set legend key label (requires sf >= 1.0-13)","code":""},{"path":"/news/index.html","id":"version-06-1","dir":"Changelog","previous_headings":"","what":"version 0.6-1","title":"version 0.6-1","text":"CRAN release: 2023-04-06 remove rgdal dependency read_stars() fixes combining bands different block sizes; #623 st_warp() gets (proper) default value threshold; #618 read_mdim() reads “raster” single pixel (point) [.stars(), r[x] allows x logical stars object [<-.stars_proxy() clones environment, r[r > 100] = NA don’t get infinite recursion realizing r read_stars() avoids reading raster twice determine choose proxy; proxy can now set (defaults ) number cells (bands * rows * columns) data read memory returned stars_proxy object; #609 fix using RasterIO read_stars() proxy=TRUE; #608 plot.stars() hook function can handle arguments row, col, nrow, ncol, nr, value bbox; #600 fix handling categorical rasters colors without category labels; #595, fallout #565 fix subsetting proxy objects time range; #596","code":""},{"path":"/news/index.html","id":"version-06-0","dir":"Changelog","previous_headings":"","what":"version 0.6-0","title":"version 0.6-0","text":"CRAN release: 2022-11-21 write_stars() writes scaled /shifted values using argument scale_offset; #589 aggregate.stars_proxy() implements aggregation non-spatial objects (lazily) fix [.stars_proxy() selecting dimension 3 higher; #561 plot.stars(), col can also palette function st_res() returns spatial resolutions, optionally dimension resolutions; #557 thanks Krzysztof Dyba read_stars() shortens band array names contain common start ending, unless names become empty shorten=FALSE set; e.g. shorten=\"B\" puts B shortened array names printing stars dimension tables omits fields NULL NA values, unless print(..., = TRUE) given improve reading categorical rasters, now avoids calling factor(); #565 thanks Krzysztof Dyba read_mdim() read bounds arrays coordinates using bounds attribute, accepts bounds argument specify attribute missing time() returns time stamps time dimension st_cells() returns cell index set point coordinates, provided sf sfc object; #558 reading & writing vector data cubes: read_mdim() reads CF compliant vector geometries, reconstructs sfc dimension; write_mdim() writes . write_mdim() uses GDAL multidimensional array API; read_mdim() uses arguments offset, count step read sub-arrays strided arrays (requires sf >= 1.0-9)","code":""},{"path":"/news/index.html","id":"version-05-6","dir":"Changelog","previous_headings":"","what":"version 0.5-6","title":"version 0.5-6","text":"CRAN release: 2022-07-21 export read_mdim(), reader using GDAL’s multidimensional array API (sf <= 1.0-8) remove tos_O1_2001-2002.nc packaged datasets keep source package size 5 Mb .POSIXct.stars() converts PCICt dimensions POSIXct values. improve handling PCICt 360 365 day calendars; read read_mdim (requires sf >= 1.0-9) read_stars() reads factor levels better attribute table; #484 thanks @ailich read_stars() puts band names band_meta DESCRIPTION= tags values; improve handling categorical rasters, exchange terra; #484 plot() handles auto colors better factor arrays read_ncdf() handles units formally setting crs; #533 print message dimensions proxy objects reflect unevaluated operations; #530 passing na.action = na.omit geom_stars() removes NA values; #532 read_stars() detects curvilinear grids automatically; #513 st_warp() warps curvilinear grids (using Euclidean distances coordinates); #513 Ops.stars() errors (common) dimension identical; #506 guess_raster() accepts empty rows/columns sparse grids; #509 speed rgb plotting; #503 Added new helper function st_tile() specify block parameters (nXOff, nYOff, nXsize, nYSize) required RasterIO argument read_stars(); #492 thanks Krzysztof Dyba","code":""},{"path":"/news/index.html","id":"version-05-5","dir":"Changelog","previous_headings":"","what":"version 0.5-5","title":"version 0.5-5","text":"CRAN release: 2021-12-19 st_as_stars.bbox() creates empy raster file proxy = TRUE; #489 st_rasterize() option align = TRUE use template aligning new raster ; #489 adrop.stars() missing dimensions longer drops x/y raster dimensions; #485 aggregate.stars() propagates units arrays; #477","code":""},{"path":"/news/index.html","id":"version-05-4","dir":"Changelog","previous_headings":"","what":"version 0.5-4","title":"version 0.5-4","text":"CRAN release: 2021-11-19 c.stars() fails tries merge arrays different units; #475 NetCDF files, read_stars() uses long_name array name; #475 add rename() method; #470 refresh CRS packaged L7_ETMs.tif; #466 .data.frame.stars() works mixed regular rectilinear dimension; #458 plot.stars() plots curvilinear rasters color table, without table col argument passed; #456 st_extract() accepts matrix points argument, performance important; see e.g. https://github.com/rspatial/terra/issues/341 fix bug st_crop() cropping area larger grid; #455 export st_downsample(), e.g. used tmap; https://github.com/r-tmap/tmap/issues/597 argument downsample plot.stars() st_as_stars.stars_proxy() st_downsample() effect (removed one-offset ). st_redimension() works curvilinear grids; #441 downsample propagated subexpressions like r[r < 50] = NA predict.stars() obtains argument drop_dimensions , TRUE, drops dimensions prediction data.frame; #362 extend options st_rgb(), #432, Gabo Gaona allow subsetting [ using labels, e.g. band names.","code":""},{"path":"/news/index.html","id":"version-05-3","dir":"Changelog","previous_headings":"","what":"version 0.5-3","title":"version 0.5-3","text":"CRAN release: 2021-06-08 read_stars() accepts function (list functions) first argument, allowing saving stars objects read package directories resolving platform-dependent paths run-time handle categorical rasters starting value 0 (adding 1, warning); #428 add %% method; #424 read_stars() gains argument tolerance control tolerance dimension value comparisons; #414 binary Ops (like +, -, * etc.) work stars_proxy objects; #390 st_rasterize() rasterizes multiple attributes, handles factors (sf >= 0.9-9) write_stars() deals better stars_proxy objects; #404 fix regression reading stars_proxy objects; #379 add [<- (partially) .na methods stars_proxy objects; #402 add replace_na() methods; #402","code":""},{"path":"/news/index.html","id":"version-05-2","dir":"Changelog","previous_headings":"","what":"version 0.5-2","title":"version 0.5-2","text":"CRAN release: 2021-03-17 read write factor levels GDAL category names; write color table; #392 handle normalize_path choosing proxy; #391 ignore units different units across bands subdataset speed st_rgb() using faster st_apply() approach; #315, #390 improve handling crs Spatial objects (avoid loss wkt comments) correctly write band subsets smaller proxy objects; #291 write arbitrarily cropped proxy objects; #291 speed st_apply() function provided works chunks time; #390 warn breaks = “quantile” results single class; #388 fix [ bug selecting bands proxy objects; #388 stars_proxy objects, write_stars() writes objects multi-layer file; #385 multi-file proxy objects can st_warp()ed use_gdal = TRUE; #385","code":""},{"path":"/news/index.html","id":"version-05-1","dir":"Changelog","previous_headings":"","what":"version 0.5-1","title":"version 0.5-1","text":"CRAN release: 2021-01-25 fix weird GDAL-related bug stars2 vignette read_ncdf() take time mid-points regular intervals, starting points; #378","code":""},{"path":"/news/index.html","id":"version-05-0","dir":"Changelog","previous_headings":"","what":"version 0.5-0","title":"version 0.5-0","text":"CRAN release: 2021-01-19 fix handling rasters color tables; #375 st_apply() methods stars_proxy objects handle … ; #374 add st_bbox(), st_crs() methods terra’s SpatVector objects; https://github.com/r-tmap/tmap/issues/536 add st_bbox(), st_crs() st_as_stars() methods terra’s SpatRaster objects; https://github.com/r-tmap/tmap/issues/536 allow multi-resolution attributes stars_proxy objects (e.g., gray scale sentinel-2 bands); see vignettes 2 7 examples. plot() defaults categorical color scale plotting factor variable; https://github.com/r-tmap/tmap/issues/526 st_extract() extracts space-time points time_column specified, handles time intervals; #352 add [[<-.stars method, now called $<-.stars, array names can set programmatically add transmute() methods plot.stars() calls droplevels factor array NA levels; #339 read_stars() reads NaNs NA; #333 improve st_extract() method stars stars_proxy objects; interpolation options reduced bilinear; #322, #279, #290 better handle categorical rasters start value 1; #329 plot layout can controlled mfrow = c(nr, nc) argument stars_proxy objects normalized path; #331 cropping selecting bbox treats cells always small polygons; #330 add faster st_extract() method stars objects; #322 added vignette: “raster functions map stars functions”, Sebastien Rochette; #122, #325 fix bug dimension values field downsampling; #324 write_stars() also writes band names; #323 add rgdal Suggests: call_list entry stars_proxy object carries proper calling environment; #309 st_as_sf.stars() copes zero attribute (empty) stars objects add st_set_bbox() generic, set raster extent, motivated #315 set tic, great help @pat-s, #313 get rid proj4strings representing coordinate reference systems; #312 (x, “Spatial”) correctly handles dimension values different one read_stars() now sets BANDNAME GDAL metadata item, else band’s GetDescription() band’s dimension values st_as_stars.data.frame() reads simple tables (non-raster data) dims length less 2 band descriptions band dimension values dimension tables simpler, shown properly Rstudio st_rgb() gains probs argument, cut stretch based quantiles (x, \"Raster\") merges multiple attributes converting raster brick","code":""},{"path":"/news/index.html","id":"version-04-3","dir":"Changelog","previous_headings":"","what":"version 0.4-3","title":"version 0.4-3","text":"CRAN release: 2020-07-08 fix bug st_as_stars.Raster; set crs one assigned raster; https://github.com/r-tmap/tmap/issues/471 add s2 Suggests: new function st_rgb() collapses (reduces) dimension rgb hex value; #302","code":""},{"path":"/news/index.html","id":"version-04-2","dir":"Changelog","previous_headings":"","what":"version 0.4-2","title":"version 0.4-2","text":"CRAN release: 2020-07-01 aggregate.stars() handles arrays NA values now correctly; brought #299 Thorsten Simon aggregate.stars() gains argument exact , TRUE, calls exactextractr polygonal aggregation; #289 read_stars() reads subdatasets dimensions equal first, warns ignoring others; #296 make copying dimensions somewhat easier; #295 st_as_stars.Raster() tries read file raster object -memory object. write_stars() normalizes path, read_stars already ; #293 merge() proxy objects acts, longer lazy; #290 st_as_stars.Raster() returns proxy object raster layer disk add st_extract() extract e.g. time series grids point locations; #279; #290 read_stars() chooses value proxy depends data dimensions; #281 x/y range subsetting stars_proxy objects now reads range, similar crop already . st_warp() preserves levels colors; https://github.com/r-tmap/tmap/issues/429 st_crop() works bounding boxes larger downsampled bounding box; #276 st_crop() non-zero default epsilon (bounding box shrinkage) exclude cells touching crop bounding box; #275 image.stars() (hence plot.stars) gains extent argument setting extent plot; https://github.com/r-spatial/sf/issues/1193","code":""},{"path":"/news/index.html","id":"version-04-1","dir":"Changelog","previous_headings":"","what":"version 0.4-1","title":"version 0.4-1","text":"CRAN release: 2020-04-07 st_warp() (stars native) flips longitudes full cycle; #256, #264, #269 handle axis order st_transform (requires sf >= 0.9-1) depend sf 0.9-0 adapt cubelyr split-dplyr; add cubelyr Suggests:; https://github.com/hadley/cubelyr/issues/2 add droplevels() method handle color tables, category tables raster attribute tables read GDAL; #128, #245; https://github.com/r-spatial/mapview/issues/208 handle dimension crs specially, proxy objects now. handle new-style crs objects upcoming sf, moving away proj4strings handle full crs objects refsys element spatial dimensions, rather proj4string st_raster_type(x) reveals raster type x; #248, https://github.com/r-tmap/tmap/issues/368 add st_as_stars.OpenStreetMap() method; #241 @mtennekes add st_flip() flip arrays along one dimensions without changing dimension properties add .owin() method convert (2D raster) stars objects spatstat owin; https://github.com/r-spatial/sf/issues/1233 temporal aggregation, aggregate.stars now also takes arguments like “week”, “month”, “5 days” add st_as_stars() method xts objects; improve .xts stars objects skip tests solaris","code":""},{"path":"/news/index.html","id":"version-04-0","dir":"Changelog","previous_headings":"","what":"version 0.4-0","title":"version 0.4-0","text":"CRAN release: 2019-10-10 plot() now uses data figure breaks, order also find extremes; #216 st_mosaic() creates mosaics spatially disjoint rasters; #210 #205 large refactoring read_ncdf, David Blodgett Mike Sumner, affecting #199, #89, #30, #86, #175 allow funny units like m s**-1; #201 add contour() method stars objects; #196 plot uses rasterImage default available; #194 x y raster dimensions can set unset xy argument st_set_dimensions; #190 retain factor levels dimension values set st_set_dimensions; #188 add conversion stars_proxy Raster: #193 make plotting multiple curvilinear grids work plot default cell borders case curvilinear, rotated sheared grids robustify handling units allow read_ncdf() ignore bounds scale applied wrongly multi-band images; #189, requires sf >= 0.7-5 .nc now recognized correctly write_stars write NetCDF file; #186 [ subset now works correctly negative logical indices; #184, #185 NA values float32 grids now correctly detected; #182, requires sf >= 0.7-5 cropping stars_proxy object now works; #179 st_apply() can now loop Raster layers; examples #176","code":""},{"path":"/news/index.html","id":"version-03-1","dir":"Changelog","previous_headings":"","what":"version 0.3-1","title":"version 0.3-1","text":"CRAN release: 2019-04-23 st_as_stars.bbox now ncells pretty argument, better choose default raster dimensions geom_stars now works stars_proxy objects, needs downsample set; #21 NA values Float32 rasters now read correctly read_stars; #182 handle bounds, given, read_ncdf provide time parsing (POSIXct, PCICt) read_ncdf; #115","code":""},{"path":"/news/index.html","id":"version-03-0","dir":"Changelog","previous_headings":"","what":"version 0.3-0","title":"version 0.3-0","text":"CRAN release: 2019-02-24 add st_area method return raster grid cell sizes; #99 fix st_warp use_gdal=TRUE, allowing multi-band warps add st_get_dimension_values get values particular dimension (meaningful); #100 allow setting intervals dimension values; see examples st_dimensions add st_contour, clean st_as_sf; #99 experimental color table support; https://github.com/r-spatial/mapview/issues/208 rewrote vignettes, added vignettes; #99 deprecate st_write.stars write_stars; #96 use “native” R array-factor support support PCICt 360- 365-day calendars; #29 remove import ncdf4 favor RNetCDF, now line practice ncmeta package. Thanks David Blodgett motivation testing (see #87, #94). st_as_sf uses date/time column names appropriate allow missing trailing comma’s subsetting: [1,,] [1,] now . move rlang Imports: ; rewrite [ subset using rlang. add conversion Spatial* classes, including gridded ones, taking care factor variables depend sf 0.7-2 add logz support log-scale keys plot image","code":""},{"path":"/news/index.html","id":"version-02-0","dir":"Changelog","previous_headings":"","what":"version 0.2-0","title":"version 0.2-0","text":"CRAN release: 2018-10-25 vignettes now use external package, starsdata, larger dataset examples support [<-.stars e.g. mask values; support .na.stars replace NA masks support cut methods factor arrays (plot, subset); #56 add st_rasterize, uses GDALRasterize rasterize sf object; #13 st_as_sf.stars now uses GDAL(F)Polygonize give regular sheared grid grid cells points, returns contour bands using GDALContourGenerateEx (requiring GDAL 2.4.0) case cells points; #13 support curvilinear grids; see #54 data_model vignette add vignette stars_proxy objects work stars_proxy objects defer processing st_apply jobs subsampling; #50 allow reading sections raster, raster lower resolution, selected bands; #48 allow reading vectors (arrays) 2^31 elements; #48 fold higher dimensions third dimension coercing Raster; #40","code":""},{"path":"/news/index.html","id":"version-01-1","dir":"Changelog","previous_headings":"","what":"version 0.1-1","title":"version 0.1-1","text":"CRAN release: 2018-07-25 add meta data reader read_stars","code":""},{"path":"/news/index.html","id":"version-01-0","dir":"Changelog","previous_headings":"","what":"version 0.1-0","title":"version 0.1-0","text":"add merge (merge attributes array dimension) split (split dimension attributes) interface sf, raster spacetime improve plotting handle logical arrays plot add st_apply, analogous apply add cropping/masking used x[buf] buf sf, sfc bbox object; masking x[buf, crop = FALSE] add Ops (+,-,/ etc) Math (sqrt, pow, sin etc) methods add dimnames dimnames<- methods stars objects downsample large grids plot pixels actually shown can plot rectilinear grids (plot rgb images regular grids) rgb argument image works [ array-like subsetting works; first index attribute selector","code":""},{"path":"/news/index.html","id":"version-00","dir":"Changelog","previous_headings":"","what":"version 0.0","title":"version 0.0","text":"interface 9 C++ gdal utils gdal_utils() (now part sf)","code":""}]