<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hello,<BR>
I have a large code that I am using for ARC GIS I know could be much smaller but it works like it is. I have programmed in C++ but am just beginning with python I believe the answer would be to do a parallel array however I am having trouble keeping the SQL statment in the string format it should be and putting in the array. So I ended up using a string.template and just incrementing manually.<BR>
Here is a sample of the code:<BR>
<BR>
# ---------------------------------------------------------------------------<BR># MakeFeature.py<BR># Created on: Tue Nov 23 2010 11:07:25 AM<BR># <BR># ---------------------------------------------------------------------------<BR>
# Import system modules<BR>import sys, string, os, arcgisscripting<BR>
# Create the Geoprocessor object<BR>gp = arcgisscripting.create()<BR>gp.overwriteoutput = 1<BR>
# Check out any necessary licenses<BR>gp.CheckOutExtension("spatial")<BR>
# Load required toolboxes...<BR>gp.AddToolbox("C:/Program Files (x86)/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx")<BR>gp.AddToolbox("C:/Program Files (x86)/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")<BR>
<BR># Local variables...<BR>wrs_season_Layer = "wrs_season_Layer"<BR>wrs_season_shp = "D:\\model\\wrs_season.shp"<BR>Temp_mdb = "D:\\model\\Temp.mdb"<BR>ecoregions = "D:\\model\\Eco\\wwfecoregions\ecoregions.shp"<BR>
<BR>t=string.Template("D:\\model\\Temp.mdb\\T$Num")<BR>
p = string.Template('"PATH" = $Path')t<BR>
<BR>
# Process: <BR>
<BR>
print "Calculating row <FONT color=#ff0000>1</FONT>"<BR>gp.MakeFeatureLayer_management(wrs_season_shp, wrs_season_Layer, p.substitute(Path ='<FONT color=#ff0000>1</FONT>'), Temp_mdb,)<BR>
gp.TabulateArea_sa(wrs_season_Layer,"PR", ecoregions, "BIOME", t.substitute(Num = '1'), "0.01")<BR><BR>
print "Calculating row <FONT color=#ff0000>2</FONT>"<BR>gp.MakeFeatureLayer_management(wrs_season_shp, wrs_season_Layer, p.substitute(Path ='<FONT color=#ff0000>2</FONT>'), Temp_mdb,)<BR>
gp.TabulateArea_sa(wrs_season_Layer,"PR", ecoregions, "BIOME", t.substitute(Num = '2'), "0.01")<BR>print "finished<BR>
<BR>
<BR>
<FONT color=#ff0000>#This process repeats for 200 paths each requiring a calculation and a separate table creation indicating which path they are calculating#</FONT><BR>
<FONT color=#ff0000>The problem I had when making $Path a variable is it won't process the SQL statement any longer because of the quotes around it. The format has to stay in (' "PATH" = X')</FONT><BR>
<FONT color=#ff0000>for it to ingest correctly, another way would be "\"PATH\" = 1" however the same problem arises when you try to turn the 1 into a variable.</FONT><BR>
<FONT color=#ff0000></FONT> <BR>
<FONT color=#ff0000>Any help would be much appreciated I would think I could just create a parallel array incrementing by 1 and just looping through for 233 paths?</FONT><BR>
<FONT color=#ff0000>Thankyou,</FONT><BR>
<FONT color=#ff0000>Lynn</FONT><BR>                                            </body>
</html>