8

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 periphery of the shapefile (the extent of the shapefile is entirely cover by polygons). In the example below, the desired polygons are shaded:

border polygons

Solution using Arcgis, QGIS, R, Python are most welcome.

  • 1
    Is the border always a nice regular shape like that rectangle? BTW: That last sentence comes across as a bit demanding. – BradHards Oct 31 '13 at 10:52
  • Nope. The border is irregular. An extract by mask or smth like that would not be ideal, I think. NB: last sentence modified, you had right. – DJack Oct 31 '13 at 11:02
7

create a new polygon layer, draw a single polygon that covers all your current polygons, then cut the newly drawn polygon based on all your existing polygons, then select all polygons from you current set that share a line segment with the newly drawn polygon using select by location and you're done


---Edited version much more efficient, based on comment----

Dissolve all polygons into one, then select all polygons from you current set that share a line segment with the newly dissolved polygon using select by location and you're done

  • 2
    Ok right. But in place of drawing the polygon, I ll dissolve all my polygons to get only one. Much more efficient than drawing one. Thx. – DJack Oct 31 '13 at 11:08
  • 1
    Yes you're correct that is much more efficient:) – Hedinn Oct 31 '13 at 11:10
2

With R:

ShapeFile.Dissolved<-rgeos::gUnionCascaded(ShapeFile)
x<-rgeos::gRelate(ShapeFile, ShapeFile.Dissolved, byid= TRUE)

I get 3 DE-9IM cases:

table(x)
2FF10F212 2FF11F212 2FF1FF212 
       63      2470    174495  

The resulted DE-9IM string code can be interpreted as follow:

1) 2FF1FF212: represent polygons from the first shapefile that don't intersect the border of the polygon of the second shapefile

2) 2FF11F212: represent polygons from the first shapefile that intersect the border of the polygon of the second shapefile with a line

3) 2FF10F212: represent polygons from the first shapefile that intersect the border of the polygon of the second shapefile with a point

The two last cases are my border polygons that I was looking for. I ve got their ID with:

poly.border<-which(x %in% c("2FF10F212","2FF11F212"))

With Arcmap:

1) Dissolve (Data Management) without selecting any "Dissolve_Field"

2) Select by location. Select features from "original shapefile", Source layer: "shapefile dissolved", Spatial selection method for target layer features: touch the boundary of the source layer feature.

3) Start editing and delete selected features

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.