Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Statistical computing language and software environment.
0
votes
1
answer
249
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 cell …
0
votes
Measure a distance between point and the nearest NA in the raster
Here is a solution converting raster patches into polygons, and subsequently into lines, using this post
library(terra)
set.seed(123)
# Create an empty raster and set all values to NA initially
raste …
0
votes
1
answer
101
views
spdep::localmoran How to access classified cluster values?
I am trying to get a LISA cluster map similar to this one, eg showing the 'High-high', 'Low-Low'.. cllassified values.
But, I can't figure out how to extract this classifications from the localmora …
0
votes
spdep::localmoran How to access classified cluster values?
OK, I found this after correcting my googling:
To access indivudual attributes of an object, one can use attributes(x)$attributeName or attr(x, attributeName).
So, in my case, to access the 'mean' col …
4
votes
2
answers
4k
views
R spatial: st_overlaps to subset also fully covered polygons?
I want to subset all polygons in fc1 completely or partially overlapping with fc2. But, the st_overlaps subsets only polygons that overlaps with the border of fc2, but skips the fully covered polygons …
2
votes
1
answer
1k
views
Creating regular sampling grid, with specific distance between points using R
Similar question is answered as Creating regular soil sampling grids using QGIS but I wish to use R. …
1
vote
Function (sample code) to extract raster value per polygon in R
Following the answer suggested by @HMSP, great solution is now offered by terra package, and using terra native formats for rasters and vectors. First convert raster and vector to terra format, and th …
0
votes
1
answer
226
views
Classify integer raster in tmap
THis is how it should look like (raster reclassified outside of R. Reclassify the values using classical matrix takes forever on my Win 10 64 b, R version 4.0.2 (2020-06-22)). …
2
votes
1
answer
2k
views
Simplify raster size to plot using ggplot geom_raster()
Isn't there something as efficient to plot rasters and use them in a map in R? tmap::tm_raster() seems promissing but other suggestions are welcome! …
12
votes
1
answer
3k
views
R spatial: Erase one polygon from another: correct use of `st_difference`?
I am trying to erase one shapefile from the other, similar to ArcGIS Erase tool:
This worked pretty well with rgeos::gDifference(spdf1, spdf2), which needs as input geometry of SpatialPolygonDataFra …
13
votes
5
answers
12k
views
How to speed up raster to polygon conversion in R?
I've decided to process my Landsat data in R instead of ArcGIS - due to my missing knowledge of python and because of (assumed) high computation capacities of R. … moreover, when I tried FOR loop, my R on Windows crashed twice... It runs on mac, for the moment. Where the problem could be and how can I increase computation speed? Am I running out of R memory? …
1
vote
How to rasterize a vector dataset in R?
(-125,0), c(0,60), c(40,5), c(15,-45), c(-125,0)))
pols <- st_sf(value = rep(1,3),
geometry = st_sfc(lapply(list(p1, p2, p3), st_polygon)))
Create first raster with desired resolution:
r … <- raster(pols, res = 1)
Rasterize sf polygon using fasterize function:
r <- fasterize(pols, r, field = "value", fun="sum")
plot(r) …
3
votes
2
answers
974
views
Switch between ArcGIS and R changes my shapefile projection?
Not the best practice, but somethimes I need to change between ArcGIS 10.6 and R (version 3.6.1) to process my shapefiles. … For example, I want to read my shapefile in R -> process it -> export it back to ArcGIS. …
1
vote
1
answer
590
views
Use geometry binary predicate list to subset simple feature object?
I am trying to create a new simple feature from two overlapping features. I want to subset all polygons that are fully or partially located within my buffer (red border).
However, the st_overlaps …
1
vote
Accepted
R spatial: add new attribute to S4 class object?
The simplest answer...
I had wrong position of the [i,] indexing. Instead of indexing the shapefile polys[i,]@data$open_edge <- TRUE the correct indexing is in shapefile attribute table slot polys@da …