当前位置: 首页>>代码示例>>Python>>正文


Python SSUtilities.getCount方法代码示例

本文整理汇总了Python中SSUtilities.getCount方法的典型用法代码示例。如果您正苦于以下问题:Python SSUtilities.getCount方法的具体用法?Python SSUtilities.getCount怎么用?Python SSUtilities.getCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SSUtilities的用法示例。


在下文中一共展示了SSUtilities.getCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
    def __init__(self, inputFC):
        outputFC = ""
        ssdo1 = SSDO_102.SSDataObject(inputFC, templateFC = outputFC)
        ssdo2 = SSDO.SSDataObject(inputFC, templateFC = outputFC)

        n = UTILS.getCount(inputFC)

        self.doCollectEvent(inputFC, n, ssdo1, ssdo2)
开发者ID:leochin,项目名称:SS_performanceTest,代码行数:10,代码来源:zCollectEvent_class.py

示例2: calculateAreas

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
def calculateAreas(inputFC, outputFC):
    """Creates a new feature class from the input polygon feature class 
    and adds a field that includes the area of the polygons.

    INPUTS:
    inputFC (str): path to the input feature class
    outputFC (str): path to the output feature class
    """

    #### Validate Output Workspace ####
    ERROR.checkOutputPath(outputFC)
    outPath, outName = OS.path.split(outputFC)

    #### Create SSDataObject ####
    ssdo = SSDO.SSDataObject(inputFC, templateFC = outputFC,
                             useChordal = False)

    #### Assure Polygon FC ####
    if ssdo.shapeType.lower() != "polygon":
        ARCPY.AddIDMessage("ERROR", 931)
        raise SystemExit()

    #### Check Number of Observations ####
    cnt = UTILS.getCount(inputFC)
    ERROR.errorNumberOfObs(cnt, minNumObs = 1)

    #### Copy Features ####
    try:
        clearCopy = UTILS.clearExtent(DM.CopyFeatures)
        clearCopy(inputFC, outputFC)
    except:
        ARCPY.AddIDMessage("ERROR", 210, outputFC)
        raise SystemExit()

    #### Add Area Field ####
    areaFieldNameOut = ARCPY.ValidateFieldName(areaFieldName, outPath)
    if not ssdo.allFields.has_key(areaFieldNameOut): 
        UTILS.addEmptyField(outputFC, areaFieldNameOut, "DOUBLE")

    #### Calculate Field ####
    clearCalc = UTILS.clearExtent(DM.CalculateField)
    clearCalc(outputFC, areaFieldNameOut, "!shape.area!", "PYTHON_9.3")
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:44,代码来源:CalculateAreas.py

示例3: checkBoundary

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
    def checkBoundary(self):
        printOHSSubject(84486, addNewLine = False)

        #### Assure That There Is Only a Single Polygon ####
        cnt = UTILS.getCount(self.boundaryFC)
        if cnt > 1:
            #### Dissolve Polys into Boundary ####
            dissolveFC = UTILS.returnScratchName("Dissolve_TempFC")
            DM.Dissolve(self.boundaryFC, dissolveFC, "#", "#", "SINGLE_PART",
                        "DISSOLVE_LINES")
            self.boundaryFC = dissolveFC
            self.cleanUpList.append(dissolveFC)

        #### Read Boundary FC ####
        ssdoBound = SSDO.SSDataObject(self.boundaryFC,
                                 explicitSpatialRef = self.ssdo.spatialRef,
                                 silentWarnings = True,
                                 useChordal = True)

        polyDict, polyAreas = UTILS.readPolygonFC(self.boundaryFC,
                                spatialRef = self.ssdo.spatialRef,
                                useGeodesic = self.ssdo.useChordal)
        self.boundArea = sum(polyAreas.values())
        self.boundExtent = getPolyExtent(polyDict)

        del ssdoBound

        if UTILS.compareFloat(0.0, self.boundArea):
            #### Invalid Study Area ####
            ARCPY.AddIDMessage("ERROR", 932)
            self.cleanUp()
            raise SystemExit()
        else:
            areaStr = self.ssdo.distanceInfo.printDistance(self.boundArea)
            msg = ARCPY.GetIDMessage(84492).format(areaStr)
            printOHSAnswer(msg)
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:38,代码来源:OptimizedHotSpotAnalysis.py

