Questions tagged [rgeos]

R bindings for the GEOS library

Filter by
Sorted by
Tagged with
0
votes
0answers
4 views

Minimum distance from each polygon (964 polgons) to a set of points (100 points) in R

I have a number of polygons and points. I want to calculate the distance from each polygon to any of the points and determine the minimum. How can I do this in R for each polygon and point?
0
votes
1answer
33 views

Calculating area between two SpatialLines

I'm trying to calculate the area between two lines. The two lines have the same start and end location, but the number of vertices for each line can vary. I've tried to create a polygon from the ...
1
vote
0answers
25 views

gIntersection results in a new dataframe with more rows

This is my first time using rgeos::gIntersection, and I have a dataset with that I rasterized using rasterFromXYZ, then turned into a spatial polygon dataframe. I wanted to intersect this SP dataframe ...
1
vote
0answers
45 views

Updating PROJ GEOS and GDAL in R

I have been having trouble linking to GEOS 3.8.1, GDAL 3.0.4, PROJ 6.3.0. I have tried reinstalling sf, rgdal, raster, and rgeos packages. I still couldn't link to GEOS 3.8.1, GDAL 3.0.4, PROJ 6.3.0. ...
2
votes
1answer
22 views

Dissolved area of polygons using the gArea function of rgeos?

I am taking occurrence point data (in the form of individual Lat/Long points), and adding a 1km buffer around them using gBuffer() in R package rgeos. I'm then using the function gArea() to calculate ...
1
vote
1answer
31 views

R spatial: add new attribute to S4 class object?

I am trying to check if my shapefile polygons have open edge or not. To have an open edge, the polygon either has no neighbors, or is >5 m taller than its neighbours. So, I want to add this new field ...
2
votes
1answer
51 views

Skipping TopologyException and continuing operation anyway using R

I'd like to see the result after an hour of working while substracting two shapefiles. This is the code, but don't ask me what in those files. Whatever it is, I'd like to know how to skip those errors ...
2
votes
0answers
101 views

Union anti-meridian “multipolygons” after re-centering world map

My goal is to create a world map (using ggplot2) with a Pacific perspective. I have managed to re-center the map, by following this solution. Code below: # world country layer sppolys <-...
2
votes
1answer
137 views

Apply function from rgeos package to data sets

I am using gDistance function from rgeos package to calculate the nearest distance from points to a polygon. Originally I used for loop to calculate the distance for each row in my points data set, ...
2
votes
0answers
66 views

Generating equal-distance band regards to one boundary of polygon in R? [closed]

I have a polygon that is made up of several points: Basically, this reflects the contour of a tumor tissue. Now I have another polygon, which is defined as 'front', means a region where tumor and ...
0
votes
0answers
149 views

Error in RGEOSDistanceFunc(spgeom1, spgeom2, byid, “rgeos_distance”) : negative length vectors are not allowed

What does the error in the title mean? I'm fairly new to GIS and can't understand which negative length vectors R is talking about? Here is what I'm doing: I have a csv of lat/long locations of ...
1
vote
0answers
204 views

Calculating nearest distance between points and Spatial Polygons in R? [closed]

So right now I have pretty large datasets, about 200,000 (lat,long) locations and a Large SpatialPolygonsDataFrame with a polygons list of length 428386 spread in a single city of around 450 square ...
1
vote
1answer
252 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,] ...
3
votes
1answer
227 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
1answer
72 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 ...
0
votes
1answer
522 views

Calculating euclidian distance in R between lines and points?

I have a large SpatialLinesDataFrame "o" (~500,000 roads) and ~3000 survey points "r", I'd like to calculate the distance to the nearest line for each survey point and extract relevant columns. My ...
0
votes
0answers
464 views

Extract raster cell values by polygon field

I have a raster as a RasterLayer (raster) and a polygon layer (bound) with 38 individual polygons as a SpatialPolygonsDataFrame. I used the polygon to mask from a larger raster. Each polygon contains ...
1
vote
1answer
279 views

Count number of points on a line in R

