Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [r]

Statistical computing language and software environment.

668 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
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 ...
6
votes
0answers
213 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
534 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

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
1answer
381 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
0answers
426 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
1answer
512 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 ...
5
votes
0answers
545 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
435 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
160 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
89 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
49 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
131 views

Using R-scripts in QGIS 3.4

I installed the Plugin, and activated R in the provider options. When I go to the processing toolbox R is available, but I don't have the use online R-scripts, which are mentioned in the documentation....
4
votes
1answer
102 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
1k 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
498 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
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
703 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 ...
4
votes
0answers
921 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
525 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
225 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
374 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
47 views

Variogram fit won't converge

I am having some difficulty fitting a variogram to the data provided at the end of this post. For context, this is baseball data where the x and z coordinates are for the location of the pitch and the ...
3
votes
2answers
27 views

Switch between ArcGIS and R changes my shapefile projection?

Not the best practice, but somethimes I need to change between ArcGIS 10.6 and R (version 3.6.1) to process my shapefiles. For example, I want to read my shapefile in R -> process it -> export it back ...
3
votes
0answers
25 views

Circular focal means with raster and NAs

I am trying to understand circular focal means using rasters having NA values. I made a couple of scenarios to better understand how to combine weight matrices and functions to summarize values. I am ...
3
votes
0answers
54 views

R raster / rasterize creating GeoTIFF with Null Value “grid lines”

I am attempting the seemingly simple task of converting a .csv with lat, lon and population values into a .tif (raster). Here's my R code: geoName <- read.csv("/pathToData/geoName.csv") ...
3
votes
0answers
40 views

Standard for publication-ready R-based geographic images?

I've been using the ggmap package to create figures that will go in journal articles for many years. These maps are a little harder to create than Leaflet maps, and as OpenStreetMap and Google have ...
3
votes
2answers
64 views

Can BFAST algorithm be applied to to a whole study area/ ROI?

I am working on identification of breakpoints in Landsat based NDVI time series (1990-2018). I am using The Breaks for Additive Seasonal and Trend (BFAST) algorithm which is a pixel based time series ...
3
votes
1answer
42 views

Multiple conditional statements for raster calculation in R

In the context of a RUSLE erosion modelling I would like to calculate the sum of precipitation at the entry date of phenological phases. Suppose I have 13 grids, one of which is the phenophase entry ...
3
votes
0answers
51 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
75 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
59 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
103 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
76 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
489 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
2answers
415 views

Handling raster data in a “rotated pole projection” with R?

My question is about using R to transform raster data from a rotated pole projection to a regular latlon grid - and then plotting it. I am working with data from a numerical weather model, which is ...
3
votes
0answers
456 views

Sentinel 2 preprocessing with R

I need to transform Sentinel 2 L1C imagery to preprocessed Level 2A data. Ideally this should happen in R, as the remaining processing stack is already done in R. Are there ready preprocessing ...
3
votes
0answers
155 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
214 views

Creating Adjacency Matrix using SpatialLinesDataFrame and SpatialPointsDataFrame in R?

I am trying to create an adjacency matrix of power plants that are connected via power lines. The plant data is point data (~8000 observations) with longitude and latitude measurements. The line data ...
3
votes
1answer
1k views

Efficiently process large rasters

I am trying to process some raster layers from Global Forest Change (https://earthenginepartners.appspot.com/science-2013-global-forest/download_v1.4.html, data produced by Hansen et al., 2013). ...
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
249 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
490 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
282 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
510 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
735 views

Group and aggregate SpatialPolygonsDataFrame by column in R

I'm working with rgdal, sp, maptools, etc. I have a SpatialPolygonsDataFrame that has each row/Polygons list with only one Polygon. It also has an identifier column which I want to use to group by, ...
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 ...