Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
0 answers
19 views

How to use cubist model for mapping? [closed]

How to properly use the Cubist model for raster prediction, or use it in some other way. code picture sample_points <- read.csv("E:/first_paper/landsat9/Modeling_data/SOM/new/Bare land.CSV&...
Hongwu Liang's user avatar
0 votes
0 answers
32 views

Raster from rasterize() in R shows different values from polygon, values don't plot as expected

I am trying to rasterize a polygon so that I can perform some zonal statistics (namely, get average values of a variable using a buffer around a point). I'd like it to be at ~100m resolution but a ...
yhentati's user avatar
1 vote
0 answers
40 views

{rast] cannot open this file

I am working with the terra package to read a raster file. narr <- rast(paste0( "/ YOUR FILE PATH /narr_air2m_", year, ".nc" )) When I run this code, I encounter the ...
fatemeh yousefian's user avatar
0 votes
1 answer
31 views

How to generate random raster cell values according to the distribution of same values from another raster

In terra I have an existing raster with values range from 1 to 4 in the following proportions. "1" appears 5 times; "2" 15 times; "3" 20 times; "4" 60 times I ...
CARLOS_BEDSON's user avatar
1 vote
1 answer
34 views

Issue with setting CRS with make_track() in amt

I am having trouble setting the CRS with the crs argument within the make_track() function. It consistently just returns CRS as NA with no error. I am not sure if there is conflicting packages or if I ...
Ellery Vincent's user avatar
1 vote
0 answers
22 views

How to specify a QGIS model algorithm output in qgisprocess R package

I am trying to run my QGIS model inside R using the qgisprocess package. The model gets a raster and vector line inputs. Its output is an attribute-only QGIS table. Here is the model diagram in QGIS ...
Faustin Gashakamba's user avatar
0 votes
2 answers
41 views

How to calculate the average data across subdatasets in a SpatRasterDataset object in terra

I have a SpatRasterDataset: library(terra) r = rast(system.file("ex/logo.tif", package="terra")) s = terra::sds(r, r/2, r/3) names(s) = letters[1:3] It looks like: > s ...
bird's user avatar
  • 3,214
0 votes
1 answer
76 views

Cropping a raster using terra does not return the expected extent

I have a raster whose extent is -180.049996946546, 179.949996948242, -90.05, 90.05 (xmin, xmax, ymin, ymax). I need it to allign it with other rasters that have the same CRS but an extent of -180, 180,...
Anjeline's user avatar
1 vote
1 answer
68 views

How to combine SST contour lines and polygons of reef distribution on a world map showing oceans bathymetry?

I would like to create a world map showing the global distribution of coral reefs in combination with the two 20°C isotherms. I have managed to plot them individually, but not in a single graph. The ...
maRvin's user avatar
  • 325
0 votes
1 answer
21 views

Set precision of SpatRaster resolution/extent

I need to create a spatRaster to match an existing NetCDF file. The NetCDF has the following resolution: gridtype = lonlat gridsize = 8100 xsize = 90 ysize = 90 xname = lon xlongname = &...
user8330904's user avatar
0 votes
0 answers
36 views

Problem with changing a raster in Lambert Conformal Conical projection to unprojected using terra in R

I have a raster in Lambert Conformal Conical projection that I would like to change to unprojected. I tried to use the project function in terra package.The result raster has an extent that is very ...
Xiaojing Wei's user avatar
0 votes
0 answers
13 views

Issue with Extreme Values in scPDSI and PDSI Calculations Using R's scPDSI Package

I'm encountering very high (e.g., Inf) and very low (e.g., < -2000) values in both scPDSI and conventional PDSI calculations using the scPDSI package in R. Package installed from this GitHub repo ...
idontreallyknowhehe's user avatar
0 votes
0 answers
29 views

terra FLT4S datatype error when reprojecting

I'm using the 'terra' package to read, reproject, and extract raster values. One of my rasters is a date (yyyymmdd, 20200822) layer, as an 'FLT4S' (though I've tried other datatype formats). When I ...
Detritus's user avatar
1 vote
2 answers
65 views

Merge touching polygons within sf dataframe or terra spatvector in R

I have a list of vector polygons in terra, some are separate and distinct, some are touching. Usually, the touching ones are- in reality- all part of the same shape, but are split in this way because ...
Jake L's user avatar
  • 1,047
0 votes
2 answers
69 views

How to extract the density population of specific longitude and latitude points from the GHSL population data?

I have a data frame with about 20,000 rows containing the latitude and longitude of points spread across the world. I need to determine the population density at those points, so I considered using ...
Olivia's user avatar
  • 189
2 votes
1 answer
45 views

How to use terra::predict for raster output to predict GAM temperature model with seasonal variation

I am trying to model temperature across seasons using (package mgcv) GAMs. I am interested in using terra::predict() to plot the predicted temperatures as a raster. Ideally, the output would be 4 ...
R Reid's user avatar
  • 21
0 votes
1 answer
64 views

