I am new to Python and need to write a simple script (stand alone) for creating contours from a DEM. I have been looking at the syntax on this page ArcGIS Help 10.1 but am not quite sure how to understand it.
Does anyone know what a good starting place might be?
I guess I start with a #comment and go from there.
Thanks for any advice.
Natasha
Solved! Go to Solution.
Between the help page and the examples at the bottom of it for a standalone script creating contours, I'm confused why you are having issues. Could you be a little more clear about what you are having trouble with in regards to the tool syntax or python in general?
I further commented the standalone example script
# Name: Contour_Ex_02.py # Description: Creates contours or isolines from a raster surface. # Requirements: Spatial Analyst Extension # Import system modules - Don't Change import arcpy from arcpy import env from arcpy.sa import * # Set environment settings #This is the folder where your DEM is located, set your own env.workspace = "C:/sapyexamples/data" # Set local variables #This is the name of your DEM file, set your own inRaster = "elevation" #This is the amount of elevation between contours(current you would get contours at 0, 200, 400 etc.) It can be changed to any float value contourInterval = 200 #Leave this one 0 baseContour = 0 #This is the output name and location of the contour shapefile to be created, set your own outContours = "C:/sapyexamples/output/outcontours02.shp" # Check out the ArcGIS Spatial Analyst extension license - Don't Change arcpy.CheckOutExtension("Spatial") # Execute Contour - Don't Change Contour(inRaster, outContours, contourInterval, baseContour)
Between the help page and the examples at the bottom of it for a standalone script creating contours, I'm confused why you are having issues. Could you be a little more clear about what you are having trouble with in regards to the tool syntax or python in general?
I further commented the standalone example script
# Name: Contour_Ex_02.py # Description: Creates contours or isolines from a raster surface. # Requirements: Spatial Analyst Extension # Import system modules - Don't Change import arcpy from arcpy import env from arcpy.sa import * # Set environment settings #This is the folder where your DEM is located, set your own env.workspace = "C:/sapyexamples/data" # Set local variables #This is the name of your DEM file, set your own inRaster = "elevation" #This is the amount of elevation between contours(current you would get contours at 0, 200, 400 etc.) It can be changed to any float value contourInterval = 200 #Leave this one 0 baseContour = 0 #This is the output name and location of the contour shapefile to be created, set your own outContours = "C:/sapyexamples/output/outcontours02.shp" # Check out the ArcGIS Spatial Analyst extension license - Don't Change arcpy.CheckOutExtension("Spatial") # Execute Contour - Don't Change Contour(inRaster, outContours, contourInterval, baseContour)
its actually a complete script with pyscripter. I realize i can use the shell in the arc editor