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.

8
votes
1answer
1k views

Writing multiple layers to GeoPackage using writeOGR() in R?

I'm trying to write multiple layers to the same GeoPackage in R, but I get an error, Creation of output file failed. I have tried to search for documentation of reading and writing to .gpkg files with ...
8
votes
1answer
3k views

Generating grid shapefile in R?

I have the following shapefile of a 10x10 degree latitude/longitude grid that I created in QGIS. I can read it into R using the rgdal package. Grid<-readOGR(".","GridShapeFile") It has the ...
8
votes
1answer
6k views

How to Export a Shapefile as KML Using R

All, I have exported an ESRI shapefile (polygon) to KML using R, but the resulting layer shows only the outer extent of the polygon. How can I fill in the area with a color? Any help is greatly ...
8
votes
1answer
861 views

Euclidean and Geodesic Buffering in R

In Understanding Geodesic Buffering, The Esri Geoprocessing Development Team distinguish between Euclidean and Geodesic Buffering. They conclude with "Euclidean buffering performed on projected ...
8
votes
1answer
5k views

Remove certain polygon from SpatialPolygonDataFrame

I am using R maptools library to parse the shapefile into a list of polygons. The function readShapeSpatial shp <- readShapeSpatial("<path to my shapefile>") gives me a ...
8
votes
3answers
328 views

spatial and spatiotemporal analyses

I have a dataset that consists of 247 mosquito traps placed in fixed positions and sampled weekly for 23 weeks. I also have dengue disease incidence data (indexed to home address) during the same time ...
8
votes
3answers
1k views

Calculating spatial lags per year in R

At the moment I am having some difficulties with calculating a spatial lag in R. I know how to calculate the lag in space-wide format but am unable to do it in long form, i.e. have repeated ...
8
votes
2answers
2k views

How do I call external files in Python Geoprocessing Service?

I have created a Python script which calls an R script and then reads the output back into Python. I can run this tool in ArcGIS Desktop (10.2.1) and it works fine. When I publish as a geoprocessing ...
8
votes
1answer
90 views

Visualising most likely direction of migration given points with ages using R?

I have a question about how best to visualise the predicted direction of migration given a set of points with estimated ages. Imagine I have a set of geo coordinates, representing communities. For ...
8
votes
1answer
799 views

How to get rpy2 for QGIS on OSX?

I am a new QGIS user, have installed QGIS on a Mac running Snow Leopard OSX 10.6.8 following all the instructions. QGIS seems to work well for everything other than when I boot up I get the message "...
7
votes
2answers
6k views

How to calculate area of 1 x 1 degree cells in a raster

I have a simple array (not geo-referenced in any way) in Matlab (which is not a language I know a huge amount about...so I can export it to other languages if needed) which has the dimensions 180 x ...
7
votes
3answers
1k views

Atmospheric correction algorithm in Python or R for Landsat 7 ETM+

I am looking for an algorithm which can be tuned in python or R for atmospheric correction for Landsat 7 ETM. Searching Google I have found only a few algorithms in ENVI or ERDAS which are not ...
7
votes
3answers
480 views

Best way to make a fake hillslope?

Anyone ever have to make a fake hill slope? or a fake digital elevation model (DEM)? What are the best methods for doing so? For more specifics, suppose I wanted to make a fake hill slope, that was ...
7
votes
3answers
9k views

Leaflet output is grey

I would like to implement leaflet in shiny with R. I try to go with the simple examples I found online: library(leaflet) library(ggmap) somePlace <- ggmap::geocode("Vienna") # Information from ...
7
votes
2answers
3k views

Transforming geostationary satellite image to lon/lat

