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 [rgeos]

R bindings for the GEOS library

0
votes
1answer
27 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
52 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
65 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 ...
0
votes
1answer
61 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
31 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
21 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
1answer
44 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
20 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
109 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 ...
0
votes
0answers
59 views

Intersect two shapefiles and out the result as shapefile

I have two shapefiles that overlap and I want to out the intersection as a shapefile. I have used gIntersection() from the rgeos package, which works perfectly. However, on using writeOGR to save the ...
6
votes
2answers
3k 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
614 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 ...
4
votes
2answers
199 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
896 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
135 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
118 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
353 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
250 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
213 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
72 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
250 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
724 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
65 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 ...
2
votes
0answers
214 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
142 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
91 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
3k 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
469 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
35 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
318 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
55 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
289 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
471 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
456 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
391 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
170 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
740 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
137 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
3k 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
384 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 ...
15
votes
3answers
13k views

Merge a list of spatial polygon objects in R

I have a list of spatial buffers (30000 buffers) that I built with the function lapply: buff.pts <- lapply(1:nrow(pts.prj), FUN=function(l){ buff <- gBuffer(pts.prj[l,], width=1000) ## 1km ...
1
vote
1answer
502 views

Correct Projection for calculating centroids of a group of points?

I have a long list of points covering all of North America for which I would like to calculate the centroid (by grouping points based on the "Name" column). My approach is to take the WGS84 co-...
3
votes
1answer
678 views

gBuffer(rGEOS) causing R to crash

I have downloaded a US federal lands data layer (fedlanp010g.shp.tar.gz) from http://nationalmap.gov/small_scale/atlasftp.html?openChapters=chpbound#chpbound In R, I am trying to create a buffer ...
3
votes
1answer
290 views

PostGIS Polygons to single sp object

I would like to be able to take my SQL queries for PostGIS and make each row for the geom attribute part of an sp object so I can plot it with R's leaflet bindings. I can't really share what my ...
9
votes
1answer
3k views

R fortify causing polygons to tear

I'm am having some trouble plotting my spatial data using ggplot2. The map looks fine when plotted using spplot, so I'm assuming that the tearing occurs at the fortify stage. The code is as follows: ...
20
votes
1answer
13k views

Getting TopologyException: Input geom 1 is invalid which is due to self-intersection in R?

The 'TopologyException: Input geom 1 is invalid' self-intersection error which arises from invalid polygon geometries has been widely discussed. However, I haven't found a convenient solution on the ...