matthewkaicarter

Nonsensical Output from Raster to Polygon in Model Builder

Discussion created by matthewkaicarter on Apr 21, 2014
Latest reply on Apr 24, 2014 by curtvprice
[ATTACH=CONFIG]33230[/ATTACH]

I'm trying to iteratively convert a ton (~300) thresholded rasters (integer value 0 or 1) into shapefiles.  I've attached a picture of my model.  The model runs through rasters, and does write shapefile output, but when I compare the resultant shapefiles to the rasters, they are completely off.  Initially, I was writing the intermediate rasters to memory, since I only need shapefiles where the original raster value = 1.  In both cases, the output is apparently unrelated to the "parent" raster file, and I'm not sure what the problem is.

One thing I've noticed is that the raster to polygon geoprocess is running suspiciously rapidly, compared to running it as a one-off tool in arcMap.  Incidentally, the output I get from doing the same thing manually in arcMap makes sense.

I'm including converted Python code below, in case that would help anyone think about this.

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# ExtractShapefiles.py
# Created on: 2014-04-21 14:42:49.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: ExtractShapefiles <Input_Workspace> <Output_Shapefile> <Intermediate_Feature_Data_1> <Intermediate_Feature_Data_2> 
# Description: 
# This model is designed to extract shapefiles from already thresholded binary raster layers of species presence.
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("Model Functions")

# Script arguments
Input_Workspace = arcpy.GetParameterAsText(0)
if Input_Workspace == '#' or not Input_Workspace:
    Input_Workspace = "C:\\Users\\mkcarte2\\Desktop\\NSF Project\\Salamander_Data\\Converted_Thresholded\\Current" # provide a default value if unspecified

Output_Shapefile = arcpy.GetParameterAsText(1)
if Output_Shapefile == '#' or not Output_Shapefile:
    Output_Shapefile = "C:\\Users\\mkcarte2\\Desktop\\NSF Project\\Salamander_Data\\Range_Shapefiles\\Current\\range_%filename%.shp" # provide a default value if unspecified

Intermediate_Feature_Data_1 = arcpy.GetParameterAsText(2)
if Intermediate_Feature_Data_1 == '#' or not Intermediate_Feature_Data_1:
    Intermediate_Feature_Data_1 = "E:\\NSF Project\\Salamander_Data\\Intermediate Shapefiles\\%filename%.shp" # provide a default value if unspecified

Intermediate_Feature_Data_2 = arcpy.GetParameterAsText(3)
if Intermediate_Feature_Data_2 == '#' or not Intermediate_Feature_Data_2:
    Intermediate_Feature_Data_2 = "E:\\NSF Project\\Salamander_Data\\Intermediate Shapefiles\\%filename%polyselect.shp" # provide a default value if unspecified

# Local variables:
desmognathus_aeneus_Current_bioclim_models_thresholded_tif = Input_Workspace
filename = desmognathus_aeneus_Current_bioclim_models_thresholded_tif
Name = Input_Workspace

# Process: Iterate Rasters
arcpy.IterateRasters_mb(Input_Workspace, "", "TIF", "RECURSIVE")

# Process: Raster to Polygon
arcpy.RasterToPolygon_conversion(desmognathus_aeneus_Current_bioclim_models_thresholded_tif, Intermediate_Feature_Data_1, "NO_SIMPLIFY", "Value")

# Process: Select
arcpy.Select_analysis(Intermediate_Feature_Data_1, Intermediate_Feature_Data_2, "\"gridcode\" = 1")

# Process: Copy Features
arcpy.CopyFeatures_management(Intermediate_Feature_Data_2, Output_Shapefile, "", "0", "0", "0")

# Process: Parse Path
arcpy.ParsePath_mb(desmognathus_aeneus_Current_bioclim_models_thresholded_tif, "NAME")

Attachments

Outcomes