Creating fishnet using a template

539
4
Jump to solution
10-04-2023 07:41 PM
JasmineSpring
New Contributor III

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")

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JasmineSpring
New Contributor III

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 

View solution in original post

0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

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")

 


... sort of retired...
0 Kudos
JasmineSpring
New Contributor III

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.

JasmineSpring_0-1696562434765.png

thank you so much!

 

0 Kudos
DanPatterson
MVP Esteemed Contributor

It looks like you have to get the origin from the template featureclass then


... sort of retired...
0 Kudos
JasmineSpring
New Contributor III

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 

0 Kudos