Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [r]

Statistical computing language and software environment.

7
votes
2answers
2k views

Clipping vs Intersecting

I was curious why clipping shapefiles was just so difficult and whether it was different to intersecting shapefiles? You will see from one my questions that I gave up trying to clip a polyline with a ...
-1
votes
1answer
15 views

Default parameter values in r's gstat idw?

In r, gstat has an Inverse distance weighted (IDW) interpolation method. Does anyone know what the default values of nmin, nmax and maxdist are?
0
votes
0answers
13 views

Converting large NetCDF daily precip data to monthly averages

I have a large NetCDF file containing daily gridded precipitation data for around 30 years and I'd like to create monthly average precipitation rasters from this. I've had a look around and the only ...
-1
votes
0answers
20 views

rasterToPoints does not return PixelCenter (R)

My goal is to sample some coordinates that ly exactly in the center of a Landsat pixel. For this sampling, i use the clHs Unfortunately, my exported .gpx coordinates are not located in pixel-center, ...
1
vote
1answer
22 views

Error in mapping connections with great circles

I am fairly new to R and to map plotting. I am trying to overlay some network information on a world map. I loaded a shapefile from Natural Earth as a large SpatialPolygonsDataFrame via readOGR. I ...
-1
votes
0answers
12 views

error in making voronoy diagram in r

