# Questions tagged [r]

Statistical computing language and software environment.

3,424 questions
Filter by
Sorted by
Tagged with
2k views

### Conditional assignment of values to adjacent raster cells?

I have a value raster: m <- matrix(c(2,4,5,5,2,8,7,3,1,6, 5,7,5,7,1,6,7,2,6,3, 4,7,3,4,5,3,7,9,3,8, 9,3,6,8,3,4,7,3,7,8, 3,3,7,7,5,3,2,8,9,8, 7,6,2,6,5,...
14k views

### Calculating shortest distance from point to line using QGIS?

What is the best method to calculate the distance from the nearest road for a series of address points in QGIS, having a very big dataset? (QGIS 2.0.1, Win XP) I read the answers to previous similar ...
3k views

### Calculating road density in R using kernel density? [closed]

I have a large (~70MB) shapefile of roads and want to convert this to a raster with road density in each cell. Ideally I'd like to do this in R along with GDAL command line tools if necessary. My ...
3k views

### How does spatial polygon %over% polygon work to when aggregating values in r?

I'm working on an environmental epidemiology project where I have point exposures (~ 2,000 industrial hog operations - IHOs). These IHOs spray on nearby fields, but the feces water droplets and smell ...
3k views

### Spatio-temporal interpolation in R or ArcGIS?

I'm trying to calculate average rainfall value from a number of points using Inverse Weighted Distance tool in ArcGIS 9.3. My problem is that: each point has it own time series, therefore the ...
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 ...
977 views

### Why does @data@values slot for RasterLayer only contain logical(0) and not the actual values?

Trying to get to the bottom of why, when I read in a raster of NDVI, the @data@values slot does not contain the actual values until I set them manually. For example: NDVI <- raster("./filename....
2k views

### Point overplotting on maps in R (e.g. with ggplot2) - how to push points to the side, mark original positions, combine close-by points …?

I've got a database containing languages, their longitudes and latitudes and a feature value (either category 1, category 2 or both - in the plot these are marked red, blue and green respectively). ...
2k views

### Plotting bar charts on maps in R?

I'm using plotrix in R to plot a state level map of the US. It has an excellent function floating.pie to put pie charts on each state. I'm wondering if there are similar functions within the plotrix ...
15k views

### R - Create a boundingbox, convert to Polygon class and Plot

I have the NE lat lng and SW lat lng. My goal is simple, I am using RStudio and I want to create a bounding box from the above two lats and longs and then generate Polygon and I want to add random ...
7k views

### R spplot tutorials

I'm in need of some tutorials/books/other training materials which cover how to use the spplot function in the sp package in R properly. As with many of these functions, it seems very powerful, but ...
4k views

I use a 'R' script for downloading MODIS imageries. However, it doesn't give MOD16 product. I could neither find the MOD16 product in earthexplorer website. Though the desired product is available at ...
2k views

### Creating randomly shaped clumps of cells in a raster from seeds of 1 cell/pixel?

As my title says, I wish to "grow" clumps of cells from seeds within a raster. My base raster is full of 1's and 0's, 1's indicate land and 0's sea/NA areas. From the 1's I wish to select 60 random ...
4k views

### 1km circles around lat-long-points in many places in world

I have hundreds of lat-long-points spread around the world, and must create circle-polygons around each of them, with radius exactly 1000 meters. I understand the points must first be projected from ...
573 views

### Count raster value in a bounding box (spatial extent)

Given a bounding box, how can I count the number of specific values (say, I am interested in the number of value == 1 ) in a raster in 1) arcpy, or 2) raster package in R?
4k views

This is a process that takes just a few seconds in GIS software. My attempt to do it in R uses a large amount of memory then fails. Is there something wrong in my code, or is this just something R ...
3k views

### How to combine sfc objects from R package sf

Using the R package sf, how does one combine sfc objects? For example, given the following code, how would one create a single sfc object sfc12 that includes the geometries from both sfc1 and sfc2? (...
4k views

### Rgeos drops associated values when intersecting polygons

I am trying to intersect two SpatialPolygonsDataFrames and get a SpatialPolygonsDataFrame as the result. Unfortunately, using the gIntersection function from rgeos (which works impressively quickly ...
1k views

### From polygon to continuous measure of diversity?

First of all; I have tried to find a similar question, without success. Maybe it's because I'm quite new to GIS and I don't really know what exactly I'm looking for. If someone points me to a similar ...
848 views

### Kriging on GRASS+R - cannot allocate vector of size 146.5 Mb

I'm trying to do a groundwater elevation map with an Ordinary Kriging on R, but always resulting on the lack of memory cannot allocate vector of size 146.5 Mb allocation (windows xp 32bit). ...
843 views

### How to anonymise a gps file?

Imagine you have a GPS trace that you want to make anonymous, in the legal sense. How would you do this? Is snapping to the nearest x distance and stripping out the time enough? Are there ...
13k views

### How can I use fortify() to create a filtered R data frame from a shapefile?

I am in the process of building a ggplot choropleth map of population in administrative areas in Wales. I have downloaded the Boundary-Line data from the Ordnance Survey and extracted what seems to be ...
2k views

### Multispectral image segmentation for natural-resources applications using R

R has the capacity for image segmentation, although all of the examples I have come across utilize a single band for the segmentation (example). I am interested in combining R's capacity for random ...
979 views

### Creating groups of points from lat/long pairs using R?

I have a database which contains Lat/Long pairs to identify the location of points of interest. I would like to group the points of interest into groups of 10. The group should be geographically ...
16k views

### Counting number of points in polygon using R?

I have two classes sharing the same CRS (Latitute and Longitude): bolognaQuartieriMap: a SpatialPolygonDataFrame containing data of a city boroughts. crashPoints: a SpatialPointsDataFrame containing ...
3k views

### Problems with NA values when reading .DEM file with R 'raster' package in Windows

I am trying to read a raster file in a .DEM format on windows using the 'raster' package in R. I get problems with NA values, when loading the data into R in Windows 7, but I do not have the problem ...
4k views

### Assigning RGB values from Geotiff image to LiDAR data, using R

I have given a Geotiff image and its corresponding Lidar data (x,y,z) in UTM coordinates. I need to merge the Lidar data with the RGB values from the image. That means, at the end, I need to plot (...
9k views

### Mosaicking rasters in R?

I am trying to mosaic several rasters into single big raster in R. Using script that posted in https://stackoverflow.com/questions/15287807/how-can-i-create-raster-mosaic-using-list-of-rasters But, I ...
627 views

### Create area buffers that are limited by a coastline

I'm trying to use ArcGIS 10.2 to create a buffer of points based on a pre-defined area (e.g 400 sq km). Further to that, the buffers of some of the points are close to the coastline that requires the ...
445 views

### Cleaning blocks pattern from urban LIDAR (blocks uplifted from streets)

We have a 1-meter LIDAR DEM from a city. A small subset can be downloaded from this link: This screenshot shows raw DEM with gray palette (darker belts are streets, and greyish and whitish ...
14k views

### How can I export raster data from Arcmap to an R *.grd file format?

I want to work with raster data in R, but I have problems exporting my raster dataset from ArcMap. By "export data"/GRID I get a file with an *.aux extension. What I need is *.grd. Can anybody help ...
7k views

### Snapping raster grids in R

I am trying to align two raster grids in R. Once aligned I would like to be able to add them together. I have tried to check whether making a stack would work: grid_snap <- stack(habi_sdw, ...
402 views

### Proximity in space and time

I have some point data which represent daily lat-lon locations of an animal, with an associated timestamp. I would like to identify all points where STATIONARY = TRUE. A point qualifies as being ...
8k views

### Calculate distance in km to nearest points (given in lat/long) using ArcGIS DEsktop and/or R?

I have two point datasets in ArcGIS, both of which are given in WGS84 lat/lon co-ordinates and the points are spread across the whole world. I would like to find the nearest point in Dataset A to each ...
2k views

### How to cluster points based on a kernel density?

I have a large dataset with 36k points representing commercial land uses, each with a field containing the square footage. I have run a kernel density analysis on this dataset, producing a raster ...
694 views

### Does Google Maps API provide statistical tools or even raster to vector conversion?

I am working with a web developer who is working with Google maps API, trying to determine what pre-processing steps I should perform (e.g. in R and GRASS), and what can be done within the google maps ...
1k views

### How to visualize azimuthal data with uncertainties?

I am trying to make a figure showing azimuthal data with a different range of uncertainties at each point. This oldschool figure from a 1991 paper captures the "bowtie plot" idea that I'm aiming for: ...
3k views

### Limiting memory that raster package uses in R?

What's the easiest way to limit the memory the raster package uses in R to 5GB of RAM? Ideally I want any raster that exceeds this size to be written to the hard drive and analysed from a temporary ...
1k views

### Help choosing most suitable bivariate choropleth mapping coloring scheme

I am trying to overlay a nominal variable (2 categories - rainfed vs irrigated) in a choropleth map over a numeric variable. In order to highlight the difference in pattern among the two categories, ...
701 views

### Preventing reflective surface in rasterVis?

I have been experimenting with digital terrain model files in ESRI ASCII grid raster format. Despite zero experience with this type of data I found it very easy to load into R, as per code below. The ...
4k views

### How to rasterize SpatialPolygons in R?

I'm trying to extract the bathymetry values of my area of interest from a world bathymetry raster layer using the 'rasterize' function in the {sp} package. *Edits: I found the 'extract' function ...
587 views

### How to find the buildings (polygons) a user can see from a given location (point) and orientation (angle range)?

I would like to retrieve the set of buildings I can see from a given location (point -lat,lng) and orientation (interval of angles) + certainly with a given depth (e.g. 100 meters). Ideally I would ...
780 views

### Remove sliver gaps between polygons with R

Is there a way to eliminate the small "slivers" between polygons using R? The desired solution would create a new SpatialPolygonsDataFrame where the shared boundaries between polygons are coincident. ...
943 views

### Interpreting semivariogram with high nugget effect?

I made a semivariogram in R using package gstat, variogram() function. I want to see if there is spatial autocorrelation in the residuals of my model (species abundance as a function of habitat, ...
328 views

### Georeferencing Museum specimens with poor locality descriptions

I am currently collating a list of specimens from databases of various natural history museums for further research. However, a well known issue associated with majority of historical data is the lack ...
4k views

### Identifying overlapping time intervals with two more criteria in R?

I have to check birds observations made over a longer period for duplicate/overlapping entries. Observers from different points (A,B,C) made observations and marked them on paper maps. Those lines ...
21k views

### How to produce spatial grid from raster?

I need a Spatial Grid as a master grid for diverse thematic maps. How do I produce a Spatial Grid from a raster discarding all NA pixels?
13k views

### Converting point to lat lon? [duplicate]

I have received a shapefile with measurement points to be analyzed, but no matter how I try, I can't find how to convert to lat lon. I suppose it would be good to know the projection but when I look ...