Questions tagged [r]

Statistical computing language and software environment.

Filter by
Sorted by
Tagged with
7
votes
1answer
9k views

ggmap: create circle symbol where radius represents distance (miles or km)

I am trying to add a circle around a given latitude and longitude point where the circle size (radius) reflects distance in miles or km. I managed to come up with this example using ggmap, where I ...
7
votes
1answer
6k views

Units of gBuffer from rgeos package

I have this polygon: library(maptools); library(sp) setwd(system.file("shapes", package="maptools")) columbus <- readShapeSpatial("columbus.shp") proj4string(columbus) <- CRS("+proj=longlat +...
7
votes
1answer
1k views

r - create multipolygon from overlapping polygons using sf package

I'm trying to remove overlapping areas from multiple polygons using sf like the following: # sample polygon poly <- data.frame( lon = c(0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 2, 2, 0.8, 1, 1, 2, ...
7
votes
4answers
2k views

How to speed up raster to polygon conversion in R?

I've decided to process my Landsat data in R instead or ArcGIS - due to my missing knowledge of python and and because of (assumed) high computation capacities of R. I want to : import r1 raster to R,...
7
votes
2answers
2k views

Interpolating Maps - Statistical Learning Techniques vs Spatial Statistics Techniques

I have recently begun experimenting with the interpolation of variales over a whole country. I have good sized training set where I have several dependant variables (continuous and categorical) ...
7
votes
1answer
645 views

Understanding the values from transition layers produced by the R package `gdistance`

Background and Aim I would like to create a cumulative raster representing walking time across a surface. For my purposes, the cost to be accumulated has to be the walking time as influenced by ...
7
votes
2answers
309 views

Walking route that covers the largest area in shortest distance

I regularly need to walk across field searching for bird nests. The field are often squares or polygons and the bird nests could be anywhere on the ground in the field. To stand the best chance of ...
7
votes
1answer
1k views

How to speed up extract(rstr,shp) ? - R

I am trying to create a function that takes in a shapefile and a binary (1's and 0's) raster, with the same extent, and extracts the values from the raster. Once this occurs I desire to sum up those ...
7
votes
2answers
466 views

Is there an open-source equivalent of ArcGIS “Zonal Statistics as Table” tool?

With ArcGIS zonal statistics as a table I can easily calculate the mean value from a raster contained within a polygon from a shapefile. I now have a Mac, and therefore I cannot access ArcGIS anymore. ...
7
votes
3answers
3k views

R raster predict using lm() time series

I try to make a prediction in raster using linear regression based on past rasters but I can not capture the lm() model in order to feed it to predict(). # # calculate regression in a raster stack (...
7
votes
2answers
3k 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 ...
7
votes
2answers
8k views

How to intersect lines and polygons in R?

Following on from an answer about intersecting polygons with lines to chop up a polygon into smaller polygon units (in QGIS), I wanted to try the same thing in R. However, I cannot seem to find a ...
7
votes
1answer
1k views

Spatial outliers detection in R?

What is the best way to detect spatial outliers in R? With spatial outlier detection I mean: Discover the objects whose non-spatial attribute values are significantly different from the values of ...
7
votes
1answer
6k views

Spearman correlation between two rasters in R [closed]

I have two rasters of the same area. The only difference is that they were created using two different methods. I would like to compare them and see how correlated they are pixel by pixel. Any ideas ...
7
votes
2answers
5k views

how to display simple arrow on the map in R using Leaflet

I try to display an arrow on the map using R and the leaflet package, code of map see my related question: # install packages install.packages(c("rgdal", "maptools", "leaflet", "htmlwidgets"), ...
7
votes
1answer
3k views

Loading a multipoint shapefile in R

This issue has only been raised in the community once, two years ago, to the best of my knowledge. I think it's high time to raise the issue again! readOGR, from the rgdal package, cannot handle ...
7
votes
1answer
2k views

Legend of a raster map with categorical data

I would like to plot a raster containing 4 different values (1) with a categorical text legend describing the categories such as 2 but with colour boxes. I've tried using legend such as : legend( 1,-...
7
votes
3answers
620 views

How to compare spatial patterns (crime cases vs population)?

I am looking for a way to statistically compare two spatial patterns in shape polygon data (not point pattern analysis). Let's say I have a city map divided in neighborhoods (barrios), in shape ...
7
votes
1answer
343 views

Open source implementation of “feature density” algorithm

I'm working on a dataset of house searches - 1 polygon for each area in which people want to find a house from an online search tool. This produces many overlapping polygons. It would be great to ...
7
votes
1answer
614 views

How do I tile raster input to speed up display in R Shiny programs?

Disclaimer: I have very little GIS experience I've been working on a project in R that involves displaying large raster maps in an R Shiny interface. I am using the leaflet package for display. The ...
7
votes
1answer
3k views

Generate rectangular fishnet or vector (grid cells) shapefile in R?

I would like to create a polygon of 20 x 10 degree graticules from 180, -180 to 90, -90 degrees. To do this in QGIS, I followed: Vector creation tools > Create grid [Grid extent: -180, 180, -90, 90]...
7
votes
1answer
1k views

Is it possible to use a raster::click event within an interactive leaflet map?

Data Download: https://www.dropbox.com/s/f849ra8l6umo9d8/crops.tif?dl=0 I have various raster images of the world that I would ultimately like to plot within an interactive leaflet map; an example is ...
7
votes
1answer
221 views

Categorising Point Clusters

I have a point dataset of solar farm locations. The points are grouped according to which substation they feed into (see below). I would like to test the hypothesis that electrical output ...
7
votes
1answer
359 views

Interpolating points observed with different time duration

I am doing spatial interpolation with a group of points. Some points have complete observation of events: for a period of 24 hours we have observed N events in each point. These points have N events....
7
votes
1answer
796 views

Weighted zonal statistics in Python and/or R [closed]

I have raster files with precipitation data (4x4 km), monthly, for about 100 years. I have a shapefile for a watershed (which includes several polygons as sub-basins). I need the average precipitation ...
7
votes
1answer
546 views

How to make a wedge shapefile in R?

I'm quite okay at R programming, but fairly new in GIS (especially in R). I have a set of coordinates and I'd like to create a custom shape around them. What I want to do step-by-step: Create a ...
7
votes
0answers
786 views

Efficiently calculate distance between raster patch edges

I have a binary raster which I've classified into patches using raster::clump. I now want to efficiently calculate the edge-to-edge, i.e. minimum, pairwise distance between patches. I am currently ...
7
votes
1answer
654 views

How can I conduct Geographically Weighted Analysis using an exponential decay function?

I have some points (representing 30 study sites) and I want to calculate the weighted mean of several variables (landscape layers) using a negative exponential decay (weights function) to give more ...
6
votes
3answers
1k views

Waypoints with coordinates in R

I have a SpatialLineDataFrame with 20 observations of 4 variables (in WGS84). I want to create waypoints every 10 meters. Every waypoint will has the x y coordinates. I tried to do it manually like: ...
6
votes
2answers
1k views

Plot tilted map in R

I would like to plot a tilted map, similar to the image below. I would prefer to do this using ggplot2 but I'm glad if there is a solution using base R. Any ideas on how to do this? Here is a dataset ...
6
votes
2answers
2k views

Use GRASS through R

I want to use GRASS GIS 7 through R 3.1.3 in kubuntu operational system. Could someone help me connect GRASS with R, and use GRASS commands through R (not the other way round!).
6
votes
4answers
4k views

Create interactive maps in R

I am a R user and quite new in GIS. From Adding Attribute data to shapefile? I know how to add/edit attribute data (say population) to shapefile using R. Now, I have some shapefiles with attribute ...
6
votes
2answers
3k views

Calculating Shannon's diversity using moving window in R

I have a raster where each pixel is a particular vegetation type. I'm interested in the diversity of vegetation types around each pixel. I'd like to assign a Shannon's diversity index value (see ...
6
votes
2answers
4k views

Mean by month on R stacked raster

I work with MODIS NDVI rasters in 2016. I have 23 rasters stacked in one object. I have 2 raster by month. I would like the average by months and conserve a raster for each month. ndvi.stack <- ...
6
votes
2answers
15k views

Interpreting Moran's I results

I have a sample of data taken from regions of a country! i want to test if there are any spatial autocorrelation on my data using Moran Indice test. the null hypothesis: is that there is no spatial ...
6
votes
2answers
357 views

Finding lines in point patterns?

I have a point pattern (see below) in which I assume to find "significant" lines of points. However, I did not find any method that is integrated in a GIS or in R that searches for such line pattern ...
6
votes
3answers
2k views

Classifying point coordinates to countries or continents?

I have about 50 000 points (latitude and longitude), and I would like to find out in which country each of the points is located. It does not need to be super precise, though. (Or actually I only ...
6
votes
2answers
5k views

R: overlay a line on a raster stack/brick, and get profile of cell values along the line

I've combed through R's raster functions and vignettes and can't seem to get this working. I want to specify a line/vector across a raster stack (a DEM and possibly related variables), and get a ...
6
votes
1answer
4k views

How to find the cell location index of a raster using Lat long information?

I have a raster for which I want to find the Cell Location (Row, Col) if I have the Lat-long information. I know how to get the value of a particular cell using lat long. extract(ras,SpatialPoints(...
6
votes
2answers
14k views

How are kappa and overall accuracy related with respect to thematic raster data?

I recently calculated kappa (using confusionMatrix{caret} in R) between a thematic raster dataset at 1m spatial resolution and another at 30m spatial resolution. I was interested in quantifying the ...
6
votes
2answers
7k views

Converting NZMG (or NZTM) to latitude / longitude for use with R map library

I am a statistician with no background in GIS so apologies for the newbie question. We routinely use R for a range of statistical and graphic analysis and are interested in using its map library to ...
6
votes
2answers
2k views

Efficient spatial joining for large dataset in R

I am working with rather large data frames that I often need to do a spatial join on. The fastest way I have come up with so far is this method: library(rgdal) download.file("http://gis.ices.dk/...
6
votes
1answer
2k views

R giving error when attempting map algebra

I'm trying to manipulate some downloaded rasters using R, and keep getting the same error when I try to do any type of map algebra. The example below uses a raster file downloaded from http://www.csc....
6
votes
1answer
772 views

Strange output from RSAGA topographic wetness index? [duplicate]

I am trying to generate a topographic wetness index raster with the RSAGA package in R. The output I am able to generate does not make sense to me, as it has a large number of NA cells and I wonder if ...
6
votes
1answer
2k views

Ripley's K function in QGIS Chugiak 2.4

I need to apply the Ripley's K-function on a point pattern in QGIS 2.4 Chugiak, but I don't know how to do. I think I need to use some plugin or extension (maybe GRASS, R or something), but I haven't ...
6
votes
4answers
5k views

In R, set NA cells in one raster where another raster has values

I have two rasters in R. I want to set values to NA in the first raster where the second raster has values. I think this should be simple, using the raster package, with two RasterLayer objects ...
6
votes
2answers
3k views

What is the equivalent of arcpy “Con” in QGIS and/or R raster-package?

I'm looking for an equivalent of the conditional expression "Con" from arcpy in an open source spatial analysis package. I'd prefer to use QGIS or R. To provide some additional detail, I need to ...
6
votes
1answer
5k views

Zonal Statistics for Polygons with R

I'd like to do zonal statistics / terrain analysis with polygon overlays - I achieved to get min / max like so: library(raster) library(rgdal) alt <- getData('alt', country = "AT") gadm <- ...
6
votes
1answer
178 views

What does shading indicate in home range plot?

I've simulated a home range in R using the clusthr function from the adehabitatHR package. The home range is made from 50 x,y coordinates. The output is attached. I'm trying to get clear on what ...
6
votes
1answer
4k views

GIS, R and shapefiles

I have some data that encodes locations in certain countries, such as the US and China, that I would like to map. The data includes location name in Latin, extended Latin and other scripts (Japanese, ...