Questions tagged [r]

Statistical computing language and software environment.

Filter by
Sorted by
Tagged with
0 votes
1 answer
302 views

exactextractr::exact_extract just keeping numeric value of categorical raster (and not the labels)

I converted a polygon to raster to then be able to apply exact_extract the most common value in another polygon of interest (areas_interest in the example below). However, the final product returns ...
cschpad's user avatar
2 votes
1 answer
124 views

Error in RGB to HSV conversion in R: "cannot use this formula, probably because it is not vectorized"

I'm trying to convert a bunch of small rgb rasters (3 channels) into hsv rasters using the raster package in R, similar to the suggestion here: QGIS - RGB multiband to HSB(HSV?) multiband It has ...
Geos's user avatar
  • 21
0 votes
0 answers
29 views

Projection reduces directional distortion

Below R code makes transects within a polygon. When I project the transect to lat long they are distorted, i.e. slanted to the left. Is there a way I can convert the transects to lat long whilst also ...
luciano's user avatar
  • 1,157
1 vote
1 answer
310 views

Complications When Calculating Moran's Index in R

I am working with the R programming language. I am running the following code: # https://www.rdocumentation.org/packages/spdep/versions/1.2-8/topics/nb2listw # https://mgimond.github.io/...
stats_noob's user avatar
1 vote
0 answers
264 views

Calculating Moran's I using R

I am trying to learn more about Moran's I (https://en.wikipedia.org/wiki/Moran%27s_I). I am working with the R programming language - I have the following shapefile of North Carolina (USA): library(sf)...
stats_noob's user avatar
0 votes
0 answers
91 views

Calling js module into Google Earth Engine in R (rgee and rgeeExtra) results in 404 error

I want to use BFAST Monitor in Google Earth Engine from within R, using rgee and rgeeExtra. Adapting code from this post to rgee, I have got the following reprex: library(rgee) library(rgeeExtra) ...
madmat's user avatar
  • 1
0 votes
1 answer
145 views

How to mask a raster and apply an unsupervised classification? R

