Skip to main content

Questions tagged [terra]

This tag refers to the R package terra. For questions about NASA's Terra satellite, use the tags of its sensors like aster or modis.

Filter by
Sorted by
Tagged with
0 votes
0 answers
15 views

QGIS Overlap analysis and R terra::intersect do not give the same results

I have performed an Overlap analysis between a Vector layer of classified values (Slope) and a series of smaller vector layers generated from KDE analysis. The aim was to produce a table with the ...
Amantil's user avatar
0 votes
1 answer
70 views

Overlapping emmissions with Euclidean decay

I have a number of emission sources (roads) with varying emission values (noise). For the sake of simplicity, let's say the sources were 3 points. The emitting noise decreases by the inverse distance ...
Ratnanil's user avatar
  • 1,003
1 vote
2 answers
113 views

Cloud masking ECOSTRESS LST data

I have downloaded a land surface temperature (LST) raster from ECOSTRESS as well as it's associate cloud mask (you can sign-up for free here and download your own data). NASA's tutorial (minute 31:15) ...
Nikos's user avatar
  • 1,093
0 votes
1 answer
27 views

Splitting and calculating across a large RasterStack using Terra in R

I have a rasterstack, created from an .nc file, named 'dat.stack' > dat.stack class : SpatRaster dimensions : 180, 360, 28896 (nrow, ncol, nlyr) resolution : 1, 1 (x, y) extent : -...
Beardedant's user avatar
0 votes
1 answer
29 views

How can I stop writeRaster from changing the extent of processed raster data?

I need to align raster data from several files. To do this I am using a for loop as shown below. As a check I print the extent of each of the rasters before calling writeRaster() to write the aligned ...
Schalk Malan's user avatar
1 vote
1 answer
30 views

Calculate asymmetric raster-cell neighborhood statistic in R

Statistics for an asymmetric raster-cell neighborhood are required. The application is modelling direct solar insolation over year-long time steps while accounting for local shading effects of ...
Eron Raines's user avatar
0 votes
2 answers
34 views

Using a raster when it is 'the output is a list of SpatRaster objects'

I am trying to make a set of rasters/maps with pixel level heterogeneity calculations using the R package 'rasterdiv'. I'd then like to look at the resulting maps in QGIS, presumably meaning I'd need ...
willbutdontwanna's user avatar
0 votes
0 answers
33 views

Find area of patch if two vector files overlap

I have two vector files containing polygons. I want to calculate the area of polygons in add if they are touched by polygons in re. I have tried but I only find the area of the intersected area, but I ...
Thomas's user avatar
  • 925
0 votes
1 answer
63 views

Sum two raster stack together ignoring NAs

I have 2 rasters with multiple layers that I want to sum together. Both raster have the same number of layers, and I want to sum all the layer from one raster to their respective layers in the second ...
Bastien's user avatar
  • 639
1 vote
2 answers
64 views

Extract adjacent raster pixels file

I have two burned area raster files in R. I want to find and extract the pixels spatially connected to the previous year's burned area. Hereafter, I want to extract all the pixels spatially connected ...
Thomas's user avatar
  • 925
2 votes
2 answers
121 views

Layer disappear after projection in R

I'm trying to calculate the standard deviation across 12 layers and then reproject the result to another CRS. Everything seems to be working fine until the conversion, where the layer disappears. ...
Emma's user avatar
  • 25
0 votes
0 answers
47 views

PROJ: cea: Invalid latitude (GDAL error 1)

I've been working on projecting raster files to a new coordinate reference system (CRS) for various datasets. However, I just encountered some warning messages that I haven't seen before. While the ...
Emma's user avatar
  • 25
3 votes
1 answer
126 views

Expanding the extent of a raster while keeping original cell values

Due to the type of models I'm running, I need to expand my rasters beyond their original extent. For example, my raster has ext(original_raster) SpatExtent : -2700100, 2750900, -2500900, 3342100 (xmin,...
gkoerich's user avatar
0 votes
0 answers
44 views

