Create fishnet in iterative model

6601
15
07-19-2011 11:52 AM
deleted-user-qQeebl6UEQjh
New Contributor
I wonder if anyone has any ideas on the following.

I am using Create Fishnet in an iterative model. The goal being to flip through all features in a feature class and create a fishnet from the bounding coordinates of each individual feature. Fishnet is fed from a feature layer denoted with the %n% keyword but the extents data does not update. The result is the same grid being created over and over again. Is there any way to ensure that the extents are being updated?
0 Kudos
15 Replies
DaleHoneycutt
Occasional Contributor III
0 Kudos
MarkZweifler
New Contributor II
Hi Señor and Trevor,

It's been a while; we will be looking into enhancements for the Create Fishnet tool. Both of you needed fishnets for individual features; could you describe why you want a fishnet per feature? What is the application/story?  Your use cases would help us understand the requirements and provide the right solutions.

If you have any additional criteria about creating fishnet, please let me know. I appreciate your time and input.

Thanks a lot!


I am wanting to do this to create a nested hierarchical grid similar to the U.S. National Grid or Military Grid. So that I have a repeating 1-4 ( 2 * 2) grid for each cell at its next highest level in the nested hierarchy.
0 Kudos
MarkZweifler
New Contributor II
As a non-Python guy I was able to devise a Model Builder workaround that involved coverting each iterated  selected polygon to a raster subdivided into pixels at the desired size. Then through a series of steps converting that raster back to a polygon layer

see screenshot below

[ATTACH=CONFIG]19338[/ATTACH]
0 Kudos
curtvprice
MVP Esteemed Contributor
I had a different solution to get around the not-so-helpful extent  handling in ModelBuilder iteration:

I used Calculate Value to extract the extent and then split that result to calculate the other parameters for the Create Fishnet tool.

Here are two of the Calculate Value setups and how I put the model together. Note I added some grace area around the extent (hence the complicated math):

[ATTACH=CONFIG]19389[/ATTACH][ATTACH=CONFIG]19390[/ATTACH]

[ATTACH=CONFIG]19391[/ATTACH]
0 Kudos
nedamohammadi1
New Contributor
Dear Esri member,
thank you so much for this code, I exactly used this , but still I have problem with this error:
'str' object has no attribute 'XMin'
could you help me?I want to build a model for creat fishnet for several raster files ..

regards

Nedaaa
0 Kudos
curtvprice
MVP Esteemed Contributor
I exactly used this , but still I have problem with this error:
'str' object has no attribute 'XMin'


Sorry about that, here's an example of the code that does not work (it worked at 9.x):

def Origin(ext):
  ext = ext.split()
  return "%s %s" % (ext[0], ext[1])


Since extent is now handled as a full-fledged object, you can fix this code by either converting it to a string:

def Origin(ext):
  ext = str(ext).split()
  return "%s %s" % (ext[0], ext[1])


or requesting the extent object properties directly (probably the best way):

def Origin(ext):
  return "%s %s" % (ext.XMin, ext.YMin)
0 Kudos