The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [r]

Statistical computing language and software environment.

Filter by
Sorted by
Tagged with
17
votes
1answer
1k views

Monte Carlo simulation using QGIS and pgRouting on optimal sidewalk construction

I am new to spatial analysis and would appreciate some general direction on a project I am attempting, outlined below (I am starting from scratch). GOAL: To find the best locations to install 2000 ...
16
votes
3answers
15k views

Merge a list of spatial polygon objects in R

I have a list of spatial buffers (30000 buffers) that I built with the function lapply: buff.pts <- lapply(1:nrow(pts.prj), FUN=function(l){ buff <- gBuffer(pts.prj[l,], width=1000) ## 1km ...
16
votes
7answers
9k views

Get Raster Values from a Polygon Overlay in Opensource GIS Solutions

I have two layers. A polygon-shape-layer with many tiles and a raster-layer containing CORINE 2006 land cover with many categories in a colourmap. I want to obtain for each polygon in the shapelayer a ...
16
votes
2answers
2k views

Need a spatial database that can be used by QGIS and R

I'm quite new to QGIS and I'm searching for a simple way to create a Database that allows me to use the tables in QGIS and R. I have a lot of data stored in Excel spreadsheets wich will be used for ...
16
votes
2answers
17k views

How to perform a true GIS clip of polygons layer using a polygon layer in R?

I would like to do a true GIS Clip in R of soils polygons using a series of single boundary polygons, but I cannot find an R function to properly do it. It should work just like the clip function in ...
16
votes
1answer
24k views

How to assign CRS to RasterLayer in R

I have a layer with coord. ref. : NA. How can I assign coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 to coord. ref. : NA? class : RasterLayer dimensions : 127,...
16
votes
4answers
6k views

How to stop writeOGR from abbreviating Field Names when using “ESRI Shapefile” driver

I'm currently using the following script to add some attribute data from a table to lots of individual shapefiles: library(rgdal) specieslist <- read.csv("SpeciesList1.txt", header=F) attdata <-...
15
votes
4answers
33k views

Converting osm file to shapefile (or data frame) in R

I was looking for a road shapefile for Australia today. I ended up going to Geofabrik. Open Street Map has data in .osm format. But they do not have one in .shp for Australia. If possible, I want to ...
15
votes
1answer
27k views

Converting a polygon into a raster using R

I'm trying to convert a shapefile into a raster within R. My approach is to read in the raster as follows: library(rgdal) # Loads SP package by default demo <- readOGR('F:/data/', 'shapefile') # ...
15
votes
1answer
6k views

equivalent of sp package's point in polygon / overing using sf

I am migrating code from sp package to the newer sf package. My previous code I had a polygon SpatialDataFrame (censimentoMap) and a SpatialPointDataFrame (indirizzi.sp) and I got the polygon cell id (...
15
votes
5answers
14k views

How to split a vector into equal smaller parts in QGIS or similar?

i want to divide a shapefile with many tiles into a lot of smaller tiles. I am searching for a smart solution, because manual edits are out of questions Anyone can help or know a nice function?
15
votes
1answer
5k views

Batch geocoding in R

I need to find a package in R or source code in R that performs batch geocoding using Bing, Yahoo, OpenStreetmap. Do you have any suggestions?
15
votes
3answers
4k views

Using R with ArcGIS for Desktop (without using GME)? [duplicate]

I am trying to learn R generally and making statistics for maps. I found some useful tricks for making maps with it but it is not the best you can do. My everyday GIS program is ArcGIS. How I can use ...
15
votes
3answers
1k views

Ecological geospatial conundrum

I am looking for a different, more elegant solution to a spatial statistics problem. Raw data consists of an x-y coordinate for each individual tree (i.e. converted to a point .shp file). Although ...
14
votes
2answers
8k views

Resources on using R in QGIS for R users?

I'm finding that much of the QGIS documentation is oriented toward use of the GUI. I want to be able to run R scripts in QGIS, but am having trouble finding a resource that will ground me in the ...
14
votes
6answers
6k views

Convert line shapefile to raster, value=total length of lines within cell

I have a line shapefile representing a road network. I wish to rasterize this data, with the resulting values in the raster showing the total length of the lines that fall within the raster cell. The ...
14
votes
2answers
28k views

Choosing the correct value for proj4string for shapefile reading in R?

I am having a shapefile of polygons and another CSV file which contains a list of points as (Lat, Lng) pairs.. I want to check for each (lat, lng) pair from the CSV file which polygon does it fall ...
14
votes
7answers
3k views

How to implement value-by-alpha map in GIS?

I've been doing some background reading about cartograms recently and stumbled upon interesting alternative - value-by-alpha maps. Concept is described in more details here and full paper is ...
14
votes
3answers
4k views

Reverse clipping (erasing ) in R?

A reverse clip saves only the part of your spatial object that is outside the bounds of another object, as opposed to a regular clip which saves the parts that are inside the other object. ...
14
votes
3answers
27k views

R: How to get latitudes and longitudes from a RasterLayer?

I am an absolute beginner of geographic data, so please, forgive me if the question is not appropriate. I downloaded data from NCDC NARR and managed to load into R using the raster package. I would ...
14
votes
1answer
41k views

Converting geographic coordinate system in R

I have points in geographic coordinate system and I wanted to convert them to swiss grid (CH1903+). Sample data: id lon lat 2 7.173500 45.86880 3 7.172540 45.86887 4 7.171636 45....
14
votes
1answer
6k views

Simplify polygons of sf object

How do I simplify an sf polygon without introducing gaps and slivers? With a shapefile, for example, I would use rmapshaper::ms_simplify(): library("pryr") library("rgdal") library("rmapshaper") ...
14
votes
2answers
15k views

Converting point data into gridded dataframe for histogram analysis using R?

I am very new at using GIS data and only modestly experienced with R. I've been reading about how to analyze spatial data using the spatial-analyst.net PDF book, so I'm not completely lost, but I ...
14
votes
3answers
1k views

Determining if trees within forest gaps are clustered using R?

The attached dataset shows approximately 6000 saplings in approximately 50 variable sized forest gaps. I am interested in learning how these saplings are growing within their respective gaps (i.e. ...
14
votes
2answers
610 views

How to translate John Snow data sets to map coordinates

In the HistData package for R (https://r-forge.r-project.org/R/?group_id=574) I have the data sets related to John Snow's map of the cholera outbreak in London, 1854. I believe they are authoritative,...
13
votes
2answers
457 views

How to create a map of Denmark with ggmap

I have installed the following two packages: library(ggmap) library(maps) I have found code online to create a world map (see below). How do I zoom the plot on a country level? For example, Denmark. ...
13
votes
2answers
21k views

How to make RASTER from irregular point data without interpolation

I was trying to make a raster image from an irregularly spaced point database. The data looks like- > head(s100_ras) x y z 1 267573.9 2633781 213.29545 2 262224.4 2633781 ...
13
votes
1answer
11k views

Create polygons of the extent and boundary of a given Raster in R

I want to create two polygons. One is of the rectangular extents of my raster. I know I can obtain the extent of the raster using r <- raster("band5.tif") e <- extent(r) plot(e) gives me this: ...
13
votes
2answers
32k views

How to extract values from rasters at location of points in R?

My question is about extracting values from rasters at the location of points. With the function extract this is very easy, and the function gives me a dataframe with the values of all the variables ...
13
votes
2answers
5k views

Random sampling of raster using R?

Is there a straightforward way of randomly sampling a raster so that the output of the process is a raster? I'm using an example that I found on the r-sig-geo list and I have also tried the ...
13
votes
2answers
6k views

use proj4 to specify Robinson projection with R ggmap and ggplot2 packages?

I want to project this map in robinson projection: library(ggmap) world <- map_data("world") ggplot() + geom_path(data = world, aes(long, lat, group = group)) And I ...
13
votes
2answers
9k views

Clip Spatial object to bounding box in R

Given a Spatial object in R, how do I clip all of its elements to lie within a bounding box? There are two things I'd like to do (ideally I'd know how to do both, but either is an acceptable solution ...
13
votes
2answers
10k views

Aggregating points to grid using R

I have a question with regard to spatial aggregation in R. What I am trying to do is aggregate a point dataset to a grid. I am unsure however how to do this as I have little experience with this sort ...
13
votes
2answers
4k views

Clip polygon and retain data?

I have these two polygons: library(sp); library(rgeos); library(maptools) coords1 <- matrix(c(-1.841960, -1.823464, -1.838623, -1.841960, 55.663696, 55.659178, 55.650841, 55....
13
votes
3answers
7k views

Choropleth in R: custom breaks and plotting

I have a question with regard to plotting a choropleth map. What is recommended with regard to plotting a map with custom breaks? And make it look a bit attractive. In my script I have used the ...
13
votes
2answers
7k views

Performing route analysis in R based on OSM transport network?

I'm analysing the likely paths taken by commuters on their way to work, based on Census flow data, job density distributions and the transport network. At the moment I'm using pgRouting and the ...
13
votes
2answers
3k 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 ...
13
votes
1answer
5k views

Clustering geographical data based on point location and associated point values

Given data points with longitude, latitude, and a third property value of this point. How can I cluster points into groups (geographical sub-regions) based on the property value? I searched by google ...
12
votes
4answers
63k views

How to convert zip codes to latitude and longitude?

I have a data set that includes a list of zip codes. Is there a way in R to convert these zip codes to latitude and longitude coordinates?
12
votes
2answers
22k views

SpatialPointsDataFrame properties and operators in R

I have created an object of type SpatialPointsDataFrame using the sp package in R. However, I am confused about the @, $, . and [] operators and when to use them to access the different properties of ...
12
votes
3answers
26k views

Extract Raster from Raster using Polygon shapefile in R

I am new to R and using the raster package. I have a problem extracting polygons from an existing raster file. If I use extract(raster, poly_shape) function on the raster it always creates a list ...
12
votes
2answers
9k views

Removing rows in shapefile in R

I've imported a shapefile into R, and joined it to a table. My shapefile contains all the census ids, while my table only contains selected census ids. I'm now trying delete all the rows didn't get a ...
12
votes
1answer
670 views

Randomly altering raster map of habitat types?

I have a raster of habitat types for a specific area in Scotland. I need to create future habitat scenarios with changes in habitat to assess the population viability of a bird species. For example, ...
12
votes
3answers
8k views

Reading File Geodatabase using R?

File geodatabase (fgdb) includes numerous file geodatabase tables. As far as I know they exist as dbf files, but are within a Database.gdb. In ArcCatalog, the file pathway resembles C:\Users\...\...
12
votes
4answers
6k views

Fastest way to convert big raster to polyline using R or Python?

I have a big raster file (129600 by 64800 pixel) with global water bodies (1 bit values 0 and 1) and try to extract ocean and inland water shorelines. I've tried with ArcGIS and QGIS to convert from ...
12
votes
1answer
18k views

Reprojecting raster from lat/lon to UTM in R?

i have to turn it into a UTM in order to make the buffer functional. wets<-readOGR(dsn=".",layer="shapefile") r.raster <- raster() extent(r.raster) <- extent(wets) res(r.raster) <- 100 ...
12
votes
3answers
6k views

How to get the second nearest neighbor between two point patterns in R?

Is there a way to get the distances for the second nearest neighbor between two point patterns in R? The spatstat package has a function called nncross but it only applies to the nearest neighbors ...
12
votes
2answers
13k views

writeOGR with a spatialpolygon simplified by gSimplify

I'm using gSimplify (rgeos package) to simplify the geometries of a shapefile. The funcion works good, but now I can't write the output in a new shapefile. I tried some ways: writeOGR(simplyshape, ...
12
votes
1answer
10k views

Subset a SpatialPolygonsDataFrame by ID in R?

I've used the gIntersect function from the rgeos package to determine which polygons intersect in two SpatialPolygonsDataFrames (spdfs). The result is a logical matrix with rownames comprising the ...
12
votes
1answer
540 views

Spatial operators in R?

How can I do spatial selections or filters in R? I can do this in PostGIS using (e.g.): SELECT * FROM mypoint, mypoly WHERE ST_Within(mypoint.geom, mypoly.geom); and it is similarly a piece of cake ...