Questions tagged [rgeos]

R bindings for the GEOS library

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

R sf package equivalent to R rgeos gProject function and, if so, can it work on polygons rather than points

I'm processing some very large 3D POLYGONZ shapefiles (100s of thousands of small triangles) representing a "fence diagram" (multiple vertical profiles) from a 3D geologic model. Attempting ...
Dan Strobridge's user avatar
0 votes
0 answers
83 views

How to intersect shapefile with polygons in R properly?

I have a WI shapefile (https://data-wi-dnr.opendata.arcgis.com/datasets/wi-dnr::wisconsin-state-boundary-24k/explore?location=44.747223%2C-89.836300%2C8.20) and a grid that I want to intersect so that ...
user8229029's user avatar
1 vote
0 answers
338 views

Distance to forest edge in R

I have a raster layer consisting 41 forest polygons and would like to calculate the distance of forest pixels to the edge within each forest polygon. I tried the code below but the result looks like ...
Donald 's user avatar
2 votes
1 answer
2k views

Creating adjacent matrix with polygons in shapefile with R

I´m very new at these geospatial data analysis and manipulation in R. Right now I have a shapefile that you can find here: http://sina.conagua.gob.mx/sina/tema.php?tema=cuencas&ver=mapa&o=0&...
Paula Langle Tamayo's user avatar
1 vote
2 answers
620 views

Preserving IDs when using gCentroid to find centroids of multiple polygons in R

This seems like it should be simple. I have multiple polygons contained in one shapefile, and I am using the gCentroid() function from rgeos to create a bunch of centroid points. The function has an ...
seak23's user avatar
  • 169
1 vote
1 answer
689 views

Converting a SpatialPointsDataFrame into km units from m, in R

I read in a UTM shapefile to R using readOGR. I want to use the resulting SpatialPointsDataFrame to build a mesh in the INLA package, but I've been told that to help with numerical stability, I should ...
Michael Smith's user avatar
5 votes
1 answer
95 views

Unexpected buffer output

Using both R and QGIS I got unexpected output from the buffer function. I'm wondering if it has something to do with my coordinate reference system, USA Contiguous Albers Equal Area Conic, because the ...
Dave-Evans's user avatar
0 votes
0 answers
131 views

Some polygons failing to fill with color

I have several Spatial Polygon Data Frames I am adding successively to a plot in R 4.0.2. The polygons represent US States, National Forests, National Parks, and wildfire perimeters. While it probably ...
gcgaines's user avatar
0 votes
1 answer
941 views

crop wrld_simpl gives error after R update

This code was working for me before I updated R to 4.0, but now it throws an error. I get this error on a Mac and a PC. I updated gdal on my mac, but this did not help. I made sure the rgeos package ...
webbe's user avatar
  • 322
0 votes
0 answers
490 views

Is there a metric projection that works everywhere in the world? If not, what's the smallest set of EPSG codes for that?

I'm doing some calculations per country, using rgeos library in R. For each country, I need to calculate the bounding box area. So I transform the country's bounding box in a sp object, project it ...
Rodrigo's user avatar
  • 782
1 vote
1 answer
189 views

Unable to process multiple polygons using SpatialPolygons object

I have a list with 4 objects, each object is a data frame. The data frame is the coordinate matrix of each polygon. I would like calculate the total area of the 4 polygons and then draw the voronoi ...
HAOYANG MI's user avatar
0 votes
1 answer
242 views

Calculating area between two SpatialLines using R

How do I calculate the area between two lines using R? 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 ...
Joseph Lewis's user avatar
1 vote
0 answers
88 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 ...
nilesguo's user avatar
1 vote
0 answers
721 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. ...
Smart D's user avatar
  • 23
2 votes
1 answer
144 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 ...
silknets's user avatar
1 vote
1 answer
499 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 ...
maycca's user avatar
  • 3,386
2 votes
1 answer
276 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 ...
Peter.k's user avatar
  • 477
2 votes
0 answers
661 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 <-...
bealhammar's user avatar
2 votes
1 answer
449 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, ...
HAOYANG Mi's user avatar
2 votes
0 answers
115 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 ...
HAOYANG Mi's user avatar
0 votes
0 answers
620 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 ...
Divyansh's user avatar
1 vote
0 answers
719 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 ...
Divyansh's user avatar
1 vote
1 answer
2k 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,] ...
Peter.k's user avatar
  • 477
3 votes
1 answer
575 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 ...
Fully Aquatic's user avatar
0 votes
1 answer
114 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 ...
Al Mac's user avatar
  • 1
1 vote
1 answer
2k 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 ...
symeboy's user avatar
  • 11
0 votes
0 answers
1k 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 ...
Fully Aquatic's user avatar
1 vote
1 answer
704 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 ...
Fully Aquatic's user avatar
1 vote
0 answers
168 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 ...
Carrie Perkins's user avatar
1 vote
0 answers
113 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 ...
MichaelChirico's user avatar
1 vote
2 answers
235 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 ...
Dinesh's user avatar
  • 267
0 votes
0 answers
142 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 ...
Momchill's user avatar
  • 284
0 votes
2 answers
722 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 ...
user13317's user avatar
15 votes
2 answers
12k 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 ...
user118668's user avatar
2 votes
1 answer
5k 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 ...
FAmorim's user avatar
  • 173
3 votes
2 answers
623 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 (...
Mox's user avatar
  • 1,036
3 votes
1 answer
4k 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 ...
philiporlando's user avatar
2 votes
0 answers
350 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 ...
Elisa Barreto's user avatar
2 votes
1 answer
661 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 ...
Waldo vdM's user avatar
0 votes
2 answers
2k 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 ...
Jindra Lacko's user avatar
  • 1,010
1 vote
1 answer
1k 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 ...
Waldo vdM's user avatar
1 vote
1 answer
614 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. ...
Vijay Ramesh's user avatar
  • 1,332
2 votes
2 answers
155 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 ...
Chad S's user avatar
  • 23
0 votes
1 answer
1k 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 ...
rip_ryan's user avatar
11 votes
1 answer
3k 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 ...
Valentin_Ștefan's user avatar
0 votes
0 answers
129 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 ...
telegott's user avatar
  • 165
3 votes
0 answers
570 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 ...
SinghD's user avatar
  • 127
1 vote
1 answer
829 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: ...
Konrad's user avatar
  • 331
1 vote
0 answers
215 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 ...
grssnbchr's user avatar
  • 457
1 vote
2 answers
6k 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 (...
Dex's user avatar
  • 11