I try to make Voronoy diagram in latitude/longitude cooredinates. Frist of all I made grid: library(gstat) library(sp) longitude_for_data = c(32,68,89,145,176, -14, -42) latitude_for_data = c(...
0
votes
0answers
23 views

Bayesian updating of land cover classification [on hold]

I am working on Land Cover Classifications and I want to apply a naive Bayes classifier for improving the accuracy. I have read a few papers but I haven't found any step by step guide to help me as I ...
0
votes
1answer
1k views

Creating buffers around points and merging with SpatialPolygonsDataFrame to create a list of matched polygons and area of intersection?

I have data on polling booths as points and data on village boundaries as polygons. I want to create buffers of 1km around the polling booths and (a) save the ID of all the villages that intersect ...
1
vote
1answer
72 views

R dissagregate method in python

It seems an easy question, but I can't find the Python equivalent of R's Dissaggregate: Disaggregate a RasterLayer to create a new RasterLayer with a higher resolution (smaller cells) I expected ...
2
votes
3answers
766 views

Does ArcGIS Desktop have equivalent to RStudio Console Windows?

I know Esri provides scripting capacity, via the Python window, but I've had a hard time with it. Making the jump from the Field calculator to the Python window was too much to me. Trying to keep 3 ...
0
votes
0answers
21 views

How to cover data by circles, limited by a maximum of values?

I have a regular grid with a cell width of 200 meters (available as raster and vector data set). Each cell has a value from 0 to 2000. I now want to draw circles around these cells in such a way ...
0
votes
0answers
13 views

extract values from raster function taking too long

My task is to extract values from raster A and B from point location file A and B, respectively. Both point location files have 375152482 obs. of 2 variables. The only different is A is in XY ...
0
votes
1answer
43 views

Create polygons (representing boundaries) from lines

I received a file of municipality boundaries, where the boundaries are represented as lines. I would like to convert this to a set of polygons, each representing a municipality. In other words, from ...
12
votes
2answers
1k views

R Scripts in QGIS 3.0?

It seems the Processing options in QGIS 3.0 no longer include R Scripts (they are not listed as available along with SAGA, GRASS, and GDAL). Is this a change in this version of QGIS or have I had a ...
3
votes
1answer
99 views

Adding lat/lon to multiple shapefiles

I have location data points for colonies (csv file). I have a shapefile that I need to duplicate and georeference to each colony. Is there a way to do this in r? EDIT: I want to create a copy of the ...
1
vote
1answer
18 views

How do I combine geometries in a shapefile based on a grouping variable?

Here is a simple example. I have a shapefile of three US states: This is the code that creates the shapefile. library(USAboundaries) library(sf) library(dplyr) states <- us_states(map_date = "...
1
vote
1answer
23 views

Rasterize the full area of a polygon, not only midpoints, using R [duplicate]

The default function in raster::rasterize is to see if a point is within a polygon and if yes, make a cell. This results in that some of the outer parts of the polygon is not covered by the new raster....
0
votes
0answers
16 views

For a specific point in space, get the pixel in which that point lies (in R)

I am a bit new to the spatial packages of R. I have a hdf file from which I can get a data.frame with the latitude and longitude of the corners of the pixels, and the latitude and longitude of the ...
15
votes
1answer
406 views

rMaps choropleth with custom json

With R I want to make an animated choropleth map with the rMaps package and a custom map. I tried to follow the example of Diego Valle described here and to use the custom map info for Datamaps. ...
2
votes
1answer
28 views

I want to plot point shapefile on a raster to know if they are at the right place in R

I have one raster and a shapefile of points. I want to check them if they are in the same coordinate system by plotting them together on a map (like in a classical GIS), here the R script : # raster ...
0
votes
1answer
14 views

Using raster::rasterize's getcover to get total polygon area with overlaps

I want to use rasterize to get how much of a raster cell is covered by polygons. This can be done like this: library(raster) p1 <- rbind(c(-180,-20), c(-140,55), c(10, 0), c(-140,-60), c(-180,-20)...
0
votes
0answers
27 views

Coding in R Studio? [on hold]

I'm doing an assignment and it uses this line of code in R but when I get to the last part it says only the 5502 ID is taken from the object. How can I make all 4 (5502, 5503, 5504 and 5507) be taken?...
2
votes
2answers
263 views

Making data table using linear kriging interpolation with variogram in R

I have a table of data with such structure: longitude_for_data = c(32,68,89,145,176, -14, -42) latitude_for_data = c(22,98,21,13 , 16,-134,-102) Z_for_data = c(30,40,60,70 , 20, 40, 100)...
0
votes
0answers
22 views

Use SPEI in R using raster or netcdf data

I want to use the SPEI package in R 1, but so far I have seen tutorials on how to use it for a single location. How could I use it by importing my own spatial grids in raster or netcdf format?
0
votes
1answer
21 views

Convert Oracle data to polygons using R

I have a polygon file, taken from an Oracle database, that looks something like this: ID FMC_AREA_TYPE_NAME DESCRIPTION 1 162 HARBOUR Esbjerg 2 164 HARBOUR Thyborøn ...
1
vote
2answers
39 views

Service Area or Catchment Area in R

I'm trying to find an R package to duplicate a specific bit of functionality of the ESRI network analyst: What ArcMap refers to as 'Service Areas'. Related terms include catchment areas isochrones '...
0
votes
0answers
18 views

Finding Alternative Routes Using OSRM (R)

Using the osmr or stplanr packages I can easily get the fastest route between two points using OSMR e.g. library(osrm) library(stplanr) library(sf) path <- osrmRoute(src = c("Buckingham", 0....
1
vote
1answer
145 views

Iterative Mean of Means Infinite Loop for calculating H-t Index

I'm trying to create a function that will calculate an Ht-Index for Quantifying the Fractal or Scaling Structure of Geographic Features (but am new to R) which basically just finds nested means of ...
2
votes
1answer
20 views

Understanding spsample in R?

I have read the documentation for this but still unsure of what the function spsample does. The documentation is here: https://www.rdocumentation.org/packages/sp/versions/1.3-1/topics/spsample I ...
0
votes
1answer
25 views

How to read WKB from a PostGIS table with the sf package in R [on hold]

I'm working with OpenStreetMap data, for the manipulation of which I mostly use raw SQL queries to a PostgreSQL/PostGIS database. However this is not the most productive workflow, and I would like to ...
2
votes
1answer
25 views

lidR lasaddextrabytes does not update header

My lidR version is 2.0.2 I am trying to add an extrabyte about treeID that I get from raster (lasmergespatial with vector is super slow). I have a problem with saving that extrabyte to LAS file. I ...
1
vote
1answer
29 views

Rasterize point layer with weighted distance

I have a point layer representing wells in a region. i am able to rasterize it and write the well density into the raster as integer, so far so good. What I aim for is to create a raster with values ...
0
votes
0answers
29 views

Getting shortest driving distances (no traffic) for large series of lat/long coordinates in R? [closed]

I have a series of about 10,000 origins and destinations (in lat/long coordinates) between which I need to calculate driving distances in miles. I'd like the driving distance to be the shortest ...
2
votes
1answer
24 views

Nested loop and terrain analysis R

I have a raster stack with 11 layers that I am running through a triply nested lapply(). I expect 44 layers to be returned, but I'm only seeing 4! Reproducible example: # Load packages library(...
0
votes
1answer
28 views

R leaflet plot with ETRS89

I am new to GIS and R leaflet, and I am trying to plot the starting points of protected rivers in Spain. Example of coordinates from the original file: Nombre.de.los.cauces.principales Coordenada.X....
1
vote
2answers
46 views

Calculate the percentage of a Line passing through Polygons

I have a polygon layer of a region (100% coverage, no overlaps) and a line layer in the same region. I want to calculate for each line to which percentage it crosses certain polygons. I have seen ...
1
vote
1answer
21 views

Why does this R code that maps points into polygons cause a segmentation fault?

As in this question/answer, I have a data frame of points (which also includes some necessary, non-coordinate data columns) and a shapefile. In this case the shapes are US states. The last line of the ...
4
votes
2answers
2k views

Read multiple layers of KML file using R

I have a KML that 3970 layers. I am trying to read it into R using the following script: library(rgdal) lyr <- ogrListLayers("file.KML") mykml <- readOGR("file.KML","Layer1") This works but ...
-2
votes
0answers
65 views

What is the future of R in spatial data analysis science? [closed]

I am new to spatial data science and have some basic knowledge in ArcGIS and QGIS. I am considering to continue my PhD in spatial analysis related to agronomy; ex precision agriculture, predicting ...
1
vote
0answers
446 views

Computing Shannon-Weiner biodiversity index using QGIS? [closed]

I wonder if anybody has some experience in calculating biodiversity index (such as Shannon-Weiner) using QGIS? I am also interested for similar experiences using R scripts within QGIS. The analysis ...
0
votes
0answers
31 views

Stratified random sampling in R? [closed]

I have a data table like > head(sdmdata) pb aspect covertype disnr disrespt disroad diswater elevation kernelrespt slope 1 1 167.53506 6 0 607.4537 14624.81 57834.41 ...
5
votes
3answers
5k views

Remove NA from Raster Layer

I have a RasterLayer and a SpatialPolygonDataFrame. I used the mask function to create a new RasterLayer. The output is correct but it does include lot's of NA values. Now I want to get rid of ...
-1
votes
0answers
28 views

Sampling methods for training data and test data [closed]

I want to evaluate the species distribution model, and I have 8 continuous variables and 1 categorical variable (which is "covertype"). The code is like: samp<-sample(nrow(sdmdata), round(0.75*...
1
vote
1answer
21 views

How to access GDAL utilities from command line using Rgdal installation? [closed]

I have just installed rgdal from within R install.packages("rgdal"). I can now successfully do library(rgdal) with the following message: Loading required package: sp rgdal: version: 1.3-9, (SVN ...
0
votes
0answers
25 views

R sf package - link to GDAL

Is it possible to ask R {sf} package to use a GDAL installation I prefer? So far I found how to check external software it uses: library(sf) sf_extSoftVersion() # GEOS GDAL ...
3
votes
1answer
38 views

How might one optimise geospatial operations on complex polygons, especially plots in R?

Question: I'm attempting to run some simple plots on some shapefiles with a high number of complex polygons. These aren't massive files - for the example below, the shapefile is 70mb (15872 obs), but ...
1
vote
0answers
36 views

All (GeoTIFF) raster values NA after converting to velox

Cross-posted to the velox GitHub repo: https://github.com/hunzikp/velox/issues/40 I'm able to extract average tree cover values for each of the three small counties in the US State of Delaware, but ...
0
votes
2answers
43 views

Resampling raster with categorical data in R?

I have a covertype raster layer which is categorical data (1,2,3...19), and I want to change its resolution, coordination system, column numbers and row numbers to fit with other raster layers. But ...
1
vote
1answer
92 views

How to use st_buffer?

I would like to calculate a buffer of 5km around country polygons. However, I somehow always get a warning and an error. Here is a reproducible example code. library(sp) library(sf) library(tmap) ...
15
votes
2answers
26k views

Extracting intersection areas in R

I have two polygons. One contains fields(X,Y,Z) and the other contains soil types (A,B,C,D). I want to know what area of every field contains which type of soil. I tried the following: library(rgdal)...