Questions tagged [r]

Statistical computing language and software environment.

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

Chi-square between rasters

I have two rasters (both with 10 m * 10 m resolution, for an area of approx. 1 000 km2) with the following variables. Both are categorical. A) Habitat type with 9 different classes. B) Soil moisture ...
0 votes
1 answer
97 views

Soilgrids points outside of projection domain

I have downloaded a global soilgrid tif from ISRIC (https://files.isric.org/soilgrids/latest/data_aggregated/5000m/ocs/) and when I import this in R with terra::rast(filename) (and similarly with ...
1 vote
1 answer
446 views

Extracting mean of multiple SpatRasters using Terra?

I have a list of rasters which I want to combine into a single raster by getting the mean for each cell, ideally in the R terra package. According to this answer, the calc function in the raster ...
1 vote
1 answer
86 views

R - gdistance: setting to 0 the conductance values of cells corresponding to a polyline

Goal I aim at setting to 0 (i.e., not traversable) the cells of a transition matrix (storing conductance values) that correspond to a (poly)line. Where I am stuck I am having hard time to figure out ...
  • 1,484
0 votes
0 answers
62 views

Segmenting transect lines using st_segmentize on R

I'm currently working on R for spatial analysis and trying to segment transect lines (shapefile) by 4km using sf::st_segmentize. I managed to do this following the instructions from here and here for ...
  • 11
1 vote
1 answer
215 views

Read geo-spatial data in R via Leaflet

I have some site boundary data as follow: UNB_BDSB_SiBdry_v08_201028lico_25831.cpq UNB_BDSB_SiBdry_v08_201028lico_25831.dbf UNB_BDSB_SiBdry_v08_201028lico_25831.prj ...
0 votes
1 answer
50 views

Count multilinestring elements crossing a raster cell in R

I have a shapefile with several MULTILINESTRING geometries, representing the borders of some species' distributions, and I want to count the number the number of species occurring in each cell. I used ...
  • 75
0 votes
0 answers
37 views

How to create a mosaic from different shapefile in R?

I have 37 shapefiles with different names.Individually each of them represent a different part of a country. I would like to create a mosaic of my 37 shp to just have one a the end. To make things ...
2 votes
1 answer
83 views

How to reorder categorical raster legend order in R

For example, I have a landcover raster and I want to use terra::plot to make a map. library(terra) test <- rast('test.tif') plot(test) The order now is "3,4,6,8". Now I want to reorder ...
  • 103
1 vote
1 answer
43 views

Convert rworldMap to UTM

I would like to use the worldMap from rworldMap, but need this in UTM projection rather than long/lat. I first clip the map to my area of interest. How do I then convert this to UTM projection? My ...
0 votes
2 answers
57 views

Apply linear stretch to Landsat 8 images in the tmap R package

I have a Landsat 8 dataset downloaded from the USGS. I import into R using the following code: B1 <- raster("LC08_L2SP_166072_20210819_20210827_02_T1_SR_B1.TIF") B2 <- raster("...
  • 103
1 vote
1 answer
24 views

Ripley's K function and toroidal shift with Splancs

R's Splancs library implements bivariate K function with confidence envelope with the function Kenv.tor. The function takes poly as an argument, and doesn't seem to restrict it to be rectangular. In ...
  • 361
0 votes
1 answer
72 views

Reprojecting a raster from long/lat to UTM take 2

This thread Reprojecting raster from lat/lon to UTM in R? was of no help to me. I have the following raster which I first need to create in lat/long in order to crop it to rworldmap. However, I then ...
0 votes
1 answer
46 views

Error message with Krige function: Error in as.character.default(X[[i]], ...) : no method for coercing this S4 class to a vector

I am trying to run the Krige function but I keep receiving NA values for var1.pred and var1.var. After using the warning() command, it says: Error in as.character.default(X[[i]], ...) : no method for ...
  • 1
1 vote
0 answers
24 views

m_proj equivalent in R

I am looking for an equivalent function of m_proj form Matlab in R. I am familiar with the crs or st_crs function in R but it is difficult to set the lon and lat limits. I am looking to convert the ...
0 votes
1 answer
63 views

projectRaster on a list of rasters

I have two raster layers in a list format called myrasterlist that differ in extent and crs. The list looks like this: [[1]] class : RasterLayer dimensions : 540, 537, 289980 (nrow, ncol, ncell)...
0 votes
0 answers
220 views

using as.polygons() with patches() from terra instead of rasterToPolygons() with clump() from raster

I am trying to figure out the equivalent of contour_poly <- rasterToPolygons(clump(my_raster > 1), dissolve = TRUE) from raster to terra. I tried contour_poly <- as.polygons(patches(...
0 votes
1 answer
45 views

using function inside raster::calc with loop

I have a raster stack with 12 raster layers (NDVI time series). My goal is to count PIXELWISE the number of managing events (grazing, mowing) and receive a raster layer that contains for every pixel ...
1 vote
1 answer
24 views

How can I make a raster layer where each pixel is a value representing the minimum distance between that pixel and a value from another layer? [closed]

For instance, say I have a raster map of open bodies of water where each point is 0 if it is not water or 1 if it is water. How can I make a new layer where every point is the distance between that ...
2 votes
1 answer
353 views

Create sf polygon from sf linestring and bounding box

I want to create a polygon using a linestring within the sf universe. I am generating a map of a coastline and I want the area that is water to be blue and the area that is land to be tan. Because ...
  • 2,056
0 votes
0 answers
106 views

R arc.write error

I am getting the following error while writing an sf object dataframe to a GDB. The dataframe imported is a feature class from a GDB brought in via the sf package. After some data manipulation I am ...
0 votes
1 answer
46 views

Unexpected resolutions when aggregating rasters with raster package in R

I have a (near) global raster of elevation data in WGS84 with a resolution of 0.00893153 x 0.00893153. I am trying to aggregate it to a resolution of 0.166667 x 0.166667 with the following: fact = 0....
0 votes
1 answer
115 views

How to compute partial correlation of pixels in R

For example, I have 20 years'NDVI and temperature and precipitation rasters. At first,I computed the pearson correlation coefficent with those codes as belows. library(terra) library(Hmisc) ndvi <- ...
  • 103
0 votes
0 answers
63 views

ks.test in spatstat package

I'm trying to make ks.test on my data in spatstat package. I use ppp function to create my pattern named ppp then when i try this code: ks.test(ppp,"x") as in the documentation it says ...
1 vote
1 answer
93 views

Raster NA Error in R - Error in { : task 5 failed - "0 (non-NA) cases"

I'm trying to conduct a landscape genetic analysis through the R Package ResistanceGA on some environmental rasters. However, I keep running into the error Error in { : task 5 failed - "0 (non-NA)...
0 votes
1 answer
42 views

R lm.LMtests error in lag.listw(listw, y, zero.policy) : y not numeric

I am working on running an OLS on a shapefile and running tests on the residuals of that OLS where I am getting an error. library(maptools) library(sp) library(spdep) library(lmtest) library(...
0 votes
1 answer
91 views

Coloring polygons (made with concaveman) in ggplot by column

I'm adapting code for a map made by someone else that uses a package concaveman to generate concave hulls from points. The goal is to plot a number of different polygons in the oceans, and to color-...
  • 145
0 votes
1 answer
20 views

R Markdown Knitting Produces Garbage

I don't even know where to begin on describing my problem. I made some maps in R Studio and when I knit the document, it gives me 30 pages of junk. I have selected the options to display the output ...
0 votes
1 answer
40 views

R Distance from Point to Line: Negative if within shape

I'm working with Brazilian deforestation data - specifically two sf objects: A point shapefile on environmental fines (centroid of land plots that have been fined for deforestation). A polygon of (...
  • 19
2 votes
1 answer
276 views

Formatting decimal point for X,Y coordinates using R

I am relatively new to R and GIS in general, but I am working with this dataset https://data.austintexas.gov/Public-Safety/AFD-Fire-Incidents-2016-January-Thru-December/5tib-gqfx Whoever created it, ...
  • 21
4 votes
1 answer
117 views

Anonymize site locations

I'm putting together some training materials for a workshop on R for spatial data analysis in archaeology, and need to anonymize the true site locations (confidential information) while keeping the ...
  • 143
1 vote
0 answers
113 views

Function for layering two rasters in R

I am trying to layer a raster over a hillshade raster in the same way that I would do using the base R plot function (example code below) and export as a GeoTiff. col_rmp <- c('#0180FF', '#0101FF', ...
  • 121
1 vote
0 answers
24 views

nodata pixels in classified raster

first of all: this is the first research I'm doing using remote sensing data and therefore this is a very basic question: I'm doing a research regarding the classification of grasland use in the year ...
1 vote
0 answers
35 views

How to generate/export a RGB raster layered over a hillshade raster based on visualisation palette in R

I have defined my own colour palette, and written my raster as a GeoTIFF with the colour palette saved into the image using the code below. col_rmp <- c('#0180FF', '#0101FF', '#01FFFF', '#01FF01', '...
  • 121
0 votes
0 answers
36 views

Writing paletted raster in R with color defined for NA values

I have a raster image that I have reclassified. I have defined my own colour palette and would like to write the raster as a GeoTiff with the colour palette saved into the image. I know how to achieve ...
  • 121
1 vote
1 answer
34 views

Raster slope created in QGIS: values do not exist when imported into R [closed]

I used an ocean bathymetry raster (depth) to create a slope raster in QGIS with the "declividad" raster tool. Besides the fact that I was only able to do this by converting the bathymetry ...
0 votes
1 answer
98 views

sf: Session aborts when reading large geopackage into R

I want to read a geopackage into R that is roughly ~ 600 mb in size. Every time I want to read it my R-Studio session aborts when doing the data = read_sf(path_geo) Is there any "trick" ...
  • 717
3 votes
2 answers
433 views

How to use a list with spatial dataframes in a for loop? - R

I have three spatial dataframes (polygons), created via this tutorial. The three spatial dataframes must be exported as shapefiles via a for loop. I created a list polygons containing the three ...
2 votes
0 answers
68 views

Issues downloading soil organic carbon data from SoilGrids

I am trying to use R to download soil organic carbon data for a specific region from SoilGrids, using their example code as a start. The code I wrote based on this worked fine to download the sand and ...
  • 21
1 vote
1 answer
39 views

How to assign a coordinate reference system to x (buffer) datasets of x iterations in a for loop - R

My aims are 1) to create different buffer sizes around three points via a for loop, 2) to assign a coordinate system to each buffer for each iteration, and 3) to store each buffer in a list ...
1 vote
1 answer
33 views

Tessellation will not display quadrat totals when plotted (spatstat, R)

I have tessellated an image, and am trying to plot the number of quadrats that appear in each tessellated region. I have two problems here: My tessellated image will not plot with my gw_ppp points, ...
1 vote
1 answer
87 views

Extracting raster cell values from Gridded World Population Dataset in R

I am using the Gridded World Population dataset which gives population density values for each cell in a raster. I want to find the population of shapefiles by extracting the population density values ...
0 votes
0 answers
35 views

How to make species list per raster grid cell in R?

I have roughly 500 raster files of about 500 species range maps. The cell values in these maps give a suitability index on the occurrence of that species in that cell. The raster files all have the ...
2 votes
0 answers
51 views

eCognition+ R/Python workflow

I am trying to generate a general classifier Model for basic LU classification using E-Cognition. Since my options for achieving so in the software are limited I thought of exporting the segmentation ...
  • 21
1 vote
1 answer
253 views

Creating a point pattern (ppp) error using SpatStat in R: "Only projected coordinates may be converted to spatstat class objects"

I have a point dataset, and I am taked with filtering out duplicate coordinates, removing all points that are outside of a specified county shapefile, and then creating a ppp points object. However, ...
2 votes
1 answer
44 views

How to iterate erasing multiple vectors from another vector using R?

I need to erase different vector layers(shapefiles) using R, but I am not sure how to do it in a fast way. I have 10 different shapefiles and a basemap (also shapefile) that I need to erase my vectors ...
1 vote
1 answer
42 views

rkt Package function on time series analysis is returning error

I am working with an NDVI time series raster composite (1989 to 2019). I am running a time series function on each pixel of the raster stack using the R code provided by Pironkova et al. 2018. The ...
2 votes
2 answers
106 views

exact_extract Coverage area wrong fcoverage fraction

I'm using R to extract the values from a raster into a polygon. It works fine for most of them, but I found this small polygon (which is smaller than the cells) where it is giving me some misleading ...
1 vote
1 answer
42 views

Is there a way to select nearest feature to a point by selected column?

I'm using crs= 2263. I have two datasets, buildings and 311. I would like to see what is the closest building to each 311 complaint. st_nearest_feature(311, Buildings) I believe this works but it ...
  • 193
3 votes
1 answer
141 views

Resample raster but keep sum of total cell values the same

I am trying to resample a raster to a finer resolution, matching the resolution of my raster of interest. The problem is, my raster I'm resampling is a population raster. When I resample, the total ...
  • 33

1
3 4
5
6 7
106