2

I am trying to create Hexagonal grids for each shapefile in a folder. I opted for ArcGIS Pro ModelBuilder tool and was successful in creating a loop that reads and loads shapefile in the memory. But afterwards, I am trying to grab the extents of each shapefile and want to generate Hexagonal grids for each polygon. Struggled a lot and still have not figured out where the issue is.

Attached copy of model that I built for reference.

enter image description here

2

A workaround can be to use arcpy.

import arcpy, os

input_workspace = r'C:\Test\Inputshapes' #Change, can also be a file geodatabase, if so add .gdb
output_workspace = r'C:\Test\Out_Tessellation' #Change, can also be a file geodatabase, if so add .gdb

arcpy.env.workspace = input_workspace
fclist = arcpy.ListFeatureClasses() #List all feature classes in input_workspace

for fc in fclist:
    arcpy.GenerateTessellation_management(Output_Feature_Class=os.path.join(output_workspace,'Tessellation_'+fc), 
                                         Extent=arcpy.Describe(fc).Extent, 
                                         Shape_Type='HEXAGON', 
                                         Size='1 SquareKilometers', 
                                         Spatial_Reference=arcpy.Describe(fc).spatialReference)

enter image description here

  • 1
    Thanks @BERA. The code helps to overcome the road block that I had in model builder. – ipowern Jan 14 at 17:20
2

If you read the help file syntax section what is it's second parameter? It is Extent and what is it's data type? Extent.

The output of your iterator is a FEATURECLASS, hopefully you'll agree this is not an EXTENT.

@BERA code extracts this property from the input featureclass so that the correct parameter type is fed into the tool.

The salient part is this:

arcpy.Describe(fc).Extent

If you want to keep your model you need to be looking at the model only Calculate Value tool to extract the extent from your FeatureClass and feed that into the parameter of the tessellation tool.

So @BERA has shown you the code you need to use, I've told you which tool you can do this in you just need to put it all together.

  • Nice, this is the correct answer. Tessellation was accepting the output from iterate feature classes as extent, but with an confusing error when executing – BERA Jan 14 at 11:16
  • @Hornbydd Thanks for the help. Its make sense and agree with you as GenerateTessellation expects Extent details. – ipowern Jan 14 at 17:24

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.