Questions tagged [terra]

Use this tag for questions related to functions from the terra package for spatial data analysis. For Terra (Luna) blockchain protocol, use terra-blockchain tag instead

is an package for spatial data analysis, especially raster data. The package also has general raster-related functions, such as for creating, reading, manipulating, and writing raster data. terra is written in and is intended to replace the raster package in the future because it is simpler and much faster. Tutorials are available at https://rspatial.org/terra.

Scope of questions

This tag should be used for programming-related questions about the R terra package. Including a minimal reproducible example of raster data in your question will increase your chances of getting a timely, useful answer. Questions should be specific to the functions in the terra package. Questions should not use the r-raster tag unless they relate specifically to the raster (i.e., r-raster tag) package and not just raster spatial data analysis.

Repositories

Maintainer

525 questions
0
votes
2 answers

Having trouble installing terra package

R keeps getting stuck at this stage when I try to install the CRAN package terra using RStudio Using Windows 10, R 4.0.4, RStuiod 1.4.1103 install.packages('terra') * installing *source* package 'terra' ... ** package 'terra' successfully unpacked…
user69494
  • 1
  • 1
0
votes
1 answer

R terra create spatraster of day lengths for a year

The length of daylight at a particular latitude can be found with the daylength function from library(geosphere). The day length varies by the day of the year. Here's the function daylength(lat, doy). I'd like to generate a 1/2 degree spatraster…
JerryN
  • 2,356
  • 1
  • 15
  • 49
0
votes
1 answer

Faster efficient way to crop netcdf in R

I have a .nc/netcdf file which is about 1GB in size. Trying to crop and make it smaller with the following code: r <- terra::rast("myfile.nc") r2 <- terra::crop(x = r, y=terra::ext(-79, -72, 0, 12.4)) fails in a 16GB RAM machine. By failing I…
Dan
  • 1,711
  • 2
  • 24
  • 39
0
votes
1 answer

algebra using rasters and dataframes

I want to predict vegetation health using 2 remote sensing vegetation indices (VIs) for multiple tree-stands across multiple months. I previously approached this by using a for() loop to iterate through a list of multi-band rasters and calculate the…
seak23
  • 195
  • 9
0
votes
2 answers

Not able to deploy Terrain Counter contract to localterra

I am trying to deploy a Terra contract of the Terrain: https://www.npmjs.com/package/@terra-money/terrain In order to deploy the counter contract I need to do the following (I am running on windows 10): npx terrain deploy counter --signer…
0
votes
1 answer

How to create maximum value composite using terra r package?

I want to create a maximum value composite raster by taking maximum values from each band of a raster stack. I am using the following code library(terra) library(RStoolbox) rast1 <- rast(lsat) #Create two raster stacks rast2 <-…
UseR10085
  • 7,120
  • 3
  • 24
  • 54
0
votes
1 answer

Add a marker that signals specific point in space from coordinates in plot from a SpatRaster object in R

from this question I managed to create a SpatRaster object that has proper colors plotted. But now I am in a bind as to how to add markers in the map that show specific points in space from coordinates. library(terra) img <-…
GEX_HEX_420
  • 105
  • 6
0
votes
2 answers

Why does writeRaster in terra give a warning message?

I am trying to rasters by layer using terra package. I am using the following code library(terra) # first create a raster r1 <- r2 <- r3 <- rast(nrow=10, ncol=10) # Assign random cell values values(r1) <- runif(ncell(r1)) values(r2) <-…
UseR10085
  • 7,120
  • 3
  • 24
  • 54
0
votes
1 answer

8 Day MODIS Raster to Monthly sum in R

I have MODIS data which contains 8 days product. Some of month has 3 images and some of month has four imgaes. So how I can build a R scrip to calculate monthly sum from this data I am using the MODIS MOD17A2HGF GPP data set which comes as a 500x500…
jackywang
  • 75
  • 6
0
votes
2 answers

R terra remove raster cells touching spatvector lines

I'm trying to calculate shapes of touching raster cells within areas using terra. I haven't been able to reproduce my problem using sample data, so I hope someone might still be able to help without that (I tried, but somehow couldn't replicate the…
GLump
  • 31
  • 5
0
votes
0 answers

Unable to upload wasm file on terra-station

I developed NFT smart contract based on Cosmwasm for Terra blockchain. It was working well, but when I upgraded cosmwasm-std version from 0.9.2 to 1.0.0-beta8, despite of successful compiling and optimization of source code, storing wasm on chain is…
0
votes
1 answer

Why intersect function from terra R package not giving all the combinations?

I want to calculate the area under every possible combination of two classified rasters. I am using the following code library(terra) #First create two rasters r1 <- r2 <- rast(nrow=100, ncol=100) #Assign random cell…
UseR10085
  • 7,120
  • 3
  • 24
  • 54
0
votes
1 answer

Understanding aggregate from the {terra} package in R

I don't understand what the R {terra} package is doing regarding aggregating cells of rasters. Here is an example without plotted output. library("terra") x <- rast(nrow=5, ncol=4) values(x) <- c(1,NA,NA,1, 1,NA,NA,1, …
TheRealJimShady
  • 777
  • 3
  • 9
  • 24
0
votes
1 answer

RASTER TO VECTOR : WriteVector from terra package leads to fatal error

I have this sampled code that I tried on RStudio these last days : library ('terra') binar <- rast("C:/Users/BIC_/Desktop/21_binarisation_SWIR.tif") poly_rast <- as.polygons(binar , values = TRUE,extent=FALSE) I want to convert my raster "binar"…
0
votes
1 answer

masking big raster using shapefile

I have a global raster at 0.0833 degree resolution which covers both land and ocean. I am trying to extract raster only for the land areas. The way I am doing is to use a global shapefile and use it as a mask. However, this is taking ages (more than…
89_Simple
  • 3,393
  • 3
  • 39
  • 94