示例4: polygon2SWM

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
def polygon2SWM(inputFC, swmFile, masterField, 
                concept = "EUCLIDEAN", kNeighs = 0,
                rowStandard = True, contiguityType = "ROOK"):
    """Creates a sparse spatial weights matrix (SWM) based on polygon
    contiguity. 

    INPUTS: 
    inputFC (str): path to the input feature class
    swmFile (str): path to the SWM file.
    masterField (str): field in table that serves as the mapping.
    concept: {str, EUCLIDEAN}: EUCLIDEAN or MANHATTAN
    kNeighs {int, 0}: number of neighbors to return (1)
    rowStandard {bool, True}: row standardize weights?
    contiguityType {str, Rook}: {Rook = Edges Only, Queen = Edges/Vertices}

    NOTES:
    (1) kNeighs is used if polygon is not contiguous. E.g. Islands
    """

    #### Set Default Progressor for Neigborhood Structure ####
    ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84143))

    #### Create SSDataObject ####
    ssdo = SSDO.SSDataObject(inputFC, templateFC = inputFC,
                             useChordal = True)
    cnt = UTILS.getCount(inputFC)
    ERROR.errorNumberOfObs(cnt, minNumObs = 2)

    #### Validation of Master Field ####
    verifyMaster = ERROR.checkField(ssdo.allFields, masterField, 
                                    types = [0,1])

    #### Create GA Data Structure ####
    gaTable, gaInfo = WU.gaTable(ssdo.catPath, [masterField],
                                 spatRef = ssdo.spatialRefString)

    #### Assure Enough Observations ####
    N = gaInfo[0]
    ERROR.errorNumberOfObs(N, minNumObs = 2)

    #### Assure k-Nearest is Less Than Number of Features ####
    if kNeighs >= N:
        ARCPY.AddIDMessage("ERROR", 975)
        raise SystemExit()

    #### Create Nearest Neighbor Search Type For Islands ####
    if kNeighs > 0:
        gaSearch = GAPY.ga_nsearch(gaTable)
        concept, gaConcept = WU.validateDistanceMethod(concept, ssdo.spatialRef)
        gaSearch.init_nearest(0.0, kNeighs, gaConcept)
        forceNeighbor = True
        neighWeights = ARC._ss.NeighborWeights(gaTable, gaSearch, 
                                               weight_type = 1,
                                               row_standard = False)
    else:
        forceNeighbor = False
        neighSearch = None

    #### Create Polygon Neighbors ####
    polyNeighborDict = WU.polygonNeighborDict(inputFC, masterField, 
                                   contiguityType = contiguityType)

    #### Write Poly Neighbor List (Dict) ####
    #### Set Progressor for SWM Writing ####
    ARCPY.SetProgressor("step", ARCPY.GetIDMessage(84127), 0, N, 1)

    #### Initialize Spatial Weights Matrix File ####
    if contiguityType == "ROOK":
        wType = 4
    else:
        wType = 5

    swmWriter = WU.SWMWriter(swmFile, masterField, ssdo.spatialRefName, 
                             N, rowStandard, inputFC = inputFC,
                             wType = wType, distanceMethod = concept,
                             numNeighs = kNeighs)

    #### Keep Track of Polygons w/o Neighbors ####
    islandPolys = []
    
    #### Write Polygon Contiguity to SWM File ####
    for row in xrange(N):
        rowInfo = gaTable[row]
        oid = rowInfo[0]
        masterID = rowInfo[2]
        neighs = polyNeighborDict[masterID]
        nn = len(neighs)
        if forceNeighbor:
            if nn < kNeighs:
                #### Only Force KNN If Specified & Contiguity is Less ####
                islandPolys.append(oid)
                flag = True
                knnNeighs, knnWeights = neighWeights[row]
                c = 0
                while flag:
                    try:
                        neighID = gaTable[knnNeighs[c]][2]
                        if neighID not in neighs:
                            neighs.append(neighID)
                            nn += 1
#.........这里部分代码省略.........
开发者ID:leochin,项目名称:GSWMtest,代码行数:103,代码来源:Weights.py

