Questions tagged [r]

Statistical computing language and software environment.

Filter by
Sorted by
Tagged with
1
vote
0answers
16 views

How can I add the outline of Europe countries in this figure in R?

Here is my code to create this distribution map of Europe in R. So how can I add the outline in this figure to divide different countries and also add the countries' names in relevant regions? library(...
2
votes
2answers
34 views

Creating smallest-circle covering polygon using R with sf

How can I create the smallest-possible circle which covers a polygon geometry using the sf (preferred) or sp packages in R? One reprex using GADM data: # Load packages library(sf) # Load Nigeria ...
1
vote
0answers
18 views

What is the canonical way to perform raster calculations using R stars?

I have a data cube that I am handling in the R stars package. It has 3 dimensions (latitude, longitude and time) and 2 attributes (northwards and eastwards components of wind). A dummy equivalent ...
1
vote
1answer
17 views

Convert a large RasterStack to Array in R

I am trying to transform a large RasterStack to an array in order to compute some extraction. The classical approach raster::as.array() is not working since the files are very large and it's taking ...
-1
votes
0answers
19 views

How to add vertical lines to log transformed axes in ggplot2 [closed]

I tried to add a vertical line to the log transformed x-axis using geom_vline(), but it kept reporting warnings like "Removed 1 rows containing missing values (geom_vline)". The code I used ...
0
votes
0answers
23 views

R 4.0.4 Raster package treating Albers as unknown projection

I'm running a fresh R installation with RStudio. Installed packages are: library(randomForest) library(randomForestExplainer) library(raster) library(rgdal) library(sf) When I try loading any raster ...
0
votes
0answers
35 views

Cumulative sum of pixel values intercepted above a given rasters

I have 41 density calculated rasters, which raster represents a layer of a las file. I need to calculate the cumulative sum of LiDAR points intercepted above a given layer. density_rasters a vector ...
0
votes
1answer
29 views

Error saving .asc bias file in R

I used the following code to create a bias file in R for MaxEnt. I am able to create the bias file, but I am not able to save it as ascii (see error message). My lat/lon csv file contains only points ...
2
votes
1answer
30 views

Surf3D, example from ggRandomForests: Random Forests for Regression

I have a model and I want to use the surf3D function in R, and produce a plot similar to the following (the image is the example from "ggRandomForests: Random Forests for Regression"). ...
5
votes
1answer
77 views

Computing the density for each layer with lidR

I am trying to perform a 3D profile index as a function. For this, I need to slice the layers and calculate the point density for each sliced layer. I write a for loop; The problem is density=...
2
votes
0answers
23 views

How to apply Sen2cor in sen2r graphical user interface?

I have recently installed the sen2r plugin in r for extracting level 1 Sentinel-2 images from ESA's Long Term Archive and using sen2cor correction to obtain level 2 scenes. An issue I face is that the ...
1
vote
0answers
27 views

Plot “large” raster with leaflet in R

I have a geotiff that is around 26MB on my hard drive. I would like to use leaflet to plot it within a shiny application. However, it just doesn't load. When I use mapview just to plot it locally it ...
-1
votes
0answers
31 views

Models for supervised land cover classification using the RStoolbox package in R [closed]

Which models can be used for land cover classification model via the RStoolbox package in R?
0
votes
1answer
23 views

Eurostat shapefiles plotting with errors

I am trying to plot interactive maps at the NUTS3 level. Initially I was using shapefiles that I constructed myself for the data in QGIS, however, when I tried to use them in R they rendered poorly ...
7
votes
1answer
287 views

What type is this PostGIS data and how can I get lat, long from it?

I have an R dataframe, with location stored in a column. Location values look like this: 0101000020E6100000797A00E6B5593E40D5CE30B5A5394940 I was told that it is PostGIS data. The goal is to visualize ...
0
votes
1answer
53 views

Pairwise shortest distance between points in a road network

1. Problem I have the coordinates for over 5000 points (cities) that lie over a road shape file, as partially illustrated below: I'm working on R, and I need to find the shortest distance between all ...
0
votes
2answers
38 views

How to calculate the average polygon shape in R (adehabitatHR)?

I have a code that generates polygons from a MCMC model. For each iteration in the model, I get a polygon of the 95% credible interval for the area. The idea here is that if I generate 10 polygons, I'...
2
votes
1answer
27 views