I have a SpatialLinesDataFrame and a SpatialPointsDataFrame. I want to calculate the number of points that fall on a line by a specific field in the lines data frame. Example: I have a river network ...
1
vote
0answers
62 views

Divide irregularly shaped polygon into 3 equal parts

I have a polygon object of a transect line that I would like to divide into 3 equal parts that are one-after-the-other along the transect line. So far I have only been able to slice the polygon ...
1
vote
0answers
39 views

Clipping polygons to existing plotting area

I have an existing plotting area onto which I want to add some polygons. In order to be sure the polygons' labels are displayed within the plotting area, I'd like to clip the polygons to this area so ...
1
vote
2answers
96 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 ...
0
votes
0answers
76 views

reverse clip (erase) for spatial point data frame (R) [duplicate]

I am trying to recreate the suggestion from this link but instead of using it on a sPolygondf, to do the same for a sPointdf. All is well, but I get an unexpected output - when I do the difference ...
0
votes
2answers
312 views

Error with Intersecting Rasters and Lines in R

I'm trying to ''cut'' a spatial lines data frame object by a raster grid using R, raster::intersect(SLDF, grid) However, when I run this code I get, Error in as.vector(x) : no method for coercing ...
8
votes
2answers
6k views

Reading Large Shapefile in R - alternatives to readOGR?

I am trying to read in a large shapefile using readOGR. The shapefile is 68837 features and 14 fields. It takes a considerably long time to read at >30min. I understand this is a well documented ...
2
votes
1answer
2k views

Raster intersect and gIntersection give different results in R

I'm trying to clip a polygon shapefile (species distribution) with another polygon grid. The goal is to calculate the area occupied by the species within each grid cell. I was able to do it with ...
3
votes
2answers
380 views

Is their an equivalent of SpChFIDS for a spatial POINTS data frame?

