While running the standalone tool in ArcMap, the optional parameter TemplateExtent is a wonderful shortcut, as it autofills 10 other parameters. However, I need to run it in a standalone script, and have been unsuccessful in using the parameter as it's used in the tool: leaving these fields to be autofilled using the TemplateExtent layer's info. Instead, as seen in Creating fishnet from template feature class using ArcPy? (courtesy of radouxju), the best solution seems to involve using Describe to find and enter each parameter explicitly:
desc = arcpy.Describe(fc)
arcpy.CreateFishnet_management(fc[:-4]+"_c200.shp",str(desc.extent.lowerLeft),str(desc.extent.XMin) + " " + str(desc.extent.YMax + 10),"200","200","0","0",str(desc.extent.upperRight),"NO_LABELS","#","POLYGON")
That approach squares with the fact that the first of these parameters are required. If I'm understanding it correctly, when run in ArcPy it has no utility since all other fields are required.
Question: So should I always ignore this paramter in the ArcPy environment, just using '#' as a placeholder; or is there some other utility?
Following PolyGeo's and Midavalo's suggestions below, here's the Python snippet that results from running CreateFishnet as a tool:
arcpy.CreateFishnet_management(out_feature_class="[path]/test_fishnet", origin_coord="447677.5 3111557.5", y_axis_coord="447677.5 3111567.5", cell_width="50", cell_height="50", number_rows="0", number_columns="0", corner_coord="482222.5 3142082.5", labels="LABELS", template="mid_5m", geometry_type="POLYLINE")
#is a placeholder used in optional parameters instead of giving a value. Basically you're saying that you're not providing a value for that parameter. – Midavalo Aug 21 '16 at 22:58arcpy.CreateFishnet_management(out_feature_class="[filepath]/test_fishnet", origin_coord="447677.5 3111557.5", y_axis_coord="447677.5 3111567.5", cell_width="50", cell_height="50", number_rows="0", number_columns="0", corner_coord="482222.5 3142082.5", labels="LABELS", template="mid_5m", geometry_type="POLYLINE")Which suggests to me I can't use Template Extent as a shortcut, that I have to find each param with Describe, and input those. Would you agree?
– joechoj Sep 05 '16 at 22:54That's what my question asks that the other post doesn't address.
– joechoj Sep 06 '16 at 00:47templateparameter expects anextentto be provided - see its syntax in the tool documentation. When using the tool from its dialog it provides an additional bit of functionality that enables a feature class to be chosen to set the value of that extent, but it is the extent not the feature class that gets submitted to the underlying ArcObjects. – PolyGeo Sep 06 '16 at 00:55