示例5: obtainData

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
    def obtainData(self, masterField, fields = [], types = [0,1,2,3,4,5,6],
                   minNumObs = 0, warnNumObs = 0, dateStr = False,
                   explicitBadRecordID = None):
        """Takes a list of field names and returns it in a dictionary
        structure.

        INPUTS:
        masterField (str): name of field being used as the master
        fields {list, []}: name(s) of the field to be returned
        types (list): types of data allowed to be returned (1)
        minNumObs {int, 0}: minimum number of observations for error
        warnNumObs {int, 0}: minimum number of observations for warning
        OID {bool, False}: OID field allowed to be master field?

        ATTRIBUTES:
        gaTable (structure): instance of the GA Table
        fields (dict): fieldName = instance of FCField
        master2Order (dict): masterID = order in lists
        order2Master (dict): order in lists = masterID
        masterField (str): field that serves as the master
        badRecords (list): master IDs that could not be read
        xyCoords (array, nunObs x 2): xy-coordinates for feature centroids
        """

        #### Get Base Count, May Include Bad Records ####
        cnt = UTILS.getCount(self.inputFC)

        #### Validation of Master Field ####
        verifyMaster = ERROR.checkField(self.allFields, masterField,
                                        types = [0,1,5])

        #### Set MasterIsOID Boolean ####
        self.masterIsOID = masterField == self.oidName

        #### Set Master and Data Indices ####
        if self.masterIsOID:
            self.masterColumnIndex = 0
            self.dataColumnIndex = 2
            fieldList = [self.oidName, "[email protected]"]
        else:
            self.masterColumnIndex = 2
            self.dataColumnIndex = 3
            fieldList = [self.oidName, "[email protected]", masterField]

        #### Initialization of Centroids  ####
        xyCoords = NUM.empty((cnt, 2), float)

        #### Validation and Initialization of Data Fields ####
        numFields = len(fields)
        fieldTypes = {}
        hasDate = False
        for field in fields:
            fieldType = ERROR.checkField(self.allFields, field, types = types)
            fieldTypes[field] = fieldType
            fieldList.append(field)
            self.fields[field] = self.allFields[field]
            if fieldType.upper() == "DATE":
                hasDate = True
                nowTime = DT.datetime.now()

        #### Create Empty Data Arrays ####
        for fieldName, fieldObj in self.fields.iteritems():
            fieldObj.createDataArray(cnt, dateStr = dateStr)

        #### Z Coords ####
        if self.hasZ:
            zCoords = NUM.empty((cnt, ), float)
            fieldList.append("[email protected]")

        #### Keep track of Invalid Fields ####
        badIDs = []
        badRecord = 0

        #### Create Progressor Bar ####
        ARCPY.SetProgressor("step", ARCPY.GetIDMessage(84001), 0, cnt, 1)

        #### Process Field Values ####
        try:
            rows = DA.SearchCursor(self.inputFC, fieldList, "",
                                   self.spatialRefString)
        except:
            ARCPY.AddIDMessage("ERROR", 204)
            raise SystemExit()

        c = 0
        for row in rows:
            oid = row[0]
            badXY = row[1].count(None)
            if self.hasZ:
                badValues = row[0:-1].count(None)
            else:
                badValues = row.count(None)

            #### Check Bad Record ####
            if badXY or badValues:
                badRow = 1
                badRecord = 1
                badIDs.append(oid)
            else:
                #### Get Centroid and Master ID ####
#.........这里部分代码省略.........
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:103,代码来源:SSDataObject.py

示例6: obtainDataGA

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
    def obtainDataGA(self, masterField, fields = [], types = [0,1,2,3,5,6],
                     minNumObs = 0, warnNumObs = 0):
        """Takes a list of field names and returns it in a dictionary
        structure.

        INPUTS:
        masterField (str): name of field being used as the master
        fields {list, []}: name(s) of the field to be returned
        types (list): types of data allowed to be returned (1)
        minNumObs {int, 0}: minimum number of observations for error
        warnNumObs {int, 0}: minimum number of observations for warning

        ATTRIBUTES:
        gaTable (structure): instance of the GA Table
        fields (dict): fieldName = instance of FCField
        master2Order (dict): masterID = order in lists
        order2Master (dict): order in lists = masterID
        masterField (str): field that serves as the master
        badRecords (list): master IDs that could not be read
        xyCoords (array, nunObs x 2): xy-coordinates for feature centroids

        NOTES:
        (1) No Text Fields; short [0], long [1], float [2], double[3]
        """

        #### Validation of Master Field ####
        verifyMaster = ERROR.checkField(self.allFields, masterField,
                                        types = [0,1,5])

        #### Set MasterIsOID Boolean ####
        self.masterIsOID = masterField == self.oidName

        #### Set Master and Data Indices ####
        if self.masterIsOID:
            self.masterColumnIndex = 0
            self.dataColumnIndex = 2
            fieldList = []
        else:
            self.masterColumnIndex = 2
            self.dataColumnIndex = 3
            fieldList = [masterField]

        #### Validation and Initialization of Data Fields ####
        numFields = len(fields)
        for field in fields:
            fType = ERROR.checkField(self.allFields, field, types = types)
            fieldList.append(field)
            self.fields[field] = self.allFields[field]

        #### ZCoords Are Last ####
        getZBool = self.hasZ and (not self.renderType)
        if getZBool:
            fieldList.append("SHAPE&Z")

        #### Create GA Data Structure ####
        cnt = UTILS.getCount(self.inputFC)
        fieldList = tuple(fieldList)
        gaTable, gaInfo = WU.gaTable(self.inputFC, fieldNames = fieldList,
                                     spatRef = self.spatialRefString)

        #### Check Whether the Number of Features is Appropriate ####
        numObs = gaInfo[0]
        ERROR.checkNumberOfObs(numObs, minNumObs = minNumObs,
                               warnNumObs = warnNumObs,
                               silentWarnings = self.silentWarnings)

        #### Process any bad records encountered ####
        numBadIDs = cnt - numObs
        if numBadIDs:
            badIDs = WU.parseGAWarnings(gaTable.warnings)
            if not self.silentWarnings:
                ERROR.reportBadRecords(cnt, numBadIDs, badIDs,
                                       label = self.oidName)
        else:
            badIDs = []

        #### Initialization of Centroids  ####
        xyCoords = NUM.empty((numObs, 2), float)

        #### Z Coords ####
        if self.hasZ:
            zCoords = NUM.empty((numObs, ), float)

        #### Create Empty Data Arrays ####
        for fieldName, fieldObj in self.fields.iteritems():
            fieldObj.createDataArray(numObs)

        #### Populate SSDataObject ####
        ARCPY.SetProgressor("step", ARCPY.GetIDMessage(84001), 0, numObs, 1)
        for row in xrange(numObs):
            rowInfo = gaTable[row]
            x,y = rowInfo[1]
            masterID = int(rowInfo[self.masterColumnIndex])
            if self.master2Order.has_key(masterID):
                ARCPY.AddIDMessage("ERROR", 644, masterField)
                ARCPY.AddIDMessage("ERROR", 643)
                raise SystemExit()
            else:
                self.master2Order[masterID] = row
                self.order2Master[row] = masterID
