Feed model with raster files, a shapefile clip feature, a layer file - output to kmz?

1730
4
Jump to solution
05-28-2013 06:20 AM
EjayLai
New Contributor
The challenge is to
1) Clip all the rasters in a folder with a polygon shapefiles
    -rasters will be selected based on a field called tileName in the shapefile that contains all the raster names, e.g. 1955_30_146.tif;
2) Apply symbology from a saved layer file(.lyr);
3) Save the clipped rasters and export them to kmz files.

See below for supporting info if you would like to jump in to tackle the issue:

Background info:

a. A folder contains all the GeoTIFs - scanned and georeferenced air photos rasters.
b. A manually created polygon shapefile - outlining the areas and removing overlapping.
c. The attribute table of the polygon shapefile has all file names of the GeoTIFs( "tileName=1955_30_146.tif").
d. Software: ArcGIS Desktop 10, Arcview License with Spatial Analysis Extension.

Here how it works in ArcMap for a single process:

1. In ArcMap, select a polygon in the shapefile and use that to clip a related raster from a folder
    -the shapefile has a field call tilename which lists the names of all the TIF rasters
    -so the tilename field is used to determine an input raster
2. The clipped raster will be added to the table of content; as its colour range have changed, the image becomes brighter!
4. Apply sympology to the raster from a saved layer files (.lyr) so that the colour matches that prior to that being clipped.
    -save the raster with the new symbology?
5. Export raster to a KML file.

Can a model be built with ModelBuilder to allow user to feed the data with a folder(TIF raster files), a polygon shapefile, and a layer files(apply same symbology to all rasters), and output locations?

Once this done, I imagine it will be possible to export the model to a python script which can be scheduled to run with window's task scheduler, for example. It is an extended task to the answer from this post.

Feel free to ask where I didn't make myself understood.

Your help will be appreciated.
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Hi Harry,

Try the attached script tool.  I just modified the one I made a few weeks ago to add the extra steps you wanted. I saved it as a 10.0 toolbox so it should work for you.

View solution in original post

0 Kudos
4 Replies
by Anonymous User
Not applicable
Hi Harry,

Try the attached script tool.  I just modified the one I made a few weeks ago to add the extra steps you wanted. I saved it as a 10.0 toolbox so it should work for you.
0 Kudos
EjayLai
New Contributor
Hi Harry,

Try the attached script tool.  I just modified the one I made a few weeks ago to add the extra steps you wanted. I saved it as a 10.0 toolbox so it should work for you.


That is awesome! I hope others will find it useful! Did you build it witp ArcPy or ModelBuilder, as I can't open it as a model?
0 Kudos
by Anonymous User
Not applicable
I authored the tool in straight Python...You can see the source code if you right click on the script tool and hit Edit.  Or you can open up the ClipRasters.py script.  Most of the tools I used are ArcGIS tools that can be done in ModelBuilder with the exception of the SearchCursor.  That is only available in arcpy.
0 Kudos
EjayLai
New Contributor
I authored the tool in straight Python...You can see the source code if you right click on the script tool and hit Edit.  Or you can open up the ClipRasters.py script.  Most of the tools I used are ArcGIS tools that can be done in ModelBuilder with the exception of the SearchCursor.  That is only available in arcpy.


Got it thanks. I figure this can't be done through ModelBuilder. Those logic and loopings need to be done with ArcPy.
0 Kudos