Although I can’t call myself a Python expert, from time to time I come across some interesting workflows worth sharing through this blog. This short story will be my first post on using Python to solve some non-standard tasks in ArcGIS for Desktop 10.2.1
This blog was actually created from a support incident where one of my clients asked me how to export the raster datasets that are stored within a file geodatabase, and referenced in a “Raster” attribute field, into a set of external files stored in one of the common files “. TIF” or “.JPEG.”
Ok, so here are a few pointers:
1. Imagine that we have a geodatabase with a point feature class and it contains two important attribute fields [image] and [name] (raster and text field types accordingly).
2. We need to export rasters from that geodatabase and produce a single JPEG or TIFF file per row. To make things more challenging we need to name the output rasters using the value stored in the corresponding row in the attribute field called [NAME], as above.
A small dataset can be processed manually: we can click on each raster (the “>” symbol within the raster field) and use the Save As option.
But what if the dataset contained thousands of records?? Well, we would have to play around with a Python code.
The following simple code can help you to resolve this monumental task: (click on the image to view it in high resolution):
The subsequent output will be a set of TIFF files created in a folder specified in the script.
To run the script, use Notepad or any other text editor app, save the code as a *.py file, replace the paths and field names and just load it to the Python Window in ArcMap. But please note that the above script is shared as a recommendation only and Esri Australia is not responsible for anything related to the deployment of this script. Just a friendly disclaimer!
A request for this functionality to be included in the core software had also been posted as a software enhancement idea on ideas.arcgis.com. So if you feel that this tool could be useful, you can just jump online and vote for the idea here: >>
Enjoy geoprocessing with Python!
Special thanks to my colleagues Tania and Rhys for their participation.