Monday, 3 April 2017

Convert 3-band raster imagery to distinct vector zones in ArcGIS


So much like the title says I would like to convert a 3-band infrared image TIF file of vegetation into distinct vector feature zones using ArcGIS. I'm guessing the only way to do this is with Spatial Analyst extension which is fine. The result goal would be having a feature class that would have polygon features of different vegetation levels based on the original raster image. Basically I don't want to have to hand draw my own polygon features by using the raster image as a base layer. Steps and tools involved would be appreciated.




Answer



The model below should get you started in the right direction. I used 4-band 1m NAIP imagery as the model input. The imagery below shows the CIR tiff on the left followed by the generalized raster in the middle and the final vector product with four vegetation zones is on the right. Unsupervised maximum likelihood classification was used on the CIR imagery. Keep in mind that you will get better results if you use supervised maximum liklihood classification, although this skill takes practice (Hint. Use the handy image classification tool bar located in Customize > Toolbars > Image Classification). In order to keep the processing to a minimum, I generalized the raster through resampling to 2 meters and ran a majority filter over the raster. Once the raster is generalized, convert to polygons and then dissolve polygons.


Run the model on a small sample of data first to work out the parameters, then add the full dataset. If you are interested in more coarse scale visualization try exporting the zones of interest to a new feature class, then aggregate and smooth the polygons. I hope this helps and best of luck!


enter image description here


enter image description here


Here's the Python code:


# Import arcpy module
import arcpy

# Check out any necessary licenses

arcpy.CheckOutExtension("spatial")


# Local variables:
samples_tif = "C:\\gdrive\\ch1\\center_sa7\\samples.tif"
temp_tif = "C:\\gdrive\\ch1\\center_sa7\\temp.tif"
temp2 = "C:\\gdrive\\ch1\\center_sa7\\temp2"
samples_max1_tif = "C:\\gdrive\\ch1\\center_sa7\\samples_max1.tif"
Output_signature_file = ""
temp2_shp = "C:\\gdrive\\ch1\\center_sa7\\temp2.shp"

final_shp = "C:\\gdrive\\ch1\\center_sa7\\final.shp"

# Process: Iso Cluster Unsupervised Classification
arcpy.gp.IsoClusterUnsupervisedClassification_sa("C:\\gdrive\\ch1\\center_sa7\\samples.tif", "4", samples_max1_tif, "20", "10", Output_signature_file)

# Process: Resample
arcpy.Resample_management(samples_max1_tif, temp_tif, "2", "MAJORITY")

# Process: Majority Filter
arcpy.gp.MajorityFilter_sa(temp_tif, temp2, "EIGHT", "MAJORITY")


# Process: Raster to Polygon
arcpy.RasterToPolygon_conversion(temp2, temp2_shp, "SIMPLIFY", "VALUE")

# Process: Dissolve
arcpy.Dissolve_management(temp2_shp, final_shp, "GRIDCODE", "", "MULTI_PART", "DISSOLVE_LINES")

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...