#.........这里部分代码省略.........
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:103,代码来源:SSDataObject.py

示例7: __init__

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
 def __init__(self, inputFC):
     n = UTILS.getCount(inputFC)
     self.doKFunction(inputFC, n)
开发者ID:leochin,项目名称:SS_performanceTest,代码行数:5,代码来源:zKFunction_class.py

示例8: __init__

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
 def __init__(self, inputFC, masterField):
     n = UTILS.getCount(inputFC)
     self.doSWM(inputFC, masterField, n)
开发者ID:leochin,项目名称:SS_performanceTest,代码行数:5,代码来源:zGenerateSWM_class.py

示例9: spaceTime2SWM

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
def spaceTime2SWM(inputFC, swmFile, masterField, concept = "EUCLIDEAN",
                  threshold = None, rowStandard = True,
                  timeField = None, timeType = None,
                  timeValue = None):
    """
    inputFC (str): path to the input feature class
    swmFile (str): path to the SWM file.
    masterField (str): field in table that serves as the mapping.
    concept: {str, EUCLIDEAN}: EUCLIDEAN or MANHATTAN 
    threshold {float, None}: distance threshold
    rowStandard {bool, True}: row standardize weights?
    timeField {str, None}: name of the date-time field
    timeType {str, None}: ESRI enumeration of date-time intervals
    timeValue {float, None}: value forward and backward in time
    """

    #### Assure Temporal Parameters are Set ####
    if not timeField:
        ARCPY.AddIDMessage("ERROR", 1320)
        raise SystemExit()
    if not timeType:
        ARCPY.AddIDMessage("ERROR", 1321)
        raise SystemExit()
    if not timeValue or timeValue <= 0:
        ARCPY.AddIDMessage("ERROR", 1322)
        raise SystemExit()

    #### Create SSDataObject ####
    ssdo = SSDO.SSDataObject(inputFC, templateFC = inputFC,
                             useChordal = True)
    cnt = UTILS.getCount(inputFC)
    ERROR.errorNumberOfObs(cnt, minNumObs = 2)
    ARCPY.SetProgressor("step", ARCPY.GetIDMessage(84001), 0, cnt, 1)

    #### Validation of Master Field ####
    verifyMaster = ERROR.checkField(ssdo.allFields, masterField, types = [0,1])
    badIDs = []

    #### Create Temporal Hash ####
    timeInfo = {}
    xyCoords = NUM.empty((cnt, 2), float)

    #### Process Field Values ####
    fieldList = [masterField, "[email protected]", timeField]
    try:
        rows = DA.SearchCursor(ssdo.catPath, fieldList, "", 
                               ssdo.spatialRefString)
    except:
        ARCPY.AddIDMessage("ERROR", 204)
        raise SystemExit()

    #### Add Data to GATable and Time Dictionary ####
    c = 0
    for row in rows:
        badRow = False

        #### Assure Masterfield is Valid ####
        masterID = row[0]
        if masterID == None or masterID == "":
            badRow = True

        #### Assure Date/Time is Valid ####
        timeStamp = row[-1]
        if timeStamp == None or timeStamp == "":
            badRow = True

        #### Assure Centroid is Valid ####
        badXY = row[1].count(None)
        if not badXY:
            x,y = row[1]
            xyCoords[c] = (x,y)
        else:
            badRow = True

        #### Process Data ####
        if not badRow:
            if timeInfo.has_key(masterID):
                #### Assure Uniqueness ####
                ARCPY.AddIDMessage("Error", 644, masterField)
                ARCPY.AddIDMessage("Error", 643)
                raise SystemExit()
            else:
                #### Fill Date/Time Dict ####
                startDT, endDT = TUTILS.calculateTimeWindow(timeStamp, 
                                                            timeValue, 
                                                            timeType)
                timeInfo[masterID] = (timeStamp, startDT, endDT)

        else:
            badIDs.append(masterID)

        #### Set Progress ####
        c += 1
        ARCPY.SetProgressorPosition()

    #### Clean Up ####
    del rows

    #### Get Set of Bad IDs ####
    numBadObs = len(badIDs)
