3

I am trying to develop a methodology for separating pixels from one another to determine whether they belong to a city cluster or not. Starting at the center pixel of the city I want to select all pixels that fall under a certain pixel neighborhood. I want to examine a few different ones 3x3, 4x4, etc.. The selection would expand outward, examining each connected pixel to select its neighbors, and so on, until there are no neighbors for any of the pixels. I have tried focal statistics in arcgis, but I cannot find out if there is a way to use the tool on just one pixel. The picture below shows the issue. I cannot tell if the pixels circled in black are actually connected to the center pixel. This is the output of focal statistics showing number of neighbors in 3x3 rectangular neighborhood. I would prefer a python solution if possible. enter image description here

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
timpjohns
  • 339
  • 2
  • 10
  • You will need to get down to a cell level to do this, which you've already realized. In ArcGis you can use Raster to Numpy Array http://pro.arcgis.com/en/pro-app/arcpy/functions/rastertonumpyarray-function.htm to read the raster to an array then index (2d) as you search recursively. Just make sure you've got plenty of memory to read the whole raster into!! – Michael Stimson Jun 13 '16 at 22:55
  • 4
    Accessing individual cells is massive overkill, region group will do the job on the fly – FelixIP Jun 14 '16 at 03:51
  • @FelixIP I actually just discovered this tool shortly after posting this. Only problem is that I want to explore more neighborhood options. Region group only has four or eight from what I can tell. – timpjohns Jun 14 '16 at 14:51
  • If cell is not connected to any of 8 neighbours, it is disconnected island. Is it connectivity you are talking about or something else? – FelixIP Jun 14 '16 at 19:31
  • @FelixIP It is connectivity but I am curious how many more pixels will be included when the neighborhood is expanded. 12 or more would be interesting. The data I am working with has somewhat arbitrary spatial relationships I want to explore. Thanks. – timpjohns Jun 14 '16 at 20:35
  • Just use a morphological expand followed by RegionGroup. There's a worked example at http://gis.stackexchange.com/a/71869/664 . – whuber Jun 14 '16 at 22:48

0 Answers0