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
1 answer

terra R coord.ref unnamed

I am using the terra library with harmonized HLS data (https://hls.gsfc.nasa.gov/). These are HDF4_EOS files (you can download an image here: https://hls.gsfc.nasa.gov/data/v1.4/S30/2020/11/T/M/M/). Once downloading a scene and attempting to load in…
vsjansen
  • 11
  • 3
0
votes
1 answer

R terra tif import colormap

When importing a .tif raster with terra::rast(), also a colormap is imported. Is there any way to force the function to not import the colormap, or to set it to NULL to use the default plot color palette? You can see the color table…
0
votes
2 answers

ellipsoid or sphere in area calculations of terra?

How the calculations of area are made in terra, when using geographical coordinates (lon/lat)? 1 - On a sphere or an ellipsoid? 2 - Using a constant width of the cells (the median width) as it was done in raster package, or using a more accurate…
0
votes
1 answer

How to zoom in on multiple points of a map and include them all in separate panels?

I have multiple polygons and a raster that make up my map. I would like to "zoom" into each of these polygons in order to better visualize the raster information within each of the polygons. I figure i can eventually use some combination of…
seak23
  • 195
  • 9
0
votes
1 answer

Is there a way to extact data from raster with buffer using rast function in terra package?

I'm extracting values for some coordinates from rasters using raster package. I'm planning to use a buffer of 1km to do the extraction. But it seems impossible using extract function in terra pakcage. Much appreciated if you can help me out.
0
votes
1 answer

Cropping and masking Rasta Data and converting it to a vector

I am trying to crop and mask raster data and convert the raster data to a vector and to an sf object with terra. However, I always get the following error message: Error in UseMethod ("st_as_sf") not applicable method for 'st_as_sf' applied to…
Penny
  • 1
0
votes
2 answers

Using xy=TRUE in R terra extract

I am trying to extract the coordinates of the centroid of pixels for which I have points that fall whithin that pixel. Here is a reproducible example library(terra) filename <- system.file("ex/elev.tif", package="terra") r <- rast(filename) #Create…
0
votes
2 answers

How to add the extracted values from raster stack to the data.frame of the Spatial object using terra package?

I want to add the extracted values from raster stack to the data.frame of the Spatial object using terra package f <- system.file("ex/logo.tif", package="terra") r <- rast(f) #Plot the raster plot(r, 1:3) #Create a vector file points <-…
UseR10085
  • 7,120
  • 3
  • 24
  • 54
0
votes
1 answer

How do you convert a GPX file directly into a SpatVector of lines while preserving attributes?

I'm trying to teach myself coding skills for spatial data analysis. I've been using Robert Hijmans' document, "Spatial Data in R," and so far, it's been great. To test my skills, I'm messing around with a GPX file I got from my smartwatch during a…
broodoots
  • 7
  • 1
  • 2
0
votes
0 answers

How to rasterise with multiple field values?

How to include multiple character vectors in the field during rasterize? sum.v <- vect(summer_values, geom=c("X","Y"), crs="epsg:4326") sum.v <- terra::project(sum.v, sun.rast) sum.v_2009 <-sum.v%>% terra::rasterize(sun.rast, c("Summer_2009",…
Stackbeans
  • 273
  • 1
  • 16
0
votes
1 answer

How can I add a class name to numeric raster values in a terra SpatRaster?

I'm working with the Circumpolar Arctic Vegetation map. Stored as a SpatRaster with terra, the raster has 21 land cover classes. > str(lc_2003) Formal class 'SpatRaster' [package "terra"] with 1 slot ..@ ptr:Reference class 'Rcpp_SpatRaster'…
canderson156
  • 1,045
  • 10
  • 24
0
votes
1 answer

Best wopt options for large rasters

What are the best wopt and gdal options when processing large rasters with terra::? I want to match a raster stack (2.5arcmin) with a raster that has a much higher resolution (500*500m). Workflow: disaggregate as close as possible, then resample and…
0
votes
1 answer

How to merge raster tiles that have minor differences in origin after reducing resolution with 'aggregate'

I have 29 raster tiles with the following properties: class : SpatRaster dimensions : 45000, 45000, 1 (nrow, ncol, nlyr) resolution : 0.0008888889, 0.0008888889 (x, y) extent : 20, 60, -40, 0 (xmin, xmax, ymin, ymax) coord. ref. :…
Lena
  • 311
  • 2
  • 10
0
votes
1 answer

Append extent of big spatRaster object to match the extent of spatVector: to compute zonal stats and to get rid of 'extents do not overlap error?'

I am working exclusively on the terra package. spatRaster details: Carbon flux data of South America (~500 GB) spatVector details: Protected Areas database of South America (~70 MB) Goal: To compute zonal statistics Error: While performing zonal…
0
votes
1 answer

Can't write compressed geotiffs to disk using terra package

I am trying to switch from Robert Hijmans' raster package to the newer and faster terra package for raster calculations in r. In doing so I have come up with a ridiculously simple issue I cannot solve. No matter what I do, I cannot get the new…
Lucas Fortini
  • 2,420
  • 15
  • 26
1 2 3
34
35