Questions tagged [r]

Statistical computing language and software environment.

Filter by
Sorted by
Tagged with
6
votes
2answers
2k views

rpy2 installation on Mac OSX. A still unresolved problem on StackExchange and rpy-list [closed]

following lgautier's advice on rpy2 installation on Mac OSX, I posted my request on rpy-list and got in touch with Yair Benita who said he could only install rpy2 through his default Mac OS X python ...
6
votes
1answer
2k views

How do I implement 'weighted' kriging in R? [closed]

I'm trying to interpolate the values of an attribute (called "disease_rate") that i've sampled at a set of spatial points and i'd like to add 'weights' to the resulting kriging estimates. Basically, ...
6
votes
1answer
1k views

Plotting data without geographical coordinates besides the main map in ggplot2

I am trying to plot some data as a bubble chart on the world map using ggplot2 package in R. I am able to proceed as follows. # Load necessay packages library(ggplot2) library(rworldmap) library(...
6
votes
1answer
381 views

Cell declustering using open-source software

I want to perform cell declustering in a small point data set. I have 9 observation points and I want to find the size of the region of influence for an observation, and afterwards use that as ...
6
votes
1answer
1k views

Competing approaches to line & polygon simplification

There seems to be a few theoretical options around at the moment for geometric simplification. Douglas–Peucker seems the most established, followed by Visvalingam's approach (used by d3.js). Now ...
6
votes
1answer
965 views

Performing cluster analysis in R with Point Datasets

I am a R-Beginner, but I want to use it for some spatial statistics. I want to check the relation between the occurrence of ill persons and the existence of water in a area of interest. To give you a ...
6
votes
1answer
3k views

Loading a png image as a map with ggplot2/ggmap

I am trying to find a workaround for ggmap's missing support of world maps (i.e. you can't create any maps that show latitudes > 80°, due to idiosyncrasies in the mapproj package). To a limited extend ...
6
votes
1answer
581 views

How to build Poisson autoregression model

I have a SpatialPolygonsDataFrame object in R with about 3000 polygons and associated data. I have columns of expected and observed cases. For the moment, I don't have any covariates. I'd like to ...
6
votes
0answers
216 views

Packing squares polygons in a raster grid

In the green area of the raster I have to fit as many square polygons as possible, of three different sizes: 3x3 cell size 2x2 cell size 1x1 cell size With the fact that the approach should be ...
6
votes
1answer
542 views

Cellular Automata Markov for forecast LULC in R software

I would like to forecast land use changes by implementing the Cellular Automata (CA) Markov Chain models in R software. I have the classified LULC maps from 3 times periods (1992,2003,2014), and also ...
6
votes
1answer
2k views

Clipping raster brick object in R

I have MODIS NDVI TIFF files for a year I want to first clip it with a irregular polygon (not by its extent only) of my study area and save it as a multi band raster in TIFF format The TIFF image are ...
6
votes
0answers
2k views

Using R to map matching GPS data? [closed]

I have many vehicles GPS data points, which consist of "timestamp, longitude, latitude, fuel consumption and distance" and the data is OSM(open street map) based. I want to match the data points to ...
6
votes
0answers
1k views

Python vs R for analzing spatial data [closed]

I am relatively new to both the python and R programming languages, having a small amount of exposure to both. Which language has the edge when working with spatial data and when would you use R over ...
6
votes
0answers
2k views

How to prevent cross-world lines in ggplot world map?

I'm having issues displaying 'great circles' paths and polygons in ggmap, an extension of ggplot2. Please enter the following code to replicate my issues: https://gist.github.com/Robinlovelace/...
6
votes
0answers
216 views

Resampling air temperature gridded data to sub-grid resolution [closed]

I'd like to obtain a 30-m resolution gridded dataset of air temperature from the ~1km gridded data of WorldClim, of Hijmans et al., 2005) for a mountainous region. The easiest procedure (I thought ...
6
votes
0answers
2k views

Using stat_density2d with coord_map in ggplot2 [closed]

In my example I am plotting a shapefile for all England & Wales, however I'm interested in the greater London area. If I allow ggplot to simply default and display the entire shapefile then the ...
6
votes
2answers
1k views

