The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [r]

Statistical computing language and software environment.

Filter by
Sorted by
Tagged with
2
votes
1answer
34 views

Calculating destination point using sf package

I have the following data: lat <- c(-1.404361, -1.403221,-1.387369) long <- c(35.35373, 35.35047,35.35171 ) distance <- c(220,150,300) bearing <- c(67,27,159) df <- data.frame(lat,...
2
votes
1answer
43 views

Creating minimum bounding geometry using the convex hull method in R

I would like to create a small enveloppe around a set of polygons that encloses around them. I would like to avoid using the bounding box function (example below) because it would be too big. Rather, ...
1
vote
1answer
29 views

Spliting a polyline object by line ID based on @data values

I am trying split a SpatialLinesDataFrame by attributes I merged into @data I extracted a list of line ID's associated with a points data frame and aggregated them by category and line ID in dplyr # ...
1
vote
0answers
27 views

Generating randomised coordinates data set using R?

I am looking to produce a data set of randomised coordinates points that can easily be generated in R with something like: Seqlat <- seq(from=-90, to=90, by=.01) Seqlong <- seq(from=-180, to=...
1
vote
1answer
32 views

Exracting data fromSpatialPolygonDataFrame conditionally in R?

For some research I am working on, I have a dataframe called charters of charter schools in New Jersey. Simplified it looks like this: school.name school.id district.id lat ...
0
votes
0answers
22 views

Wrong northing value: standardizing with a correction by 10 000 000 meters

I'm trying to draw points on a map and I have a problem using the projections. I have no problem getting points from longlat to UTM. But it seems that there is a problem when specifying UTM zone 15M ...
1
vote
1answer
56 views

How to detect green areas in Google Earth imagery using R?

I want to detect urban green areas in Google Earth imagery, using R. I've already downloaded contiguous images and assembled them into a larger image. The above PNG image has 800x769 pixels, but the ...
2
votes
2answers
49 views

Can BFAST algorithm be applied to to a whole study area/ ROI?

I am working on identification of breakpoints in Landsat based NDVI time series (1990-2018). I am using The Breaks for Additive Seasonal and Trend (BFAST) algorithm which is a pixel based time series ...
0
votes
0answers
19 views

Generating envelope for Gcross function in R?

I am using R to generate envelope for the Gcross function. At first I used Gcross to generate the theoretical value together with true G(r) value with border correction, my codes are: Bind_ppp <- ...
1
vote
0answers
28 views

Speeding up spatial subsetting in R?

I need to subset a global fishing dataset to just have the fishing in the Pacific. Right now I have a shapefile of the Pacific and I am using the sp method of subsetting (see below) oceans <- ...
1
vote
1answer
57 views

Why do original colors in GEE images appear in different colors?

I seek help to understand why colors that I specified in Google Earth Engine (GEE) do not appear in raster objects in R. Let me explain the processes that I have been going through. The following ...
1
vote
1answer
21 views

Sampling stratified random points using R for accuracy assessment

I want to sample stratified random points using R. I found the sampleStratified function from the R raster package. This functions samples the same amount of points for each class of my ...
1
vote
1answer
29 views

Why does the AddGeometryColumn function not exist in RSQLite?

I am trying to add the geometry to a new table with the following statement: library(RSQLite) # db.sqlite was created with spatialite-gui con <- dbConnect(RSQLite::SQLite(), dbname = "C:/GIS/db....
0
votes
2answers
37 views

Rasterize multipoint geometry in R

I would like to rasterize data on protected areas for certain countries (e.g. https://www.protectedplanet.net/country/TH, download button is at the bottom of the page). The dataset contains two ...
1
vote
0answers
37 views

Map gridded rainfall data to lat-longs and extract daily rainfall data? [closed]

My objective is to create a dataset, wherein for certain locations (lat-longs) I need to report daily rainfall from 1950 to 2017. Rainfall data source: Indian Meteorological Department (IMD) daily ...
1
vote
1answer
18 views

Generating pattern in each of set of polygons using sp (r)?

I have an object of class SpatialPolygonsDataFrame, and for each polygon in the dataframe I have a number of points I would like to generate in that polygon (e.g. I have 130 polygons, and I have a ...
2
votes
0answers
36 views

R: How to get a filename list of raster layers in a geodatabase?

In R, how do we get a file list of rasters in a geodatabase folder? We know the case of vector layers as follow. library(rgdal) fgdb = "C:/path/to/your/filegeodatabase.gdb" subset(ogrDrivers(), ...
0
votes
0answers
16 views

Setting extent before stacking multiple TIFF files in R?

I downloaded 15 tiles from Earthdata of MOD17A2 (GPP). I converted the HDF files to TIFF formats via R software. Now I would like to stack them altogether, I am aware there are many questions related ...
2
votes
0answers
30 views

Row-wise Reprojection of SPDF in R [closed]

I have multipolygons that span across the globe. I was wondering if it was possible to re-project each row, i.e. each country/ ISO3 to a local projection, using a central grouping mechanism. For ...
2
votes
1answer
74 views

R (spatstat, sp, sf): Grid a single polygon, divide, alphanumeric labels based on column/row

I am trying to take a polygon and add grid lines over top, then divide the polygon into many polygons based on the grids. I've accomplished this through st_make_grid() and raster::intersect(). The ...
1
vote
1answer
42 views

Remove empty polygons from shapefile in R

I have a shapefile witch contains several empty polygons. I´m extracting values from raster file based in some polygons of this shapefile. But my loop stops at every empty polygon. Simple solution ...
2
votes
0answers
36 views

Stratified ordinary kriging using gstat and stars packages

The gstat package supports stratified ordinary kriging using sp objects as shown at https://github.com/r-spatial/gstat/blob/master/demo/examples.R (the code below). This year (https://r-spatial.github....
0
votes
0answers
21 views

Calculate the sinuoisty of a line

I have an sf polyline layer in R an would like to calculate the sinuosity (i.e. actual length of segment divided by the shortest distance between start and endpoint). Does anyone know of a function ...
-1
votes
1answer
39 views

How to convert missing values to the mean of the other values in R? [closed]

I need to convert the missing values of a column in a dataframe with the rest of values of this column, grouped by Districts and Month. This is a sample of my df1: Date Day Month Year ...
1
vote
1answer
45 views

Calculating total shared boundary between polygons based on their attributes?

I tried to do this over the weekend but had no luck - even after searching this forum. I'm trying to calculate the frontage (length of the property bordering the street) of a number of properties. I'...
0
votes
0answers
12 views

R: Creating custom polygons based on geom of subset data [duplicate]

I hope that I titled this question correctly. Reproducible code: library(tigris) library(leaflet) colorado <- counties("colorado") leaflet(colorado) %>% addProviderTiles("CartoDB.Positron"...
1
vote
0answers
33 views

Generate equal distanced sections on polygon

I generated a polygon by buffering a reference line. What I want to do now is generating multiple equal-distanced points along the reference lines, upon which to generate sections on the polygon. A ...
2
votes
2answers
48 views

Loading shapefiles for reprojection using sf

I'm trying to automate my workflow, but having trouble with one step. My data come as processed shapefiles saved in .RDA files; I load them to a PostGIS system, cleaning up little issues (spTransform()...
1
vote
0answers
14 views

Raster or Brick from nedf with lat lon = matrix

I have a netcdf file 3 dimensions, lat, lon, time : lat and long are matrix (nrow=263, ncol=512) time is vector of date the variable is precip observed at a given (lat, lon) and date What I would ...
0
votes
2answers
50 views

Convenient way to download MCD19A2 product using R

I want to download MODIS MCDA219 product. I have been downloading manually from https://ladsweb.modaps.eosdis.nasa.gov/ and https://earthdata.nasa.gov . As a new to R user, recently I have learn ...
2
votes
1answer
38 views

Creating random plots with coordinates within polygon using R [closed]

I am trying to create random plots in a polygon shapefile and then to plot it with index no as 1,2,3,... along with a legend comprising XY coordinates corresponding to each index no. Code example: ...
2
votes
2answers
45 views

Use Lat and Long to Zoom and Crop A Color GEOTIFF Based Map In R

I have a strong background in R but have only done limited GIS work. I have a color Geotiff file that I downloaded from the USGS Earthexplorer. It is a "LandsatLook Image with Geographic Reference". ...
0
votes
1answer
41 views

Could not find function “coord_quickmap” in R

I was trying to actually crop part of a country (example is Korea) using this code in R: korea + coord_quickmap(xlim = c(126.5, 128), ylim = c(35, 37)) However, this error appears.. Error in ...
1
vote
0answers
76 views

Enable WMS GetFeatureInfo request in Leaflet using R?

I've 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 ...
1
vote
0answers
22 views

Error while rendering Leaflet map on Shiny

I have been trying to reproduce a Leaflet map on a Shiny webpage. I have made this code so far: library(shiny) library(shinydashboard) library(leaflet) library(rgdal) library(dplyr) library(DT) Map &...
1
vote
1answer
38 views

How to convert a polygon to a polyline using the sf package in R?

I have some simple polygons that I would like to convert to polylines using the sf package in R. I have found st_polygonize to convert polylines to polygons but I cannot but the reserve operation. ...
1
vote
0answers
21 views

Extracting or masking of very large raster to reduce file size on disk?

I have a very large 8-band raster (339806 x 61704) that I cannot load to memory to manipulate (R, raster:canProcessInMemory indicates I need 4999.16 GB of ram to load this file). However, I only need ...
1
vote
1answer
52 views

Creating connected network of roads from overlapping roads using R?

I am trying to create a dataset of roads data to do shortest path analysis. To do this, my roads data needs to be connected: it should be possible to jump from one road to another. I am planning to ...
3
votes
1answer
70 views

R Code in QGIS - Stratified Random Sampling of Land Cover Classified Raster

I'm trying to write code using the Processing R Provider scripting in QGIS. The script is to perform a stratified random sampling scheme on a classified land cover raster image. The land cover codes ...
1
vote
0answers
14 views

Create ltraj in adehabitatLT Error

I'm trying to use adehabitatLT analyze animal movements. However, I'm having issues with creating a ltraj object in R. I have followed the as.ltraj() example in the documentation and I'm getting this ...
1
vote
0answers
41 views

Multiple Spatial Point Patterns, create “average” heatmap

I am using R's spatstat package to analyze spatial patterns of objects across plant leaves. Let's say I have 10 leaves, each with corresponding X,Y coordinates of the objects and a window in the ...
4
votes
2answers
560 views

Splitting polygons at narrowest part using R?

I have a dataset of polygons like this one: I would like to split these polygons in separate parts at their most narrow location (if they have one). For example the two small polygons should not be ...
1
vote
0answers
29 views

Check geometries in QGIS for multiple KML Files all at once in R or Python? [closed]

I am very new to GIS analysis so please bear with me. I have 2000 KML files. I am currently using QGIS Check Geometries function to generate the error report that consists of the following. A CSV ...
3
votes
2answers
61 views

Replacing values of raster in R to produce landuse-like raster map?

I have a raster Z with elevation values (0, 0.12, 2.12), which I created myself in R. I want to produce a land-use raster from these elevation values, i.e. if Z<0.12, I assign land-use class 1 to ...
1
vote
0answers
29 views

Set up R in QGIS 3.4 on Mac OS X

I'm trying to get R into QGIS on my mac. I've installed the plugin "Processing R Provider plugin" but I can't "get R scripts from online scripts collection". It has something to do with the all caps "...
1
vote
1answer
48 views

Extract raster files from VIIRS VNP02 files provided in NetCDF format?

I work in R with HDF files and sometimes i use HEG tool to deal with HDF files. But now NASA has introduced something else that is NetCDF files with VIIRS VNP02 data. I want to extract I04 and I05 ...
1
vote
1answer
27 views

Finding location of specific value in spatial TIFF file using R?

I want to find location of specific value in one spatial GIS TIFF file and then compare location to main file in order to find some information. for example consider this image which is my main image. ...
0
votes
1answer
29 views

Subset raster stack in R by a vector of number sequences?

I have a large raster stack that I need to subset by somewhat irregular time spans. I'd like to do something like this: rstack[[c(1:3, 4:8, 9:15)]] But there are 30 sequences like the ones above ...
3
votes
1answer
120 views

Distance between two points - by ID in QGIS

I have a dataset of 350 or so individuals. Each individual has a start point (2 columns with Lat and Long) and end point (2 columns with Lat and Long). I would like calculate the distance between ...
2
votes
1answer
93 views

Re-projecting a Raster in R to matching resolution, crs, and origin, but different extent

I have raster layers in a few different projections that I've loaded into R. I eventually plan on using the "merge" function of the raster package to bring these together as one surface, but to do ...