Questions tagged [r]

Statistical computing language and software environment.

1,282 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
13 votes
0 answers
3k 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/...
RobinLovelace's user avatar
9 votes
2 answers
1k 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 ...
Vijay Ramesh's user avatar
  • 1,342
8 votes
0 answers
1k 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 ...
Nery's user avatar
  • 99
7 votes
0 answers
1k views

R sf package - link to GDAL

Is it possible to ask R {sf} package to use a GDAL installation I prefer? So far I found how to check external software it uses: library(sf) sf_extSoftVersion() # GEOS GDAL ...
Kazuhito's user avatar
  • 30.8k
7 votes
1 answer
1k 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 ...
Tomas's user avatar
  • 1,252
6 votes
0 answers
314 views

Implementing PostGIS query using sf in R to make ST_Intersection faster

I'm trying to implement this query that speeds up st_intersections by using faster functions, namely ST_Contains and ST_Within, to do ST_Intersection only where absolutely necessary, from PostGIS to R ...
Elio Diaz's user avatar
  • 3,456
6 votes
0 answers
1k 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 ...
telegott's user avatar
  • 165
6 votes
0 answers
116 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 ...
KATGeo's user avatar
  • 61
6 votes
0 answers
812 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)...
MNewco's user avatar
  • 61
6 votes
1 answer
797 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, ...
Yollanda Beetroot's user avatar
5 votes
0 answers
1k views

Rotate coordinates from climatic data in raster format (cordex-EU domain 11) to usual coordinate systems

I am trying to create a dataset that shows future climatic condition in Europe aggregates to NUT2 administration level in R. To do so, i work with cordex data (domain EU 11), that is coming ...
Catherine Pfeifer's user avatar
5 votes
0 answers
831 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 ...
Delphine's user avatar
5 votes
0 answers
2k 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 ...
Denys D.'s user avatar
5 votes
1 answer
537 views

Working out travel time from gdistance's conductance values in R?

Introduction This question is indirectly related to a previous post of mine (Calculating accumulated walking pace from starting location outwards using R?), but asks guidance about a different aspect, ...
NewAtGis's user avatar
  • 1,536
5 votes
0 answers
726 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 ...
AlwaysInTheDark's user avatar
5 votes
0 answers
2k 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 ...
Phil's user avatar
  • 85
5 votes
0 answers
2k 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. ...
usersam's user avatar
  • 259
4 votes
0 answers
347 views

Choosing the right coordinate system to measure area all over the world

I'm kind of new to GIS, I have a background in physics, but I'm pretty confused with all the projection available and how to use them. I have a dataset of 133 coordinates around the world. I am using ...
Laurent's user avatar
  • 41
4 votes
0 answers
232 views

Spatial regression: general nesting spatial model using splm package in R

I have a shapefile of panel data (multiple years of observations for each polygon). I am estimating fixed effects spatial regression models with this data. I used one year of this data to generate a ...
C. Ashley's user avatar
  • 405
4 votes
0 answers
476 views

Optimising use of st_within for parallelisation

I'm trying to use st_within() to calculate points within polygons on a fairly complex shapefile. This operation tends to take 4-5 hours which is a bummer for debugging the code. I have access to a ...
Jeremy Kidwell's user avatar
4 votes
2 answers
570 views

Extract pixel values in raster stack using shp

