[GIS] Extract/Split raster dataset by attribute (OBJECTID)

arcgis-desktopextract-by-maskrasterspatial-analyst

I have a raster dataset with an attribute table generated from a series of image classification (unsupervised) and processing tools (majority filter + boundary clean). The attribute table shows pixels of the classified image, grouped by classification i.e. the "OBJECTID" field.

I want to extract the portion of the image by "OBJECTID" to divide the classified image into separate rasters and ultimately, separate feature classes. e.g. take all pixels with OBJECTID = 2 and copy into new raster or convert to feature class

This has proved somewhat impossible for me so hopefully there's something simple that I'm missing?

Best Answer

One way to do this is by using the Spatial Analyst --> Extraction -->Extract by Attributes Tool (see ESRI documentation here)

The tool interface is fairly straightforward. For example in the Where Clause option you can build a query with the query builder or just enter “OBJECTID” = 2 to select a subset where OBJECTID = 2

In arcpy it is similar:

outRaster = arcpy.sa.ExtractByAttribute(inRas, “OBJECTID = 2”)
outRaster.save(r’C:\test.img’)

Additionally if you do not want to have to do the above for each OBJECTID and want to go directly to a feature class, you may want to consider using the Conversion --> From Raster --> Raster to Polygon Tool (see ESRI documentation here)

Use the OBJECTID as the Field option to the tool.

At times this will result in a messy polygon feature class with many different polygon’s having the same OBJECTID to clean this up. Run the Data Management --> Generalization --> Dissolve Tool (see ESRI documentation here)

Select OBJECTID as the Dissolve Field and check the Create multipart features option checkbox.

Related Question