Hello
I need some help to work out how to configure create fishnet using a template specified in the parameter of a script tool to create a 2m grid. Im not sure how to get the x and Y values from the template. Thank you for your help its very apprecaited
Output1 = arcpy.GetParameterAsText(0)
Input1 = arcpy.GetParameterAsText(1)
arcpy.management.CreateFishnet(Output1,"","" , '2', '2',None,None,"", "NO_LABELS", Input 1, "POLYGON")
Solved! Go to Solution.
This is the solution I used in the end
desc = arcpy.Describe(Templatelayer)
arcpy.CreateFishnet_management(Grid_layer,str(desc.extent.lowerLeft),str(desc.extent.XMin) + " " + str(desc.extent.YMax),"2","2",None,None,str(desc.extent.upperRight),"NO_LABELS","#","POLYGON")
. Thank you for your help
why not add another parameter and set its default value
size - arcpy.GetParameterAsText(2)
arcpy.management.CreateFishnet(Output1,"","" , size, size,None,None,"", "NO_LABELS", Input 1, "POLYGON")
The size is ok because it is always 2m. It is using the template (another layer) set as a parameter that is the issue when its scripted in python. I get the following error.
thank you so much!
It looks like you have to get the origin from the template featureclass then
This is the solution I used in the end
desc = arcpy.Describe(Templatelayer)
arcpy.CreateFishnet_management(Grid_layer,str(desc.extent.lowerLeft),str(desc.extent.XMin) + " " + str(desc.extent.YMax),"2","2",None,None,str(desc.extent.upperRight),"NO_LABELS","#","POLYGON")
. Thank you for your help
Hi @JasmineSpring ,
Sorry I am very late to this and know its solved but a similar solution from me. I am only interested in making 2 rows and 4 columns but here is the code for what it is worth.
import arcpy
import os
wksp = r"Insert workspace here"
in_md = "Insert name of input dataset"
out_fc = "Insert name output feature class"
arcpy.env.workspace = wksp
# Create a fishnet grid
desc = arcpy.Describe(in_md)
xmin = desc.extent.XMin
xmax = desc.extent.XMax
ymin = desc.extent.YMin
ymax = desc.extent.YMax
point_origin = f'{xmin} {ymin}'
point_yaxis = f'{xmin} {ymax}'
arcpy.CreateFishnet_management(out_feature_class=out_fc,
origin_coord=point_origin,
y_axis_coord=point_yaxis,
number_rows="2",
number_columns="4",
labels="NO_LABELS",
template=in_md,
geometry_type="POLYGON")
Cheers,
Nick