Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [r]

Statistical computing language and software environment.

1
vote
0answers
15 views

R tmap: how to remove blank space when using `tm_facets()`?

I am using R package tmap to plot maps with multiple facets, using tm_facets(). It seems like space is not maximally used: there is a lot of blank/unused space on the resulting plot. Is that a ...
0
votes
1answer
22 views

gdal_translate in R changing the cell resolution of extracted subdataset from HDF

I'm trying to extract subdataset from MODIS LST HDFs using following code. library(gdalUtils) HDF_list = list.files(path, pattern= "\\.hdf$", all.files=FALSE, full.names=TRUE,recursive=FALSE) ...
0
votes
0answers
31 views

Merge shapefile data within the same spatialpolygonsdataframe in R, when not all data have the merge column populated?

I have a 156Mb shapefile of New Zealand polygons down to the individual suburb level. There are 7,369 polygons. Each polygon has a unique ID (1...7369) in an ID column. There is a Suburb column ...
1
vote
0answers
36 views

Importing CSV to Carto from R?

I would like to import a csv file to my Carto account using R. I know the csv has been generated, and I'm able to save it in other locations. Running the code to upload this file to Carto appears to ...
4
votes
1answer
63 views

Using if statement in R script within QGIS

I am creating an R script in QGIS and I am facing an issue with an if statement. First, I declare the input from the user ##Which_S2_bands_do_you_want_to_use=selection 2 3 4 5 6 7 8 11 12;2 3 4 8 11 ...
2
votes
1answer
61 views

Why does R set CRS inconsistently?

I'm running into a situation (using R on MacOS) where sf() is giving different levels of precision on the CRS. This causes problems for geospatial operations, as indicated below with st_crop(). Can ...
2
votes
1answer
54 views

Automatically get an adequate projection system based on a bounding box [closed]

The website http://projectionwizard.org/ offers a very easy way to get an appropriate projection system based on a bounding box and choosing whether projection criterion should be equal-area, equi-...
0
votes
0answers
29 views

Randomly move (and rotate) an sf polygon within a broader extent using R

I have an area of interest within which I have multiple polygons (two in the example below). I would like to randomly move each of the polygons so that they are completely within the larger extent and ...
1
vote
0answers
36 views

Reclassify raster conditional on attribute values in R

My raster has nonsensical values (based on combination of multiple rasters in previous steps), with attributes maintained (again, due to combination of rasters in previous steps), see below for sample ...
2
votes
1answer
39 views

Using multiple Boolean variables in R script within QGIS

I am testing the capabilities to run my R script in QGIS. I am facing a basic question. I am defining a dropdown menu with all the parameters for a specific variable: ##test1=group ##Sensor?=...
0
votes
0answers
27 views

Plotting a half degree grid on a map and extracting species information using R

I have a dataset which looks like this(subset): Latitude Longitude Species -34,68871595 20,0331831 Ischnura senegalensis -34,59082383 20,05421162 Ceriagrion glabrum -34,59082383 ...
4
votes
2answers
55 views

Removing noise from point cloud with lidR package

I have unclassified Terrestrial Laser Scanning (TLS) point cloud data which has some noise. Is there a function in the lidR package which can be used to remove noise?
4
votes
1answer
46 views

Parallelize Extracting Large Raster Values (one band) to Points

I have sf data with single point geometries (points) and a 23,000 x 18,000 elevation RasterLayer with a single band, loaded from a geotiff (elev). They have the same CRS. I want to extract the ...
1
vote
1answer
49 views

Executing r.viewshed (GRASS) in R

What libraries do I need to execute this GRASS tool (or any other) from an script in R ? Has anybody try to compare performance between using r.viewshed from QGIS and r.viewshed from R ?
0
votes
1answer
32 views

Convert geometry set to simple features collection using `sf` in R

How can geometry set objects be converted to simple features collection objects with the package sf in R? I want to add attribute data to the geometry but am prevented from doing so because geometry ...
1
vote
1answer
31 views

Addition and subtraction of rasterbrick objects in R

I have two rasterbrick objects showing precipitation. Both have longitude and latitude dimensions of 144 x 72. The first (brick1) has 478 monthly time layers (39 years, 10 months) running from Jan ...
1
vote
1answer
55 views

