3

I have a layer with multiple polygons (input) and a fishnet layer in polygon (clip layer).

I want to clip the multiple polygons with the fishnet to be able to calculate how big portion of the input layer that cover each cell in the fishnet layer.

If I select a fishnet cell and run the clip tool I get what I want, the area of the input polygon(s) covering the fishnet cell. But if I dont have any cells selected from the fishnet layer and want to run it with all of them, it does not work, it clip the layer with the extent instead of the independent polygons in the fishnet.

Any suggestions of how to do this? I have arcgis 10

4

Try the following:

  1. Run an Intersect on your two polygon layers
  2. Run a custom script tool called Split Layer by Attributes

I had a similar question a while back and had great success with the advice given to me.

  • Thanks for the advice. I took a look on the tool you linked to. If I understand it right it create a shp file for each polygon? Anyway, it seem to really to do what I want. The way I worked it out was to use intersect and then the dissolve tool to get the polygons withing each of the fishnet grids. After some hassle (of what should not be a problem) I joined my dissolved layer to my fishnet layer, from there I could calculate the percentage of polygon cover within each cell (in my case forest) – user10685 Oct 22 '12 at 10:33
1

Please try the "Split" or "Union" tool instead.

  • I was trying the split tool before, but I got the error "000361 : The name starts with an invalid character". So I created a new string column and used field calculator to get my id value "1, 2, 3" etc.. But I found somewhere that it should be in alphaumerical values, If I understand that right it would be like ID1, ID2 etc. Bot how do I create such column? I have over 22000 records and cant do it by hand. – user10685 Oct 22 '12 at 7:49
0

Try this, I used it to label the grid.

A1 B1 C1.....A2 B2 C2...etc

Remember to make adjustments to the code for the # of rows and columns.

In field calculator, select python, then:

import string  
c=-1; r = 0  
def code_grid(rows=1,cols=1):  
  c += 1  
  global c, r  
  UC = list(string.ascii_uppercase)  
  if c >= cols:  
    c = 0  
    r += 1  
  label = UC[c]+str(r)  
  return label  

expression box
code_grid(4,6)
0

WAY late to the party, but I created a scrip to do this exact thing. The script takes an input shapefile and creates a grid over top of your data, performs an intersect on the original shapefile, then exports that intersection into a new layer. The orginial grid is retained as well! It works for me but as anyone looking at my code should be able to tell I'm new to this so there is for sure faster/better ways to do this.

# GridCreatorScript.py
# This script creates a grid over a user provided FC. All features can be adjusted within
# the script, designed for and optimized for >[10mil:1] scale

# --------------------------------------------------------------------------------------------
print "Importing modules and setting env settings..."

# Import modules and set enviornment settings
import arcpy, tkFileDialog
from arcpy import env

workingFolder = tkFileDialog.askdirectory(initialdir='C:/,
                                  title="Select the folder you'd like to work in")
env.overwrite = True
env.workspace = workingFolder

# Set and Describe FC Attributes
fc = tkFileDialog.askopenfilename(filetypes=[('shapefiles','*.shp')],
                                  title="Choose the SHAPEFILE you'd like to have grids created over)
desc = arcpy.Describe(fc)

print "Setting tool parameters..."

# Set tool parameters
fileName = str(workingFolder) + "/gridPoly"
out_feature_class = fileName
orgin_coord = str(desc.extent.lowerLeft)
y_axis_coord = str(desc.extent.XMin) + " " + str(desc.extent.YMax)
cell_width = "2"
cell_height = "2"
corner_coord = str(desc.extent.upperRight)
labels = "NO_LABELS"
geometry_type = "POLYGON"

print "Tool parameters set."
print "Running 'Create Fishnet' tool..."

# Run create fishnet tool
arcpy.CreateFishnet_management(out_feature_class,
                               orgin_coord,
                               y_axis_coord,
                               cell_width,
                               cell_height,
                               "",
                               "",
                               corner_coord,
                               labels,
                               "#",
                               geometry_type)

print "Grids created."
print "Creating layer from FC..."

# Make a layer from the input feature class
arcmap.MakeFeatureLayer_management(str(fileName) + ".shp", 'grid_lyr')

print "Layer created."
print "Selecting grids that intersect your feature..."

# Select from the created layer
arcpy.SelectLayerByLocation_management('grid_lyr', 'intersect', fc)

print "Features Selected"
print "Copying selected features to new layer..."

# Copy these selected features to a new layer
arcpy.CopyFeatures_management('grid_lyr', 'selectedGrids')

print "Layer created."

print "-----------------------------------"
print "Operation complete."

Your Answer

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