Questions tagged [r]

Statistical computing language and software environment.

0
votes
0answers
15 views

How to get compression of raster in R?

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 ...
-1
votes
0answers
42 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
21 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
109 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
30 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
14 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
789 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
43 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
34 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() ...
0
votes
0answers
16 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
10 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
29 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, ...
2
votes
0answers
20 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 ...
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
24 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
153 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
326 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
139k 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
588 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
107 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
21 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
49 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 ...
0
votes
0answers
16 views

How to bind points with polygons extracted from raster using R [closed]

I have big tiff and load it using raster: tif = raster(paste0(path)) Next, I can extract all the polygons from the file (using some value P of interesting layer value): rtp = rasterToPolygons(tif, ...
0
votes
0answers
29 views

How to calculate mean for each raster layer in a stack? [closed]

I have a data of monthly temperature (with several values in each layer (i.e temperature values for a month)for 31 years (372 layers). Now have to calculate mean for each month for 1980-2010 and save ...
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
95 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
20 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 ...
2
votes
1answer
42 views

Configuring lidR catalog to overwrite raster output (with different extension)?

I have a small issue with configuring the lidR package for parametrizing the extracted raster files with grid_metrics() function. My question is how to set in the catalog options that: be able to ...
4
votes
1answer
24 views

Using lidR to count number of pulse returns at different intervals?

I am trying to get the number of pulse at different height interval. I have used the lidR package to do this before with the code below but it seems that recent update in the package breaks my code. ...
0
votes
1answer
49 views

Setting origin raster to resample using R?

I need to resample a raster from nrow= 467, ncol=805, res=0.0416667 degree to nrow=2335, ncol=4025, res=0.00833333 degree. Basically make the pixel size smaller, because I have too many small polygons ...
1
vote
1answer
23 views

R: rasterize SpatialPolygonsDataFrame and keep factor field

I want to rasterize a SpatialPolygonsDataFrame and keep the values of a factor column. Consider the following code (from Processing vector to raster faster with R): library('raster') library('rgdal'...
1
vote
3answers
39 views

Error in Converting XY Coordinates to Lat-Long Using r proj4 Library

I am trying to write a script that will allow my colleagues to easily convert XY coordinates into lat and long. The idea here is to take a spreadsheet with only X and Y available and create a new ...
1
vote
0answers
34 views

Raster projected in Google Earth Engine showing weird values within R

I classified a raster in GEE and I am trying to work with the same within R. I have 7 land cover classes and when I view the output in R, I get something that does not make sense. Please see the ...
2
votes
3answers
145 views

R - Create multiple linestrings from multiple coordinates

I have a dataframe with two sets of coordinates X,Y and prevXal,prevYval and I would like to make linestrings column wise, and create an sf object of the same number of linestrings as rows in the ...
3
votes
0answers
43 views

Test the relationship between two point patterns

I have two point patterns obtained from medical images. Points are used to represent cell markers. By visualization, the point pattern A is extremely possible to be a subset of point pattern B. So is ...