Questions tagged [r]

Statistical computing language and software environment.

628 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10
votes
1answer
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 ...
7
votes
0answers
742 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 ...
6
votes
0answers
207 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
473 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
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/...
5
votes
0answers
372 views

Correctly handling climate projection data with R

EDIT: An example setup can be found here: The main file is extract_cordex.R I need to analyze climate data as part of my thesis, however I am not particularly trained in working with climate data and ...
5
votes
0answers
521 views

How to interpolate within defined boundaries of a deformed mesh using R?

My goal is to create an interpolation map of some output model results that are mapped on a deformed mesh (from a numerical simulation). The model results are in an x-y plane (representing coordinates)...
5
votes
0answers
408 views

Can extracting raster values work in polygons' CRS without raster resampling?

I am trying to extract raster values using polygon layer with different CRS. Raster is in WGS84 (EPSG:4326) and the polygons in UTM (EPSG:23031). 1. If I want to work in the projection of the ...
5
votes
1answer
138 views

Cokriging: zero distance cross-semivariance in undersampled cases [gstat error]

Trying to cokrige two variables that are not perfectly colocated (one has sparser measurements than the other), I faced an issue that I'll illustrate with the following MRE. With the meuse dataset, ...
4
votes
2answers
68 views

Calculate the travel time from locations to the closest N points

I want to calculate the travel time (based on walking time) from locations to the closest N points of another dataset. Then I want to create a hull around those N closest points per location Is this ...
4
votes
0answers
42 views

Quantifying similarity between two independent areas?

I'm assessing areas for suitability for species relocations, so essentially I'm looking to quantify how similar a possible relocation site is to a source site in several metrics. The species may ...
4
votes
1answer
97 views

Calculating accumulated walking pace from starting location outwards using R?

