import arcpy, os arcpy.env.overwriteOutput = True inPts = arcpy.GetParameterAsText(0) inDistance = arcpy.GetParameterAsText(1) outputFolder = r"c:\gpServices\writeToFolder" #this needs a matching entry in the datastore. #If you have the output param set to required, make sure the path/name in the dialog matches the path set inside the script outputFC = os.path.join(outputFolder, r"output.gdb\output2") arcpy.Buffer_analysis(inPts, outputFC, inDistance)
# Import Python Libraries import arcpy, os, string from arcpy import env # Set Overwrite Output Environment env.overwriteOutput = True # Define Output Folder outputFolder = r"E:\arcserver\data\tooldata" # helper method to check if a field exists in a fc def check_for_field(featClass,fieldName): hasField = 0 desc = arcpy.Describe(featClass) fields = desc.fields for field in fields: # check without case as ArcGIS is not case sensitive if field.name.upper() == fieldName: hasField = 1 return hasField # Define inputs # Input ISOCODE fcString = arcpy.GetParameterAsText(0) # Project Data # Input Fishnet fish = outputFolder + os.path.sep + fcString + ".gdb" + os.path.sep + fcString + "_fishnet_full_attributes" # Coordinate System wgs84 = arcpy.SpatialReference(4326) # Describe Fish desc = arcpy.Describe(fish) # Calculate Raster Extent extent = desc.Extent xmin = int(round(extent.XMin - .5)) xmax = int(round(extent.XMax + .5)) ymin = int(round(extent.YMin - .5)) ymax = int(round(extent.YMax + .5)) # Define Gridding Variables gridFieldsWildCard = arcpy.GetParameter(1)#"*TOTPOPBT_2010*M" gridFields = arcpy.ListFields(fish,gridFieldsWildCard) # Lines per degree, determines the output resolution 120 = 30 arc-seconds resolution # 1 degree divided into 120 parts is 30 seconds linespd = 120 ## Update As Needed cellSize = 1.0 / linespd # Output the gridded count rasters for field in gridFields: gridField = field.name arcpy.AddMessage("The field to be gridded is " + gridField) # Output Grids outPopGrid = outputFolder + os.path.sep + fcString + "_grids.gdb" + os.path.sep + fcString + "_" + gridField arcpy.env.extent = arcpy.Extent(xmin,ymin,xmax,ymax) arcpy.env.outputCoordinateSystem = wgs84 arcpy.env.cellSize = cellSize arcpy.AddMessage("The extent is " + str(arcpy.env.extent)) if arcpy.Exists(outPopGrid): arcpy.AddMessage(outPopGrid + " exists") else: try: arcpy.PolygonToRaster_conversion(fish,gridField,outPopGrid,'CELL_CENTER','#',cellSize) arcpy.AddMessage("Created " + outPopGrid) except: arcpy.AddMessage(arcpy.GetMessages())
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.