#.........这里部分代码省略.........
开发者ID:leochin,项目名称:GSWMtest,代码行数:103,代码来源:Weights.py

示例10: __init__

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
    def __init__(self, inputFC):
        n = UTILS.getCount(inputFC)

        self.doCalDisBand(inputFC, n)
开发者ID:leochin,项目名称:SS_performanceTest,代码行数:6,代码来源:zCalculateDistanceBand_class.py

示例11: initialize

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
    def initialize(self):
        """Reads data into a GA structure for neighborhood searching and
        sets the study area envelope."""

        #### Shorthand Attributes ####
        ssdo = self.ssdo
        weightField = self.weightField
        if weightField:
            fieldList = [weightField]
        else:
            fieldList = []

        #### Create GA Data Structure ####
        ssdo.obtainDataGA(ssdo.oidName, fieldList, minNumObs = 3, 
                          warnNumObs = 30)
        N = len(ssdo.gaTable)

        #### Get Weights ####
        if weightField:
            weights = ssdo.fields[weightField].returnDouble()
            #### Report No Weights ####
            weightSum = weights.sum()
            if not weightSum > 0.0: 
                ARCPY.AddIDMessage("ERROR", 898)
                raise SystemExit()

        
        #### Set Study Area ####
        ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84248))
        clearedMinBoundGeom = UTILS.clearExtent(UTILS.minBoundGeomPoints)

        #### Set Initial Study Area FC ####
        if self.studyAreaMethod == 1 and self.studyAreaFC:
            #### Assure Only A Single Polygon in Study Area FC ####
            polyCount = UTILS.getCount(self.studyAreaFC)
            if polyCount != 1:
                ARCPY.AddIDMessage("ERROR", 936)
                raise SystemExit()
            self.tempStudyArea = False

            #### Read User Provided Study Area ####
            polyInfo = UTILS.returnPolygon(self.studyAreaFC, 
                                           spatialRef = ssdo.spatialRefString)
            self.studyAreaPoly, self.studyArea = polyInfo

            #### Create Temp Min. Enc. Rectangle and Class ####
            tempMBG_FC = UTILS.returnScratchName("tempMBG_FC")
            clearedMinBoundGeom(self.studyAreaPoly, tempMBG_FC, 
                                geomType = "RECTANGLE_BY_AREA",
                                spatialRef = ssdo.spatialRef)
            self.minRect = UTILS.MinRect(tempMBG_FC)
            UTILS.passiveDelete(tempMBG_FC)

        else:
            #### Create Min. Enc. Rectangle ####
            self.studyAreaFC = UTILS.returnScratchName("regularBound_FC")
            self.tempStudyArea = True
            clearedMinBoundGeom(ssdo.xyCoords, self.studyAreaFC, 
                                geomType = "RECTANGLE_BY_AREA",
                                spatialRef = ssdo.spatialRef)
            polyInfo = UTILS.returnPolygon(self.studyAreaFC, 
                                           spatialRef = ssdo.spatialRefString)
            self.studyAreaPoly, self.studyArea = polyInfo

            #### Create Min. Enc. Rectangle Class ####
            self.minRect = UTILS.MinRect(self.studyAreaFC)

            if self.reduce:
                #### Only Need To Create FC if Reduce Buffer ####
                UTILS.createPolygonFC(self.studyAreaFC, self.studyAreaPoly, 
                                      spatialRef = ssdo.spatialRefString)


        #### Set Extent and Envelope and Min Rect ####
        self.envelope = UTILS.Envelope(ssdo.extent)
        self.maxDistance = self.minRect.maxLength * 0.25
        if self.maxDistance > (self.minRect.minLength * .5):
            #### 25% of Max Extent is Larger Than Half Min Extent ####
            #### Results in Reduced Study Area Failure ####
            if self.reduce:
                self.maxDistance = self.minRect.minLength * 0.25

        #### Determine Distance Increment ####
        if not self.dIncrement:
            if self.begDist: 
                distRange = self.maxDistance - self.begDist
            else: 
                distRange = self.maxDistance
            self.dIncrement = float(distRange / self.nIncrements)

        #### Determine Starting Distance ####
        if not self.begDist:
            self.begDist = self.dIncrement
        
        #### Determine All Distance Cutoffs ####
        rangeInc = xrange(self.nIncrements)
        cutoffs = []
        for inc in rangeInc:
            val = (inc * self.dIncrement) + self.begDist
            cutoffs.append(val)
#.........这里部分代码省略.........
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:103,代码来源:KFunction.py

示例12: network2SWM

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]

