Questions tagged [r]

Statistical computing language and software environment.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
27 views

R programming and coding [closed]

I have questions about making a loop or function to select all elements of a specific variable. Actually I have a variable with 100 names on that. Some thing like this: Area<- c(“Germany”, “Italy”, ...
0 votes
1 answer
34 views

How can I update a large raster with new values in R with speed?

I have a raster with 2332800 cells. Half of these cells are probably oceans and unneeded. I need to update these cells with new values. Right now I'm using a for loop and it takes a very long time: ...
0 votes
1 answer
12 views

Raster to SpatialPolygonsDataframe: close/crop polygons at the raster boundary, in R

library(raster) # read in bathymetery raster [https://drive.google.com/file/d/15kAcfQBJh_JiYgH-YrZZTJeeWOPd0Ysh/view?usp=sharing][1] r = raster('./ibcso.tif') plot(r) # set cells above sea level to ...
0 votes
0 answers
23 views

Working with multiple tiff files at one go

I want to predict my species of interest in the future using 4 Global Climate Models (GCM) at one go so that I can be able to plot outputs and save them as separate tiffs. code using single GCMs pfut &...
  • 1
0 votes
1 answer
36 views

What are the xmin, xmax, ymin, ymax values for Australia?

I am trying to crop the bioclimatic data from WorldClim.org to get environmental features only for the Australian habitat using the extent() method. Finally, I plan to combine the bioclimatic data ...
  • 13
0 votes
1 answer
19 views

tmap, tm_arrange, make maps of similar size

I am currently producing maps using R’s package tmap. My goal is to combine two maps in a single PDF, and I want the extent of each map to be the same. The first map zooms in a given country and shows ...
1 vote
1 answer
19 views

R lidR write tree points to shapefile

I have created a tree point object using the locate_tree function. The tree point object is sfc_point and I want to write this to a shapefile. However, I am getting the following error. How can I fix ...
0 votes
1 answer
38 views

Create shapefile geometries from scratch using R

I would like to interactively create polygons from within R/RStudio. I am familiar with creating shapefiles using QGIS, but I would like to create a similar, but more streamlined workflow using R. ...
1 vote
1 answer
37 views

Legend for confusion matrix in R

I have created a confusion matrix plot in R however I would like to get the legend that shows the values for the colours. How would I do this? So far I have the following: z = c(135,9,0,7,0,0,55,3, ...
  • 25
1 vote
1 answer
35 views

R lidR compute tree crown width

I have a LiDAR tile with segmented which includes respective tree IDs using silva2016. Now, I am looking for a way to compute the crown widths of each of the segmented trees. How or which metric can I ...
1 vote
0 answers
25 views

How to share QGIS R Processing Toolbox

I have developed a R Processing Toolbox. This has the file name: ToolboxRQGIS.rsx How can I share this toolbox with my colleagues in the easiest way? For a QGIS plugin, I can archive the developed ...
  • 65
0 votes
1 answer
18 views

Confusion matrix plot in r

I have a computed confusion matrix from google earth engine that I would like to use in r to derive a plot. how do I manually enter the confusion matrix and plot in R?. This is the confusion matrix: 1:...
  • 25
0 votes
0 answers
18 views

R lidR segment trees using Dalponte algorithm

When I run the code provided below, I get the following warning message. How I can resolve this error, as this message is returning segment_trees with zero trees? Message: In CPL_write_gdal(mat, file, ...
0 votes
1 answer
30 views

Creating a catalog from raster files with terra in R

I would like to first explain what I aim to do. I am used to use the R package lidR and I find very useful the comand readLAScatalog, which creates a catalog, "a representation of a collection of ...
0 votes
2 answers
41 views

Subset polygons in R

I am trying to separate a specific area on my window of analysis. I have a georeferenced floor plan with rooms as polygons. I want to select and plot only some the rooms I tried this: rooms <- ...
  • 29
2 votes
2 answers
58 views

Getting different Moran indexes?

I'm struggling to evaluate the spatial autocorrelation of several databases. These databases consist of coordinates and different environmental information associated with those coordinates. Strangely,...
  • 103
1 vote
1 answer
12 views

R lidR save clip_roi object to a LAS file

I am trying to save a clip_roi object to a LAS file and I used the code in the following question. However I still get the same error: Error: Argument is not a LAS object How can I save a clip_roi ...
1 vote
1 answer
73 views

Percentage of point features within polygon boundaries R

I am trying to create a histogram with the percentage of a concentration of points in a specific area. My data is someting like this: setwd("C:\\Users\\HP\\Desktop\\myrtos") getwd() library(...
  • 29
1 vote
1 answer
12 views

R lidR catalog_retile returns clipped output

I am trying to stich a few LAS tiles into a single file. The final retiled LAS appears to be clipped. How can I fix the clipping issue? LAS list catalog plot: Code: library(lidR) # Create a LAS ...
1 vote
1 answer
12 views

R lidR include filename of LAS object tile in interactive map popup

Is it possible to show the filename of the tile selected in the interactive leaflet plot? Currently it's empty as shown below. However, whenever I expand the object in the Environment pane, I can see ...
1 vote
1 answer
12 views

R lidR Plot multiple LAS catalog objects on a single Leaflet plot

I have five LAScatalog objects from five different subfolders present in the same parent folder. I would like to plot them together on an interactive Leaflet plot using lidR? Please note that I know I ...
0 votes
0 answers
18 views

How to scrape only tweets with lat_lon (geocode) information in R

I'm scraping tweets by using the rtweet package in R. As I'm interested in getting only tweets who bring with them the information about lat and long (geocode) about a specific location, I use the ...
0 votes
0 answers
32 views

Calculating landscape metrics with a landcover raster and a firescar shape, but the percentage_inside column shows some values ​far from 100%

I am trying to get the landscape metrics corresponding to a set of firescars, using the R package "landscapemetrics". The total wildfire data set encompasses around 1,000 fire scars, ...
0 votes
1 answer
22 views

Kriging with gstat and Gaussian model produces bad outputs

I am trying to produce kriging models from elevations points using the gstat package. I can fit models to the empirical variogram using exponential, spherical, and Gaussian curves. However, despite ...
0 votes
1 answer
19 views

How do you get GPM IMERG data in R?

I want to get proper GPM IMERG data with variables including time in R and work with it. I used "https://disc.gsfc.nasa.gov/" and got the link list in txt file. I don't know what to do from ...
1 vote
0 answers
54 views

How to properly save netCDF file with stars

I'm trying to save properly formatted stars object to netCDF file with no success. Here is a reproducible example of what I'm doing. library(tidyverse) library(stars) # example data ex <- tibble(...
  • 247
0 votes
0 answers
21 views

Apply function at grid cell level across layers of a raster file

I have a netcdf raster object with multiple layers (time: 30 years * 12 month = 360 steps). The raster is constituted of multiple grid-cells (say 1000). I want to linearly detrend each month ...
0 votes
1 answer
32 views

R Reprojecting global forest change rasters

I have been trying to calculate forest cover and forest loss in West Kalimantan Province, Indonesia, during 2000-2020. I use the gfcanalysis package in R for this purpose. Unfortunately, the minimum ...
  • 1
0 votes
1 answer
24 views

R having trouble reading in shapefile

I am trying to replicate the Kriging interpolation in R with this article's code https://www.analyticsvidhya.com/blog/2021/05/spatial-interpolation-with-and-without-predictors/ I have successfully ...
0 votes
2 answers
61 views

Plot polygon's attribute on R

I have created a settlement plan on ArcGIS Pro, on which every polygon corresponds to a specific room in the settlement. All the polygons/rooms have some features (E.g. Fire Place, Bench etc.). I have ...
  • 29
0 votes
1 answer
30 views

Merging/mosaic raster list or raster stack

I am trying to figure out proper solution to combine >100 raster images. These raster images are individual animal utilization distributions (values 0-1) that are modeled using dynamic brownian ...
0 votes
2 answers
22 views

SF Collection Plots in lat/long but Geometry is Not

I'm using urbnmapr to get a county base map. I want to plot my own points on top of this map. Even though the urbnmapr map plots with lat/long on the x y axis, the lat/long points that I want to plot ...
0 votes
1 answer
67 views

Monte Carlo simulation

I have an equation to calculate z from multiplying several rasters and numbers as seen below: z <- a*b*c*d*e The raster layers and values are as below: library(terra) set.seed(234) r <- rast(...
  • 363
1 vote
1 answer
55 views

What are the vectors inside a shapefile?

I have downloaded a shapefile "NT_SurfaceWater_Area.shp" from the UK Ordnance Survey and I have loaded it into R and can plot it. But, unlike other examples of shapefile which I've seen ...
-1 votes
0 answers
18 views

Error reading TIF in R: TIFFReadDirectory:Failed to read directory at offset 9858754

I am using R to create a Canopy height model (CHM) using DSM and DTM TIF files. I have performed this exercise previously on a smaller dataset and everything worked fine. However, I am now receiving ...
  • 1
0 votes
1 answer
28 views

R terra::mask report error ‘Error: [mask] extents do not match’

I have a temperature tif, and I want to extract my study area.But it reports that extents do not match. I want to know how to fix it and why the extents do not match? I think to_be_masked raster's ...
  • 103
0 votes
0 answers
33 views

Use non-linear regression output to predict values across raster including categorical attributes

We are aiming to correct general snow depth values from publicly available layers at a coarse resolution (~1km) using our vegetation and other parameters collected in the field at point locations ...
  • 1,845
2 votes
1 answer
124 views

Plot a tidy map of English regions

I'm trying to plot a tidy map of English regions in R. I'm using code that runs successfully on other shapefiles, but when I run this the code executes without error, but then just presents a blank ...
1 vote
1 answer
45 views

Random forest classifcation for Sentinel-2 low out of bag but high prediction error

I used Random Forest for land cover classification on the Sentinel-2 images in a forest. I have 3 classes: forest (0), bareland (1), and cloud (2). My variables include 4 bands (B2, B3, B4, and B8), ...
  • 269
1 vote
1 answer
66 views

Convert dataframe with polygon geometry variable into SF object

I am working with the Native Land data accessible via API: library(httr) library(jsonlite) library(raster) library(sf) library(tmap) res = GET("https://native-land.ca/api/index.php?maps=...
1 vote
1 answer
41 views

R lidR stitching several LAS files into one

I have 110 LAS files for a county, and I would like to stitch/combine them all into one single LAS file and write it to disk without bringing it into R. Since, each LAS file when imported into R has a ...
1 vote
1 answer
49 views

R lidR clip_roi error

I am trying to clip a LAS object based on an sf object. Now both the objects have the same CRS according to ArcGIS Pro 3, but clip_roi still returns an error that the CRS don't match. Error: Error in ...
1 vote
1 answer
41 views

Aggregate (dissolve) polygons leaving internal lines - R

After dissolving polygons, some of the internal lines remain. It seem to be a problem common also to ther softwares (ArcGis and Qgis at least). The dissolve result is this: To dissolve using R, I'm ...
0 votes
1 answer
30 views

How to force close polygon to overlap/share the border

I am using a shapefile of Brazilian municipalities, so there should be no gap between the polygons. Unfortunately, there are some: It seems to be fine, but a closer look reveal the problem (note the ...
0 votes
0 answers
35 views

How to plot Peirce Quincuncial and Spilhaus maps in R?

I am trying to project shapefiles of world maps in Peirce Quincuncial and Spilhaus. Although the projection is applied without errors, the plot function doesn't work. It seems something to do with the ...
1 vote
0 answers
18 views

Proportional allocation method for translating vector to raster format in R [closed]

My data consists of a shapefile of polygons representing municipalities in a given country. Each polygon has a population value in the shapefile's attribute table. I would like to disaggregate these ...
  • 11
1 vote
1 answer
39 views

Reading NetCDF subset R

I'm having trouble trying to read a plus 2Gb NetCDF file from https://cds.climate.copernicus.eu/cdsapp#!/dataset/satellite-land-cover?tab=form in R If I try to read the whole file R returns me a ...
  • 13
0 votes
1 answer
47 views

How to extract point data (latitude, longitude) of different soil variables from SoilGrids without actually downloading the TIFF files

Objective I have a dataset of ~200 observations, from scientific papers describing agroforestry, with associated coordinates (lat., lon.) dispersed all over the temperate world (US, Europe, China, etc....
1 vote
1 answer
56 views

Problem with determining the circles inscribed into polygons

I have a problem with determining the circles inscribed in polygons. In any case, regardless of the specified tolerance, I get an error. I'd like to get an effect like this post: https://twitter.com/...
  • 48
0 votes
1 answer
53 views

Get OpenStreetMap data for USA state boundaries using R osmdata package

I'd like to download data for California (i.e., parking lots > 8100 m2). But I can't get osmdata::getbb() to produce the correct boundary. library(tidyverse) library(osmdata) library(sf) library(...
  • 421

1
2 3 4 5
106