Questions tagged [r]
Statistical computing language and software environment.
5,160
questions
0
votes
1
answer
14
views
R terra not reading attributes from NetCDF file
I'm trying to read precipitation data from the Global Meteorological Forcing Dataset for land surface modeling dataset (http://hydrology.princeton.edu/data.pgf.php).
library(terra)
pp <- rast("...
0
votes
0
answers
11
views
How to execute an R code on differet area (cities) [closed]
I want to execute my code (the same) which have been applied on one city (a code who use data from a raster and do classical operations such "crop" "extract pixel" value....) all ...
0
votes
0
answers
15
views
Aggregate Points inside polygons sum multiplied by census data [closed]
I have two shapefiles, one a point layer of residential addresses within a county and the other is a polygon layer of fire and rescue first due districts, and I am trying to find the number of address ...
0
votes
1
answer
30
views
Combining districts in shapefile to produce custom regions in R
I am working with a dataset that uses custom regions ("North", "South" and "West") and I would need to plot them onto a map with tmap.
As a first step, I assigned the ...
-2
votes
0
answers
28
views
Calculating terrain roughness of given location [closed]
I have the longitudes and latitudes of my study locations (LName) and would like calculate terrain roughness in R. I searched the internet but could not find any helpful information.
Can you provide ...
-2
votes
0
answers
20
views
Why r2 (coefficient determination) is low while RMSE value is good? [closed]
I am doing pixel-based crop yield prediction using Random Forest Regression in R software based on Sentinel 2 bands. I did training and test. Then, I wanted to predict crop yield for the specific ...
-1
votes
0
answers
38
views
How to learn Python and Arcpy(ArcGIS Pro) from knowing nothing in a clear and efficient way? [closed]
I am a complete new to Python and Arcpy.
I have learned some knowledge about R before,such as raster and terra packages but now I think learning Python is much more difficult than learning R. And I ...
0
votes
0
answers
28
views
Recenter map that crosses international dateline with ggplot and geom_sf
Consider the map of Europe below. Parts of Russia are on the other side of the map. How might I "recenter" the map so that there is less empty space? I guess I need to somehow move the ...
0
votes
1
answer
17
views
Merging .tif files via gdalbuildvrt not working
I have a piece of code in R that I have used for a while now to transform .xyz files to .tif and then merge all those .tif files into one big .tif. It has worked well when I last used it 2 years ago, ...
3
votes
2
answers
40
views
Plotting a categorical terra raster with a colour map
I'm trying to plot a categorical terra raster object with an explicit colour for each level, like you'd do with a land cover raster, but running into problems when the raster doesn't have every level ...
0
votes
0
answers
19
views
R : Reading KMZ and appending geography to polygon from png
Question: How do I make a png embedded within a kmz useable as a polygon?
Context:
I am trying to read a KMZ file generated by a free 3rd party tool and to make the .png image within useable as a ...
0
votes
0
answers
18
views
Function voxel_metrics in lidR 4.0.1 gives error "Argument is not a LAS object" when used with a LAScatalog
I am attempting to use the lidR voxel_metrics() function to compute leaf area density across a large spatial extent. Due to the size of the LAS file (~10 GB) I have imported it as a LAScatalog object ...
0
votes
0
answers
24
views
Getting NaN values when I extract pixel values of a raster using a point shapefile in R
I try to extract pixel values at defined points in a raster file in R, using a point shape file.
With some raster files it works perfectly, with others it returns 'NaN' values for all extracted points....
0
votes
0
answers
25
views
Getting polygon coordinates for areas outside known polygons using R
I have downloaded shapefile containing polygons for urban areas. However, I am interested in polygons representing rural areas. Therefore I would like to convert the shapefile containing urban areas ...
1
vote
1
answer
18
views
Transform CRS of Shapfile (sf) and Raster( raster)
I'm working with R. And to have a Rasterfile and a Shapefile. Now I want to fit their CRS/ EPSG so I can plot them together. Several approaches I've tried won't work.
Someone may help?
THE CRS/EPSG:
...
2
votes
2
answers
63
views
What's the most efficient way to calculate line length per raster cell in R?
Problem
I'm looking for an efficient, memory friendly to calculate total line (vector data) length per raster cell.
The question of line length per cell has already been posed here in 2014 and a few ...
1
vote
1
answer
18
views
Classify POI where poi is based on ~Classification and a ~UserAttribute
Can I use a multi-criteria-poi when calling classify_poi()? While I am really trying to classify points based on matching ~Classification and ~UserAttribute values, the code below throws the same ...
0
votes
0
answers
14
views
Use sen2r() with L2A data to create BOA and SCL?
I have three L2A files downloaded. They are in the .SAFE format. My understanding is that sen2r can process these data, but I don't know which arguments to use. I tried this: sen2r(list_prods=c("...
0
votes
0
answers
34
views
Handling internal reprojections for geoprocessing using R
Suppose I want to create a tool/function that has to, e.g., create buffers or measure distances internally to produce an output with a geographic projection.
How do I ensure that the distance ...
1
vote
1
answer
43
views
Filter shapefiles - keeping inside parts only
I'm quite new to GIS so sorry if this is a daft question - is it possible to filter out non-overlapping parts of a shapefile? I have a boundary shapefile which I would like to cover with small areas ...
0
votes
0
answers
29
views
Error in Rbindlist from a rasterstack and shapefile extraction file
I have multiple rasters files and a grid shapefile.
I load the shapefile:
grid = st_read('/grid.shp')
I load the raster and create a raster stack
`path <- "/VI_tif"` #folder where I ...
0
votes
0
answers
92
views
Change the resolution of the friction surface raster and compute cumulative travel time in R
I have downloaded the 2015 friction surface from the Malaria Atlas project website (see bottom of the page). On their websites, authors specify that the measure units of such a raster are minutes to ...
0
votes
0
answers
22
views
Projecting rasters, shift to the north
I would like to project one raster onto another and while doing so I think the values are changing their position "to the north".
Is this an expected behavior?
I was hoping to create a ...
1
vote
2
answers
32
views
How to crop an ASCII file?
I have data downloaded from https://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-count-rev11. It is in an ASCII file, and I want to plot the map and the populations of just California. What is ...
0
votes
1
answer
16
views
Performing a k-means clustering with raster time series
I would like to perform a k-means clustering on time series data. I tried doing it with rts package.
library(rts)
path <- system.file("external", package="rts")
lst <- list....
0
votes
0
answers
21
views
Predict raster time series based on the fitted linear mixed model in R
I have a raster stcak composed of 70 images. I use the linear mixed model to build the relationship between this raster stack time-series data extracted from several pixels and field measurement data. ...
0
votes
0
answers
18
views
Rescale and reoffset in a for loop
I am looking for a way to run a loop to rescale and reoffset multiples laz files.
I've tried with:
path <- "D:/LIDAR/UNCINATA/2020_VALDELINARES/LAZ/"
files <- list.files(path=path, ...
0
votes
0
answers
53
views
How to speed up the intersection of two large shapefiles in R with sf (or any other way)
I have two large-ish shapefiles.
Shapefile 1:
One can be downloaded from here:
https://data.statistik.gv.at/data/OGDEXT_DSR_1_STATISTIK_AUSTRIA_20111031.zip
It is ~20 MB in size
Seems to be super ...
2
votes
1
answer
24
views
Save raster tiles created by catalog_apply as single file
I have a big point cloud (3.5 GB) and want to create a big DTM from it using R. In the "old" lidR version this was possible by turning on automerge = TRUE. If the tiles could not be merged, ...
0
votes
1
answer
48
views
r Terra Mosaic Raster uses huge amounts of memory and takes too long - any alternatives?
I built a process using google earth engine code editor to output a raster of urban land cover in Wisconsin. Google exports these as 210 shard which are geotiffs ranging from 2-100mb in size. Most are ...
0
votes
0
answers
17
views
Terra: Setting the right resolution when transforming data frame to SpatRaster
I have a data frame which cell sizes aren't regular due to some statistic analysis and filtering, but for presentation purposes I need to transform the data frame back to a SparRaster. I don't want to ...
0
votes
0
answers
23
views
Masking a curvilinear/rotated grid netCDF with a shapefile?
Obviously it's difficult to reproduce a netCDF here on Stackexchange, especially a curvilinear/rotated grid type.
So let me start with what I already know.
I know how to mask a regular netCDF with ...
0
votes
1
answer
28
views
terra R package functions error that file exists and needs overwrite=T
For the past 2 days I am trying to use the terra R package functions crop(), mask() and project() for simple spatial analyses. However, after 2-3 min of running each of the functions gives the same ...
0
votes
1
answer
24
views
Permission denied (GDAL error 4) when attempting to open folder using list.files
I'm new to R and using terra and cannot figure out this permission error. This exact code works on another researcher's computer, so I'm not sure why it's not working on my Rstudios. The folder and ...
0
votes
0
answers
19
views
tmap, always put biggest shapefiles as first layer
I am using TMAP library to generate a series of maps. The number of maps to generate is huge and the number of shapefiles to plot in each map is also big.
Each shapefile is of a different size, some ...
0
votes
1
answer
34
views
Creating BoxPlot in R
I want to create boxplot to show Forest Percent by localunit (GaPa_NaPa). The attribute data is as shown below:-
The data frame is as shown below:-
structure(list(GaPa_NaPa = c("Gaidahawa", ...
0
votes
1
answer
20
views
Extract values from raster matching csv and raster filenames
I have a folder with many csv files. Each file has several columns as well as lat and long columns. Another folder have many rasters in tif format. The .csv files are named based on Julian date (e.g. ...
1
vote
1
answer
49
views
Map View in R: Labelling Name for Polygon in Map
I have created following choropleth map for cropland.
The code I used is:-
library(mapview)
library(dplyr)
library(sf)
setwd("C:/Users/lenovo/Desktop/IEM")
Province3Miscellaneous<-...
1
vote
0
answers
22
views
Combining all Block Group shapefiles together as one
I'm trying to load in all the shapefiles from the Census found here (https://www2.census.gov/geo/tiger/TIGER2019/BG/), and merge them all together as one large shapefile for the entire US overcoming ...
1
vote
1
answer
37
views
Object name not found in R
I have created following map for disaster by district as shown below.
The code I used is:-
install.packages("cartography")
install.packages("sf")
install.packages("tidyverse&...
0
votes
1
answer
28
views
Looping to do cloud mask for several raster files in R [closed]
I have over 200 land surface temp (LST) rasters and I want to mask each LST raster using the corresponding cloud Mask raster. The working directory has two folders one for LST and one for cloud Mask. ...
0
votes
1
answer
22
views
Adding attribute to SpatialPolygonsDataFrame in R
I have a SpatialPolygonsDataFrame with 14 different polygons. Each polygon currently has an attribute column "id", which is a single string that identifies the original colony, year, and ...
0
votes
1
answer
35
views
Zero-width buffer trick makes the Caspian Sea disappear (using R)
I am new to plotting with coordinate systems. I am trying to generate a Pacific-centered map, and am using this wonderful code as a starting point. I have a bunch of data points from databases I'm ...
0
votes
1
answer
31
views
R: Cannot create a RasterLayer object from this file
I need to download the climate data from CHELSA in form of GeoTIFF file. I need many layers, for which I downloaded them successfully but failed to load them as raster. For simplicity here is how to ...
0
votes
1
answer
21
views
Invalid argument to unary operator in R
I want to calculate the rate of change in Maximum Temperature (of 2 yrs) for a spatial data. The rate of change of maximum temperature for the 2 years data (say 2021 & 2019) is calculated as:- [{(...
0
votes
0
answers
19
views
Classify which cells were uphill and which were downhill when calculating Tobler's Hiking Function
I am using the ArcGIS Desktop (10.7.1) Path Distance tool and a table and DEM to calculate the cumulative time to reach locations. Is there a way to track and map which cells were downhill and which ...
1
vote
1
answer
49
views
Plotted shapefile doesn't lie on base map
I am working on choropleth map showing particulate matter by some district of an area. The attribute table is as shown below (with geometry):-
The code I used is:-
library(mapview)
library(dplyr)
...
2
votes
1
answer
32
views
Dividing a 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 ...
2
votes
1
answer
61
views
Changing color ramp in R
I am trying to plot water quality by 3 districts of a nation. I have plot the map according to Biological Oxygen Demand value from the table as shown below:-
The code I used is as shown:-
install....
0
votes
0
answers
31
views
Error while using readOGR to import shapefiles
I am using a Mac System and unable to read shape file.
states12 <- readOGR(dsn = ".", layer= "cb_2018_us_state_500k", verbose=TRUE)
The Error I am getting
RStudio is Quitting ...