Why does terra produce different value ranges for the same raster? [closed]

I have been using terra to read and then save various global raster data sets. Today I noticed quite different value ranges depending on how I look at the data or what I do with it. I am confused and ...
wondering's user avatar
0 votes
0 answers
34 views

R crashes when running R's terra and Julia's GeoArrays.jl packages in R simultaneously via JuliaCall

I want to run some code in R that uses the terra package to handle rasters. At the same time, from R, I need to be able to load rasters into memory in Julia using GeoArrays.jl. On MacOS and Windows, ...
Edward Lavender's user avatar
1 vote
0 answers
48 views

Installation of terra package using conda and renv returns error for `int8_t` not defined

I'm working in a conda environment in Windows trying to initialize an renv environment (with renv::init()) a colleague shared with me. It fails when trying to compile the installation for conda with ...
Luise's user avatar
  • 654
0 votes
1 answer
54 views

In tidyterra for R, could facet_grid be implemented?

In R, package tidyterra allows use of facet_wrap(~lyr) to plot multiple spatial raster layers in one figure. library(terra) library(ggplot2) library(tidyterra) x <- rast(array(data = rnorm(120,0,1),...
Dan B's user avatar
  • 31
0 votes
2 answers
40 views

issues plotting cropped raster DEM in ggplot

It's probably a stupid mistake but I can't figure out what I am doing wrong. I have a DEM raster I can visualize using plot() and ggplot() just fine. But when I try to crop and mask it to a smaller ...
tlyons253's user avatar
0 votes
1 answer
35 views

Reclassifying a large rasterstack in Terra based on another raster

I'm trying to do the following: I have a stack of monthly temperature rasters, and from this I calculate the 90th quantile of the stack. Then, I want to have a count for how often each raster cell is ...
Beardedant's user avatar
1 vote
1 answer
68 views

Reprojected raster data shifts East

I'm working in R using terra and sf. I am working with some data products that are in sinusoidal projection (see crs string below, I can't change the starting product projection) and I need to ...
CodeUP's user avatar
  • 13
0 votes
1 answer
57 views

Speed up of the workflow: masking + global summing for 50 not-so-small tiles using terra R package

As a newbie of terra I am finding difficult to speed up a very simple task: I have 50 tiles of 200 x 200 x 9000 (a list of SpatRaster). I need to apply a mask to each tile and compute a global sum for ...
Alessandro's user avatar
0 votes
1 answer
83 views

terra::split | R session aborts when splitting polygon fatal error

When trying to split a polygon R runs into a fatal error and aborts. This happens when using R Studio and R on itself. I wrote the code on an earlier version of R on a different machine (also a mac), ...
Amantil's user avatar
1 vote
2 answers
87 views

How to speed up getting corresponding cells of one raster that overlap another raster when data are large/high resolution

I have a high resolution raster (highRes), and a lower resolution raster (lowRes), and I would like to return, for every low resolution cell, the values and the percent coverage of the high resolution ...
Pascal's user avatar
  • 1,664
1 vote
1 answer
37 views

Differences in CRS when reading in NetCDF using terra::spatRaster

I've noticed a difference in behaviour in terra::rast on two different computers running: Windows; R4.4; terra 1.71-78; GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1 Linux; R4.4; terra 1.71-71; 3.10.1, GDAL 3....
user8330904's user avatar
2 votes
1 answer
100 views

Issue projecting polygon that crosses dateline R

I have a polygon in a North America equal area projection and I would like to transform to unprojected long/lat. I would like to use it to crop a global raster in unprojected longlat. The problem is ...
Pascal's user avatar
  • 1,664
1 vote
3 answers
52 views

Convert bounds into raster in R

I have a data frame with quad keys and associated values for activity index, and I want to convert it into a raster. The quadkeyr package is too slow for the scale of my data (each hour across all of ...
Priya Patel's user avatar
1 vote
2 answers
61 views

Add a legend to a voronoi diagram with field values

I try to create a map with a voronoi diagram of some climate stations. I've already created the diagram and also colored the areas in the diagram with a fitting color. Now I want a continuous legend ...
Alexander Klug's user avatar
0 votes
1 answer
93 views

Trouble installing R package rnaturalearth and terra

I am trying to install the package rnaturalearth and when I run either: devtools::install_github("ropensci/rnaturalearth") or install.packages(rnaturalearth) it runs for a while and at the ...
Eli Rush Kallison's user avatar
0 votes
0 answers
105 views

Merge several rasters into one large raster file in R with 'terra'

I have several rasters (.tif) files and want to merge them into a final large raster. Each smaller raster file is also in relatively large size. I used the terra R package's vrt function to first ...
LittleXQ's user avatar
0 votes
1 answer
63 views

Matching data structure between two netCDF files

I have two netCDF files: WATCH data: > watch_Tair: 2 variables (excluding dimension variables): int timestp[tstep] title: time steps units: time steps (days)...
herakles_1950's user avatar
0 votes
1 answer
75 views

Error on terra:rasterize -not taking all point values [closed]

I am trying to generate random points on a polygon with each having a separate ID number and then converting to a raster for subsequent use in Circuitscape. For some reason "Rasterize" ...
CARLOS_BEDSON's user avatar
0 votes
1 answer
58 views

How to extend the boundary of polygon until a line?

I have two objects: eez:https://github.com/yuliaUU/test/blob/main/eez.RDS bordering_polygons: https://github.com/yuliaUU/test/blob/main/madg_bordering_polygons.RData So what I want to do is to try to ...
yuliaUU's user avatar
  • 1,713
0 votes
2 answers
103 views

R - error with terra::extract : unable to find inherited method for function "extract" for signature "SpatRaster", "SpatialPolygons"

I'm trying to convert an R script using package raster in order to use package terra instead. So I changed the raster::raster function for terra::rast function, and also the raster::extract for terra::...
Colsourie's user avatar
0 votes
1 answer
36 views

Embedding text in a terra raster?

Is there a simple way of embedding a given text in a terra raster, at a given position? Thanks, Jean-Luc
Jean-Luc Dupouey's user avatar
0 votes
1 answer
57 views

Convert image coordinate system to correct coordinate system in R

I'm doing object detection of trees on a raster image in TIFF format. The output of my model is a series of bounding boxes that provide xmin, xmax, ymin, ymax for each bounding box for each tree in my ...
Priya Patel's user avatar
0 votes
1 answer
63 views

How to assemble large data cube for efficient handling with`terra`?

My raster files are organized hierarchically in folders according to simulation, variable and time span. How would an adept terra user assemble and load the data cube for efficient posterior data ...
Daniel Zuluaga's user avatar
0 votes
1 answer
178 views

Terra package rast() Raster Stack

I have a number (21) of raster layers (19 WorldClim climate data, euroDEM digital elevation model [DEM] and Corine LandCover [CLC]) which I am trying to create a raster stack for. I have used the ...
Sarah's user avatar
  • 1
0 votes
1 answer
95 views

How to calculate zonal statistics class and polygon wise using terra R package?

I want to calculate class and polygon-wise zonal statistics using terra R package. I could able to calculate polygon-wise mean values using the following code: library(terra) #Read a raster file ...
UseR10085's user avatar
  • 7,992
0 votes
3 answers
87 views

Mask a list of rasters using a list of spatial vectors (shapefiles)

I have a list of raster files and a list of shapefiles ordered by date (one for each of 52 weeks of the year). I need to mask each raster with its corresponding shapefile and I am stuck on the code to ...
Erin Snook's user avatar
2 votes
1 answer
57 views

Sampling random points in R with both raster and shapefile constraints

I am trying to sample random points according to 2 conditions: in non-NA cells of a raster inside the polygons of a shapefile I tested the terra::spatSample() function, but I can't meet the second ...
Marine Régis's user avatar
0 votes
0 answers
54 views

Using R, list and access individual files on an ownCloud public folder

I have a public folder on ownCloud containing over 5,000 files. I need to access each individually in R (what all my collaborators use), but I don't have an individual sharing token. I would like to ...
Tess H's user avatar
  • 69
0 votes
1 answer
69 views

Calculate distances from points to nearest edges of polygons

I have this list of lat/long coordinates (from Google maps). tpts <- data.frame(lat = c(40.91947468397188, 39.13618031492076, 44.54912813480803, 38.55433576050368, ...
rt11's user avatar
  • 45
2 votes
1 answer
69 views

Aggregate daily raster data by weeks in R

I have daily snow and ice extent raster files for 2022 from NOAA (https://noaadata.apps.nsidc.org/NOAA/G02156/GIS/4km/2022/). I need to get the maximum ice extent per week for the year. My task is ...
Erin Snook's user avatar
0 votes
1 answer
135 views

Remove Overlapping Polygons

I have a large SpatVector with many individual polygons, some of these polygons overlap with eachother and I want to remove all polygons in any location where there is an overlap, leaving the non ...
wertisml's user avatar
2 votes
1 answer
112 views

Problems working with vector layers in R terra "Points of LinearRing do not form a closed linestring "

in the last weeks I got inconsistent results using vector layers in R using the terra package. For example, using this dataset: http://www.soest.hawaii.edu/pwessel/gshhg/gshhg-shp-2.3.7.zip A month ...
user3369539's user avatar
0 votes
0 answers
21 views

I cannot run parallelized code on a remote server using R

I am trying to run a simple code with the terra package in R using a remote server. When the code is not parallelized, the script runs fine. However, when I attempt to parallelize the code, I ...
KEN's user avatar
  • 77
0 votes
0 answers
41 views

Fastest way to check if a SpatRaster has at least one non-NA value?

I am currently using this: any(as.numeric(terra::global(x, fun = "notNA")[,1]) > 0) It works fine, but I think terra::global is checking the entire raster. I'm looking for a method that ...
Kevin's user avatar
  • 533

1
2 3 4 5
16