#.........这里部分代码省略.........
    fieldList = ";".join( ["NAME", totalImpedance] )

    #### Get Chunks if Necessary ####
    numOrigins = int(10000000. / numObs)
    allMaster.sort()
    chunkedIDs = UTILS.chunk(allMaster, numOrigins)
    sqlStrings = UTILS.sqlChunkStrings(inputFC, masterField, chunkedIDs)
    numChunks = len(sqlStrings)

    #### Create Field Map for Origins ####
    masterToken = "Name " + masterField + " #"
    orgFieldMap = [masterToken, 'CurbApproach CurbApproach 0', 
                    'SourceID SourceID #', 'SourceOID SourceOID #',
                    'PosAlong PosAlong #', 'SideOfEdge SideOfEdge #']   
    orgFieldMap = ";".join(orgFieldMap)

    #### Keep Track of Features That Snap to Network ####
    snappedFeatures = set([])

    for chunkNum in xrange(numChunks):
        progMsg = ARCPY.GetIDMessage(84145).format(chunkNum + 1, numChunks)
        ARCPY.SetProgressor("default", progMsg)
        
        #### Make Origins from Chunk of Destinations ####
        sqlValue = sqlStrings[chunkNum]
        DM.MakeFeatureLayer(destinationLayer, destFCLayer, sqlValue)
        NET.AddLocations(ODCostMatrix, naClassNames["Origins"], destFCLayer, orgFieldMap,
                         "#", "#", "#", "#", "CLEAR")

        #### Solve OD Matrix and Select Data ####
        NET.Solve(ODCostMatrix, "SKIP")

        #### Count the Number of NonZero Spatial Linkages #### 
        numLinks = UTILS.getCount(lines)

        #### Create Search Cursor for OD Line Info ####
        rows = ARCPY.SearchCursor(lines, "", None, fieldList)
        row = rows.next()

        #### Set Tool Progressor and Process Information ####
        ARCPY.SetProgressor("step", ARCPY.GetIDMessage(84127), 0, numLinks, 1)

        #### Process First Record ####
        ODInfo = row.getValue("NAME")
        lastID, neighID = [ int(i) for i in ODInfo.split(" - ") ]
        impValue = row.getValue(totalImpedance)
        weight = WU.distance2Weight(impValue, wType = fixed, 
                                    exponent = exponent)
        neighs = []
        weights = []
        if lastID != neighID:
            neighs.append(neighID)
            weights.append(weight)

        #### Process Remaining Records ####
        progMsg = ARCPY.GetIDMessage(84146).format(chunkNum + 1, numChunks)
        ARCPY.SetProgressor("step", progMsg, 0, numLinks, 1)
        while row:
            #### Get Origin and Destination Unique IDs ####
            ODInfo = row.getValue("NAME")
            masterID, neighID = [ int(i) for i in ODInfo.split(" - ") ]

            #### Obtain Impedance and Create Weight ####
            impValue = row.getValue(totalImpedance)
            weight = WU.distance2Weight(impValue, wType = fixed, 
                                        exponent = exponent)
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:70,代码来源:Network2SWM.py

