Questions tagged [rgeos]

R bindings for the GEOS library

Filter by
Sorted by
Tagged with
2
votes
0answers
37 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 <-...
1
vote
1answer
21 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
38 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
37 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
35 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
32 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
74 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
39 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
228 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
281 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
162 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
35 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
29 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 ...
0
votes
2answers
67 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
36 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
174 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 ...
7
votes
2answers
4k 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 ...
1
vote
1answer
1k 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
280 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 (...
1
vote
1answer
1k 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
181 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
152 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
540 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
335 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
296 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
87 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
348 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 ...
8
votes
1answer
979 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
72 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
273 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
239 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
112 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
569 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
36 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
353 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 ...
2
votes
1answer
1k 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, : ...
1
vote
2answers
2k 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
59 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
371 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
2k 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
543 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
539 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 ...
0
votes
1answer
421 views

rgeos bugs with gDistance function

I can't use the gDistance function of rgeos without a R crash even when I used the example script: pt1 = readWKT("POINT(0.5 0.5)") pt2 = readWKT("POINT(2 2)") gDistance(pt1,pt2,T) *** caught ...
5
votes
1answer
1k views

Dissolve only overlapping polygons in R

I have a spatialpolygons-dataframe in R that contains overlapping polygon features. I would like to dissolve only the overlapping features into separate polygon features (one feature per par of ...
1
vote
1answer
193 views

Calculating distances of lines in R

I drew some lines in a GIS application in this projection: +proj=longlat+ellps=WGS84 +datum=WGS84 - is there a name for this projection? I imported my lines into R and to prepare for calculating ...
1
vote
1answer
869 views

Proximity filter

The aim of what I'm currently messing around: Creating a distance buffer around points in a SpatialPointsDataFrame If the value a this point is > 0, always keep it If the value a this point is = 0 ...
3
votes
0answers
151 views

Casting group of two polygons with rgeo returns nil

Here's an array of 2 polygons I'm trying to cast into a multipolygon (wkt string format). The polygons are in a linear CRS, SRID:3361 ["POLYGON ((990863.9961167622 709913.6373089257, 990983....
1
vote
1answer
4k views

Convert xy spatial points into spatial lines

I have produced a SpatialPoints object (named v3) in R from the function gIntersection (package rgeos). The SpatialPoints object v3 has the following structure and is represented by red points on the ...
1
vote
2answers
428 views

Attaching data to SpatialPolygonsDataFrame

As this is a more GIS related question (and maybe solvable with ogr/gdal functions I'm not aware of), I try it here first, although working with R. What I want to achieve: I have some data, based on ...