Questions tagged [r]

Statistical computing language and software environment.

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

Calculate isochrones in R within a personal network

I just need to calculate the isochrones in R from an starting point within a personal network. This network is a sf linestring with an id attribute and a speed value. There are not any other ...
0 votes
1 answer
42 views

Add a source text to the map but don't function

I created a map with that code tm_shape(map, bbox = bbox_new) + tm_borders("grey", lwd = 1) + tm_fill("ratio") + tm_layout(legend.position = c(0.825,0.4), legend.bg.color = &...
's user avatar
3 votes
1 answer
99 views

Create map in R with better position of the legend

I have created a map with the following code map = st_as_sf(map) tm_shape(map) + tm_borders("grey", lwd = 1) + tm_fill("ratio") + tm_compass(position = c("right", &...
's user avatar
0 votes
1 answer
56 views

Creating custom rectangles for SF features

I am trying to create a custom rectangle for each point in my df. I am using two functions to loop through each feature and write a new polygon output. I would like one SF data frame with each of the ...
1 vote
1 answer
55 views

Detecting which municipality lies on which region?

I am again struggling with spatial data. I have to shapefiles. One is the municipality shapefile and the other the region shapefile. I have a shapefile that contains 106 regions of Switzerland. crs ...
's user avatar
1 vote
1 answer
82 views

Merge dataset and shapefile to calculate mean ses in r

I have a shapefile with 106 regions of switzerland and a dataset which is very large, so it is not possible to show it, otherwise it is not clear : I read it on R both datasets Library(readr) ms_shp &...
's user avatar
0 votes
1 answer
87 views

Change the CRS in R, but the current CRS is not clear [closed]

I have a set of datasets that looks like this called ch municipality BIP(CHF) x y 1 55'000 2486904 1112086 2 76'000 2486907 1112001 3 89'000 2487005 1112178 4 45'000 2488520 1112113 5 77'000 ...
's user avatar
1 vote
1 answer
40 views

How to separate the legend and hist in tmap of R?

I want to let hist in other position.But I can't find any function in tmap to do it. library(tmap) data(World, land) tm_shape(land, ylim = c(-88,88)) + tm_raster("elevation", ...
  • 103
0 votes
3 answers
45 views

Create multiple rasters from single spatialpixeldataframe, by Unique id

I have a SpatialPixelDataFrame (spdf) which contains gridded values (UD) for different Unique id's (n = 21). I would like to create an individual raster for each Unique_id, with value (UD) as the cell ...
0 votes
1 answer
99 views

Terra extract returns Nan value

I have tried to extract some temperatures for a given shapefile over North America. I used the terra package for extracting this data. It works for 14 of 16 areas in the shapefile. When I even try to ...
  • 798
0 votes
1 answer
39 views

Calculating inter-point distances worldwide - a dilemma

I am new to GIS, and am to cluster geospatial datapoints using DBScan() in the fpc package on R. However, my dataset is in ESPG 4326 (WGS 84). Since WGS 84 stores lat-long as degrees, and not metres. ...
4 votes
0 answers
103 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 ...
  • 41
0 votes
0 answers
41 views

GeoPandas DataFrame to Esri feature class [duplicate]

Is there a way to input a GeoPandas DataFrame as FeatureClass into a GDB without using the arcgis module? I managed to do it in Python (3.7.11) with: import arcgis # need to eliminate!!! import arcpy ...
  • 101
0 votes
1 answer
29 views

Extract non common areas between rasters in R

I'm trying to extract the non common areas between two rasters in R. I have two rasters: yellow and red. I want to extract all the points of the yellow that do not overlap with red (i.e. all the ...
0 votes
1 answer
55 views

Using a dynamic formula with parrallel kringing in R

I am trying to achieve parallel Kriging in R on several variables using a loop. Here is a reproducible example using data meuse and a code for parallel kriging that I found here. In the code below, ...
  • 561
0 votes
1 answer
60 views

How can I keep the time information while converting NetCDF file to dataframe?

My final objective is to perform a regression (latitude predicted by precipitation). To achieve that, I have download this dataset from Copernicus: https://surfobs.climate.copernicus.eu/dataaccess/...
0 votes
1 answer
134 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("...
  • 11
0 votes
1 answer
90 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 ...
0 votes
0 answers
70 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
45 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
178 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 ...
  • 54k
0 votes
0 answers
77 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 ...
  • 1
0 votes
0 answers
27 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
43 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....
  • 23
0 votes
1 answer
41 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
1 vote
1 answer
122 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: ...
  • 11
3 votes
2 answers
128 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 ...
  • 184
1 vote
1 answer
22 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
33 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("...
  • 175
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 ...
  • 99
1 vote
1 answer
74 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
32 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 ...
  • 39
1 vote
0 answers
103 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 ...
  • 113
0 votes
0 answers
24 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 ...
  • 131
1 vote
2 answers
36 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 ...
  • 11
0 votes
1 answer
40 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....
  • 133
0 votes
0 answers
42 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. ...
  • 1
0 votes
0 answers
26 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, ...
1 vote
1 answer
116 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 ...
  • 717
2 votes
1 answer
26 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, ...
  • 445
1 vote
1 answer
176 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
111 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 ...
  • 199
0 votes
0 answers
46 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 ...
  • 141
1 vote
1 answer
92 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 ...
  • 790
0 votes
1 answer
134 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 ...
  • 1
0 votes
0 answers
21 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
44 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", ...
  • 165
0 votes
1 answer
29 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
1 vote
1 answer
135 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<-...
  • 165
1 vote
0 answers
35 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 ...