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.

11
votes
3answers
794 views

How to anonymise a gps file?

Imagine you have a GPS trace that you want to make anonymous, in the legal sense. How would you do this? Is snapping to the nearest x distance and stripping out the time enough? Are there ...
-2
votes
0answers
21 views

Reproject lat/lon to coordinate system [on hold]

I have an nc file for precipitation using latitude (degrees north) and longitude (degrees east). I now want to reproject this to SWEREF99TM coordinate system. I have tried in R, ArcMap and ENVI, ...
0
votes
0answers
21 views

After installation of gdal (to enable PostGIS tools) on Windows, sf gives warnings about dependencies?

To get a PostgreSQL/PostGIS setup working on my Windows 10 machine I had to manually install GDAL using these instructions: https://sandbox.idre.ucla.edu/sandbox/tutorials/installing-gdal-for-windows ...
2
votes
1answer
34 views

Counting points in polygons with sf package of R? [on hold]

I'm quite new to R and especially GIS with R. So recently I had to proceed to a quite simple analysis: counting health centers (points) per administrative unit (polygons). Quite common process in ...
1
vote
1answer
39 views

Combine bands with shapefile [duplicate]

I want to create a data frame in R combining the bands wth the shapefile. The final file will have the pixels as rows, the bands as well as the other columns from the attribute table from the ...
0
votes
1answer
35 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 ...
1
vote
2answers
163 views

Zooming in on raster file in R

I used the nsidcICE function located here: https://github.com/cran/raster/blob/master/R/nsidcICE.R and the following code to open a sea ice raster file. However, I would like to overlap vector points ...
0
votes
1answer
34 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 ...
2
votes
1answer
116 views

Handling raster data in a “rotated pole projection” with R?

My question is about using R to transform raster data from a rotated pole projection to a regular latlon grid - and then plotting it. I am working with data from a numerical weather model, which is ...
0
votes
0answers
14 views

Day of the year values of pixels

