I've been trying to run an ArcPy code which creates a fishnet for sampling. Everything in the code works fine, but when it gets to arcpy.CreateFishnet_management(), it stops running.

I've already checked the documentation of ArcGIS Desktop about this function, and I don't know what I'm missing. The error says that there is no value assigned to parameter origin_coord nor to y_axis_coord. I've checked the documentation about this and in the part that describes template parameter it says:

Specify the extent of the fishnet. The extent can be entered by specifying the coordinates or using a template dataset.

My problem is that, since I'm specifying the template to be the same as the feature, I'm leaving those parameters (origin_coord and y_axis_coord) empty, but the documentation says I could do so.

Here is the code:

# coding utf-8
import arcpy

arcpy.env.overwriteOutput = True
ws = 'D:\Projeto_VANT\SIG\proc_parc.gdb'
arcpy.env.workspace = ws

arcpy.CreatePersonalGDB_management('D:\Projeto_VANT\SIG', 'output')
outpath = 'D:\Projeto_VANT\SIG\output.mdb'

talhoes = r'teste'

estados = ('SP', 'MG')
florestas = ('PROPRIA', 'PARCERIA')

                                  """ "ESTADO" IN {} AND "FLORESTA" IN {} """.format(estados, florestas),
arcpy.FeatureClassToFeatureClass_conversion(in_features = 'talhoes_layer',
                                            out_path = outpath,
                                            out_name = 'talhoes1')
talhoes1 = r'talhoes1'

arcpy.AddField_management(talhoes1, 'CONCAT_T', 'TEXT')
arcpy.CalculateField_management(talhoes1, 'CONCAT_T', """ [ESTADO] & "_" & [CODIGO] & "_" & [TALHAO] """, 'VB')

list_of_fields = [f.name for f in arcpy.ListFields(talhoes1)]

with arcpy.da.SearchCursor(talhoes1, ['CONCAT_T', 'AREA']) as tal_cursor:
    for x in tal_cursor:
                                          """ CONCAT_T = '{}' """.format(str(x[0])))
        arcpy.env.workspace = outpath
        talhao = r'Layer_{}'.format(x[0])
        negBuf_tal = r'negBuf40_{}'.format(x[0])
        arcpy.CreateFishnet_management(out_feature_class = 'Fish_{}'.format(x[0]),
                                       cell_width = 22.6,
                                       cell_height = 22.6,
                                       number_rows= 0,
                                       number_columns = 0,
                                       labels = True,
                                       template = negBuf_tal,
                                       geometry_type = "POLYGON")

        print('Talhao {} succesfully extracted!'.format(x[0]))
        arcpy.env.workspace = ws

And here is the error message:

Traceback (most recent call last):
  File "D:/ArcPy_Classes/Scripts/sampling_sig.py", line 51, in <module>
    geometry_type = "POLYGON")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py", line 17024, in CreateFishnet
    raise e
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000735: Fishnet Origin Coordinate : Value is required
ERROR 000735: Y-Axis Coordinate : Value is required
Failed to execute (CreateFishnet).

Finally, I got it, but I had to calculate the extents.
Here is the solution I got:

desc = arcpy.Describe(negBuf_tal)
                                           str(desc.extent.XMin) + " " + str(desc.extent.YMax),
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.