[R-sig-Geo] Identifying regions on the boundary
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Wed Mar 30 18:49:26 CEST 2011
2011/3/30 Virgilio Gómez-Rubio <virgilio.gomez at uclm.es>:
> Barry,
>
> What you propose is what I would do too. Another approach is to display
> the adjacency matrix as a graph (i.e., vertices for the "location" of
> the country and edges for the connections between them). I would say
> that all the countries whose vertex can be surrounded by edges will be
> land-locked, so that the remaining countries will be non-landlocked.
>
Here's a two-liner that seems to work but uses gRelate to compute all
the inner/boundary/exterior relations so is surely overkill since I
only care about the boundary. I use gUnionCascaded to get the outer
'coastline', so the coordinates should be exactly those of the
constituent countries, and hence no slivers...
edgeFinder <- function(sp){
outer = gUnionCascaded(sp)
substr(gRelate(sp,outer,byid=TRUE)[1,],5,5)!="F"
}
The horrible substr expression gets the right part of the DE9IM string. I think.
Barry
More information about the R-sig-Geo
mailing list