I am using the following code to extract mean pixel values over an area represented by a polygon: mean<-lapply(S2_stack, FUN=function (S2_stack) {data.frame(mean=extract(S2_stack, polygons2, fun=...
GCGM's user avatar
  • 1,118
4 votes
1 answer
1k views

Split a polylines according to a specific point in R

I have 2 distinct spatial objects: on one hand I have a SpatialLinesDataFrame on the other hand I have a SpatialPointsDataFrame Considering one line and one point that intersects that line, I ...
Karim Claudio's user avatar
4 votes
0 answers
1k views

Possible to drop NA geomType in readOGR?

I have a gdb file which is giving me trouble. f = '/path/to/folder.gdb' layers = ogrListLayers(f) geom_list = lapply(layers, readOGR, dsn = f) Gives an error on one of the layers: Source: "f&...
MichaelChirico's user avatar
4 votes
0 answers
992 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 ...
Norwin's user avatar
  • 521
4 votes
1 answer
286 views

Loading raster to R from PostgreSQL via pgGetRast takes a lot of time

I wrote R code in R Studio to load a raster (stored in PostgreSQL) to R. The database is stored here: C:\Program Files\PostgreSQL\ The following versions are installed on the computer: R version 3.4....
Li Ku's user avatar
  • 85
4 votes
1 answer
13k views

Error in compareRaster(c(x, rasters)) : different extent

I have a RasterStack that I want to add two rasters to. I am using this code library(rgdal) library(raster) #original rasterstack rasterfiles <- list.files("C:\\path_to_rasters", "*.tif$", ...
Stefano Potter's user avatar
4 votes
0 answers
523 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 ...
generic_user's user avatar
4 votes
0 answers
703 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, ...
Zonderpaard's user avatar
4 votes
0 answers
270 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 ...
nmatton's user avatar
  • 116
4 votes
1 answer
474 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 ...
Waseem Ali's user avatar
4 votes
0 answers
2k 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", "...
Lincoln Mullen's user avatar
4 votes
2 answers
673 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 ...
Stefan's user avatar
  • 2,152
3 votes
0 answers
740 views

How to compute weighted mean centroid of lat+lon points taking into account spheroid

I have a bunch of points (lat+lon coordinates). Each one has a weight. I would like to get a weighted mean centroid of the points, taking into account the spheroid (as my points are scattered across ...
bill999's user avatar
  • 125
3 votes
0 answers
686 views

How to force single value terra::rast to plot as continuous

I have a couple of raster in R. Some have a range of values while others have a single value (all 0, for instance). I want to plot all rasters with the same color scale and legend so I can visually ...
Daniel's user avatar
  • 2,443
3 votes
1 answer
526 views

Dividing square into smaller squares by using their shapes rather than their bounding boxes in R

I want to divide a square into 25 smaller squares. The square layer has a UTM coordinate system, so when plotted, it doesn't have flat bottoms and tops. When I try st_make_grid() function to overlay a ...
KO 88's user avatar
  • 165
3 votes
0 answers
269 views

Issues downloading soil organic carbon data from SoilGrids

I am trying to use R to download soil organic carbon data for a specific region from SoilGrids, using their example code as a start. The code I wrote based on this worked fine to download the sand and ...
Cat's user avatar
  • 31
3 votes
0 answers
226 views

Error while using "wbt_conditional_evaluation" in R from WhiteboxTools package "whitebox"

When I try to perform the conditional tools "wbt_conditional_evaluation" in R, I get this message error : Error running WhiteboxTools (conditional_evaluation) whitebox.exe_path: "C:/R/...
Francis Lessard's user avatar
3 votes
0 answers
333 views

Rasterize polygon shapefile giving cells average value of overlapping geometries

I want to rasterize a polygon shapefile in r - loaded as an sf. Using stars, I can do st_rasterize to create a stars object snapped to a template raster, which is great because I the next step I want ...
Pablo Herreros Cantis's user avatar
3 votes
1 answer
564 views

How do I change my x and y axes from a range of 0-1 to -180-180 in R? I'm using netndf datasets

I have temperature anomaly arrays for the months of February 2008-2021 that I have turned into a raster brick. I am now plotting these in ggplot2. See below code: febanomaly_raster <- brick(anomaly....
Nick Masto's user avatar
3 votes
2 answers
1k views

Retrieving raster layer names from a raster stack R

I have a raster stack with many layers and I want to compare the layers that contain the maximum value using cell by cell comparison and finally retrieve the layer names from the raster stack on each ...
Amsalu's user avatar
  • 59
3 votes
0 answers
784 views

Parallelizing calculations on large SF object in Windows environment

I have a large SF object, containing 1 km x 1 km grid cells, where I need to aggregate the area of polygons within the grid cells, i.e. grouping by grid cell, but also grouping by a second variable, ...
Kuns's user avatar
  • 41
3 votes
0 answers
530 views

Can I resample a raster in R using "max" as function?

With a raster and a reference raster, I'd like to do something like this: # resample raster to ref_raster to match resolution/origin using max as aggregate raster = resample(raster, ref_raster, 'max') ...
Honeybear's user avatar
  • 2,454
3 votes
0 answers
513 views

Extracting point data from WMS using R. Is it possible?

I am collecting traffic accident data on European countries and the Austrians pointed me to this WMS metadata page. https://data.statistik.gv.at/web/meta.jsp?dataset=OGDEXT_UNFALLSRV_1 which has the ...
Cannon's user avatar
  • 99
3 votes
1 answer
654 views

Rendering three-composition raster map with ternary colormap using R

Say there are three raster maps, representing percentages of sand, silt and clay respectively. The three values for each cell are hence summed up to 1. I want to use one raster map to characterize the ...
tunar's user avatar
  • 141
3 votes
0 answers
486 views

Merge single- and multi-band rasters with stars

I can easily use c() to merge two single band rasters or two multi-band rasters using the R package stars, however, when I try merging a single band raster with a multi band raster, I get the error ...
Matt SM's user avatar
  • 1,841
3 votes
0 answers
369 views

Finding the nearest distance between points in a grid cell

I'm trying to find the distance between the nearest points in a grid-cell, such that there is no equivalence relation between these points. Meaning if there are three points {a, b, c}, then a = b; not ...
Lime's user avatar
  • 173
3 votes
0 answers
1k views

Downloading SoilGrids data from WCS in R

I am trying to download SoilGrids GeoTIFF data in R using WCS. I have followed the tutorial set up by ISRIC (https://git.wur.nl/isric/soilgrids/soilgrids.notebooks/-/blob/master/markdown/wcs_from_R.md)...
apple's user avatar
  • 165
3 votes
1 answer
822 views

Exporting geodatabase using R-Bridge with ArcGIS Pro

I am trying to export a spatial points data frame as a Arc geodatabase using arc.write function in the R-bridge (arcgisbinding) in R. I'm working in R v3.6.1, ArcGIS Pro v2.4.0 Advanced License, and ...
Bolli's user avatar
  • 31
3 votes
0 answers
376 views

How to create a hexbin polygon over a world map with a geom_sf object in R?

I have global data with over 180,000 data points. For every pair of coordinates I have a value, and many times I have multiple values at the same coordinates (see example of the dataframe df). I want ...
Leo Ohyama's user avatar
3 votes
0 answers
716 views

Spatial interpolation of climate data using latitude, longitude and elevation in r

I have downloaded E-OBS gridded daily climate data on 0.1-degree grid. For each grid point, I have longitude, latitude, elevation and climate data, i.e. precipitation sum / mean temperature. Now, I ...
JerryTheForester's user avatar

1
2 3 4 5
26