Calculating the cross-nearest-neighbor distance in spatstat

I wish to calculate the cross-nearest-neighbor distance between two point patterns in spatstat. According to Pr. Sadahiro, the cross-nearest-neighbor distance is defined as: My inputs are sf datasets,...
1
vote
1answer
35 views

How to remove areas of water from the US census tract map using R/RStudio

I am trying to aggregate all of the census tracts in the United States for analysis and display, including a realistic depiction of water features when zoomed in. I run into memory issues when doing ...
3
votes
1answer
28 views

How to filter heights using LAScatalog in lidR

I would like to filter the points that are used in a canopy height model. In particular I would like filter out any points whose height is over 200 feet. I've tried the code below but when I plot the ...
1
vote
0answers
26 views

Cannot open TIFF file due to missing codec

I am trying to rasterize a tif file by doing this: newData <- raster("file.tif"). However, when I run it, it says that it "Cannot open TIFF file due to missing codec". Upon ...
1
vote
1answer
35 views

Loop for cropping, cloud masking Sentinel 2 L2A images

I have 6 stacks Sentinel 2 images (10m resolution) that I want to crop to my AOI and cloud masking. After which I want to calculate NDVI in R. The stacks are 3 from different months of 2016 and 3 from ...
1
vote
0answers
25 views

Upper and lower bounds from gstat::krige() and gstat::idw()

Is it possible to obtain lower and upper bound values from a kriging estimation using gstat::krige() in the same way it can be obtained from a simple lm() model? The following lm() example comes from ...
3
votes
1answer
27 views

error running readLAS() in lidR: 'new_proj_and_gdal' is not an exported object from 'namespace:rgdal'

I've just updated lidR to 3.1.1 and am now unable to load a .las file using readLAS(): las <- lidR::readLAS(paste(sfm_dir,"/","...
0
votes
0answers
10 views

Extract HDF5 group name and apply it as a variable name using R

I'm new to using HDF5 files and need to extract information from several thousand such files, each with 6 groups of interest (e.g., ('/gt1l', '/gt1r', '/gt2l', '/gt2r', '/gt3l', '/gt3r'). I would ...
0
votes
0answers
27 views

Extracting all levels of a NetCDF file and exporting as multiband raster