Transforming admin units into hexagons: the assignment problem

I have an administrative tessellation with about 8000 units (the Census tracts of California) and, for the sake of visualisation, I would like to transform it into regular hexagons (or squares). I ...
3
votes
0answers
25 views

Calculate the length of shared boundaries between multiple polygons

I am trying to calculate the length of shared boundaries between multiple polygons in R. Specifically, I would like to calculate the shared boundary length of all the polygons in Census Place GIS data ...
0
votes
0answers
49 views

R : How to build heat-map based on ratios with leaflet package

I'm just starting to try out some things in the GIS arena and perhaps this question is a concept mistake. I've read the post R : How to build heatmap with the leaflet package and the fantastic answer ...
0
votes
1answer
23 views

Second-level neighbors of large polygon (neighbors' neighbors)

I have a large-ish set of polygons and am after identifying second-level neighbors of each, that is, the neighbors of the neighbors of each polygon (distinctly, i.e. the 2nd-level neighbors cannot ...
-1
votes
0answers
37 views

Creating and combining polygons in R with sf

I'm getting a bit confused by a few supposedly basic tasks involving polygons in R. I'm tying to keep everything in sf, but if I need to switch to sp that's ok. Firstly, I'm creating some polygons ...
0
votes
1answer
27 views

get intersects of indexed grouped polygons between 2 SpatialPolygonDataframes in R

I am testing 2 different methods (m2b & hmm) for classifying the movement behaviour of penguins to ultimately classify feeding behaviour from gps points and from these create kernel polygons to ...
2
votes
1answer
77 views

Error from aggregate function from the R package sf

I am currently reading the new (and free!) book by Edzer Pebesma and Roger Bivand (you can find it here). In chapter four they describe how one can aggregate all the measurement stations within one ...
0
votes
1answer
56 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, ...
0
votes
1answer
67 views

Counting number of polygons within polygons using R?

I have two huge shapefiles. One contains polygons of one kind of vegetation and the other one representing a grid. A situation as follows but, of course, much bigger: I need: the efficient way to ...
0
votes
0answers
26 views

tmap::tm_facets() in interactive mode in html R Markdown file, small multiples variable title renders in wrong place

If you look at this reproducible snippet, when knitting, the first small multiples set renders both its and the next small multiples' title variable in the first set of maps. Here's the reproducible ...
1
vote
0answers
28 views

Creating decision rules on pixel level in time series layer in R? [closed]

I am using Landsat 5, 7, 8 images and RStudio. My goal is to compute the disturbance in a given area using the Vegetation Change Tracker (VCT) algorithm. I would like to ask you if you could provide ...
0
votes
1answer
86 views

dist2Line - Error in dist2Line(…) could not find the function “dist2Line”

I have a csv file with points (about 20 millions georeferenced points) and a line shapefile. I want to find for each point the closest distance to the line. The line is not a straight line it's ...
2
votes
2answers
33 views

r raster: unique returns duplicated values?

I am using function unique() in package raster. I expect it to return the unique values for each layer, yet I get duplicated values... is that the expected result, or is there an issue somewhere? ...
2
votes
2answers
123 views

Plotting spatial points data in R?

I have some kind of noob question: how do I plot spatialpoints dataframe in R using spplot (or ggmap) based on column values? let's say we have this: library(sp) data(meuse) v <- ...
1
vote
0answers
41 views

R process: Zonal Stat Raster has No Data Values vs Arc output

I am trying to re-create my ArcGIS Zonal Stat model with R All my files will be 30m pixels; 18000 x 18000. I have used R two different ways to create the output and both create NoData values in the ...
0
votes
1answer
24 views

Subset raster stack with logical indeces R

Is it possible to subset a raster stack by indexing on a logical vector? r1 <- raster(nrow = 100, ncol = 100) r1[] <- round(runif(ncell(r1), 1, 4), 0) r2 <- raster(nrow = 100, ncol = 100) r2[...
1
vote
2answers
29 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
1answer
79 views

Exporting crown boundaries from tree segmentation in R?

I am using lidR package to segment my trees using lastrees directly from the points clouds. The function works fine, however I would like to export to vector file the canopy boundaries from ...
3
votes
1answer
51 views

Watershed a catalog RasterStack in place of RasterLayer in lidR?

I want to use watershed with lidR package on a catalog. I paste this command: rep <- "/home/lasfiles" new_ctg <- catalog(rep) lidR:::catalog_laxindex(new_ctg) opt_output_files(new_ctg) <- ...
0
votes
0answers
34 views

Pixels, distance to line (negative left, positive right) r

I am using r to do some spatial analysis. Here is my project, I am using raster files (that contain information on land use) and a polyline (which is a border between two regions). I am analyzing ...
1
vote
1answer
35 views

Polygon to line (polyline) in R

I am looking for an easy way to convert a polygon to a polyline in r. I have tried this but dit not succeed: polygon <- readOGR("~path/", "polygon.shp") polyline <- as(polygon, "...
0
votes
1answer
33 views

R and Mapview: How can I chose different colors for different layers?

Here is an example: library(sp) library(mapview) data(meuse) d<-st_as_sf(meuse,coords = c("x","y")) d1<-d[sample(nrow(d),20),] d2<-d[sample(nrow(d),20),] mapview(list(d1,d2)) Both layers,...
3
votes
1answer
32 views

Is it possible to default an output directory for R Scripts in QGIS 3.4.4?

I am currently running R Scripts through the Processing R Provider plugin on QGIS 3.4.4. I was wondering if it is possible to to set a default file path for your vector output that is the same as ...
0
votes
0answers
33 views

Empty output rasters when running the bfmSpatial function in R

I have 131 monthly MOD11A2 (LST) images and I want to make a time series analysis using the BFAST Monitor. The images came from the average of the original 8day products. I have made them a time ...
2
votes
1answer
46 views

Tolerance setting in watershed segmentation(EBimage/lidR) in R

Can anyone here explain to me what the "tol" parameter in the watershed algorithm implemented in the BioConductor package EBImage (and lidR) does? I find the explanation in the EBImage help difficult ...
1
vote
0answers
20 views

How to include duplicate samples (same locations, different temporal sampling) in Geographically Weighted Logistic Regression? [closed]

I want to assess local most important predictors for a specific event within a region. The same locations (grid) were all sampled in two different time occasions. I am assuming predictors to be ...
1
vote
0answers
30 views

Warning message in raster::rotate(): “this does not look like an appropriate object for this function”

I'm attempting to rotate a stacked raster using the raster package in R. The raw stacked raster looks like this: When I attempt to rotate the raster to change the longitudinal scale from 0-360 to -...
1
vote
1answer
45 views

How to split polygons by overlapping feature?

How can I divide the multiple overlapping polygons into multiple non-overlapping polygons? Here is an example: I would like to divide the long yellow polygon in the image into 3 polygons based on ...
1
vote
2answers
54 views

How to make a raster gradient in any direction in R

How can I create a raster, where the values increase in a certain direction? I know how to do the "main" directions with full 90 degree steps, as illustrated in the image. But I would need some help ...
0
votes
0answers
23 views

Slider with tm_shape?

Is there any way to program a slider for each year of a panel data set with tm_shape? I know that this is possible with leaflet as described on a website for Geocomputation with R three quarters down ...
0
votes
1answer
38 views

Why does transformation of coordinates to UTM fail with GDAL in R

I have a CSV-list of coordinates that I know are coordinates in Gauß-Krüger (Transverse Mercator) and I want to transform them to UTM in R with GDAL. I read the csv in, separated the columns, added ...
2
votes
3answers
90 views

Coordinate system for shapefile, no .prj file, using R

I am trying to use the shapefiles found on this page for oil & gas data from the Netherlands: https://www.nlog.nl/en/files-interactive-map from table at the bottom with "ARC_grid" and "Google ...
1
vote
0answers
43 views

Orthorectification with R

How can I orthorectify an oblique image of a flat landscape when I know the conditions of the photo (coords, height, direction, lens, etc)? I would like to perform this kind of stuff from GRASS ...
3
votes
1answer
36 views

clustered st_convex_hull

I am trying to obtain a polygon from each group of points "G" but I obtain only one single polygon for all the points. I grouped data by the G variable but it doesn't work. library(sf) library(...