# 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: CreateFishnet.py # 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)
Solved! Go to Solution.
# Set the origin of the fishnet originCoordinate = "%f %f" % (pxy.X,pxy.Y) # Set the orientation yAxisCoordinate = "%f %f" % (pxy.X,(pxy.Y+1))
# Set the origin of the fishnet originCoordinate = "%f %f" % (pxy.X,pxy.Y) # Set the orientation yAxisCoordinate = "%f %f" % (pxy.X,(pxy.Y+1))
%f seems to force it to understand the points as a string? So I'll need to play around with it a bit more.
>>> "%f %f" % (1,2) '1.000000 2.000000'
originCoordinate = "{0} {1}".format(pxy.X,pxy.Y)