AnsweredAssumed Answered

Fishnet creation with ArcPy with origin coordinates from a bounding box (ArcGis 10.0)

Question asked by mlu_lb on Sep 17, 2012
Latest reply on Sep 20, 2012 by curtvprice
Hello GIS-Community,
I'm trying to create a script that helps to create Fishnet based on an irregular formed shape (polygon). It should use the bounding box of that shape as origin coordinate (Xmin, Ymin) and opposite corner (Xmax, Ymax). I managed it to somehow get these values from a created Envelope based on that irregular shape but I can not get it to use it as an input for the Fishnet creation. Maybe it's a wrong data type!? As he sometimes stated 'Input for orig. coordinate should be numeric'.
As I never tried to create a scrit before, I mostly took ArcPy script parts from ArcGIS web help from different geoprocessing tools trying to combine them with try and error method.

It's not necessary to create all the temporary shapes such as the bounding box, but it's not a problem neither.
We're on ArcInfo licensing level.

So here is the messy script text I sticked together...
Envelope gets created as I want it. Coordinates from corners of the envelope are taken right (as 'Print' command shows), but giving these values to the fishnet creation doesn't work out.
If i give absolute numbers to 'origin coordinate', 'y-axis orientation' and 'opposite corner' it works as it should... so there must be some mistakes.

Any suggestions on that?
Thank you for your help!

# creating bounding box (envelope) import arcpy from arcpy import env env.workspace = "C:/data" arcpy.FeatureEnvelopeToPolygon_management("E:/ArcMap/1412-boundary2012_proj.shp",                                           "E:/ArcMap/1412extent.shp",                                           "SINGLEPART")  # Create a Describe object from the shapefile # desc = arcpy.Describe("E:/ArcMap/1412extent.shp")  # Print dataset properties # minX=(desc.extent.XMin)  maxX=(desc.extent.XMax)  minY=(desc.extent.YMin)  maxY=(desc.extent.YMax)  print(minX) print(maxX) print(minY) print(maxY)  #create boundary points from envelope # pxy = arcpy.Point(minX, minY) ptGeometry = arcpy.PointGeometry(pxy)  pxY = arcpy.Point(minX, maxY) ptGeometry = arcpy.PointGeometry(pxY)  pXy = arcpy.Point(maxX, minY) ptGeometry = arcpy.PointGeometry(pXy)  pXY = arcpy.Point(maxX, maxY) ptGeometry = arcpy.PointGeometry(pXY)  print(pxy) print(pxY) print(pXy) print(pXY)  print pxy.X,pxy.Y print pxy.X,pxy.Y  # Name: # Description: Creates rectangular cells # Author: ESRI  # import system module import arcpy from arcpy import env  # set workspace environment #  env.workspace = "C:/data/output"   # Set the extent environment using a keyword. arcpy.env.extent = "E:/ArcMap/1412extent.shp"  # Set coordinate system of the output fishnet #  env.outputCoordinateSystem = "<install directory>/Coordinate Systems/Projected Coordinate Systems/UTM/NAD 1983/NAD 1983 UTM Zone 11N.prj"  outFeatureClass = "E:/ArcMap/bound_net.shp"  # Set the origin of the fishnet originCoordinate = pxy.X,pxy.Y  # Set the orientation yAxisCoordinate = pxy.X,(pxy.Y+1)  # Enter 0 for width and height - these values will be calcualted by the tool cellSizeWidth = '60' cellSizeHeight = '60'  # Number of rows and columns together with origin and opposite corner  # determine the size of each cell  numRows =  '0' numColumns = '0'  oppositeCoorner = pXY.X,pXY.Y  # Create a point label feature class  labels = 'false'  # Extent is set by origin and opposite corner - no need to use a template fc templateExtent = 'E:/ArcMap/1412extent.shp'  # Each output cell will be a polygon geometryType = 'POLYGON'  arcpy.CreateFishnet_management(outFeatureClass, originCoordinate, yAxisCoordinate, cellSizeWidth, cellSizeHeight, numRows, numColumns, oppositeCoorner, labels, templateExtent, geometryType)