Questions tagged [r]

Statistical computing language and software environment.

2
votes
1answer
11 views

Look up OS grid letters from easting/northing in R

Suppose I have an easting/northing point: data<-c("423851", "300384") I would like to find out the grid letters for this point using the British National Grid system (Ordnance Survey). If you ...
1
vote
0answers
17 views

R generating prediction raster from Random Forest model

I fit a Random Forest model to tabular data from test sites in R, and now would like to generate a raster showing predicted probability values using raster data corresponding to the same predictors (e....
2
votes
0answers
15 views

How to find external boundary of a bunch of vectors (using R libraries)

I have vectorized raster as in the image. This is actually 1419 polygons in SpatialPolygons class object. I'm looking for a method which would allow me to extract the one most external polygon (...
-2
votes
0answers
59 views

How to make regression kriging with elevation in R? [on hold]

I am looking to display this kind of map for my country, can someone help me do it. The goal is to map some weather data based on altitude for example : temperature, precipitation,...etc. My main ...
0
votes
1answer
32 views

Use sf (R) to return the overlapping area between two polygons by rows?

I have two sfc data frames with the same number of rows (individual IDs), but each data frame contains a polygon assigned to the individual. For example, dataframe1 may have a circle assigned neared ...
2
votes
3answers
697 views

Use function spplot

Does anybody know how to plot with "spplot" fuction two elements of diferents classes?. One element from "SpatialPolygonDataFrame" class and other from "raster" class.
3
votes
0answers
41 views

Open GPKG, query layers and save to new GPKG

I have recently started to use SQL and geopackages queries in R. I know how to open it, access the individual layers (geometry and tables), and select and process individual layers. But, I don't know ...
0
votes
0answers
12 views

How to output raster that contains band numbers of pixelwise maximum values?

I have got a ndvi_2015.tif with 12 bands of monthly ndvi values (band 1 = January, band 2 = February etc.), which I used to create a summary raster layer using the max() function in R. Now I want to ...
1
vote
0answers
15 views

How to crop raster in R without losing the colors?

I have a 2x3 raster in R, with values 1 to 6. library(raster) r <- raster(nrows=3,ncols=2,xmn=0,xmx=2,ymn=0,ymx=3,vals=1:6) colors <- c('red','orange','yellow','green','blue','purple') plot(r,...
0
votes
0answers
33 views

How to get compression of raster in R? [on hold]

I have geoTiff files which looks like be uncompressed. How can I read the value (using tif = raster(file)) to be sure what compression has been used for those files? For example, I have a file of 1.2 ...
0
votes
0answers
26 views

Finding spatial correlation between two variables? [on hold]

I have data on test scores and the income of different tracts, and I am trying to find if areas with lower test scores correlate to areas with lower incomes. I have tried looking at different ...
18
votes
2answers
7k views

Fixing orphaned holes in R

I'm trying to perform a union on a common field after merging two adjacent shapefiles. The shapefiles end up with at least one thin sliver of space between them. When I attempt a union I get the ...
-2
votes
0answers
53 views

Extracting data (Longitude, Latitude and Elevation ) from raster using R [on hold]

f <- 'C:/Users/KOTA/Desktop/Elev/Elev_KM.tif' r <- raster(f) Lat.Lon=coordinates(r) z=values(r) DATA=data.frame(Coord=Lat.Lon, Elev = z);DATA Coord.x Coord.y Elev 1 43.104 -11.304 ...
0
votes
0answers
33 views

Auto zoom when uploading shapefile R / Leaflet

I would like to configure an automatic zoom at the canvas of the shapefile layer that I upload. For that it would be necessary that a function automatically detects the latitude and the longitude of ...
1
vote
1answer
112 views

Layer names changed after reclassification of rasterstack, R

Following one of my previous questions about looping through a rasterstack (here), I now face a different issue. My initial rasterstack had dates as names (e.g. X2000_05_08.1) and I reclassified it in ...
0
votes
0answers
36 views

Using all NetCDF file variables?

I am working in R,using a few packages as Raster, ncdf4, Biomod2, ggplot... I am trying to use all variables that are in a NetCDF file. This NetCDF file has 12(months)*5(years)=60 Rasters. I get ...
1
vote
0answers
15 views

How to recognize original group from unified set of polygons in R

I have simple question. How can I know the original group after apply z = sf::st_union(x, y)? I have 2 sets: length(x[[1]]) = 4253, length(y[[1]]) = 91. Finally, I have z of lenght 411 but don't know ...
0
votes
1answer
790 views

For loops + boxplot for raster?

I have several Rasterstacks (b1_mask, b2_mask,...) of several layers representing only a determined pixel-intensity range. (So point "A" in some layers is "NA" - in others a "value" of that certain ...
0
votes
1answer
46 views

Input points shapefile in shiny app

The application I created allows me to import a polygon shapefile into my Leaflet map. However, I would like to set up a point shapefile import on the same button. I tried several attempts, especially ...
0
votes
1answer
38 views

Mask with ring polygon in R?

I'm trying to mask a raster with a ring polygon using the function raster::mask, but only recognizes the outer edges of the polygon, can anyone help me with this? I only need the pixels within the ...
0
votes
0answers
11 views

Copying polygons from lists of polygons to one SpatialPolygon list in R?

I do not know how to regroup polygons from SpatialPolygons list in the following manner: I have object rtu: > rtu class : SpatialPolygons features : 81 extent : 450685, 458760, ...
0
votes
1answer
37 views

Using R with Leaflet and Shiny to produce WMS?

I've have been using R with Leaflet and Shiny to produce a web map that is accessible to the public online. It is a real-time air temperature map of Tasmania, Australia based on current Bureau or ...
3
votes
1answer
2k views

Overlaying lines and aggregating their values for overlapping segments using R?

I have a number of routes (5 in this example data) stored in a SpatialLinesDataFrame called r. These have different origins but all converge on the same destination (Manchester Airport): Each ...
-1
votes
0answers
21 views

SurfaceArea function of R giving very big unacceptable area for DEM?

I have been trying to calculate DEM area using surfaceArea function of R. It is giving a very high unacceptable erroneous area. I have a 10 m by 10 m USGS DEM file. I read the DEM using raster() ...
1
vote
0answers
18 views

Creating a 3D TIN or similar 3D Delaunay triangulation in R

Background: I have topographical datasets with height information as a starting point. The endgame is to create a dataset of triangulations which I can use to import into Parasolid to be used further ...
1
vote
0answers
13 views

Easy way to plot separate groups of SpatialPolygons in R

I have SpatialPolygons grouped by 81 polygons and in each there are some other Polygons I'd like to plot them group by group but have little trouble with it. > rtu_spl class : ...
0
votes
0answers
11 views

Setting tiles as relative to VRT in R gdalUtils

I'm using VRT files to mosaic many separated tiles over my study region. I'd like to set an additional argument in gdalbuildvrt function from gdalUtils R package. This additional argument is used to ...
0
votes
1answer
32 views

After I give kring command, this error comes up: data item in gstat object and newdata have different coordinate reference systems

> library(gstat) > library(readxl) > library(sp) > library(rgdal) #2013(FATALITIES) data <- read.csv("C:/Users/sbs/Desktop/Study/RA/Accident analysis/New folder/Iowa total crashes ...
2
votes
1answer
36 views

Using viewport rotate in R?

I am trying to rotate a viewport object in R. However, I end up getting boundaries for the rotated object. Any idea as to how to rotate but not end up with these boxes? Below is the code. m_cont, ...
4
votes
0answers
35 views

Quantifying similarity between two independent areas?

I'm assessing areas for suitability for species relocations, so essentially I'm looking to quantify how similar a possible relocation site is to a source site in several metrics. The species may ...
2
votes
1answer
32 views

Batch reading features from many Geodatabases in R

I would like to learn to batch import from many geodatabases at once and merge the files together into a new unified shapefile. All of the GDBs and Features have a similar name and file structure. For ...
0
votes
1answer
25 views

Order features in a spatialpolygonsdataframe in ggplot2

I have a spatialpolygonsdataframe with many overlapping features. I want to create a map in which the smaller features are displayed on top of the larger ones so that the small ones aren't fully ...
0
votes
2answers
156 views

Land Cover Change Classification in R

I have two Land Cover (LC) classification raster over the same area and the same cell size. One from the year 2018 and the other from the year 2014. Both raster are classified with the values 1 - 6, ...
6
votes
3answers
4k views

Extracting values from raster according to Lat and long of values?

having 12 files with 12 hdrs for one year: these files are raster (projected WGS84,lat long): samples = 1440 lines = 720 bands = 1 header offset = 0 ...
0
votes
0answers
30 views

Overwrite my shapefile in a temporary file

I would like to save my shapefile in a temporary file (named after the name of the shapefile). I would like this one to be saved after the transformation of the coordinate system. For the moment, my ...
3
votes
2answers
327 views

random sample of raster cells based on multiple classes in R

I have a raster dataset that is classified into vegetation classes. I would like to randomly sample from the dataset based on the vegetation classes, but not sure how to do it. Here is some example ...
60
votes
6answers
140k views

Opening shapefile in R? [closed]

I need to open a shapefile from ArcMap in R to use it for further geostatistical analysis. I've converted it into ASCII text file, but in R it is recognized as data.frame. Coordinates function doesn't ...
0
votes
1answer
604 views

spTransform error (unable to find inherited method for function spTransform)

I am trying to reproject a shapefile. For example, the land shapefile from Natural Earth. library(sf) shape <- read_sf(".../ne_10m_land.shp") shape_proj<-spTransform(shape, CRS("+proj=gnom +...
0
votes
1answer
109 views

How to extract raster attributes by lat/long location?

How can you extract an attribute value from a raster from a point (lat/long)? Example data: Raster with attribute table - value of interest is temperature I have a list of points with lat/long ...
0
votes
1answer
10 views

Plot GeoTIFF using tm_rgb from R tmap package

I've exported a raster object from QGIS into GeoTIFF format and imported it into R as a raster brick using the brick() function from the raster package. The file is too large to share but it imports ...
2
votes
5answers
1k views

Find nearest point along polyline using 'sf' package in R

This is a follow-up question related to my earlier post about using the sf package to split polylines using nearby points. I have 450 points with XY coordinates and a large river network (~214,000 ...
1
vote
1answer
24 views

How to build polygons from buffered points and merge overlapping ones using R?

I have a sample of 3 groups of points which are similarly spread within their groups. > pts x y [1,] 453067.5 364073.5 [2,] 453066.5 364072.5 [3,] 453068.5 364072.5 [4,] ...
1
vote
0answers
19 views

How to convert from Large RasterLayer to Formal RasterLayer class in R?

I'm a bit confused about types here. While I'm loading a image: tif = raster(paste0(path)) I get some "Formal Class RasterLayer" object. But while I change it's matrix of values, for example: idx &...
-1
votes
1answer
39 views

Converting Kelvin to Fahrenheit in raster stack using R?

I have a raster stack with 372 layers with Kelvin temperature. I want to convert Kelvin to Fahrenheit. I know the function, but do not know how to adjust the code so it can be applied to all layer in ...
3
votes
1answer
51 views

gIntersection error: linearRing not created

I am trying to do something relatively simple but with large shapefiles. I have a shapefile of protected areas in the USA: and watershed boundaries: I want to calculate the percentage and ...
6
votes
4answers
6k views

Dissolving ploygons in QGIS or Grass to new polygons of defined population sizes?

I have a shapefile with 3800 polygons representing the smallest administrative areas in Ireland. Many of these, in rural areas, have tiny populations, under 100 people. In urban areas, all would have ...
0
votes
1answer
69 views

Performing trend analysis with R?

I have data of monthly temperature for 60 years. I want to analyze the trend for the monthly temperature in R. How do I construct R Code which would analyze monthly trend over the time series to ...
1
vote
1answer
35 views

Save a shapefile in a temporary file

I would like to add a line after the transformation of my shapefile in order to save it in a temporary file. uploadShpfile <- reactive({ if (!is.null(input$shp)) { inFile <- input$...
1
vote
1answer
96 views

R levelplot: How to shade some pixels out to show statistical significance

I am posting this also on stackoverflow because the topic is in the middle between GIS and R programming. I need to include statistical significance in a map in R using rasteVis, which is based on ...
0
votes
0answers
21 views

Extract time series from NetCDF stars proxy object

I'm trying to extract a time series from a netCDF file opened as a stars_proxy object in R. Looking at the raster to stars mapping table, I should use the aggregate function. But I'm getting a CRS ...