I am getting the error: In matrix(values, nrow = ncell(x), ncol = nlayers(x)) : data length [6691] is not a sub-multiple or multiple of the number of rows [25628]. In reaction to knr <- setValues(...
Aaron_Elph's user avatar
3 votes
1 answer
1k views

Convert sf::st polygon into raster

I have WGS84 coordinates that form a closed polygon. I need to turn this polygon into a raster, but the different solutions to similar questions I found don't work for some reason I don't understand. ...
Anke's user avatar
  • 173
0 votes
1 answer
201 views

Multiple Centroids in a Polygon?

I am working with the R programming language. I am trying to calculate the geographic centroids of different polygons within Canada. I downloaded the following shapefile and tried to calculate and ...
stats_noob's user avatar
1 vote
0 answers
94 views

Edge correction for density estimation and point pattern analysis by R [closed]

I have point data and coordinates for study area. By using R, I need to investigate: Density of data by using kernel method (quartic kernel). Choose the best bandwidth by using Mean Square Error (MSE)...
MertBakirZC's user avatar
2 votes
1 answer
34 views

Setting the initial point of a line

I've been working on a project that consists in plotting points, which are not georeferenced, by their odometric position on a line, which is georeferenced. Eg.: Point 1 is 325 meter away from the ...
Diogo Bichon's user avatar
0 votes
1 answer
112 views

R Spatial Lag Model won't run

I am not sure why the code won't run even though I clearly have the neighborhood list, but yet it still shows the error: Error: No neighbourhood list Packages: spdep #making new neighbors list ...
GeographyGo's user avatar
0 votes
0 answers
173 views

Correctly merge and filter GPS coordinates from LINESTRING in R's sf package

I have an SFC object with 2508 features of LINESTRING geometry type in R's sf package. When I extract the GPS coordinates and plot them, I notice some parts of the trace are connected in the wrong ...
Andreas's user avatar
  • 131
0 votes
0 answers
256 views

Plotting Raster on top of Vector layer in Mapview - R

I am wondering if it is possible to display a raster layer on top of a vector layer when two mapview maps are combined without using alpha.regions = 0 to make the polygon fill transparent. So far I ...
Jokin Gorrotxategi's user avatar
1 vote
0 answers
150 views

GWR model not working [closed]

I am trying to build a GWR regression model. The context is a study about air pollution and children+families. The error is new data matrix rows mismatch I'm not sure what is wrong with my data. # ...
GeographyGo's user avatar
1 vote
1 answer
191 views

Issue when running spatial weights matrix in R

I am trying to run my code in R for a spatial weights matrix, but the following error shows up. I think it's got something to do with my data, but I'm not sure how to resolve it. nb = st_contiguity(...
GeographyGo's user avatar
0 votes
1 answer
271 views

Merging small polygons with largest neighbour in R

I have a bunch of polygons representing land cover classes, however I don't need this much detail. I would like to merge small polygons (ie < 150m2) with it's largest neighbour. This would be ...
seak23's user avatar
  • 181
1 vote
2 answers
176 views

How to use all pixels covered by training polygons for random forest classification in R

I have a training dataset containing around 350 polygons and their land cover classes which I use to train a random forest classifier to classify my raster image. I would like to use the values of all ...
Jessie Qian's user avatar
0 votes
1 answer
787 views

How to calculate mean values of all cells of raster files in R?

I have monthly raster (.tiff) files such as 200501.tif, 200502.tif and so on...till 202012.tif. I want to calculate mean values of each raster (i.e. of all the cells (all rows and columns) of each ...
Alexia k Boston's user avatar
1 vote
0 answers
139 views

Clipping a ggmap object by an sf object

Is there a way to clip a ggmap object by an sf object? I have a Google Earth satellite image that I have pulled using ggmaps: gmap<- get_map(location=c(lat = mylat, lon = mylon ), zoom=15, ...
Andrew C.'s user avatar
0 votes
1 answer
36 views

Coordinates by hodometric position [closed]

I have a vector which is an oil line, it is georreferenced, but this line, as you can imagine, isn't straight. What I need is to find a way to get a coordinate point by it's hodometric position. eg.: ...
Diogo Bichon's user avatar
0 votes
0 answers
98 views

Partial correlation of more than two raster stacks

Is there a way to compute partial correlation between three raster stacks? I have 3 rasters namely SIF, SM and VPD. > SIF_stack class : RasterBrick dimensions : 360, 720, 259200, 10 (nrow, ...
Shunrei's user avatar
  • 41
2 votes
3 answers
225 views

R raster stack mathematical conditioning operation

I am new to R and currently I am trying to create a drought frequency map using a stack of VHI rasters but, I still can't figure out a way. My attempt is as follows. The stack of rasters contains data ...
DilankaMunasinghe's user avatar
1 vote
0 answers
22 views

Mimic raster output from ArcGIS GWR (raster gradient through NA spaces) in R

I'm trying to mimic the raster style output you get from ArcGIS Geographically Weighted Regression, where instead of simply plotting the coefficient/value in the raster cell that aligns with the ...
ttalVlatt's user avatar
1 vote
1 answer
47 views

CRS Options for Geospatial Plots

I am trying to learn about geospatial visualization. Here is a shapefile I downloaded for the UK: library(sf) library(leaflet) # Set the URL url <- "https://data.london.gov.uk/download/...
SiuMai2k22's user avatar
0 votes
2 answers
213 views

Multiply two rasters in R, one raster has stack of 25 images, and another raster has one image

I want to multiply two rasters (one has 25 images, and the second raster has 1 image). I am using the loop function for multiplication. But I am not getting the results. library(raster) library(rgdal) ...
user221527's user avatar
0 votes
0 answers
127 views

Merge multiple Isochrones

I have 2 Isochrone maps generated by OpenRouteService (using the R package). Each segment represents a walk of 60 seconds, 300 seconds in total. Since both starting points are quite near, the ...
Daniel AG's user avatar
1 vote
3 answers
104 views

Export multiples files in an output directory while renaming them as months

I have various .tif files (3 files per month) from 2006-2010. Nomenclature of files are as following: 20060103 20060113 20060124 20060203 20060213 20060221 ... ... ... 20100624 I have calculated ...
Alexia k Boston's user avatar
1 vote
1 answer
236 views

How to create line time-series plot using .tiff images in R

I have monthly .tiff images from 2000-2020 in following way: 200001 200002 200003 . . . 202012 (format is yyyymm) Using the code given below, I am able to calculate monthly averages but I am not able ...
Alexia k Boston's user avatar
0 votes
1 answer
219 views

Calculating driving distances from shapefiles in R

I am working with the R programming language. I am interested in learning about how to calculate the driving distance (e.g. based on road networks) between two sets of coordinates. For example: CN ...
stats_noob's user avatar
1 vote
1 answer
49 views

Kriging: extract data for other unknown points

I have one month of data that I converted to STDFDF. #set the spatial location of the regions Data.loc <- data.frame(Stat = c("Firmo","Citta dei Ragazzi", "Rende", ...
Elena Iakimova's user avatar
2 votes
1 answer
601 views

Strategies for working with large shapefiles

I am interested in learning about how to work with "Road Network" files - for example, I would like to find out the driving distance between two sets of geographical coordinates (i.e. ...
stats_noob's user avatar
2 votes
1 answer
86 views

Specifying ggplot2 aesthetics for factors stored in SpatialLinesDataFrame

I produced a set of 2 contour lines for 6 different individuals. The contours for each individual were originally stored in a single list which contained 6 separate SpatialLinesDataFrames (one per ...
Ryan's user avatar
  • 123
1 vote
0 answers
77 views

SPI function on a dataframe versus on a raster stack?

I have a raster stack representing monthly precipitation values from 2007 to 2016. class : RasterStack dimensions : 360, 720, 259200, 120 (nrow, ncol, ncell, nlayers) resolution : 0.5, 0.5 (x, ...
Shunrei's user avatar
  • 41
0 votes
3 answers
645 views

Replace raster values with multiple other Rasters in R

I have a main raster that only has 12 values in it 1-12. Then I have 12 separate rasters in them with temperature data. For every value in my main raster I want to replace the value with data from my ...
Lavendarfire's user avatar
1 vote
1 answer
69 views

Using software to download shapefiles vs manual downloads

I am new to geospatial analysis and am trying to self-learn about this topic. I learned that the core of geospatial concerns itself with analyzing "shapefiles" - these appear to be ...
SiuMai2k22's user avatar
3 votes
1 answer
142 views

How to subtract buffers of identical ID in R (terra)?

For a research project, I need to define treated and control areas around land parcels, located by coordinates and uniquely identified by an ID. The treated areas consist of disk-shaped buffers around ...
bazoonga's user avatar
1 vote
1 answer
206 views

Imported raster file becomes grainy/distorted when plotting with R

Note: edited post for clarity, April 3rd I'm pretty new to GIS stuff, and I'm trying to incorporate some map rasters into my plots of sampling locations in R. I've got a fairly high-resolution geo-...
Olle's user avatar
  • 133
1 vote
1 answer
421 views

Error in valid.viewpor: invalid 'yscale' in viewport

I have one month of data that I converted to STDFDF. #set the spatial location of the regions Data.loc <- data.frame(Stat = c("Firmo","Citta dei Ragazzi", "Rende", ...
Elena Iakimova's user avatar
2 votes
1 answer
89 views

negative or null values in custom function

I'm working with the package lidR (v 4.0.3) to extract the tree positions using a custom function but it behaves weirdly. If I use the following, I get an error: f = function(x) { 0.413 * x^0.5532 } ...
Nico's user avatar
  • 305
1 vote
0 answers
55 views

When I add a custom R Script Tool to my ModelBuilder, it gives me this error message

I have been trying to add an R Script Tool to my model in Model Builder within ArcGIS Pro--the tool, called Tree Detection, works well when I run it on its own, but every time I try to run it as part ...
MiriamSeely's user avatar
0 votes
1 answer
1k views

Issue with terra::mask

I try to mask the mapenter image description here in the rectangles with the borders of Switzerland. str(swissmask) S4 class 'SpatVector' [package "terra"] > swissmask class : ...
Beat's user avatar
  • 3
0 votes
1 answer
474 views

How stackApply function in R works to calculate monthly mean of daily .tiff files?

I have various .tif files (3 files per month) from 2006-2010. Nomenclature of files are as following: 20060103 20060113 20060124 20060203 20060213 20060221 ... ... ... 20101224 I want to calculate and ...
Alexia k Boston's user avatar
1 vote
1 answer
164 views

Select buffers that do not overlap

I have a dataset with amenities. I've created a buffer of 200 meters around each amenity. m_circles <- st_buffer(m, dist = 200) It looks like this: How can I keep only the buffers (polygons) that ...
Daniel AG's user avatar
1 vote
0 answers
231 views

Intersections Between Two Shapefiles in R

I have these two shapefiles in R: file_1 file_2 I imported these files into R: file_1 <- sf::st_read("C:/Users/me/OneDrive/Documents/folder1/lada000b21a_e.shp", options = "ENCODING=...
stats_noob's user avatar
2 votes
1 answer
119 views

How to create a "random" shapefile

I have the following shapefile in R: #https://stackoverflow.com/questions/75845500/r-find-out-list-of-boundary-coordinates library(sf) library(leaflet) library(dplyr) # built in shapefile nc <- ...
stats_noob's user avatar
1 vote
1 answer
535 views

R: Plotting a shapefile, plots the shapefile many times, not just once

I am trying to make a map using a particular shapefile as the first layer. The shapefile has multiple attributes and when I plot it, the plot shows the spatial data multiple times for each column in ...
Koda's user avatar
  • 25
1 vote
1 answer
353 views

GeoTIFF to data.frame using R [closed]

I have data with population counts in GeoTIFF format and would like to convert it to a data.frame using R. The data I have can be accessed here. I would like to obtain a table with the form: ...
Santiago's user avatar
  • 111
1 vote
1 answer
826 views

Casting all geometries from SpatVector from type "MULTIPOLYGON" to type "POLYGON" in R

sf function st_cast() doesn't work on SpatVectors, and I've tried to look for a way to convert all geometries to single polygons, but to no success. Is there a way to do that in R ? I guess something ...
Léo Jacquat's user avatar
1 vote
0 answers
35 views

Cannot rotate angle of LAS dataset using spTransform

I previously was able to adjust the angle of my las data using the below function I made. No idea why it has started giving issues? Has spTransform changed? I am using the code below in R: rotatelas &...
zaguy22's user avatar
  • 33

1
6 7
8
9 10
118