GRASS GIS from server taking hours to import a shapefile

I have a large shapefile (1GB) with 12k features. It takes 8 minutes to load in R studio (v.4.3.3) using terra package (v.1.7-71), function vect(), on a Windows machine with 32GB of RAM and an Intel(R)...
LT17's user avatar
  • 303
1 vote
3 answers
171 views

Convert vector data to terra raster where vector points are center of tiles with irregular grid

I would think there should be a simple solution to this, but I can't figure it out. I have a csv file with the following data wealth_data <- read.csv(text ="latitude,longitude,rwi,error -2....
Cannon's user avatar
  • 113
0 votes
1 answer
56 views

How to reference many raster layers in the lapp function of {terra} in R

I am attempting to create rasters with estimates of extraterrestrial radiation as outlined by the FAO Irrigation and Drainage paper 56. It only depends on julian day and latitude, and its calculation ...
thiagoveloso's user avatar
0 votes
1 answer
86 views

Running climate models with ClimateNA and *.asc (ASCII) SpatRaster causes - Run time error 62 ''Input past end of file'

I am trying to use the ClimateNA software using a 250 m DEM SpatRaster that I have exported from R using the terra package into ASCII (*.asc) format as is required. I can successfully export my DEM ...
Mark Thompson's user avatar
0 votes
1 answer
60 views

How do I remove SpatRasters from a list or sprc that have only NaN values

Minimum example: library(terra) library(future) library(rsi) library(here) n.cores <- future::availableCores() - 1 f <- system.file("ex/elev.tif", package="terra") r1 <- ...
Mark Thompson's user avatar
0 votes
0 answers
55 views

Creating a new layer from raster attribute table in R with terra?

Say I have a raster with a raster attribute table: library(terra) r <- rast("whateverfilepath.tif") rat <- levels(r) I would like to create a new layer based upon a value from the ...
Reid L's user avatar
  • 1
2 votes
1 answer
99 views

Trying to create buffer around buildings, but terra::buffer fails for larger rasters

