I seem to use ESRI's ArcPy site package for virtually all of my Python geoprocessing. To ESRI's credit, these are an incredible suite of tools that can help accomplish a great deal. However, I would also like to create geoprocessing scripts outside of the ESRI ArcPy domain. For example, if I want to clip a raster to a polygon, I would start with the following script from ESRI:
# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
# Set environment settings
env.workspace = "C:/sapyexamples/data"
# Set local variables
inRaster = "elevation"
inMaskData = "mask.shp"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute ExtractByMask
outExtractByMask = ExtractByMask(inRaster, inMaskData)
# Save the output
outExtractByMask.save("C:/sapyexamples/output/extractmask")
I'm not sure how I would accomplish the same task programmatically without ArcPy. My questions for the serious programmers out there: What collection of Python tools do you use to accomplish tasks that ESRI users would accomplish with the ArcPy site package? Where do I begin?
Best Answer
GDAL is the tool to use. In fact that entire call is one line for gdal_rasterize:
if you knew the no data value of the dem
For some python control:
where your variables could be set in python
For full python:
I just took a quick peek at the syntax for the C API, so my syntax for python is probably off a little. See gdal_alg.h: http://gdal.org/gdal__alg_8h.html