Fishnet Batch

247
3
09-29-2011 03:31 PM
AdamWoodard
New Contributor
Hey,
I am looking for a way to batch out grid generation(fishnet) from Landsat imagery on hundreds of files.
         1. First is there a way to batch it out, I only need a 4x4 grid to overlay the imagery
         2. If possible, can the grid be of the active area of the imagery, landsat imagery has a square background of ???No Data???, this is what the grid usually reads from

Thanks
Adam
0 Kudos
3 Replies
markdenil
Regular Contributor II
Interesting problem.
You could start by converting the image to a polygon feature class. (Raster to Polygon)
(Maybe reclass the image to a binary raster (image = 1, nodata = nodata) first.)
This should give you a polygon of the image area: a tilted rectangle.

Run Feature Veticies To Point: this gives you corner points (plus some more, maybe)
Run Add XY Coordinates on the point class: now the points have recorded coordinates

Use a Search Cursor to find the left-most and top-most points, and grab their coordinates.

Now you want the distance between the points.
If you have ArcInfo, make a layer of the left point, and a layer of the top point,
and run Point Distance. Get the distance from the resulting table

If you DON'T:  you can use trig
OR you can generate a line between the points and get the length.... whatever.

divide the distance by 4 (for your 4 x 4 grid).

In Create Fishnet:
Fishnet Origin Coordinate = the left point
Y-Axis coordinate = the top point
Cell Size Width (and Height) distance between the points divided by 4
Number of Rows (and Cols) 4

Maybe not perfect, but its a place to start...

Oh, yes, do it in Python.... Loop through the images and clean up the intermediate files as you go.

M.Denil
0 Kudos
NobbirAhmed
Esri Regular Contributor
Use Create Fishnet tool (Data Management Tools > Feature Class toolset). Use the imagery data as the template extent.

Run once. From Results tab copy the result as Python snippet.

Then, use a python for loop to run in a batch.
0 Kudos
markdenil
Regular Contributor II
Would that not give a lattice that matches the image extent, rather than the image data area?
The need was for a grid that did not include the no data area.
I agree that the whole thing is very much simplier if the grid just has to match an orthoganal rectangle.

M.Denil
0 Kudos