I am trying to implement TWDTW model in R with dtwSat package. (You can find all the data here: https://www.jstatsoft.org/article/view/v088i05) In page 12, the paper gives a method to produce a land ...
0
votes
2answers
34 views

Reading shapefiles using for loop: Error in readOGR() : length(dsn) == 1L is not TRUE

I'm using a for loop to read in multiple shapefiles within a directory and manipulate them individually. Presently I cannot do this because the for loop results in the error: "Error in readOGR(...
2
votes
0answers
17 views

Split a tmap legend and display in two locations

I would like to split the legend of a tmap object, so that one of the two elements is in the top left, and one in the top right. I have been through the documentation of tm_legend, but could not find ...
2
votes
1answer
35 views

Split a polylines according to a specific point in R

I have 2 distinct spatial objects: on one hand I have a SpatialLinesDataFrame on the other hand I have a SpatialPointsDataFrame Considering one line and one point that intersects that line, I ...
3
votes
0answers
42 views

How do I use lastrees on a catalog with a function requiring a CHM raster?

I'm still fairly new to using LiDAR data and R, so please let me know if this isn't clear. I am using the lidR package to segment individual trees over a large landscape. I have been using the ...
1
vote
1answer
46 views

Decreasing distance between legend's items in R— round 2

In response to the question posted here, Farid Cher provided a slick modification to choro.legend that enabled R users to control the amount of space inserted between legend colors and their ...
-1
votes
0answers
11 views

Fill missing dates and hours in time series using R? [on hold]

I have a data series ranging from 2013 to 2017, hourly. The data series has many gaps in some days and hours. I need to fill these gaps with blank or NaN. How can I do this using R? In this link ...
2
votes
1answer
59 views

Writing raster with attribute table in R?

I fitted a species distribution model and predicted the suitable habitat using this model, and then I got a map plotted in R. I tried to save this prediction as a raster, using code: rf<-...
1
vote
1answer
56 views

Estimate the spatial relationship between two sets of points

I have two sets of point data, structured like below. Table A long | lat | class ... | ... | A ... | ... | A ... | ... | A Table B long | lat | class ... | ... | B ... | ... | B ... | ... | ...
1
vote
3answers
1k views

Is there an equivalent of dplyr::bind_rows (or the old plyr::rbind.fill) for spatial objects?

bind_rows can append dataframes even when they do not have identical columns. It fills any non-matching columns with NAs. Is there an equivalent for spatial point data frames in R? I have two ...
3
votes
0answers
43 views

Create foldable section in QGIS tool using R script

I am developping a GUI tool in QGIS using an R script and I am wondering how to add this kind of foldable section in the graphical interface
0
votes
1answer
22 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 ...
1
vote
1answer
42 views

Splitting an administrative region into given number of parts

I have the following plot. I want to divide the administrative region into given number (say 20) equal parts. library(maps) data(world.cities) Pakistan <- data.frame(map("world", "Pakistan", ...
31
votes
3answers
14k views

How to perform Random Forest land cover classification?

This is a follow-up to a previous post: Machine Learning Algorithms for Land Cover Classification. It seems that the Random Forest (RF) classification method is gaining much momentum in the remote ...
2
votes
0answers
21 views

Smoothing MODIS LAI? [on hold]

I am trying to smooth 8 days LAI data from MODIS and managed to work around it with several algorithms such as loess, Savitzky–Golay, smooth.spline etc. This is pretty much going well if the level of ...
0
votes
0answers
17 views

Using BFAST Spatial algorithm in R?

I have 65 monthly MOD11A2 (LST) images. The images came from the average of the original 8 day products. I have made them a time series stack using the timeStackMODIS function of the bfastSpatial ...
1
vote
1answer
72 views

Interpolation Algorithm with gdal in R

I'm currently having some problem while trying to create a GTiFF file. require(raster) require(sp) require(rgdal) require(gdalUtils) library(rgeos) map <- readOGR ('MyShapefile.shp',layer='...
0
votes
0answers
15 views

How long should a spatial mixed model with spaMM take?

I have a dataset that's about 5k lines long, with a binomial response variable, five continuous fixed effects, and one random effect with seven levels. I initially ran a model with glmer{lme4}: glmer....
0
votes
1answer
49 views

What is the meaning of ' QC_val=0x…' in the cleanMODIS of the bfastSpatial package?

I am using the bfastSpatial package in R. One of the parameters that I have to set is the QC_val=0x 'a number'. I do not understand what number I have to insert. I am using MOD11A2 product (MODIS LST ...
0
votes
1answer
113 views

Simplifying a SpatialPointsDataFrame in ggplot world

I've been working on a map showing lines running across Europe. Each line is coming from a GPX file, parsed in like so: spdf <- readOGR("data/file.gpx", layer = "track_points") Now, if I plot the ...
1
vote
1answer
21 views

What unit is returned by the ncf::correlog function?

I'm using the correlog function from the ncf package to figure out the distance between points at which spatial autocorrelation isn't detected. I was wondering what unit was being returned in the ...
3
votes
2answers
656 views

Backtransformation of kriging predictions and variances

I'm not sure how to back-transform log-normal kriged results. This example using the "meuse" data shows how to make variogram and use it to get kriging predictions (and variances) using the popular '...
0
votes
1answer
64 views

Using R and SQL together in sf - what is an efficient workflow?

Do anyone have any tips/tricks/workflows for working with an SQL query within a read_sf/st_read function call in RStudio? (I am struggling to figure out how to make a postgrsql/postgis example ...
0
votes
2answers
48 views

Dissolve only overlapping polygons in R using sf

I extracted information from open street map that contains many polygons, some of them overlapping. I want to union all polygons that overlap with other polygons. This question has been asked before ...
3
votes
1answer
36 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 ...
2
votes
1answer
839 views

Efficiently process large rasters

I am trying to process some raster layers from Global Forest Change (https://earthenginepartners.appspot.com/science-2013-global-forest/download_v1.4.html, data produced by Hansen et al., 2013). ...
0
votes
1answer
272 views

Plotting and/or exporting VIIRS SDR DNB data as GeoTIFF in R?

I already asked this question @stackoverflow however, perhaps it fits better here, due to the spatial nature of VIIRS data and the hdf5-eos file format. Im looking into how to handle .h5 (hdf-eos) ...
0
votes
0answers
24 views

Multiple break levels in color legend

Please look at the color legend of the image: This image was plotted in ferret program, which has different breaks, like 0-3 with 0.5 interval, 3-9 with 3 interval, 9-10 with 1 interval, 10-20 with ...
0
votes
0answers
10 views

Why does an Error occur when Publishing Leaflet with Shapefile to ShinyApps.io?

This shiny leaflet works in rStudio, but when I publish to shinyapps.io, I get this error. This is the R code for this : ##Sheridan County library(shiny) library (leaflet) library(readr) library (...
3
votes
1answer
3k views

Legend colour with specific value

I have model plotted in R base<- raster("example.tif") plot(base) image I'd like to change value (0,5,10,15,20,25) breakpoints<-c("0,5,10,15,20,25") plot(base,break=breakpoints) Error in ....
1
vote
0answers
27 views

Reset / Clear button, upload shapefile on R Shiny

I would like to create a button that would allow me to reset a fileinput, and delete the previously imported shapefile. Here is my code: server.r: library(shiny) library(shinydashboard) library(...
0
votes
1answer
122 views

Rearrange plotorder of SpatialPolygonsDataframe

I have a SpatialPolygonDataframe (loaded with readOGR) I want to plot in either tmap or leaflet. A lot of the polygons are overlapping, and the smaller polygons are completely covered by larger ...
1
vote
0answers
34 views

Extract Raster Values with points in R

I have a raster file with gridded population raster26 class : RasterLayer dimensions : 132, 140, 18480 (nrow, ncol, ncell) resolution : 699, 931 (x, y) extent : 2248290, 2346150, ...
2
votes
1answer
21 views

Using shapefile from MT.gov in Leaflet with R?

I would like to use shape files from http://ftp.geoinfo.msl.mt.gov/Data/Spatial/MSDI/Cadastral/Parcels/Sheridan/ However, the shape files are not showing up. My code is working with files from a ...
-4
votes
0answers
23 views

Urban change modelling using Rstudio [closed]

Any one know how to find lulc change change prediction using Cellular automata and markov chain in Rstudio like we did using Idrisi Terrsat?
1
vote
2answers
74 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
0answers
10 views

Is there a way to get coordinates from a map using Leaflet on a Shiny app in R by clicking, but without a marker?

In this example I have some polygons and I click on the centroids (variable centroides) to get values from a raster (variable s). server <- function(input, output, session) { points <- ...
1
vote
1answer
141 views

What's the difference in these two shapefiles?

I'm trying to plot points on these maps in R, with points from "Coordinates" in the same folder. The WL.shp plots fine with the data, but the NG.shp (which should only be larger and of the same area +...
5
votes
1answer
2k views

How to use Igraph with leaflet for R?

I try to draw a graph in map with R code : df<-data.frame("from" = c("Lyon", "Toulouse", "Paris", "Marseille"), "to"= c("Paris", "Paris", "Marseille", "Toulouse")) meta <- data....
0
votes
1answer
21 views

Write a text file per image with same name in R

In R I would like to create a text file for each picture I have in a folder and with the same name. By example: Picture 1.png - Picture 1.txt Picture 2.png - Picture 2.txt But the text file name I ...
0
votes
1answer
52 views

Mismatch in area calculation using R and ArcMap?

I am new to spatial statistics using R. In this scenario, I am trying to calculate the polygons area with in a shapefile by usingrgeos::gArea and compared with ArcMap calculate geometry value. both ...