Questions tagged [r-stars]

Questions about the stars R package for spatiotemporal arrays.

stars is an R package for spatiotemporal arrays and raster and vector "data cubes".

58 questions
2
votes
1 answer

"CRS object has comment, which is lost in output" in krige

I am trying to krige for water quality dataset with Latitude, longitude which using CRS("+init=epsg:4326"). GGT <- read.csv("C:/Users/user/Data/newdata2019.csv") coordinates(GGT) = ~Lon+Lat GGT <- st_as_sf(GGT) st_crs(GGT) <- 4326 GGTgrid <-…
Heeone Lee
  • 43
  • 1
  • 6
2
votes
0 answers

Removing small polygons inside the larger polygons in R

I'm starting from the attached raster file which is a world map of 5 climate zones. I then convert it into a simple feature. My goal is to get rid of those small polygons contained in the larger ones so that I'm only visualizing the outlines of the…
Herman Toothrot
  • 1,463
  • 3
  • 23
  • 53
2
votes
1 answer

How to reassign cell/pixel values in R stars objects

I am new to the stars package in R, and am trying to work out how I assign new values to cells within a two dimensional stars object (a raster in raster package speak). With raster I can do as follows > library("raster") > library('stars') > tif =…
Terry B
  • 83
  • 7
2
votes
1 answer

How to extract values from a raster using polygons with the R stars package?

Using the stars package, it is possible to the st_extract() function to extract values from a raster at defined locations. library(stars) #> Loading required package: abind #> Loading required package: sf #> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ…
Philippe Massicotte
  • 1,321
  • 12
  • 24
2
votes
1 answer

extract mean value of raster with buffer condition on second layer/attribute

I have this stars object (could be also formatted to raster): stars object with 2 dimensions and 2 attributes attribute(s): LST_mean elevation Min. :14.98 Min. :296.0 1st Qu.:16.89 1st Qu.:346.9 Median :17.64 Median…
2
votes
0 answers

convert large stars object to sf object

My ultimate goal is to convert landcover raster (.tif) objects to an sf object representing the raster's grid and the original values of each cell within each geometry. I have been able to do this for smaller rasters doing the following: library(sf)…
2
votes
1 answer

How to plot global rasters with tmap in Robinson projection without duplicated areas?

I've been plotting some global rasters lately using mainly raster and tmap. I'd like to plot the maps in Robinson projection instead of lat-lon. Simple projection to Robinson however duplicates some areas on the edges of the map as you can see from…
vdoe
  • 33
  • 4
1
vote
0 answers

Dimension problem while reading netcdf4 files in 'stars' R package

In essence I'm trying to do a relatively simple set of operations on a collection of netcdf4 files I've downloaded. They're sourced from ESA's Lakes Climate Change Initiative database of satellite-derived limnological data, and each netcdf4 file…
1
vote
2 answers

stack geotiff with stars 'along' when 'band' dimension contains band + time information

I have a timeseries of geotiff files I'd like to stack in R using stars. Here's the first two: urls <-…
cboettig
  • 12,377
  • 13
  • 70
  • 113
1
vote
1 answer

stars::read_stars and raster::raster have different projections when reading the same .nc file

I'm trying to read a .nc raster file in R. The older function raster::raster() reads the data perfectly fine. I'd like to reproduce the results using a newer function stars::read_stars(), but somehow it does not work for me. The data…
Miao Cai
  • 902
  • 9
  • 25
1
vote
0 answers

Plotting the output from predict function of stars package throws error

I am trying to plot the output from predict function in stars package. But it is throwing error library(stars) tif = system.file("tif/L7_ETMs.tif", package = "stars") i = read_stars(tif, proxy = TRUE) %>% split() nclus = 5 sam = st_sample(i,…
UseR10085
  • 7,120
  • 3
  • 24
  • 54
1
vote
0 answers

Discrepancy in outputs between stars::st_contour() and graphics::contour in R

I have a raster object (link to file here) that plots contours 'wrong' in ggplot2 compared to base graphics. Using ggplot2, the bottom area is missing the two 50% contour circles that are present in the base graphics plot. The total areas produced…
FlyingDutch
  • 1,100
  • 2
  • 14
  • 24
1
vote
1 answer

Subsetting ncdf file using stars package in R

I am trying to subset a climatic variable from Copernicus. devtools::install_github("r-spatial/stars") library(stars) library(ncdf4) library(RNetCDF) pp <- read_ncdf("~/climate_data/pp_ens_mean_0.1deg_reg_v25.0e.nc", proxy = TRUE) >…
Recology
  • 165
  • 1
  • 10
1
vote
2 answers

Is there a way to reduce the resolution of a Stars object in r, similar to the aggregate function in Raster or Terra?

I am trying to learn the stars package in R, however I am working with data that is very high resolution. I know that that within the Raster package, doing the following: aggregate(raster, factor = 4) Would transform the raster from one that had a…
Andrew
  • 41
  • 3
1
vote
1 answer

Reassign cell value NA in stars object

I recently started using the stars R package. I'm struggling with reassigning NA values to "Unknown". I found a potential solution here, but it doesn't seem to work on NAs. Any suggestions to fix this issue are greatly appreciated. for some reason…
FlyingDutch
  • 1,100
  • 2
  • 14
  • 24