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.

-4
votes
1answer
27 views

Performing geospatial analysis in R?

I obtained a rectangular sort of image when I subset shapefile on the raster image. I want to get exact irregular shaped image so that I can proceed my classification to that particular area (B is my ...
2
votes
1answer
39 views

How do I plot spatialpolygon dataframe layer on a leaflet map

I am not sure why this piece of code works library(leaflet) library(raster) adm <- getData('GADM', country='SGP', level=1) popup <- paste0("<strong>Name: </strong>", ...
-1
votes
1answer
33 views

The slot for “plotOrder” comes up as 1 instead of a vector with length specific to my data

My goal is to find neighbors from my SpatialPolygons object using the poly2nb() command from the sp package in R. This is my code thus far: p <- s_gis %>% select(long, lat) %>% ...
2
votes
1answer
39 views

Raster from point data in R different from point data in QGIS

I have some point data, with longitude, latitude and a value, in .csv file format. This is how the file looks in QGIS: I wanted to create a raster of this map, with each of the points ...
0
votes
0answers
37 views

Calculate shortest path distance on a network with R, sf and stplanr

I want to estimate a spatial logistic regression model for car crashes in Milan using R. I downloaded data from OSM for several highways segments in Milan using the R package osmdata. The response ...
0
votes
1answer
57 views

Opening Esri Geodatabase file with GDAL/QGIS/Grass?

EDIT: I have a 64-bit installation of QGIS but 32-bit Microsoft Office Access drivers. It has been suggested that this is the cause of the problem, which is also indicated in this post: https://www....
0
votes
2answers
96 views

Convert SpatialPoints to SpatialPointsDataFrame

Give an object x of class SpatialPoints how do I convert it to a SpatialPointsDataFrame ? class : SpatialPoints features : 50 extent : 3187836, 3827836, -489229.3, 950770.7 (xmin, ...
1
vote
0answers
18 views

Point to line interpolation using heading in R [closed]

I asked this question at StackOverFlow, but got no answers, so I thought I would try here also: I can draw a spline through 10 successive points like done in this post set.seed(1) n <- 10 x <- ...
2
votes
2answers
97 views

Is there a way to clip a layer with a shape from another layer in `sf`?

I would like to get the greens polygons that intersects (or overlapsed) the red outlined polygon (see image below). I tried sf::st_intersection() but the polygon in yellow (yes that just one polygon) ...
1
vote
1answer
52 views

rgdal installation error: How to set GDAL_DATA directory?

I've long had GDAL, proj, etc. installed and working fine for various other related software (e.g., QGIS). Unfortunately, every time R gets updated it tends to lose links to previously installed R ...
0
votes
1answer
20 views

Plotting Geographical Grid from Long/Lat Coordinates in R

I have a file of coordinates (Long/Lat) that should enable me to plot a series of 10km grid squares covering the UK. However, for each grid square I have five sets of coordinates by way of plotting ...
0
votes
1answer
41 views

Why raster layer name change to default when using raster::calc function?

Why raster layer name change to default when using raster::calc function, but not when using Arith-methods: Toy example copied from Reference manual (calc function). library(raster) r <- raster(...
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 ...
0
votes
0answers
36 views

How to increase capacity of osrmRoute in osrm package in R

I had plotted the routes of some locations. The maximum number of locations allowed for routing using the OSRM package in R is 100 coordinate points. How can I extend beyond this restriction?
0
votes
2answers
79 views

Slope, curvature, aspect with RQIS 3

I'm trying to calculate morfometrics index provided by SAGA using RQGIS 3 with QGIS 3.4 version. I`ve followed tutorial examples, but i dont have been successful. The script run, but don't produce ...
0
votes
0answers
29 views

Subsetting rasterstack for subtraction between elements using R?

I want ro calculate the differences between rasters within a raster stack with a certain step, and I am unsure how to do so. What I want is to subtract every element from its 5th next one, something ...
0
votes
1answer
47 views

Reclassifying rasterstack in R?

I have a very large raster stack of 6253 raster layers and I want to reclassify it. For the reclass, I have tried the following but with no success: my_rules <- c(-0.500, -0.251, 1, -0.251, -0....
0
votes
0answers
22 views

Converting line vector layer to raster with pixellate.psp creating missing data?

The following example converts a line vector layer (road network) into a density raster. It seems to be working for others, but it looks like it's creating data gaps at my resolution (50m). library(...
1
vote
1answer
35 views

Combining data frame with bnd as spatial polygon data frame?

I want to use this data set (publicly available for R) library(R2BayesX) library(spBayesSurv) data("LeukSurv") Observations: 1,043 Variables: 9 $ time <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
0
votes
1answer
23 views

Not found the code for a map R animation

I tried to make an animated map in R with tmap package, like here https://geocompr.robinlovelace.net/adv-map.html#animated-maps I tried to find the code for the animated map presented in section [8.3 ...
0
votes
0answers
23 views

Find borders between all unique country pairs with R

I would like to obtain a border as a line between all unique country pairs that are contiguous. Here is how to do it: library(spData) library(sf) library(rnaturalearth) library("rmapshaper") #load ...
2
votes
1answer
40 views

Extracting residuals of maxent model in R?

I used "dismo" package in R, and ran a build a maxent model. Now I want to extract the residuals from the model in order to run a Moran I test later. But I got an error. The code was like: xm<-...
2
votes
0answers
29 views

Biweekly time series for raster stack in r

I have a netcdf file with daily data and I calculate for each week some statistics, using the "apply.weekly" command in the "xts" library. However, I would like to calculate bi-weekly statistics, ...
1
vote
1answer
51 views

Extract random coordinate points using classes (ranges) of values from a raster image

I want to use a raster to stratify an image using different texture. I have a raster image (ndvi_2019) for which I want to extract random coordinates as points from each classes. First, I want to form ...
1
vote
0answers
35 views

R MODIS MOD13Q1 - How to handle data quality issues?

I'm running into some issues with 250m 16-day MOD13Q1 NDVI data using the MODIS package in R. Looking at the following raster plot, there are certain days where the NDVI does not match the true ...
1
vote
1answer
25 views

Find layer name of sp object

After making some changes to an sp object I want to save it as a shapefile using writeOGR()so that I don't have to repeat the cleaning every time. I haven't found a way to identify the layer name of ...
2
votes
0answers
43 views

Merging two neighboring cells in grid of type SpatialPolygonsDataFrame?

I have a grid of type SpatialPolygonsDataFrame (each cell has a set of data attributes). I want to merge each cell which has a surface < X with one of its neighbours. An example is depicted in the ...
1
vote
1answer
112 views

R sf count number of Polygons in Multipolygon

How can I count the number of polygons that are present in a multipolygon with the R package sf? Example: In the following image that represents a multipolygon I count 3 polygons. I want to be able to ...
1
vote
0answers
39 views

BIOMOD2: error message: Error in .local(sp, env, …) : object 'mask.tmp' not found

I am trying to model a plant species (composed by 298 occurrences) with BIOMOD2 using the consensus landcover as explanatory variables. However, R shows me an error message during the formatting of ...
0
votes
1answer
42 views

Extracting information from KML files in R, beyond coordinates and date/time

I have GPS-telemetry data from animal movement monitoring that records, besides Longitude-Latitude coordinates and date/time, other information (GPS HDOP, elevation and other important stuff). I can ...
0
votes
1answer
71 views

Animation map in R error in Loading shapefile in R

I want to make an animation map in R. I have tried several command lines but I get some errors, as follows: > library(raster) > s <- shapefile("//Users//Merry//Desktop//ro_judete_poligon//...
1
vote
1answer
47 views

Converting large raster to vector?

I have a shapefile which contains 10.000 polygons and I want to know how many of them falls on a specific land use. Unfortunately, the land use map that I have to use is a raster map and not a vector ...
0
votes
0answers
37 views

How to specify shapefile variables length in R?

I am using R to edit some shapefiles with readOGR and writeOGR functions. I can edit the name and type of my shapefile variables, but not the length. Example: i want that my variable of type string ...
0
votes
0answers
26 views

read error after mosaic_rasters in R

I am using mosaic_rasters from gdalUtils to combine different raster files. More specifically, I am using the 12 tiles that cover Southern Africa from the well-known Hansen et al. (2013) forest map (1....
0
votes
1answer
46 views

Multiple attribute maps in R?

In pursuit of replicability (as well as requirements of funding agency), I am trying to produce all of the maps for a current project in R. For single attribute maps, so far so good! I am using ...
0
votes
1answer
16 views

Set same dimensions multipolygon and point data

I'm trying to plot point data (coördinates) on a multipolygoon map. But I can't get them on top of each other and in the right shape. Underlying projection data of the Netherlands multipolygon data: ...
0
votes
1answer
27 views

Unable to plot in R some locations over a shapefile

I have a shapefile of polygons that I got from here, and a CSV file with longitude, latitude data (i.e. lon= -71.4; lat=42.5). The shapefile has the following CRS information: "+proj=lcc +lat_1=41....
0
votes
1answer
53 views

“OGR: not enough data error” when using st_transform in R

I'm trying to use st_transform (from the R package sf) on a sf object and am getting the following error when projecting from WGS 1984 to Albers Equal Area: > sf_obj_prj <- sf_obj %>% ...
1
vote
1answer
27 views

Error in mapping connections with great circles [closed]

I am fairly new to R and to map plotting. I am trying to overlay some network information on a world map. I loaded a shapefile from Natural Earth as a large SpatialPolygonsDataFrame via readOGR. I ...
-1
votes
1answer
34 views

Default parameter values in r's gstat idw?

In r, gstat has an Inverse distance weighted (IDW) interpolation method. Does anyone know what the default values of nmin, nmax and maxdist are?
0
votes
0answers
31 views

How to cover data by circles, limited by a maximum of values?

I have a regular grid with a cell width of 200 meters (available as raster and vector data set). Each cell has a value from 0 to 2000. I now want to draw circles around these cells in such a way ...
0
votes
0answers
39 views

extract values from raster function taking too long

My task is to extract values from raster A and B from point location file A and B, respectively. Both point location files have 375152482 obs. of 2 variables. The only different is A is in XY ...
2
votes
2answers
40 views

How do I combine geometries in a shapefile based on a grouping variable?

Here is a simple example. I have a shapefile of three US states: This is the code that creates the shapefile. library(USAboundaries) library(sf) library(dplyr) states <- us_states(map_date = "...
3
votes
1answer
32 views

For a specific point in space, get the pixel in which that point lies (in R)

I am a bit new to the spatial packages of R. I have a hdf file from which I can get a data.frame with the latitude and longitude of the corners of the pixels, and the latitude and longitude of the ...
0
votes
1answer
62 views

Create polygons (representing boundaries) from lines

I received a file of municipality boundaries, where the boundaries are represented as lines. I would like to convert this to a set of polygons, each representing a municipality. In other words, from ...
2
votes
1answer
34 views

I want to plot point shapefile on a raster to know if they are at the right place in R

I have one raster and a shapefile of points. I want to check them if they are in the same coordinate system by plotting them together on a map (like in a classical GIS), here the R script : # raster ...
0
votes
1answer
26 views

Using raster::rasterize's getcover to get total polygon area with overlaps

I want to use rasterize to get how much of a raster cell is covered by polygons. This can be done like this: library(raster) p1 <- rbind(c(-180,-20), c(-140,55), c(10, 0), c(-140,-60), c(-180,-20)...
1
vote
1answer
31 views

Rasterize the full area of a polygon, not only midpoints, using R [duplicate]

The default function in raster::rasterize is to see if a point is within a polygon and if yes, make a cell. This results in that some of the outer parts of the polygon is not covered by the new raster....
0
votes
0answers
33 views

Use SPEI in R using raster or netcdf data

I want to use the SPEI package in R 1, but so far I have seen tutorials on how to use it for a single location. How could I use it by importing my own spatial grids in raster or netcdf format?
0
votes
0answers
39 views

Finding Alternative Routes Using OSRM (R)

Using the osmr or stplanr packages I can easily get the fastest route between two points using OSMR e.g. library(osrm) library(stplanr) library(sf) path <- osrmRoute(src = c("Buckingham", 0....