I am trying to convert this .nc file with land cover data from ESA CCI (http://maps.elie.ucl.ac.be/CCI/viewer/download.php). There is a separate .nc file for each year, and each file contains the ...
0
votes
1answer
37 views

Calculate aspect for stream segments in R from 2D linestring and DEM

I would like to calculate the general aspect for stream segments in R. The stream network has been derived from the DEM and is in 2D. I have split the stream segments into equal parts of 100m (or less)...
1
vote
0answers
14 views

Proper way to assign CRS in rgdal 1.5-23 [duplicate]

Perhaps my question has been already answered but if it did, I haven´t be able to find it. I´ve updated the rgal package to version 1.5-23 (GDAL 3.2.1 & PROJ 7.2.1) and when I run the following ...
0
votes
1answer
29 views

Leaflet R - plotting raster with colour palette

I am trying to plot a raster image using Leaflet, however I am having issues getting the colours right. I've read in the raster like this and plot the the resulting raster variable. library(raster) ...
4
votes
1answer
53 views

Changing raster plot break values text using R

I have the following R code that generates a plot. b <- c(0,30,60,90,120,150,180) rast <- raster("study.area.accessibility.tif") r <- clamp(rast, 0, 180) plot(r, col=topo....
1
vote
1answer
38 views

Recursive calculations on a river network

I have a dataset that contains network distances along a river network. This dataset was created using Topotoolbox in Matlab, with the node and segment information exported. I've been working on the ...
1
vote
1answer
42 views

r sp::CRS() returns NA

I just updated R (from 4.0.2 to 4.0.3) and all my R packages (previously updated about a month ago), and got an error in a previously working workflow on raster objects. It seems that it comes from ...
2
votes
1answer
26 views

How to read .csv polygon data with sf?

I am trying to read a .csv file where each row contains information about a polygon. The polygon geometry information is stored in a shape column such as 'longitude latitude altitude accuracy; ...'. ...
1
vote
0answers
15 views

R -raster: Define raster extent from centre and rotation

I am quite new to R spatial transformation. My aim is to write a GeoTiff to be correctly geolocated in GIS software (e.g. ArcGIS). I have a raster with known coordinates of the centre (proj: UTM WGS84 ...
1
vote
1answer
43 views

sf::st_transform() gives “crs not found” error

I am using sf package version 0.9-6. I define a new object in ESRI:4326 and then try to reproject it to an Albers projection. I get an error, despite explicitly setting the crs when defining the ...
0
votes
1answer
23 views

Applying function to each element of a SpatialLinesDataFrame

Question: How do I apply functions to each element of a SpatialLinesDataFrame, in particular using other data also stored as an attrbiute (e.g. coordinates or elevation per line vertex)? I've a number ...
0
votes
1answer
15 views

Extracting source code from R functions in RStoolbox

I am trying to access the underlying code to the tasseledCap function in RSToolbox in R, but have been unable to view some of the, I think, internal functions. Specifically, in the tasseledCap ...
2
votes
1answer
28 views

Overlapping LAS tiles and edge artifacts

I've read the Overlapping LAS tiles post, but it doesn't pertain to the following situation. I'm trying to process a las catalog where I clip the catalog at specific plot locations with a 30 m radius. ...
0
votes
0answers
18 views

Finding the angle between two GIS linestring features using R

I have two simulated linestrings, one that represents a satellite ground-track and the other representing a linear surface feature (e.g., sea ice lead, road or river). I'm trying to determine how to ...
0
votes
0answers
15 views

Checking if the point lies within the polygon in R using sf package

I have a point's coordinates as well as an object with the class of sfc_polygon in R. I would like to check if this point lies inside that polygon or not. I created an object with the class of ...
-2
votes
0answers
32 views

Fonction de calcul de la longueur de calcul sous R [Calculation function of the calculation length under R]

Bonjour je voudrais avoir une idée comment faire une fonction sous R qui calcule la longueur d'une frontière partagée entre une division administrative (par exemple commune) et un pays voisin. Google ...
0
votes
1answer
18 views

Classify integer raster in tmap

I want to plot a raster of the forest cover accross Europe using tmap::tm_raster(). The raster data are available here: If I plot it, this is what I get: # Read raster data: forest <- raster("...
0
votes
1answer
29 views

abind Error when converting a .tif raster data object to an sf object using st_as_sf() in R

When I try to convert a .tif raster data object to an sf object using st_as_sf() in R, I get the following error: Error in abind(x, along = length(dim(x)) + 1) : along must be between 0 and 2 Does ...
0
votes
1answer
20 views

Calculating nearest distance between two Linestrings using R

I have two simulated linestrings, one that represents a satellite ground-track and the other representing a linear surface feature (e.g., a road or river). I am trying to calculate the minimum ...
0
votes
0answers
12 views

How to use parallel parlapply for features whithin an sf object

I'm trying to create an intersection between two layers but, because of their size, st_intersection can't be done in one ony execution. I'm trying to do so spliting the process in parallel so this is ...
0
votes
1answer
19 views

Working with irregularly spaced gridded NetCDF data in R [closed]

(I've also posted this on stackoverflow #66047260, but then it occurred to me that this is a better place for it.) I'll be working with modelled air pollution data soon. I've been given some sample ...
0
votes
1answer
57 views

How can I extract Moran's I from buffered pixels withins raster

I have a raster with NDVI and I have a dataframe with coordinates I want to extract stats from at a 125m radius. extract(NDVI,coordinates,method='simple',buffer=125,fun=mean) this works for most of ...
3
votes
1answer
50 views

sf geometry column naming differences R

I've got several shapefiles stored as geopackages and I want to merge all of them by using rbind. But unfortunately the geometry columns are namend differently as "geometry or "geom" ...
1
vote
1answer
42 views

Intersect points and polygons

I have a dataset where I'm trying to look determine determine which polygons my sampling locations occur in. I have been following the example here: https://gis.stackexchange.com/questions/282750/...
0
votes
0answers
31 views

R lidR stdmetrics_z

When using stdmetrics_z in the R package lidR, it produces 36 bands of metrics. I am unable to find the definition of each of these bands (metrics). In the help it says to view the wiki page but there ...

1
2 3 4 5
89