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.
-
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 pro.arcgis.com/en/pro-app/arcpy/functions/… 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 StimsonCommented Jun 13, 2016 at 22:55
-
4Accessing individual cells is massive overkill, region group will do the job on the fly– FelixIPCommented Jun 14, 2016 at 3: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.– timpjohnsCommented Jun 14, 2016 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?– FelixIPCommented Jun 14, 2016 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.– timpjohnsCommented Jun 14, 2016 at 20:35
|
Show 1 more comment