My Talk: Extending Python Scripts
So, I gave a talk yesterday "Extending Python Scripts" (it's 5MB). I'm a big fan of using Python for geoprocessing (I'm naturally psyched about the expansion of Python capabilities coming up in 9.4).
The ability to make maps in 9.4 through Python highlights one of its current shortcomings- an analysis process must provide output that is readable to user. If you've designed the analysis, great; however, if you're deploying the process for someone else, the outputs need to be readily usable in multiple situations.
A similar situation occurs in ArcMap. One of the ways ESRI solves this is by including charting functionality and bundling Crystal Reports, an external helper tool.
In the same way, we can incorporate external libraries into our Python scripts to let us process the results of the analysis into a more usable form. This particularly useful when designing scripts for use in a server context; you are much less certain of what the user has available for tools to re-process the analysis.
In my talk, I covered 5 libraries that I've used in geoprocessing scripts:
-ReportLab, a PDF library
-xlwt, an Excel writing utility
-PIL, an image processing utility
-urllib, built-in library to grab stuff via the web
-smtplib, built-in library to send e-mails
Of these, I feel that the urllib is the most powerful. With it, you can grab data from ArcGIS Server REST sources as well as other websites. This allows you to do create mash-ups within the geoprocessing applications!
The other libraries all in some way deal with providing output. Excel and PDFs are more user friendly than shapefiles or dBase tables and more widely accepted in consumer client situations. smtplib provides the capability to e-mail the results, rather than have them displayed at the time of analysis; we've used this at public displays, where people can e-mail a report of their house to themselves while talking with our planners.
My example scripts are available at the Model and Script Tool Gallery.
The ability to make maps in 9.4 through Python highlights one of its current shortcomings- an analysis process must provide output that is readable to user. If you've designed the analysis, great; however, if you're deploying the process for someone else, the outputs need to be readily usable in multiple situations.
A similar situation occurs in ArcMap. One of the ways ESRI solves this is by including charting functionality and bundling Crystal Reports, an external helper tool.
In the same way, we can incorporate external libraries into our Python scripts to let us process the results of the analysis into a more usable form. This particularly useful when designing scripts for use in a server context; you are much less certain of what the user has available for tools to re-process the analysis.
In my talk, I covered 5 libraries that I've used in geoprocessing scripts:
-ReportLab, a PDF library
-xlwt, an Excel writing utility
-PIL, an image processing utility
-urllib, built-in library to grab stuff via the web
-smtplib, built-in library to send e-mails
Of these, I feel that the urllib is the most powerful. With it, you can grab data from ArcGIS Server REST sources as well as other websites. This allows you to do create mash-ups within the geoprocessing applications!
The other libraries all in some way deal with providing output. Excel and PDFs are more user friendly than shapefiles or dBase tables and more widely accepted in consumer client situations. smtplib provides the capability to e-mail the results, rather than have them displayed at the time of analysis; we've used this at public displays, where people can e-mail a report of their house to themselves while talking with our planners.
My example scripts are available at the Model and Script Tool Gallery.
