1

I have an polygon of GIS object,e.g. rectangle. I would like to extract all of edges according to their compass orientation. How can i do that?

Here is a simple example

poly = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))
polygons = Polygons(list(poly), "s3")
SpP = SpatialPolygons(list(polygons))
plot(SpP)

The upper edgs for eg. is related to the north. But how can i identify it via script?

satart
  • 103
  • 1
  • 2
  • 6
  • 1
    Please provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Thomas Jul 25 '13 at 10:39
  • 1
    The (signed) gradient of a straight line (whether it's the edge of a polygon or not) *is* the line's compass direction. What is the problem here ? – High Performance Mark Jul 25 '13 at 10:45
  • I'd suggest you use `maptools::coordinates` to calculate the polygon centroid, then find the line mid-points (you can get vertex info using `ggplot2::fortify`) and work out the bearing between them with `atan2`. Then you can categories the outputs by bearing. – geotheory Jul 25 '13 at 14:19
  • Indeed, i tried to identify the centroid with maptools. I will try the next step with fortify. Thank you for the hint. – satart Jul 26 '13 at 08:50
  • maptools::SpatialLinesMidPoints did also the job top find mid-point of a line – satart Jul 26 '13 at 09:27

0 Answers0