示例13: doFishnet

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
    def doFishnet(self):
        #### Initial Data Assessment ####
        printOHSSection(84428, prependNewLine = True)
        printOHSSubject(84431, addNewLine = False)

        #### Find Unique Locations ####
        msg = ARCPY.GetIDMessage(84441)
        ARCPY.SetProgressor("default", msg)
        initCount = UTILS.getCount(self.ssdo.inputFC)
        self.checkIncidents(initCount)
        collectedPointFC = UTILS.returnScratchName("Collect_InitTempFC")
        collInfo = EVENTS.collectEvents(self.ssdo, collectedPointFC)
        self.cleanUpList.append(collectedPointFC)
        collSSDO = SSDO.SSDataObject(collectedPointFC,
                                   explicitSpatialRef = self.ssdo.spatialRef,
                                   useChordal = True)
        collSSDO.obtainDataGA(collSSDO.oidName)
        #################################

        if self.boundaryFC:
            #### Assure Boundary FC Has Area and Obtain Chars ####
            self.checkBoundary()

        #### Location Outliers ####
        lo = UTILS.LocationInfo(collSSDO, concept = "EUCLIDEAN",
                                silentThreshold = True, stdDeviations = 3)
        printOHSLocationalOutliers(lo, aggType = self.aggType)

        #### Agg Header ####
        printOHSSection(84444)
        if self.boundaryFC:
            extent = self.boundExtent
            forMercExtent = self.boundExtent
            countMSGNumber = 84453

        else:
            countMSGNumber = 84452
            extent = None
            forMercExtent = collSSDO.extent

        if collSSDO.useChordal:
            extentFC_GCS = UTILS.returnScratchName("TempGCS_Extent")
            extentFC_Merc = UTILS.returnScratchName("TempMercator_Extent")
            points = NUM.array([ [forMercExtent.XMin, forMercExtent.YMax],
                                 [forMercExtent.XMax, forMercExtent.YMin] ])
            UTILS.createPointFC(extentFC_GCS, points, 
                                spatialRef = collSSDO.spatialRef)
            DM.Project(extentFC_GCS, extentFC_Merc, mercatorProjection)
            d = ARCPY.Describe(extentFC_Merc)
            extent = d.extent
            fishOutputCoords = mercatorProjection 
        else:
            fishOutputCoords = self.ssdo.spatialRef

        #### Fish Subject ####
        printOHSSubject(84449, addNewLine = False)
        dist = scaleDecision(lo.nonZeroAvgDist, lo.nonZeroMedDist)
        area = 0.0

        #### Construct Fishnet ####
        fish = UTILS.FishnetInfo(collSSDO, area, extent,
                                 explicitCellSize = dist)
        dist = fish.quadLength
        snap = self.ssdo.distanceInfo.linearUnitString(dist)

        #### Cell Size Answer ####
        snapStr = self.ssdo.distanceInfo.printDistance(dist)
        msg = ARCPY.GetIDMessage(84450).format(snapStr)
        printOHSAnswer(msg)
        self.fish = fish

        #### Fishnet Count Subject ####
        printOHSSubject(84451, addNewLine = False)

        #### Create Temp Fishnet Grid ####
        gridFC = UTILS.returnScratchName("Fishnet_TempFC")
        self.cleanUpList.append(gridFC)

        #### Apply Output Coords to Create Fishnet ####
        oldSpatRef = ARCPY.env.outputCoordinateSystem
        ARCPY.env.outputCoordinateSystem = fishOutputCoords

        #### Fish No Extent ####
        oldExtent = ARCPY.env.extent
        ARCPY.env.extent = ""

        #### Apply Max XY Tolerance ####
        fishWithXY = UTILS.funWithXYTolerance(DM.CreateFishnet,
                                              self.ssdo.distanceInfo)

        #### Execute Fishnet ####
        fishWithXY(gridFC, self.fish.origin, self.fish.rotate,
                   self.fish.quadLength, self.fish.quadLength,
                   self.fish.numRows, self.fish.numCols, self.fish.corner,
                   "NO_LABELS", self.fish.extent, "POLYGON")

        #### Project Back to GCS if Use Chordal ####
        if collSSDO.useChordal:
            gridFC_ProjBack = UTILS.returnScratchName("TempFC_Proj")
            DM.Project(gridFC, gridFC_ProjBack, collSSDO.spatialRef)
#.........这里部分代码省略.........
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:103,代码来源:OptimizedHotSpotAnalysis.py

示例14: doIntegrate

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
    def doIntegrate(self):
        #### Initial Data Assessment ####
        printOHSSection(84428, prependNewLine = True)
        printOHSSubject(84431, addNewLine = False)

        #### Find Unique Locations ####
        msg = ARCPY.GetIDMessage(84441)
        ARCPY.SetProgressor("default", msg)
        initCount = UTILS.getCount(self.ssdo.inputFC)
        self.checkIncidents(initCount)
        collectedPointFC = UTILS.returnScratchName("Collect_InitTempFC")
        collInfo = EVENTS.collectEvents(self.ssdo, collectedPointFC)
        self.cleanUpList.append(collectedPointFC)
            
        collSSDO = SSDO.SSDataObject(collectedPointFC,
                                explicitSpatialRef = self.ssdo.spatialRef,
                                        useChordal = True)
        collSSDO.obtainDataGA(collSSDO.oidName)
        #################################

        #### Locational Outliers ####
        lo = UTILS.LocationInfo(collSSDO, concept = "EUCLIDEAN",
                                silentThreshold = True, stdDeviations = 3)
        printOHSLocationalOutliers(lo, aggType = self.aggType)

        #### Raster Boundary ####
        if self.outputRaster:
            self.validateRaster(collSSDO.xyCoords)

        #### Agg Header ####
        printOHSSection(84444)

        #### Copy Features for Integrate ####
        msg = ARCPY.GetIDMessage(84443)
        ARCPY.SetProgressor("default", msg)
        intFC = UTILS.returnScratchName("Integrated_TempFC")
        self.cleanUpList.append(intFC)
        DM.CopyFeatures(self.ssdo.inputFC, intFC)

        #### Make Feature Layer To Avoid Integrate Bug with Spaces ####
        mfc = "Integrate_MFC_2"
        DM.MakeFeatureLayer(intFC, mfc)
        self.cleanUpList.append(mfc)

        #### Snap Subject ####
        printOHSSubject(84442, addNewLine = False)
        nScale = (collSSDO.numObs * 1.0) / self.cnt
        if lo.nonZeroAvgDist < lo.nonZeroMedDist:
            useDist = lo.nonZeroAvgDist * nScale
            useType = "average"
        else:
            useDist = lo.nonZeroMedDist * nScale
            useType = "median"
        distance2Integrate = lo.distances[lo.distances < useDist]
        distance2Integrate = NUM.sort(distance2Integrate)
        numDists = len(distance2Integrate)

        #### Max Snap Answer ####
        msg = ARCPY.GetIDMessage(84445)
        useDistStr = self.ssdo.distanceInfo.printDistance(useDist)
        msg = msg.format(useDistStr)
        printOHSAnswer(msg)

        percs = [10, 25, 100]
        indices = [ int(numDists * (i * .01)) for i in percs ]
        if indices[-1] >= numDists:
            indices[-1] = -1

        ARCPY.SetProgressor("default", msg)
        for pInd, dInd in enumerate(indices):
            dist = distance2Integrate[dInd]
            snap = self.ssdo.distanceInfo.linearUnitString(dist,
                                                           convert = True)
            DM.Integrate(mfc, snap)
        del collSSDO

        #### Run Collect Events ####
        collectedFC = UTILS.returnScratchName("Collect_TempFC")
        self.cleanUpList.append(collectedFC)
        intSSDO = SSDO.SSDataObject(intFC,
                                    explicitSpatialRef = self.ssdo.spatialRef,
                                    silentWarnings = True,
                                    useChordal = True)
        intSSDO.obtainDataGA(intSSDO.oidName)
        EVENTS.collectEvents(intSSDO, collectedFC)
        descTemp = ARCPY.Describe(collectedFC)
        oidName = descTemp.oidFieldName

        #### Delete Integrated FC ####
        del intSSDO

        #### Set VarName, MasterField, AnalysisSSDO ####
        self.createAnalysisSSDO(collectedFC, "ICOUNT")
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:95,代码来源:OptimizedHotSpotAnalysis.py