Create a 3D topographic map with locations marked on the map using R

I am currently trying to create an interactive 3D surface plot using plotly in R. My dataset includes a matrix of Latitude and Longitude and I have a DEM for the region I would like to make this ...
6
votes
1answer
389 views

extract() in R raster package slow with non-native format

I've noticed that running extract takes very different amounts of time depending on whether or not the raster is in memory, on disk in the Native format (.grd), or on disk in another format (e.g., ...
5
votes
5answers
7k views

Counting road intersections and blocks

I have a shp file that consists of the road system of Mexico City. I would like to count the number of road intersections (crossings) and blocks (which I would define as a segment starting from one ...
5
votes
3answers
7k 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 ...
5
votes
2answers
599 views

Splitting polygons at narrowest part using R?

I have a dataset of polygons like this one: I would like to split these polygons in separate parts at their most narrow location (if they have one). For example the two small polygons should not be ...
5
votes
2answers
5k views

What is the proj4string of the Lambert azimuthal equal-area projection?

Shapefiles of European data are available on the Eurostat website. I have loaded the NUTS_2013_60M_SH Shapefile in R with the command; europeRG <- readOGR(dsn = patheurope, layer = "...
5
votes
2answers
4k views

How to produce “SpatialPixelsDataFrame” from stacked RasterLayer?

How to produce "SpatialPixelsDataFrame" from staccked RasterLayer ? I have a stacked rasterlayer and I want to convert them to SpatialPixelsDataFrame. RasterLayer information is > RAD.all[[1]] ...
5
votes
4answers
6k views

Calculating percent cover from shapefiles

I normally do not work with shapefiles, so I am a bit lost here. I have two shapefiles each with multiple objects. The first is a set of 32 polygons (each one is a plot). The second shapefile has >10,...
5
votes
3answers
4k views

Converting SpatialLinesDataFrame to SpatialPointsDataFrame in R?

In R I have a SpatialLinesDataFrame (for example from a coastline shapefile) and I want to convert it to a SpatialPointsDataFrame. I want to keep all the vertices from the line shapefile to become ...
5
votes
2answers
2k views

Creating map layouts using R?

I've been trying to replace GIS tools (ArcGIS and QGIS) with R and some packages (leaflet, raster, sp and rasterVis) but I can't replicate GIS layout maps. Has anyone created layout maps using ...
5
votes
3answers
11k views

Convert shapefile with lists to data frame in R

I would like to ask some help for converting a shapefile to data frame. I downloaded data related to roads from Natural Earth. I imported the shapefile using shapefiles package like the following. ...
5
votes
1answer
2k views

How to use Igraph with leaflet for R?

I try to draw a graph in map with R code : df<-data.frame("from" = c("Lyon", "Toulouse", "Paris", "Marseille"), "to"= c("Paris", "Paris", "Marseille", "Toulouse")) meta <- data....
5
votes
2answers
824 views

Problem overlapping shapefile and raster in R?

I want to plot a shapefile over a raster file in R but I can't make them overlap perfectly: the raster appears to be rotated of few degrees counter-clockwise. Is it a problem with the projection? ...
5
votes
2answers
7k views

Visualizing Raster in R?

I have a dataset which I believe is generated for ArcGIS .It includes a .tif, .tfw, .tif.aux, .tif.ovr and a .tif.vat.dbf files. I want to view this in R like other users view it with ArcGIS. Is ...
5
votes
1answer
2k views

Create raster in R - distance to line feature

I have some line features (eg. 1000 meter isobath), and I would like to make a raster file for my study area where the value of each cell is the distance to the line feature. Any idea what function I ...
5
votes
2answers
5k views

Creating OUTSIDE_ONLY buffer around polygon using R?

I would like to create buffers in polygons, surrounding my original polygon. However, I want to keep only the "outside polygon", not include also original polygon. In Buffer in ArcGIS I can just set ...
5
votes
2answers
8k views

How to check my EPSG and units in R when it is not defined in proj4string?

After reading my .shp in R using readOGR(), I tried to figure out what is my EPSG and what are my units in my projections? when I tape my.shp = readOGR(dsn=setwd(dsn = dsn, my....
5
votes
4answers
398 views

Create a new GRASS database in R with CRS projection

How to create a new GRASS database in R with CRS projection? I am able to create a new one using the following code but it is not projected require(raster) require(spgrass6) initGRASS("/Applications/...
5
votes
2answers
3k views

Reclassifying raster stack based on condition and other layers using R?

I want to reclassify raster r1 in the following form: all the values that are larger than r2 to be 1 all the values that are less than r3 to be 0 all the rest of the values to be equal to r4 I ...
5
votes
2answers
757 views

Changing raster calculation values - shorten this script?

i'm doing something quite straightforward regarding raster algebra but am struggling either to find the correct function or make a function work correctly; Basically I have 2 rasters, representing ...
5
votes
3answers
1k views

Dissolving/Unifying Ill Behaved/Irregular Polygons in R

I'm working on a project involving bringing together multiple subjects circling difficult to find parts of an image. The output from users is pretty awesome. Cool, right? However, what I want is to ...
5
votes
2answers
3k views

How to iterate through features in a shapefile using R?

I am interested in iterating through a point shapefile to perform tasks on a point by point basis using R. In Python, this can be accomplished using the following workflow: import arcpy shp = r'C:\...
5
votes
1answer
2k views

How to select polygons by points in R?

I have a shapefile with polygons and another one with points. I would like to create a new shapefile with those polygons that don't contain any point inside. I tried the function sp::over in R and it ...
5
votes
1answer
5k views

Error “no method for coercing this S4 class to a vector”

I am trying to reproduce the example posted on Extracting intersection areas in R Although, when I try to create the SpatialPolygon "p2", R returns the error: "Error in as.vector(x) : no method for ...
5
votes
1answer
528 views

Verify if a lat-long fall in my route

I am using ggmap package to generate routes. The resulting data frame will contain the routes information from the given source to the destination. library(ggmap) route_df <- route(from = "...
5
votes
3answers
5k views

Randomly sampling points in R with minimum distance constraint?

I'm trying to randomly select a number of points within my data frame (example data below) with a constraint that the minimum distance between the selected point must be greater than a certain ...
5
votes
1answer
1k views

Extract points from regular data.frame with coordinates based on SpatialPolygonsDataFrame in R

I have a regular data.frame called datos.merged class(datosmerged) [1] "data.frame" The last two columns are the corresponding geographical coordinates datosmerged[1,c(23,24)] XCOORD ...
5
votes
4answers
2k views

Measuring distance between two points considering elevation raster?

Is it possible to compute the distance between 2 coordinates (x1,y1,z1) - (x2,y2,z2) considering an elevation raster (cells containing elevation)? On the image, there are 2 coordinates (red crosses). ...
5
votes
2answers
4k views

How to calculate distance from POINT to LINESTRING in R using `sf` library and get all POINT features from LINESTRING where distances were calculated?

I'm trying to calculate distances from a set of POINT features (1, 2, 3, 4, 5, 6 & 7) to a LINESTRING feature using sf library in R. I could calculate all the distances using the function ...
5
votes
2answers
835 views

Backtransformation of kriging predictions and variances

I'm not sure how to back-transform log-normal kriged results. This example using the "meuse" data shows how to make variogram and use it to get kriging predictions (and variances) using the popular '...
5
votes
1answer
4k views

Using a fixed palette range to plot an NDVI raster in R

I would like to plot an NDVI raster with rasterVis packages using the normalized colors from red to green. I don't understand how fix the color scale from 0 to 1 even if my raster value are between 0....
5
votes
2answers
935 views

Retrieving LiDAR metrics from relative vertical layers of point cloud?

I need to obtain the proportion of all returns within 5 equally spaced height bins between the cutoff (1 meter) and the maximum height value. I need to get this proportion of all returns for 1000 ...
5
votes
1answer
27k views

How to plot certain values of a column in R?

Lets say we have a shapefile of cities with a column called category cities@data category A B A C A A B C How can i plot the A category only etc? Tried c<-cities$category[A] plot(...
5
votes
3answers
3k views

Save and load maps for ggmap to use without internet access

I would like to use the ggmap package to download and display maps. Unfortunately I have some firewall restrictions preventing R from accessing the internet directly. The error I get from get_map is ...