0
votes
0answers
26 views

calculate distance between points crossing the antimeridian

How can I calculate the distance between two points (lon/lat) if any of the points exceeds the antimeridian (+-180 longitude)? Im using the distVincentyEllipsoid {geosphere} to calculate the shortest ...
2
votes
1answer
41 views

Compute the area of a given polygon (in vector format) lying between specified lines of latitude

I have species distributions (in vector format) and I would like to calculate how much of the area for a given species distribution is within certain lines of latitude, such as temperate and tropic ...
4
votes
2answers
87 views

Converting shapefile to raster: Character attributes

I've got a shapefile that I would like to convert into a raster, but the trick is that the attribute I want a raster version of is character data. I'm familiar with geoprocessing using GDAL (in the ...
2
votes
3answers
130 views

How to get count of non-NA raster cells within polygon using R

I've been running into all sorts of issues using ArcGIS ZonalStats and thought R could be a great way. Saying that I'm fairly new to R, but got a coding background. The situation is that I have ...
5
votes
1answer
208 views

calculate {minimal} distance between polygons in R

I have calculated the surface area of species distributions (merging polygons from shapefiles), but since this area can be comprised of quite distanced polygons, I would like to calculate some measure ...
3
votes
1answer
173 views

remove land area from marine region polygons

In my pursuit to merge multiple polygons for the purpose of calculating the surface area of marine species distributions, using shapefiles from Marineregions, I am now trying to remove potential land ...
1
vote
2answers
210 views

unionize intersections of merged polygons

[Updated quesion] I am using the following code to merged polygons from shapefiles for the purpose of calculating the surface area; library(maptools) library(rgdal) library(rgeos) #enter slots, ...
2
votes
0answers
93 views

Joining nearest neighbor small polygons using R

The figure shows a plot of numerous polygons (zoom in) made from a raster file by require(sp) require(raster) pol100 <- rasterToPolygons(r, fun=function(x){x==1}, dissolve=FALSE) There polygon ...
3
votes
1answer
52 views

How to re-ID polygons with sapply instead of for loop

I have a line of code that renames the id's of polygons in a SpatialPolygonsDataFrame by directly manipulating the ID slot of the polygon. I'm a bit slow when it comes to sapply, having used for loops ...
8
votes
2answers
235 views

Simple way to detect/select border polygons of a shapefile

I am looking for a simple way to detect/select border polygons of a shapefile. Border polygons are here polygons that are not completely surrounded by other polygons i.e. polygons located at the ...
0
votes
0answers
24 views

calculating mean and standard deviation for raster values using whole pixels within a polygon [duplicate]

i have a raster image and a corresponding shape file. i would like to calculate the statistics of the values within polygons which have a common attribute but only using pixels which are fully ...
1
vote
0answers
60 views

level of spatial aggregation of polygons

I am looking for a method that allows me to obtain the spatial aggregation of polygons for each cell of a grid with 10kmx10km resolution. In each cell (10kmx10km), I want to be able to consider that ...
1
vote
1answer
90 views

Extract polyline of border between differing polygons

I have a shape file with polygons with an associated variable that can take different values. I would like to extract the borders between polygons of differing value (red and blue) as a polyline (dark ...
2
votes
2answers
256 views

Iterating polygons on a SpatialPolygonsDataFrame in R with readWKT

I have fetched some data (39 objects) from my PostGIS database and converted this data into a matrix: rs <- dbSendQuery(con, "SELECT ST_AsText(polygon_accumulation) AS ShapeWKT from ...
4
votes
1answer
354 views

How to split a polygon using R

I have an irregular polygon which is a spatial object. I want to divide it into multiple polygons (say, n=25) with equal height. To show how I want to divide it, I've plotted grids on the ...
2
votes
1answer
254 views

combine raster and polygon values in R

My question is similar to this one Get Raster Values from a Polygon Overlay in Opensource GIS Solutions but I think I need another step. I have a polygon layer of ecoregions which I brought into R ...
1
vote
1answer
85 views

Union of polygons doesn't work 100 % correctly

I'm using the function gUnaryUnion to merge polygons in R. In one particuliar case this doesn't work correctly - some of the old polygon contours are still visible: Can anybody help ?
4
votes
0answers
141 views

Cut polygon and retain data

I have these two polygons: library(sp); library(rgeos); library(maptools) coords1 <- matrix(c(-1.841960, -1.823464, -1.838623, -1.841960, 55.663696, 55.659178, 55.650841, ...
0
votes
1answer
140 views

How to shift polygons by updating their details in R

I have two polygon shapefiles and I want to see to what extent the observed amount of overlap is due to chance. I'd like to randomly move the polygons in one shapefile to new locations, measure the ...
1
vote
1answer
91 views

Remove parts of line that fall within a polygon

I have a polygon and two lines. How can I remove the portion of each line that falls within the polygon? # polygon coords <- matrix(c(-1.798123, -1.793072, -1.805767, -1.804129, -1.798123, ...
5
votes
2answers
544 views

How to speed up the plotting of polygons in R?

I want to plot the country borders of North America over a raster image depicting some variable and then overlay contours on top of the plot using R. I have been successful in doing this using base ...
2
votes
5answers
723 views

Counting road intersections and blocks

I have a shp file that consists of the road system of Mexico City. I would like to count the number of road intersections (crossings) and blocks (which I would define as a segment starting from one ...
2
votes
1answer
252 views

R: How can I create a polygon from several polygons and a line?

I have some spatial objects that I want to combine, namely three polygons and a line. The ultimate goal is to create a polygon that I can overlay on an area of a map of administrative divisions of the ...
2
votes
1answer
173 views

Remove intersect of one polygon from another in R

I am trying to remove the intersect from Poly2 onto Poly1. Below are the coords of the 2 polygons. > coords1 [,1] [,2] [1,] 992.0161 7462.531 [2,] 950.1962 7413.532 [3,] 902.3632 ...
2
votes
1answer
200 views

Tearing in ggmap (R) after using spTransform and random point generation using splancs

I am using R and the package ggmap to try and generate some random points within the city limits of Chapel Hill, NC. I have downloaded the shapefile for the town of Chapel Hill from the Orange County ...
8
votes
5answers
3k views

How best to fix a non-noded intersection problem in PostGIS?

I'm using a PL/R function and PostGIS to generate voronoi polygons around a set of points. The function that I am using is defined here. When I use this function on a particular dataset I get the ...
1
vote
0answers
347 views

How to clip the contour map with the polygon using R software?

Hi I am wondering how can I create the contour lines from the discrete x, y and z dataset and then add the shapefile to cut the contour lines by polygon. I want to clip the contour map by the shape ...
7
votes
1answer
3k views

How do I change the polygon fill color and border color for SpatialPolygons objects?

I have SpatialPolygons or SpatialPolygonsDataFrames which I'd like to plot. How do I change the color using the three plotting systems in R (base graphics, lattice graphics, and ggplot2)? Example ...
4
votes
1answer
395 views

Iterate features on SpatialPolygonsDataFrame in R

I have a SpatialPolygonsDataFrame object. Is there way to use apply on this object rather than using a for loop to iterate features in this object?
4
votes
0answers
289 views

Rgeos drops associated values when intersecting polygons

I am trying to intersect two SpatialPolygonsDataFrames and get a SpatialPolygonsDataFrame as the result. Unfortunately, using the gIntersection function from rgeos (which works impressively quickly ...
7
votes
2answers
1k views

Proper way to rbind SpatialPolygonsDataFrames with identical polygon IDs?

What's the proper R idiom for rbinding SPDFs together when the IDs overlap? Note that here (as is often the case) the IDs are basically meaningless so it's pretty annoying that I can't just make ...
11
votes
5answers
3k views

Get Raster Values from a Polygon Overlay in Opensource GIS Solutions

I have two layers. A polygon-shape-layer with many tiles and a raster-layer containing CORINE 2006 land cover with many categories in a colourmap. I want to obtain for each polygon in the shapelayer a ...
2
votes
1answer
648 views

Conversion of raster features to polylines: skeletonization?

I would like to identify linear features, such as roads and rivers, on raster maps and convert them to a linear vector features (i.e. polylines). I typically use R as my primary GIS, and have posed ...
1
vote
1answer
2k views

merging 2 polygon adjacent to each other using R

I have several shp files which are the components (or tiles) of a map, I have joint all these tiles together to have a large shp file. Then I realized some of the polygon is now splitted into 2 ...
9
votes
1answer
2k views

Instantiating spatial polygon without using a shape file in R

So, the usual way we read a shapefile in R is via the maptools package, like this: sfdata <- readShapeSpatial("/path/to/my/shapefile.shp", proj4string=CRS("+proj=longlat")) However, I have a use ...