POST
|
Thanks Dan, the file names and folder names are huge and renaming 17000 rasters would be a nightmare. Upon a second look I noted the python coding uses forward slashes rather than back slashes for directory paths. I also thought that the "elevation" was a variable call to the contour function but it is actually the name of the raster file you are trying to process. Below is the working code with comments for anyone it can help. This is basically from the help guide with brief commentary that tripped me up. import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "enter the directory path where your files are"
inRaster = "enter your file name with .asc at the end"
contourInterval = 5
baseContour = 0
outContours = "D:/map/dembula/really long nested folder structure with spaces in the folder name/testcountours.shp"
arcpy.CheckOutExtension("Spatial")
Contour(inRaster, outContours, contourInterval, baseContour)
... View more
12-19-2016
05:04 PM
|
0
|
2
|
1053
|
POST
|
Thanks I've used the syntax highlighter for python and keep getting syntax errors on line 4. It's a pretty long directory name and file name but I've used the syntax call from the help guide which is repeated below. import arcpy from arcpy import env from arcpy.sa import * env.workspace = "input file directory and filename" Contour("elevation", "D:\test\contour.shp", 5, 0) I've also tried copying the code from the background process syntax and getting the same error. import arcpy from arcpy import env from arcpy.sa import * Contour "input file directory and filename" "D:\test\contour.shp" 5 0 1 Can anyone please tell me if there is a glaring issue in the code?
... View more
12-19-2016
02:07 PM
|
0
|
1
|
1053
|
POST
|
Thankyou Abdullah, I'm having trouble creating a raster dataset and using model builder so I'll stick with the coding.
... View more
12-12-2016
05:30 PM
|
0
|
2
|
1053
|
POST
|
I have quite a few hundred rasters that I am looking to generate contour lines off. I have successfully run the Contour tool on individual rasters located in the 3D Analyst Tools -> Raster Surface -> toolkit but can anyone advise if there is a script or other tool that I can point to a series of directories to process quite a few hundred sets of contour lines off? I've seen the script in the help file which is below but is there a fileobject algorithm that can be run over a directory with to extract filenames with many files in it? Contour (3D Analyst) # Name: Contour_3d_Ex_02.py# Description: Creates contours or isolines from a raster surface.# Requirements: 3D Analyst Extension# Import system modulesimport arcpyfrom arcpy import env# Set environment settingsenv.workspace = "C:/data"# Set local variablesinRaster = "elevation"contourInterval = 200baseContour = 0outContours = "C:/sapyexamples/output/outcontours02.shp"# Check out the ArcGIS 3D Analyst extension licensearcpy.CheckOutExtension("3D")# Execute Contourarcpy.Contour_3d(inRaster, outContours, contourInterval, baseContour)
... View more
12-08-2016
07:06 PM
|
0
|
9
|
3206
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|