The ICARE Data and Services Center distributes the SEV_AERUS-AEROSOL-D3 product in HDF5 format (http://www.icare.univ-lille1.fr/archive/?dir=GEO/MSG+0000/SEV_AERUS-AEROSOL-D3.v1.03/). The main ...
7
votes
2answers
3k views

Creating a raster of the residuals of a regression between two rasters

I am trying to create a raster of the residuals of a regression between two rasters. i.e. I would like to carry out a regression of one raster against another of the same extent and plot the residual ...
7
votes
1answer
8k views

Plotting map resulted from kriging in R

I want to plot a map weighted by prices. I got a data frame of latitudes, longitudes and prices: > str(data) 'data.frame': 1253 obs. of 3 variables: $ lon : num 11.2 11.1 11 11 11.3 ... $ ...
7
votes
1answer
9k views

Replace NA's with 0 for raster data using R?

I am new in R. How can I replace NA's with 0 for my raster data which have spatial information?
7
votes
2answers
3k views

Strange spatial interpolation results from ordinary kriging

I'm using Ordinary Kriging to interpolate a set of spatial data. I'm working on different sets which represent different days of measurement. I get good results, apart from one specific set. Will post ...
7
votes
3answers
3k views

Per-pixel (statistical) calculations on a raster stack using GDAL

In R, it's relatively trivial to perform per pixel calculations based on a raster stack (e.g., get std.dev for each pixel on a 12 layer GeoTIFF). Unfortunately, the speed is less than desirable when ...
7
votes
2answers
184 views

Calculating block statistics from land cover raster using R?

I have a raster (5 x 5 m resolution) representing land cover. Each cell contains a integer value (from 1 to 10) representing a total of ten land cover classes (e.g. 1-forest; 2-agricultural areas; 3-...
7
votes
1answer
8k views

How to create a continuous scale with distinct/custom color and value breaks with ggplot2 map

As stated in the title, I'm trying to create a continuous scale with distinct color and value breaks within the ggplot2 package in R. I'm using some dummy code to illustrate my problem: library(...
7
votes
6answers
3k views

Estimating river Channel Width using Python/ArcGIS/MATLAB/R?

I am trying to estimate the river channel width from digitized polygon or poly-lines shapefiles. To do so, I converted poly-line shape files to points.shp at regular intervals (at 1 cm). Later, I ...
7
votes
2answers
5k views

R function for Thiessen Polygons

For a point data set with temperature data I have, I want to create their Thiessen Polygons in R. So far, the only algorithm I have found is that of Carson Farmer (http://carsonfarmer.com/2009/09/...
7
votes
2answers
1k views

Is it possible to run an R script on a layer in QGIS?

I'd like to run an R script on a layer loaded in QGIS (to rotate a set of points created there using the Vector:Research Tools:Regular Points tool). I thought ManageR might work but cannot get it ...
7
votes
2answers
4k views

Alternatives of spTransform?

Let's say that we have a shapefile with a certain projection. s<-readOGR(dsn=".",layer="Spain") We also have the airports of Spain as points in another projection. a<-readOGR(dsn=".",layer="...
7
votes
1answer
3k views

R raster Package Moran's I interpretation

I am using raster package to calculate the local Moran's I . The example gives the range of Moran's I between - 1 to 2.47. On my own data I have see the value range -3.070423 - 7.228558 How can Moran'...
7
votes
3answers
4k views

R - How to sampleRandom() from large raster without NA values

I have a number of vary large rasters which need to be randomly sampled with the return value being a matrix of x, y, and value. The raster package sampleRandom(raster,n, na.rm=TRUE, xy=TRUE) will do ...
7
votes
2answers
773 views

Robust Zonal stats in R and QGIS

Comparing results of zonal statistics in QGIS and R, I noticed that the results they both yield do somehow differ. Manually checking, I also found that both QGIS and R seem to partly produce erroneous ...
7
votes
1answer
6k views

Create a circle of defined radius around a point and then find the overlapping area on a shapefile

My use case is related to calculating the area of a polygon in a shapefile that is covered by another polygon. Specifically, I want to do the following: Create circles that have a 100m radius, from ...
7
votes
1answer
5k views

How to obtain openstreet API key for nominatim (r)?

I wanted to use r package nominatim for my program written in R. I tried to run very simple example osm_search('Cracow University of Economics'), however I got the following error: Please provide a ...
7
votes
3answers
5k views

How to get count of non-NA raster cells within polygon using R

I've been running into all sorts of issues using ArcGIS ZonalStats and thought R could be a great way. Saying that I'm fairly new to R, but got a coding background. The situation is that I have ...
7
votes
1answer
6k views

Finding clusters of points based distance rule using R? [duplicate]

I have some points that I need to divide into groups based on clusters of points: x <- c(-1.482156, -1.482318, -1.482129, -1.482880, -1.485735, -1.485770, -1.485913, -1.484275, -1.485866) y <- ...
7
votes
3answers
2k views

Kriging with barriers in R?

I wonder if there is a way to interpolate xyz points in a raster within certain bounds using R? In ArcGIS this is called interpolation with barriers. I wonder if there is something similar in R? I ...
7
votes
1answer
4k views

How to assign colors to specific raster values using R

I am using the levelplot function of the awesome rasterVis package to create a map whose values diverge around zero. I am plotting a raster file using a red to blue palette, but I am trying to assign ...
7
votes
1answer
2k views

Difference between raster() and readGDAL()?

I am new in working with rasters and after having trouble working with them i'd like to know the difference between those two import functions. for example i did this library(raster) s<-...
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
918 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
2answers
4k views

Open JPEG2000 (Sentinel 2) in R

Is there any way I can open Sentinel 2 JPEG2000 file (.jp2) using R? Or more specifically with the {raster} package in R? I keep getting the Error message that .jp2 is: not recognised as a ...
7
votes
4answers
1k 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
1answer
2k views

Novel ways of filling in missing values in a raster

I am looking for robust ways to fill in missing values in some rasters. They all have a single layer. Missing values consist of single pixels to medium sized patches. Rasters are around 1000 x 1000 ...
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
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
431 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
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 ...
7
votes
2answers
7k 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
436 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
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
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,-...