This code: seattle <- spChFIDs(seattle.shp, paste("seattle.shp", row.names(seattle.shp), sep=".")) Results in this error: Error in (function (...
2
votes
1answer
2k views

Adding labels to spatial grid in leaflet using R?

Problem: I am trying to add grid cell labels to a leaflet map in R using shapefiles provided by TIGER/Line Census Data. The desired result is a leaflet map displaying the raster ID layer labelled ...
2
votes
0answers
244 views

Calculating combined area of multiple polygons by counting overlapping area only once in R?

I'm using a shapefile in which polygons represent the geographic distribution of species. I need to calculate the combined range of several species sets, but the overlapping areas should be counted ...
2
votes
1answer
264 views

Does the inputs extent have to be identical for raster::intersect to crop a RGB GEOTiff?

Background: I have a shapefile with multiple polygons over a large area and then I also have GEOTiff image files. I want to crop the TIFF files with each of the polygons. The problem is that when I ...
0
votes
2answers
810 views

gUnaryUnion from rgeos packge fails randomly

I am using gUnaryUnion() function from the rgeos package to "melt" administrative regions into bigger units. At times I do get the expected result, and other times (seemingly randomly, so I suspect ...
1
vote
1answer
564 views

Why does projection not affect answer calculated by rgeos::gArea?

I am trying to calculate the area of various polygons from a shapefile containing areas of land with mining rights is South Africa. Through this site and posts like: Understanding unit of area sizes ...
1
vote
1answer
375 views

raster::intersect not working in R

I have a SpatialPointsDataFrame and a raster for a region. I would like to retain only those points that occur within the elevational limits of the raster. Unfortunately, no points are being filtered. ...
2
votes
2answers
105 views

Missing 1.6% of expected area after buffering SpatialPoints from vector of widths

Goal: I am buffering a random set of points (i.e. centroids) with different widths from a vector of predefined areas to make a random null model of polygons in a given extent. I am iterating through a ...
0
votes
1answer
498 views

spatial filtering data in R between two vectors

I have two shapefiles in R. One contains a vector of coastline (called coastline) and the other file of parcels (called parcels). I want to filter the parcel data for only those parcels within 1 mile ...
9
votes
1answer
1k views

Euclidean and Geodesic Buffering in R

In Understanding Geodesic Buffering, The Esri Geoprocessing Development Team distinguish between Euclidean and Geodesic Buffering. They conclude with "Euclidean buffering performed on projected ...
0
votes
0answers
87 views

Reclass a landuse shapefile based on another shapefile using R

I have a landuse shapefile that I want to modify based on another shapefile. In this example I have three classes in landuse shapefile A. Say I'd know that everything within one of the small ...
3
votes
0answers
364 views

How to apply a rectangular buffer on spatial polygons in R/qGIS

I am trying to find a way to apply a rectangular buffer on my spatial polygon dataframe in R. At the end, I would like to be able to shrink my polygons by specified units on both sides. So far, I have ...
1
vote
1answer
434 views

Understanding unit of area sizes calculated via rgeos::gArea?

I'm interested in finding the unit for the obtained area size of the polygons without refererring to the externally available documentation. Example A suite of shapefiles is imported as follows: ...
1
vote
0answers
137 views

Creating an offset line with the rgeos package

I discovered the ST_OffsetCurve function in PostGIS, it is based on GEOS. I'd like to compute the same in the R software, using the package rgeos. I couldn't find a same-named function though. Has ...
1
vote
2answers
4k views

Simplifying and plotting polygons in Leaflet package in R?

I was finding the plotting of shapefiles very slow in R. After reading this (How to speed up the plotting of polygons in R?) I found all the tips were helpful for plotting in base R. The second one (...
1
vote
0answers
674 views

gIntersects with large spatial data

I am using the gIntersects function from the rgeos package to check whether a river layer (polyline) intersects with a species maps (polygons). However, it is taking ages to do the calculations, ...
1
vote
1answer
37 views

Spatialdataframe from a multipoligon array column

i have a df with a character colum that contains an arrays of wgs84 coordinates. > head(df$Multipoint) [1] "[[11.038156,44.525654],[9.768989,45.620678],[7.923145,45.060564]]" ...
2
votes
1answer
382 views

Reproject global latlong into UTM slices

I'm working with a global shapefile in R that is latlong projected. I'd like to reproject it into the appropriate UTM projection for individual zones. But, I'd like to chop it up into those zones ...
3
votes
1answer
2k views

Ring Self-intersection at or near point

I'm trying to make a buffer around each polygon in my data. At some point I get: Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td, unaryUnion_if_byid_false, : ...
2
votes
2answers
4k views

How to overcome invalid input geom and self-intersection when intersecting shapefiles in R

I downloaded two shapefiles from IUCN (available here and here) to determine the range overlap between two species. When I bring the shapefiles into R, I am able to plot them on a map together, ...
1
vote
0answers
67 views

Distortion when using SpatialPolygons and SpatiaPolygonsDataFrame

Using library rgeos I tried to plot a map using a shapefile I have (it is loaded as a SpatialPolygonsDataFrame) with some geometric objects (squares and circles defined as SpatialPolygons). I do it ...
0
votes
3answers
546 views

I want to do SpatialLines programatically

This is my dataframe: df <- data.frame(ID = rep(1:100, each = 2), x =runif(200, 10, 90), y = runif(200, 10, 90)) For each ID I need to create SpatialLines, I haven't had good luck. I think I ...
3
votes
2answers
3k views

Checking whether two rasters intersect using R?

I would like a method for checking whether two rasters (or a raster and an extent) overlap that returns a Boolean and doesn't involve an if/then statement. Something like the gIntersects function. ...
2
votes
3answers
700 views

What are the coordinates on my rectangle of the closest point to a polygon in R?

I have a non-overlapping extent rectangle and a sample lake polygon. I can measure the distance from the rectangle to the polygon but I want to know which point on the rectangle is the closest to the ...
2
votes
1answer
786 views

How to subset a SpatialPoints object to get the points located on each side of a SpatialLines object using R?

I need to subset the SpatialPoints object to get the points located in the left or in the right side of the SpatialLines object (red line, see figure below). This is the code example in R: # Load ...