Goal In R, I would like to calculate an accumulated cost surface around a starting location, with the cost representing the time (say, hours) to walk from the location outwards in all directions (say,...
4
votes
0answers
933 views

Fastest way to union a set of polygons in R

I want to find the fastest way to union a set of polygons into one large polygon. Lets first get some data: # Load libraries library('raster') library('geosphere') library('mapview') library(...
4
votes
0answers
469 views

Determining areas on a Voronoi Diagram around a point

I currently have two data sets concerning the Netherlands, one containing longitudes and latitudes of population cores (Hubs) along with other information, such as average house price, and the other ...
4
votes
1answer
461 views

commuteDistance in gdistance package in R giving error

I am currently trying to run a function that "calculates the expected random-walk commute time between nodes in a graph. It is defined as the effective distance (resistance distance) between the ...
4
votes
0answers
1k views

Clustering of events within a space-time window (R)

I am relatively new to clustering methods and am trying to determine the best method for clustering (or merely grouping) events that fall within a space-time window using preferably R. My goal is to ...
4
votes
1answer
347 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., ...
4
votes
0answers
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 ...
4
votes
0answers
866 views

Crop raster based on another raster R

library(raster) How can one clip one raster based on another raster? RasA: class : RasterLayer dimensions : 459, 533, 244647 (nrow, ncol, ncell) resolution : 10000, 10000 (x, y) extent ...
4
votes
0answers
505 views

Spatial weight matrix with boundary effects in R?

I need some help to finalize code for a spatial weight matrix that uses a nearest neighbor definition within regions, but does not allow neighbors from across a political border. For example, ...
4
votes
0answers
1k views

How to avoid “Unable to compute a transformation between pixel/line”?

I am trying to re-project from Equi-rectangular to the NASA global EASE grid (Equal Area Scalable Earth) grid 1383 586 with a ~25 km cylindrical projection (ESPG=3410). The file is provided as HDF5. ...
4
votes
0answers
214 views

How to set m parameter of clusterR function in R?

I want to manage a clustered computation on raster and thus use the "clusterR" function in R (package 'raster'). However, there's a tuning m parameter to set, but the only explanation about this ...
4
votes
1answer
368 views

Plotting Bare Soil Line on landsat data in RStudio?

I am using RStudio with landsat package for computing and plotting the Bare Soil Line (BSL) on landsat tif image running on my HP Pavilion i7 laptop. The codes for running the BSL() function is as ...
4
votes
0answers
1k views

Fortifying re-projected shapefile for ggplot2 in R

I have a shapefile of US county boundaries which I got from the NHGIS. I can load the file using the rgdal package and see information about it: library(rgdal) shp_1860 <- readOGR("shp", "...
3
votes
0answers
46 views

Test the relationship between two point patterns

I have two point patterns obtained from medical images. Points are used to represent cell markers. By visualization, the point pattern A is extremely possible to be a subset of point pattern B. So is ...
3
votes
0answers
40 views

Split a tmap legend and display in two locations

I would like to split the legend of a tmap object, so that one of the two elements is in the top left, and one in the top right. I have been through the documentation of tm_legend, but could not find ...
3
votes
0answers
57 views

Create foldable section in QGIS tool using R script

I am developping a GUI tool in QGIS using an R script and I am wondering how to add this kind of foldable section in the graphical interface.
3
votes
1answer
64 views

gIntersection error: linearRing not created

I am trying to do something relatively simple but with large shapefiles. I have a shapefile of protected areas in the USA: and watershed boundaries: I want to calculate the percentage and ...
3
votes
0answers
41 views

Calculate the length of shared boundaries between multiple polygons

I am trying to calculate the length of shared boundaries between multiple polygons in R. Specifically, I would like to calculate the shared boundary length of all the polygons in Census Place GIS data ...
3
votes
0answers
392 views

Selecting and deselecting markers in leaflet under R shiny?

I would like to write a script that selects a marker on the map whenever I click on it and then deselect it when I click/select another marker (that is, so that no more that one marker is selected on ...
3
votes
0answers
143 views

Difference in area calculation between QGIS and R

I used R to calculate the area of every land polygon of the world (Projection of the source shapefile: WGS84; CRS: EPGS: 4326). To do that, I loaded the required packages ("sp" and "raster") and I ...
3
votes
0answers
36 views

smearing in Linux, but not in Windows

I must have a Linux library out of wack since the following image has "smears" on the colors. Is there a better term? On my Windows 7 RStudio it works fine. this image is from a Ubuntu 16.04 LTS ...
3
votes
1answer
228 views

Error in fit.variogram.gls method of gstat package in R

I was trying to fit the variogram parameters of an empirical variogram using GLS (Generalized Least Squares) fitting method. I used the 'fit.variogram.gls' method of the 'gstat' package in R. I tried ...
3
votes
0answers
441 views

Leaflet map in R Markdown - not rendering when placed after other plots

I have an R markdown document using shiny with 6 or 7 plots. They all display until the 7th plot, which is a leaflet map, which doesn't display - when I 'run document' there is a big empty space at ...
3
votes
0answers
250 views

Dealing with duplicate locations kriging - a method for replacing with a single location taking the mean of the duplicates? (R)

I understand that the existence of duplicate points (locations) when Kriging will result in a singular covariance matrix. The only way I've encountered people dealing with this is to keep the first of ...
3
votes
0answers
505 views

Using Random Forest for big data?

I used Random Forest regression for my work, but now I have another problem because I have really big data. I am using a VHR and this is much raster information. My script in R is this: rand.zero <...
3
votes
0answers
75 views

Using euclidian distances as spacing for regular points grid in QGIS?

As a means of checking spatial autocorrelation in the selection of training samples for image classification, I am trying out semivariance analysis. I have managed to generate variograms from image ...
3
votes
0answers
726 views

Create a new NetCDF file combining information from two other NetCDF files in R

I wish to combine the "t" variable from the second .nc file, and use the lat, lon variables from the first .nc file as the lat and lon of the t variable, and store them to a new .nc file, that will ...
3
votes
0answers
414 views

ogr2ogr{gdalUtils} correct syntax to set Ground Control Points for vector georeferencing

I would like to know correct syntax of R {gdalUtils} package (version 2.0.1.7) to georeference Shapefiles using corner points as GCPs. (These Shapefiles have y=height and x=width information, without ...
3
votes
0answers
84 views

Data structure for analysis of relationship between rainfall and vegetation indices?

I have several hundred raster files (NDVI) of the same area dating back to the 1980’s, as well as daily rainfall observations from a nearby weather-station over the same period. The raster files are ...
3
votes
0answers
637 views

Failed to create a raster-brick from a netCDF file (.nc)

I am trying to build a raster-brick from a netCDF file (network Common Data Form) leave this link for more information () but to make a brick (which is part of the package raster) throws me the ...
3
votes
0answers
281 views

Keys for merging US state/county ANSI's with GADM Unique identifiers?

I've got county-level data from USDA NASS, and I want to merge it with gridded climate data. A preliminary step is the associate the counties with the coordinates of their centroids. If I merge by ...
3
votes
0answers
424 views

Doing spatial regression using big data when Spatial weight matrix is too large for R?

I am currently doing an analysis on a quite huge data set - 250,000 polygons. I have figured out the general Moran's I for a linear model, but when I was trying to do a spatial lag or spatial error ...
3
votes
1answer
854 views

How to Construct Spatio Temporal Clusters of Time Series Data in R

I have count data of one disease for various districts of a state of India on monthly basis. Is it possible to draw spatio temporal clusters in R? I have checked some R- packages for example ...
3
votes
0answers
389 views

Interpreting Global Moran's I and should I krig?

I am trying to weigh up if kriging (or cokriging) the residual error from my model is a valid approach. My first step was to compute whether the error is spatially autocorrelated. I have done this ...
3
votes
0answers
333 views

How to run GAM with raster package?

When I am using the raster package to predict a surface probability map of species distribution using the following functions in R, the following error occurrs: CA132122200=raster("F:/CBG maps-UnProj/...
3
votes
0answers
510 views

How to calculate 90% confidence interval in a raster stack

I have a stack of grid files (23) in ASC format from a MODIS sensor and I need to calculate a 90% confidence interval, mean, min, etc, for each one in R, how can I do that? specially the interval. #...
3
votes
0answers
345 views

R: Can raster predict function pass to predict.rfsrc (a prediction function in a parallel verion of RandomForest)?

It seems that raster predict function can pass to predict.randomForest by setting the "type='response'". I am using a parallel version of randomForest package called the "randomForestSRC" and I am ...
3
votes
0answers
234 views

R - how to create a pre-determined number of identical square polygons to use for a choropleth map?

I am trying to plot crime data density (again!) over a city map, say of NY. As a well known problem there are plenty of examples on this (http://www.obscureanalytics.com/2012/12/07/visualizing-...
3
votes
0answers
838 views

Decision tree classifying of satellite image in R?

I want to classify satellite image in R using RWeka classifier, J48. I have a CSV file with the classes required, and raster data loaded in R. I am able to make the tree, however, I am not able to use ...