示例15: delaunay2SWM

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import getCount [as 别名]
def delaunay2SWM(inputFC, swmFile, masterField, rowStandard = True):
    """Creates a sparse spatial weights matrix (SWM) based on Delaunay
    Triangulation.  

    INPUTS: 
    inputFC (str): path to the input feature class
    swmFile (str): path to the SWM file.
    masterField (str): field in table that serves as the mapping.
    rowStandard {bool, True}: row standardize weights?
    """

    #### Set Default Progressor for Neigborhood Structure ####
    ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84143))

    #### Create SSDataObject ####
    ssdo = SSDO.SSDataObject(inputFC, templateFC = inputFC,
                             useChordal = True)
    cnt = UTILS.getCount(inputFC)
    ERROR.errorNumberOfObs(cnt, minNumObs = 2)

    #### Validation of Master Field ####
    verifyMaster = ERROR.checkField(ssdo.allFields, masterField, types = [0,1])

    #### Create GA Data Structure ####
    gaTable, gaInfo = WU.gaTable(ssdo.catPath, [masterField],
                                 spatRef = ssdo.spatialRefString)

    #### Assure Enough Observations ####
    N = gaInfo[0]
    ERROR.errorNumberOfObs(N, minNumObs = 2)

    #### Process any bad records encountered ####
    numBadRecs = cnt - N
    if numBadRecs:
        badRecs = WU.parseGAWarnings(gaTable.warnings)
        err = ERROR.reportBadRecords(cnt, numBadRecs, badRecs,
                                     label = ssdo.oidName)

    #### Create Delaunay Neighbor Search Type ####
    gaSearch = GAPY.ga_nsearch(gaTable)
    gaSearch.init_delaunay()
    neighWeights = ARC._ss.NeighborWeights(gaTable, gaSearch, 
                                           weight_type = 1,
                                           row_standard = False)

    #### Set Progressor for Weights Writing ####
    ARCPY.SetProgressor("step", ARCPY.GetIDMessage(84127), 0, N, 1)

    #### Initialize Spatial Weights Matrix File ####
    swmWriter = WU.SWMWriter(swmFile, masterField, ssdo.spatialRefName, 
                             N, rowStandard, inputFC = inputFC,
                             wType = 3)

    #### Unique Master ID Dictionary ####
    masterSet = set([])

    for row in xrange(N):
        masterID = int(gaTable[row][2])
        if masterID in masterSet:
            ARCPY.AddIDMessage("Error", 644, masterField)
            ARCPY.AddIDMessage("Error", 643)
            raise SystemExit()
        else:
            masterSet.add(masterID)

        neighs, weights = neighWeights[row]
        neighs = [ gaTable[nh][2] for nh in neighs ]

        #### Add Spatial Weights Matrix Entry ####
        swmWriter.swm.writeEntry(masterID, neighs, weights) 

        #### Set Progress ####
        ARCPY.SetProgressorPosition()

    #### Clean Up ####
    swmWriter.close()
    del gaTable

    #### Report if Any Features Have No Neighbors ####
    swmWriter.reportNoNeighbors()

    #### Report Spatial Weights Summary ####
    swmWriter.report()

    #### Report SWM File is Large ####
    swmWriter.reportLargeSWM()
开发者ID:leochin,项目名称:GSWMtest,代码行数:88,代码来源:Weights.py


注:本文中的SSUtilities.getCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。