I'm trying to create a raster with info on whether or not each point is near a building. To this end, I'm starting with a geotagged raster that contains the locations of buildings (resolution 10 ...
Olle's user avatar
  • 155
0 votes
0 answers
17 views

LidR error "Error: [writeRaster] file exists. You can use 'overwrite=TRUE' to overwrite it" when rasterising canopy height model [duplicate]

I am currently using the LidR package to rasterize a canopy height model from a LAScatalog object: opt_output_files(ctg_norm) <- paste0("C:/Programming/C_Forstenried/las_outputs/temp/{*}chm&...
Merlijn Dingemanse's user avatar
0 votes
1 answer
68 views

Values of ordinary kriging with gstat and terra are equal as the input data

I am trying to interpolate a raster using ordinary kriging. When I use the data from meuse to try the model, I get an interpolated output. However, when I run the code with my own data, the ...
Raksha's user avatar
  • 3
0 votes
1 answer
127 views

Sampling 10% of cells in terra raster in R

(I am new to spatial analysis so please excuse if this is an obvious question) In terra, I have a SpatRaster of the world at 1km resolution (3006072000 cells, 5 layers). I would like to randomly ...
LeeJonesEco's user avatar
0 votes
1 answer
20 views

Rasterizing misaligned grids [r - terra]

I'm working with satellite data and trying to convert it to a raster in R. The downloaded product from NASA was vectorized on their end which is frustrating. The problem is that the satellite is ...
Kevin F's user avatar
0 votes
1 answer
114 views

Some polygons are loading incorrectly as terra SpatVect but not SpatialPolygonsDataFrames

I am seeing an issue with some polygon features loading incorrectly as terra SpatVectors. I cannot replicate this issue yet, but here is an example polygon as an rds on Google Drive. If I load this ....
Scott Z's user avatar
  • 141
0 votes
0 answers
134 views

terra::project seems to be changing the values of a raster

I am trying to calculate the proportion of a land use category in R just like it's explained here: Calculating continuous raster representing land cover proportion from categorical raster using QGIS? ...
c roc's user avatar
  • 29
0 votes
1 answer
396 views

Clipping sf vector by terra raster extent with R

I am trying to do something fairly simple: I want to clip a vector with point features down to only features that are contained within a raster extent. For raster I am using the package terra, for ...
Honeybear's user avatar
  • 2,524
0 votes
1 answer
116 views

lidR: Writing output from pixel_metrics() from "multiple-output-function" to separate raster files

First some background from the original question: I'm using the lidR package to make rasters of metrics calculated on point clouds. I have a custom function that calculates 9 metrics outputed as a ...
Martin Stjernman's user avatar
1 vote
0 answers
71 views

From points to raster - how do I set a gaussian function with a cutoff

Context SMAP's user guide states: "We use Gaussian weighting to interpolate the L2B estimates onto the map grid with a search radius of approx. 45 km and a half-power radius of 30 km.". ...
J Lal's user avatar
  • 11
2 votes
1 answer
165 views

Leaflet in R mangling terra RGB rasters

I'm working with an RGB raster in leaflet (some Landsat data). I'm stretching and sampling it down so that it's small enough. The following works great. # stretch and then resample like ...
jebyrnes's user avatar
  • 483
1 vote
0 answers
81 views

Georeferencing rasters using GCPs in R: stars/terra equivalent of gdal_translate / gdalwarp?

With the retirement of rgdal and transition to sf/stars/terra functions in October 2023 now passed, is there a way of georeferencing raster images with GCPs (Ground Control Points) other than using ...
Thomas Moore's user avatar
1 vote
1 answer
236 views

How to calculate the area percentage of polygons overlapping with cells of raster using terra, R

I have a raster with 1 km x 1km cells and some Points, then create 600 m buffers for each point. Now I would like to calculate the area percentage of the buffers for each cell. Finally get a raster ...
Wei Liao's user avatar
0 votes
1 answer
254 views

Use lookup table to create new raster layer based on values in multi-layer SpatRaster using R terra

I am doing an ecosystem classification project where I have 3 raster layers that each correspond to different ecological classes with different numbers of categories. I want to take the unique ...
Meirzev's user avatar
0 votes
1 answer
104 views

Categorical land use raster to continuous values raster in R

I would like to transform categorical land use rasters from ESA CCI (http://maps.elie.ucl.ac.be/CCI/viewer/download.php) to rasters with continuous values. The crs is lon/lat WGS 84 and I would like ...
c roc's user avatar
  • 29
0 votes
1 answer
42 views

Starting cumsum of a rasterfile from value of another rast file in terra

I have one raster and one raster stack. The single raster layer represent day of year when I need to start cumulative sum of the raster stack. Rstart<-rast(nrows=10, ncols=10) Rstart[]<-1:100 ...
Renan le roux's user avatar
0 votes
1 answer
126 views

Transforming categorical land use raster to raster with continuous values

I would like to transform categorical land use rasters from ESA CCI (http://maps.elie.ucl.ac.be/CCI/viewer/download.php) to rasters with continuous values (% of cover of each land use class in each ...
c roc's user avatar
  • 29
0 votes
1 answer
152 views

Finding layer with maximum value for each pixel in terra

I have a raster like this here: https://drive.google.com/drive/u/0/folders/1AEKu4TKpzJg95oXv8dxep24xpXaesr0F The tif has 11 Layers (timestamps). For each pixel I want to find the timestamp with the ...
Lenn's user avatar
  • 1,297
0 votes
2 answers
101 views

R classification of ADM0, ADM1, ADM2 and cities into 1x1 grid [closed]

I want to work on linking temperature to socioeconomic variables. there are wonderful databases offering 1deg x 1deg spatial resolution for temperature (such as CRU and the Berkeley BEST data base). ...
ivo Welch's user avatar
  • 115
0 votes
0 answers
43 views

How to iterate a spatraster faster using 'terra'

I try to use the phenological data and soil moisture data from 2000 to 2018 to judge this question: whether a certain day before a specific phenological period is too wet, the standard is that the ...
gonie's user avatar
  • 13
0 votes
1 answer
156 views

Measure a distance between point and the nearest NA in the raster

I have a set of points placed within one patch. I would like to measure the nearest distance between the point and the closest cell with NA values (eg. outside of my patch). Patch is defined as a ...
maycca's user avatar
  • 3,376
3 votes
1 answer
284 views

Find locations (cell's centroid) of a raster's min and max value using R and terra

I have a raster like this one: https://drive.google.com/drive/u/0/folders/1AEKu4TKpzJg95oXv8dxep24xpXaesr0F I want to find the locations (can be the centroid or the bounding box of these cells) for ...
Lenn's user avatar
  • 1,297
0 votes
0 answers
65 views

Terra/geodata world map cropping issues, possibly due to truncated extent

Cropping geodata world map across Greenwich (not exactly though) or close to the poles gives a "Topology Exception" error on RStudio (Posit) cloud, although not on RStudio desktop. Also, the ...
mlyn's user avatar
  • 3
0 votes
0 answers
121 views

Error using Terra in R to combine Geometries using combineGeoms

I am trying to eliminate polygons in a multipolygon that have an area smaller than x. This is my code: v = terra::vect(f) area <- expanse(v) th <- area < 25 x <- combineGeoms(v[!th], v[th])...
B-C B.'s user avatar
  • 765
2 votes
1 answer
123 views

Is there a comprehensive list of mapnprojections implemented in R?

I would like to experiment a bit with different and less-frequently used projections in R for global maps, but I am playing a guessing game as of which are actually working. I tried to look up ESRI or ...
Herman Toothrot's user avatar
1 vote
0 answers
146 views

Why does Terra's extract(fun= mean) give different values than global(fun = mean) in R?

I am trying to extract mean and quartile ranges from a raster. I normally used terra's extract function to do this, but since I needed quartile numbers as well I tried it a different way. I noticed ...
Lavendarfire's user avatar
1 vote
1 answer
163 views

Terra::extract delivers unexpected values when extracting table from raster using polygons

I have a categorical raster and a polygon vector layer. I want to get a table with the area of each class from the raster layer that is covered by polygons. I tried the following: extr <- terra::...
Manuel Popp's user avatar
0 votes
0 answers
120 views

Plot borders larger than set extent (Terra in R)

I am trying to plot what I think is a very simple map. I have three inputs, map of Canada, map of USA, and a shapefile with rivers. I have set my extent, and when plotting the map I can see a cutoff ...
MHolb's user avatar
  • 1
0 votes
0 answers
388 views

How can I project very large rasters with terra, raster or stars packages in r?

I am trying to project a very large raster (about 7GB each) from NAD 1983 UTM Zone 16N to Wisconsin Transverse Mercator (ESPG:3071) and neither the terra nor the raster package seem to work. Terra ...
Bob SomeAle's user avatar
0 votes
1 answer
276 views

The zonal() function of the Terra package outputting incorrect results

I am attempting to use the zonal() function of the Terra package in R to find out how much population there is for a given municipality. I am using nic_m_0_2020.tif as the source for the population ...
Bushidoenator's user avatar
0 votes
0 answers
66 views

How can I create tiled Shaded Relief rasters from tiled DTM rasters, while avoiding edge artifacts?

I have a series of DTM tiles from which I'd like to create Shaded Relief tiles with the same extent. I am trying to make use of the Virtual Raster Dataset in Terra. The tiles are loaded into a VRT and ...
Ray J's user avatar
  • 541

1
2 3 4 5