my code is:
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"running..."</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> arcpy<SPAN class="punctuation token">,</SPAN> os
<SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> env
<SPAN class="keyword token">import</SPAN> os
<SPAN class="keyword token">import</SPAN> os<SPAN class="punctuation token">.</SPAN>path
env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN>r<SPAN class="string token">"P:\\GIS Public\\Projects\\Meter Zones\\route_polygons\\route_polygons.mxd"</SPAN>
<SPAN class="keyword token">global</SPAN> shp
shp <SPAN class="operator token">=</SPAN> <SPAN class="string token">".shp"</SPAN>
<SPAN class="keyword token">global</SPAN> tif
shp <SPAN class="operator token">=</SPAN> <SPAN class="string token">".tif"</SPAN>
x<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN>
in_features<SPAN class="operator token">=</SPAN> r<SPAN class="string token">'P:\\GIS Public\\Projects\\Meter Zones\\route_polygons\\meters.shp'</SPAN>
out_layer <SPAN class="operator token">=</SPAN> <SPAN class="string token">'meters_temp'</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management <SPAN class="punctuation token">(</SPAN>in_features<SPAN class="punctuation token">,</SPAN> out_layer<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN>
in_features2<SPAN class="operator token">=</SPAN> r<SPAN class="string token">'P:\\GIS Public\\Projects\\Meter Zones\\route_polygons\\parcels.shp'</SPAN>
parcles_temp <SPAN class="operator token">=</SPAN> <SPAN class="string token">'parcles_temp'</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management <SPAN class="punctuation token">(</SPAN>in_features2<SPAN class="punctuation token">,</SPAN> parcles_temp<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">while</SPAN> x <SPAN class="operator token"><=</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> arcpy<SPAN class="punctuation token">,</SPAN> os
<SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> env
<SPAN class="keyword token">import</SPAN> os
<SPAN class="keyword token">import</SPAN> os<SPAN class="punctuation token">.</SPAN>path
<SPAN class="comment token"># slection fuction: select meters with x for cycle/ route</SPAN>
layer <SPAN class="operator token">=</SPAN> out_layer
criteria <SPAN class="operator token">=</SPAN> <SPAN class="string token">'route_sequ ='</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management <SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">,</SPAN><SPAN class="string token">'NEW_SELECTION'</SPAN><SPAN class="punctuation token">,</SPAN>criteria<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#slect by location: select parcles by selected meters</SPAN>
in_layer <SPAN class="operator token">=</SPAN> parcles_temp
selector <SPAN class="operator token">=</SPAN> out_layer
distance <SPAN class="operator token">=</SPAN> <SPAN class="number token">60</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByLocation_management <SPAN class="punctuation token">(</SPAN>in_layer<SPAN class="punctuation token">,</SPAN>select_features <SPAN class="operator token">=</SPAN> selector<SPAN class="punctuation token">,</SPAN> search_distance<SPAN class="operator token">=</SPAN>distance <SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#copy features to shape file</SPAN>
in_features <SPAN class="operator token">=</SPAN> parcles_temp
out_feature_class <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"P:\\GIS Public\\Projects\\Meter Zones\\route_polygons\\"</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> shp
arcpy<SPAN class="punctuation token">.</SPAN>CopyFeatures_management<SPAN class="punctuation token">(</SPAN>in_features<SPAN class="punctuation token">,</SPAN> out_feature_class<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#merge polpgons in to 1</SPAN>
in_features <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"P:\\GIS Public\\Projects\\Meter Zones\\route_polygons\\"</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> shp
out_feature_class <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"P:\\GIS Public\\Projects\\Meter Zones\\route_polygons\\"</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">'merge'</SPAN> <SPAN class="operator token">+</SPAN> shp
arcpy<SPAN class="punctuation token">.</SPAN>Dissolve_management <SPAN class="punctuation token">(</SPAN>in_features<SPAN class="punctuation token">,</SPAN> out_feature_class<SPAN class="punctuation token">,</SPAN> multi_part<SPAN class="operator token">=</SPAN><SPAN class="string token">'MULTI_PART'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># add feild</SPAN>
in_table <SPAN class="operator token">=</SPAN> out_feature_class
field_name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Route"</SPAN>
field_type <SPAN class="operator token">=</SPAN> <SPAN class="string token">'TEXT'</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddField_management <SPAN class="punctuation token">(</SPAN>in_table<SPAN class="punctuation token">,</SPAN> field_name<SPAN class="punctuation token">,</SPAN> field_type<SPAN class="punctuation token">,</SPAN> field_length<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#populate feild</SPAN>
in_table <SPAN class="operator token">=</SPAN>out_feature_class
field<SPAN class="operator token">=</SPAN> <SPAN class="string token">"Route"</SPAN>
expression <SPAN class="operator token">=</SPAN> x
arcpy<SPAN class="punctuation token">.</SPAN>CalculateField_management <SPAN class="punctuation token">(</SPAN>in_table<SPAN class="punctuation token">,</SPAN> field<SPAN class="punctuation token">,</SPAN> expression<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#add cycle feild</SPAN>
in_table <SPAN class="operator token">=</SPAN> out_feature_class
field_name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Cycle"</SPAN>
field_type <SPAN class="operator token">=</SPAN> <SPAN class="string token">'TEXT'</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddField_management <SPAN class="punctuation token">(</SPAN>in_table<SPAN class="punctuation token">,</SPAN> field_name<SPAN class="punctuation token">,</SPAN> field_type<SPAN class="punctuation token">,</SPAN> field_length<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#apend in to database</SPAN>
inputs <SPAN class="operator token">=</SPAN> out_feature_class
target <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"P:\\GIS Public\\Projects\\Meter Zones\\route_polygons\\route_polygons.shp"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Append_management <SPAN class="punctuation token">(</SPAN>inputs<SPAN class="punctuation token">,</SPAN> target<SPAN class="punctuation token">,</SPAN> schema_type<SPAN class="operator token">=</SPAN><SPAN class="string token">'NO_TEST'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># expoert to raster</SPAN>
in_features <SPAN class="operator token">=</SPAN>r<SPAN class="string token">"P:\\GIS Public\\Projects\\Meter Zones\\route_polygons\\"</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">'merge'</SPAN> <SPAN class="operator token">+</SPAN> shp
value_field <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Route"</SPAN>
out_rasterdataset <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"P:\\GIS Public\\Projects\\Meter Zones\\route_polygons\\TIFF"</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">".tif"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>PolygonToRaster_conversion <SPAN class="punctuation token">(</SPAN>in_features<SPAN class="punctuation token">,</SPAN> value_field<SPAN class="punctuation token">,</SPAN> out_rasterdataset<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> x
x<SPAN class="operator token">=</SPAN>x<SPAN class="operator token">+</SPAN><SPAN class="number token">1</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"done"</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
everything works except for the last function PolygonToRaster. the error i get is:
Traceback (most recent call last):
File "P:\GIS Public\Projects\Meter Zones\route_polygons\make_route_pologons.py", line 53, in <module>
arcpy.Dissolve_management (in_features, out_feature_class, multi_part='MULTI_PART')
File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 4192, in Dissolve
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset P:\\GIS Public\\Projects\\Meter Zones\\route_polygons\\1.tif does not exist or is not supported
Failed to execute (Dissolve).
i need to export the files in to a TIFF file. i know something wrong with the line out_rasterdataset = r"P:\\GIS Public\\Projects\\Meter Zones\\route_polygons\\TIFF" + str(x) + ".tif". can you help with the syntax?
thank you