I am not sure what to call my problem. From this image, I have a set of classified polygons (colored). I would like a way to classify the white polygons in the image.

I don’t have any attributes to base the classification on other than proximity to a classified polygon. I have tried a naïve approach by using the near tool in Arc. This works fine enough but it becomes sensitive to outliers. For example, a set of unclassified polygons may be surrounded by polygons of category "A" but if there is a single “island” polygon of category "B" nearby, they’ll be classified the same as the island polygon.

I am looking for a way to rank the likelihood that an unclassified polygon belongs to a particular category based on proximity to arbitrary k-polygons. For example, if there is a polygon of category "B" immediately adjacent to an unclassified polygon but the next five closest polygons are of category "A", I'd like the system to rank the unclassified polygon as category "A".

I am wondering if there’s anything in R that would solve my problem. Really, any off the shelf method would work (python, qgis, postgis, arc). enter image description here

  • Perhaps a spatial join or near followed by an attribute join might help, but you will need to convert your raster to features. Both will join to the attributes of the nearest feature (most likely feature). Take special care in warning the end user of your derived values or it might come back to bite you. – Michael Stimson May 3 '14 at 23:45
  • Hi Micheal, thanks for your comment. I have tried the process you describe with the near feature. The problem is it becomes sensitive to outliers. I would like to be able to rank the polygons with more than one near feature. – dharv May 4 '14 at 15:23
  • Trying to think through the problem. How are rules determined? Why should a poly be type surround instead of type island in your outlier example? The three large polys between two shades of blue center of your image - which side should they go to? You have two things to consider or approaches to take, proximity and adjacency. You're looking for majority nearest? Every solution I think of comes back to working with raster instead of vector. Maybe Moran's or a regression analysis? What if you converted to centroids instead of polys for analysis? Have you looked at the Similarity Search tool? – Chris W May 4 '14 at 20:24
  • Can you link to your data files, or a representative subset? – Matthew Plourde May 15 '14 at 15:20

I've thought of a workflow that could be implemented via model or script based on adjacency or proximity, but it relies on counts and not a spatial variable (just as your near ranking does).

  1. Select poly.
  2. If classed next poly.
  3. If unclassed, select all [adjacent polys - touching or shares boundary or shares vertex, you decide] or [proximate polys in a search radius].
  4. Deselect unclassed.
  5. Determine class with most(?) occurences in remaining selection.
  6. Assign that class to poly
  7. Next poly.
  8. Iterate through every poly once in this manner.
  9. Repeat the loop until all polys are classed.

I'm not much of a programmer or model builder yet, so I know some of those steps would have multiple sub-steps and I don't fully know how to implement it (or if it's been done before - ie off-the-shelf). It attempts to adapt a raster modeling process I thought of to vector.

This could lead to poor results because your polys vary in size so much and the method is more suited to uniform areas. seven small polys on one side of a target only surrounded by four others (of the same type) would get classed as the small polys are, even though the majority of the adjacent boundary is different. A clear example of this are those polys between the two shades of blue in your image. If only count matters, they're going to go left because there are more adjacent polys that direction. If size matters, they would go right since there is a single very large poly adjacent to all three. I suppose you could add some sort of area weight in there, that larger polys are more important (or not) than smaller ones.


For anyone reading this, I eventually worked out a solution in PostGIS to select the nearest k neighbors (i.e. 9) and select the most common occurring class from the nearest neighbors. Then, I assigned that class to the white polygons. This approach was less sensitive to single, misplaced polygon classes.

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.