Exemplo n.º 1
0
def buff(bDist, out):
    arcpy.env.workspace = "C:/Users/mpleasan/Desktop/Assign9_Nov7/c11ex2.gdb/manatee/"
    lines = arcpy.ListFeatureClasses("*", "Polyline")
    for b in bDist:
        for o in out:
            vt = arcpy.ValueTable()
            vt.addRow(o)
            for l in lines:
                arcpy.Buffer_analysis(l, l + "buff" + str(b),
                                      str(b) + " Meters", "FULL", "ROUND",
                                      "ALL", "#", "PLANAR")
                vt.addRow(l + "buff" + str(b))
            print vt
            arcpy.Intersect_analysis(vt, o + "lines" + str(b))
Exemplo n.º 2
0
def firstFunction(wksp, lfc, bd, bdunits, flood, fld1, fldval):
    polygons = []
    buffDis = str(bd) + " " + bdunits
    for x in lfc:
        arcpy.Buffer_analysis(x, x + "buff", buffDis, "FULL", "ROUND", "ALL",
                              "")
        q = fld1 + " = '" + fldval + "'"
        poly = arcpy.Select_analysis("flzone", "polysel", q)
        polygons.append("polysel")
        vt = arcpy.ValueTable(2)
        bfcs = arcpy.ListFeatureClasses("*buff*", "Polygon")
        for f in bfcs:
            vt.addRow(f)
        oname = "cliparea"
        arcpy.Union_analysis(vt, "out", "ALL", "", "GAPS")
        arcpy.Dissolve_management("out", oname, "", "", "MULTI_PART",
                                  "DISSOLVE_LINES")
        return oname
Exemplo n.º 3
0
    def prepFieldMap(self):
        pp = self.ProgressPrinter.newProcess(inspect.stack()[0][3], 1,
                                             1).start()
        fm_year = arcpy.FieldMap()
        self.fms = arcpy.FieldMappings()

        self.vTab = arcpy.ValueTable()
        for dist in self.disturbances:
            ws = dist.getWorkspace()
            arcpy.env.workspace = ws
            arcpy.env.overwriteOutput = True
            fcs1 = self.scan_for_layers(ws, dist.getFilter())
            if fcs1:
                # print "Old fire list is: ", fcs1
                for fc in fcs1:
                    # fc = os.path.join(ws, fc)
                    self.fms.addTable(fc)
                    if "NBAC" in fc:
                        fm_year.addInputField(fc, dist.getYearField(), 0, 3)
                    else:
                        fm_year.addInputField(fc, dist.getYearField())
                    self.vTab.addRow(fc)

        # Set the merge rule to find the First value of all fields in the
        # FieldMap object
        fm_year.mergeRule = 'First'
        # print "vTab equals: "
        # print self.vTab
        # Set the output field properties for FieldMap objects
        field_name = fm_year.outputField
        field_name.name = 'DistYEAR'
        field_name.aliasName = 'DistYEAR'
        fm_year.outputField = field_name

        # Add the FieldMap objects to the FieldMappings object
        self.fms.addFieldMap(fm_year)
        pp.finish()
Exemplo n.º 4
0
# Read in the Parameters
baseFeatureClass = arcpy.GetParameterAsText(0)
obstructionFeatureClasses = arcpy.GetParameterAsText(1)
templateFeatureClass = arcpy.GetParameterAsText(2)
eraseOutputFeatureClass = os.path.join(arcpy.env.scratchWorkspace, "temperase")
unionedFeatureClass = os.path.join(arcpy.env.scratchWorkspace, "tempunion")
splitObstructionFeatureClasses = obstructionFeatureClasses.split(";")
numFC = len(splitObstructionFeatureClasses)

# Union together the obstructions and then erase them
if obstructionFeatureClasses != "" and numFC > 0:

    arcpy.AddMessage(str(numFC) + " feature class(es) provided")
    # create a value table
    vtab = arcpy.ValueTable(2)
    vtab.loadFromString(obstructionFeatureClasses)

    # union
    arcpy.AddMessage("unionedFeatureClass: " + unionedFeatureClass)
    arcpy.Union_analysis(vtab, unionedFeatureClass)
    deleteme.append(unionedFeatureClass)
    deleteme.append(eraseOutputFeatureClass)
    # Erase
    arcpy.Erase_analysis(baseFeatureClass, unionedFeatureClass,
                         eraseOutputFeatureClass)
    arcpy.CopyFeatures_management(eraseOutputFeatureClass,
                                  templateFeatureClass)
    if DEBUG == True:
        arcpy.AddMessage("Features copied from union to template")
else:
Exemplo n.º 5
0
7   To later revise any of this, right-click to the tool's name and select Properties.
"""

# Import external modules
import sys, string, os, arcpy, traceback
import numpy as np
from scipy.special import expit as activation_function
from scipy.stats import truncnorm
from arcpy.sa import *

arcpy.env.overwriteOutput = True

try:

    value_table = arcpy.ValueTable()
    result_table = arcpy.ValueTable()

    value_table.loadFromString(arcpy.GetParameterAsText(0))
    target = arcpy.GetParameterAsText(2)
    output = arcpy.GetParameterAsText(3)

    if arcpy.GetParameterAsText(1):
        result_table.loadFromString(arcpy.GetParameterAsText(1))
    else:
        result_table.loadFromString(arcpy.GetParameterAsText(0))

    def raster_to_grid(input_table):
        input_grid_name_list = []

        # Loop through the list of inputs
    # Local variables

    arcpy.env.workspace = r"c:\ArcpyBook\data"
    outFeatureClass = r"c:\ArcpyBook\data\AllTracts.shp"

    # Create a fieldmappings adding the three new fields
    fieldmappings = arcpy.FieldMappings()
    fldmap_STFIPS = arcpy.FieldMap()
    fldmap_COFIPS = arcpy.FieldMap()
    fldmap_TRACT = arcpy.FieldMap()

    # List all feature classes that start with 'County' and type Polygon
    fclss = arcpy.ListFeatureClasses("County*", "Polygon")

    # Create a value table with the FC to merge
    vTab = arcpy.ValueTable()
    for fc in fclss:
        fieldmappings.addTable(fc)
        fldmap_STFIPS.addInputField(fc, "STFID")
        fldmap_COFIPS.addInputField(fc, "STFID")
        fldmap_TRACT.addInputField(fc, "STFID")
        vTab.addRow(fc)

    # Set Starting and ending point from the input as well as the name of the output fields

    # STFIPS field
    for x in range(0, fldmap_STFIPS.inputFieldCount):
        fldmap_STFIPS.setStartTextPosition(x, 0)
        fldmap_STFIPS.setEndTextPosition(x, 1)

    fld_STFIPS = fldmap_STFIPS.outputField