Пример #1
0
def setUniqueIDField(ssdo, weightsFile):
    """Replace SSUTILITIES.setUniqueIDField to support flexible weights file 
    headers."""
    if weightsFile == None:
        return ssdo.oidName
    
    weightsSuffix = weightsFile.split(".")[-1].lower()
    swmFileBool = (weightsSuffix == "swm")
    
    if swmFileBool:
        return UTILS.setUniqueIDField(ssdo, weightsFile)
    
    fo = UTILS.openFile(weightsFile, "r")
    header = fo.readline().strip()
    headerItems = header.split(" ") 
    
    if len(headerItems) == 1 and weightsSuffix == "gal":
        return ssdo.oidName
    
    elif len(headerItems) > 1:
        for item in headerItems:
            if not item.isdigit() and item.lower() != "unknown" \
               and len(item) > 0:
                masterField = item
                # check to see if in ssdo
                for fieldName, fieldObj in ssdo.allFields.items():
                    if fieldObj.baseName.upper() == masterField.upper():
                        return masterField
                    
    msg = "Header is not valid in Weights file (%s)." % weightsFile
    ARCPY.AddWarning(msg)
Пример #2
0
def setupStandardDistance():
    """Retrieves the parameters from the User Interface and executes the
    appropriate commands."""

    inputFC = ARCPY.GetParameterAsText(0)
    outputFC = ARCPY.GetParameterAsText(1)
    stdDeviations = ARCPY.GetParameterAsText(2).upper().replace(" ", "_")
    weightField = UTILS.getTextParameter(3, fieldName=True)
    caseField = UTILS.getTextParameter(4, fieldName=True)

    fieldList = []
    if weightField:
        fieldList.append(weightField)
    if caseField:
        fieldList.append(caseField)

    stdDeviations = circleDict[stdDeviations]

    #### Create a Spatial Stats Data Object (SSDO) ####
    ssdo = SSDO.SSDataObject(inputFC, templateFC=outputFC, useChordal=False)

    #### Populate SSDO with Data ####
    ssdo.obtainData(ssdo.oidName, fieldList, minNumObs=2, dateStr=True)

    #### Run Analysis ####
    sd = StandardDistance(ssdo,
                          weightField=weightField,
                          caseField=caseField,
                          stdDeviations=stdDeviations)

    #### Create Output ####
    sd.createOutput(outputFC)
Пример #3
0
    def setStudyArea(self):
        """Sets the study area for the nearest neighbor stat."""

        #### Attribute Shortcuts ####
        ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84248))
        ssdo = self.ssdo

        if self.studyArea == None:
            #### Create Min Enc Rect ####
            studyAreaFC = UTILS.returnScratchName("regularBound_FC")
            clearedMinBoundGeom = UTILS.clearExtent(UTILS.minBoundGeomPoints)
            clearedMinBoundGeom(ssdo.xyCoords, studyAreaFC, 
                                geomType = "RECTANGLE_BY_AREA",
                                spatialRef = ssdo.spatialRef)
            polyInfo = UTILS.returnPolygon(studyAreaFC, 
                                           spatialRef = ssdo.spatialRefString,
                                           useGeodesic = ssdo.useChordal)
            studyAreaPoly, studyArea = polyInfo
            UTILS.passiveDelete(studyAreaFC)

            if studyArea == None:
                #### Invalid Study Area ####
                ARCPY.AddIDMessage("Error", 932)
                raise SystemExit()

            self.studyArea = studyArea 
def setupParameters():
    """ Setup Parameters for Distance-based Weights Creation """
    
    #### Get User Provided Inputs ####
    inputFC = ARCPY.GetParameterAsText(0)
    outputFile = ARCPY.GetParameterAsText(1)
    distanceType = UTILS.getTextParameter(2).upper() #
    idField = UTILS.getTextParameter(3)
    
    #### Validate Input of Distance Type ####
    if not distanceType or distanceType not in DISTTYPE:
        ARCPY.AddError("Distance type is not set, or it is not in the "
                       "predefined list...")
        raise SystemExit()

    #### Setup Default Values of Threshold/KnnNum/InverseDist ####
    threshold = UTILS.getNumericParameter(4) \
        if distanceType == DISTTYPE[0] or distanceType == DISTTYPE[2] else None
    knnNum = UTILS.getNumericParameter(5) \
        if distanceType == DISTTYPE[1] else None
    inverseDist = UTILS.getNumericParameter(6) \
        if distanceType == DISTTYPE[2] else None
    
    #### Run Dist Weights Creation ####
    distW = DistW_PySAL(inputFC, outputFile, idField, distanceType, threshold,\
                        knnNum, inverseDist)
    
    #### Create Output ####
    distW.createOutput()
Пример #5
0
    def copy2FC(self, outputFC, outName = None, setNullable = False):
        """Copies self to an output feature class.

        INPUTS:
        outputFC (str): path to output feature class
        outName (str): optional output field name (for joins and such.)
        setNullable (bool): if set to true, overwrite self to nullable
        """

        if outName == None:
            outName = self.name

        if setNullable:
            nullable = True
        else:
            nullable = self.nullable

        UTILS.addEmptyField(outputFC, outName, self.type,
                            alias = self.alias,
                            nullable = nullable,
                            precision = self.fieldObject.precision,
                            scale = self.fieldObject.scale,
                            length = self.fieldObject.length,
                            required = self.fieldObject.required,
                            domain = self.fieldObject.domain)
Пример #6
0
def setupParameters():
    """ Setup Parameters for Distance-based Weights Creation """

    #### Get User Provided Inputs ####
    inputFC = ARCPY.GetParameterAsText(0)
    outputFile = ARCPY.GetParameterAsText(1)
    distanceType = UTILS.getTextParameter(2).upper()  #
    idField = UTILS.getTextParameter(3)

    #### Validate Input of Distance Type ####
    if not distanceType or distanceType not in DISTTYPE:
        ARCPY.AddError("Distance type is not set, or it is not in the "
                       "predefined list...")
        raise SystemExit()

    #### Setup Default Values of Threshold/KnnNum/InverseDist ####
    threshold = UTILS.getNumericParameter(4) \
        if distanceType == DISTTYPE[0] or distanceType == DISTTYPE[2] else None
    knnNum = UTILS.getNumericParameter(5) \
        if distanceType == DISTTYPE[1] else None
    inverseDist = UTILS.getNumericParameter(6) \
        if distanceType == DISTTYPE[2] else None

    #### Run Dist Weights Creation ####
    distW = DistW_PySAL(inputFC, outputFile, idField, distanceType, threshold,\
                        knnNum, inverseDist)

    #### Create Output ####
    distW.createOutput()
Пример #7
0
def setupParameters():

    #### Get User Provided Inputs ####
    inputFC = ARCPY.GetParameterAsText(0)
    depVarName = ARCPY.GetParameterAsText(1).upper()  
    indVarNames = ARCPY.GetParameterAsText(2).upper()  
    indVarNames = indVarNames.split(";")
    outputFC = UTILS.getTextParameter(3)
    weightsFile = UTILS.getTextParameter(4)

    #### Create SSDataObject ####
    fieldList = [depVarName] + indVarNames
    ssdo = SSDO.SSDataObject(inputFC, templateFC = outputFC)
    masterField = AUTILS.setUniqueIDField(ssdo, weightsFile = weightsFile)

    #### Populate SSDO with Data ####
    ssdo.obtainData(masterField, fieldList, minNumObs = 5) 

    #### Resolve Weights File ####
    if weightsFile:
        patW = AUTILS.PAT_W(ssdo, weightsFile)
    else:
        patW = None

    #### Run OLS ####
    ols = OLS_PySAL(ssdo, depVarName, indVarNames, patW = patW)

    #### Create Output ####
    ols.createOutput(outputFC)
Пример #8
0
    def copy2FC(self, outputFC, outName=None, setNullable=False):
        """Copies self to an output feature class.

        INPUTS:
        outputFC (str): path to output feature class
        outName (str): optional output field name (for joins and such.)
        setNullable (bool): if set to true, overwrite self to nullable
        """

        if outName == None:
            outName = self.name

        if setNullable:
            nullable = True
        else:
            nullable = self.nullable

        UTILS.addEmptyField(outputFC,
                            outName,
                            self.type,
                            alias=self.alias,
                            nullable=nullable,
                            precision=self.fieldObject.precision,
                            scale=self.fieldObject.scale,
                            length=self.fieldObject.length,
                            required=self.fieldObject.required,
                            domain=self.fieldObject.domain)
Пример #9
0
    def createInterpretReport(self):
        """Creates the interpretation table for OLS."""

        #### Generate Interpretation Table #####
        header =  ARCPY.GetIDMessage(84081)

        #### Set up Rows in Tables ####
        decimalSep = UTILS.returnDecimalChar()
        if decimalSep == ".":
            pValue = "0.01"
            VIF = "7.5"
        else:
            pValue = "0,01"
            VIF = "7,5"

        significance = [ARCPY.GetIDMessage(84111), ARCPY.GetIDMessage(84082).format(pValue)]
        coefficient = [ARCPY.GetIDMessage(84080), ARCPY.GetIDMessage(84349)]
        probs = [ARCPY.GetIDMessage(84086), ARCPY.GetIDMessage(84350).format(pValue)]
        multicoll = [ARCPY.GetIDMessage(84103), ARCPY.GetIDMessage(84083).format(VIF)]
        rSquared = [ARCPY.GetIDMessage(84104), ARCPY.GetIDMessage(84084)]
        jointFW = [ARCPY.GetIDMessage(84105), ARCPY.GetIDMessage(84085).format(pValue)]
        bpRow = [ARCPY.GetIDMessage(84106), ARCPY.GetIDMessage(84087).format(pValue)]
        jbRow = [ARCPY.GetIDMessage(84107), ARCPY.GetIDMessage(84088).format(pValue)]

        #### Finalize Interpretation Table ####
        intTotal = [significance, coefficient, probs, multicoll,
                    rSquared, jointFW, bpRow, jbRow]

        body = UTILS.outputTextTable(intTotal, pad = 1,
                                     justify = ["center", "left"])
        self.interpretTable = "\n%s%s" % (header, body)
        self.interpretRaw = intTotal
Пример #10
0
    def createCoefficientTable(self, tableName):
        """Creates Output Coefficient Database Table for OLS.

        INPUTS:
        tableName (str): catalog path to the output table
        """

        #### Set Progressor ####
        ARCPY.AddMessage(ARCPY.GetIDMessage(84071))
        ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84071))
        outPath, outName = OS.path.split(tableName)

        #### Set Up Field Names and Types ####
        inputFields = UTILS.getFieldNames(olsCoefFieldNames, outPath)
        inputTypes = ["TEXT", "DOUBLE", "DOUBLE",
                      "DOUBLE", "DOUBLE", "DOUBLE",
                      "DOUBLE", "DOUBLE", "DOUBLE"]

        #### Set Up Input Data ####
        inputData = []
        coefList = list(self.coef.flatten())
        for rowInd, rowVal in enumerate(coefList):
            inputData.append( (self.varLabels[rowInd], rowVal,
                               self.seCoef[rowInd], self.tStats[rowInd],
                               self.pVals[rowInd], self.seCoefRob[rowInd],
                               self.tStatsRob[rowInd], self.pValsRob[rowInd],
                               self.coefSTD[rowInd])
                             )

        #### Write Coefficient Table ####
        UTILS.createOutputTable(tableName, inputFields,
                                inputTypes, inputData)
    def validateRaster(self, ssdoCoords):

        printOHSSubject(84439, addNewLine = False)
        envMask = ARCPY.env.mask
        maskExists = False
        if envMask:
            try:
                descMask = ARCPY.Describe(envMask)
                maskExists = True
            except:
                maskExists = False

        if not envMask or not maskExists:
            #### Use Convex Hull ####
            msg = ARCPY.GetIDMessage(84440)
            ARCPY.SetProgressor("default", msg)
            printOHSAnswer(msg)
            boundaryFC = UTILS.returnScratchName("tempCH_FC")
            UTILS.minBoundGeomPoints(ssdoCoords, boundaryFC,
                                     geomType = "CONVEX_HULL",
                                     spatialRef = self.ssdo.spatialRef)
            self.boundaryFC = boundaryFC
            self.cleanUpList.append(boundaryFC)

        self.maskExists = maskExists
Пример #12
0
def setupParameters():

    #### Get User Provided Inputs ####
    inputFC = ARCPY.GetParameterAsText(0)
    depVarName = ARCPY.GetParameterAsText(1).upper()
    indVarNames = ARCPY.GetParameterAsText(2).upper()
    indVarNames = indVarNames.split(";")
    outputFC = UTILS.getTextParameter(3)
    weightsFile = UTILS.getTextParameter(4)

    #### Create SSDataObject ####
    fieldList = [depVarName] + indVarNames
    ssdo = SSDO.SSDataObject(inputFC, templateFC=outputFC)
    masterField = AUTILS.setUniqueIDField(ssdo, weightsFile=weightsFile)

    #### Populate SSDO with Data ####
    ssdo.obtainData(masterField, fieldList, minNumObs=5)

    #### Resolve Weights File ####
    if weightsFile:
        patW = AUTILS.PAT_W(ssdo, weightsFile)
    else:
        patW = None

    #### Run OLS ####
    ols = OLS_PySAL(ssdo, depVarName, indVarNames, patW=patW)

    #### Create Output ####
    ols.createOutput(outputFC)
Пример #13
0
    def __init__(self, ssdo, varName, outputFC, wType,
                 weightsFile = None, concept = "EUCLIDEAN",
                 rowStandard = True, threshold = None,
                 exponent = 1.0, permutations = None, 
                 applyFDR = False):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())

        #### Assess Whether SWM File Being Used ####
        self.swmFileBool = False 
        if weightsFile:
            weightSuffix = weightsFile.split(".")[-1].lower()
            self.swmFileBool = (weightSuffix == "swm")

        #### Warn Inverse Distance if Geographic Coord System ####
        #if wType in [0, 7]:
        #    WU.checkGeographicCoord(self.ssdo.spatialRefType, 
        #                            WU.wTypeDispatch[wType])

        #### Create Shape File Boolean for NULL Values ####
        self.outShapeFileBool = UTILS.isShapeFile(outputFC)

        #### Initialize Data ####
        self.initialize()

        #### Construct Based on SWM File or On The Fly ####
        self.construct()
Пример #14
0
def setupMedianCenter():
    """Retrieves the parameters from the User Interface and executes the
    appropriate commands."""

    inputFC = ARCPY.GetParameterAsText(0)
    outputFC = ARCPY.GetParameterAsText(1)
    weightField = UTILS.getTextParameter(2, fieldName = True)
    caseField = UTILS.getTextParameter(3, fieldName = True)        
    attFields = UTILS.getTextParameter(4, fieldName = True)   

    fieldList = []
    if weightField:
        fieldList.append(weightField)
    if caseField:
        fieldList.append(caseField)
    if attFields:
        attFields = attFields.split(";")
        fieldList = fieldList + attFields

    #### Populate SSDO with Data ####
    ssdo = SSDO.SSDataObject(inputFC, templateFC = outputFC,
                             useChordal = False)

    #### Populate SSDO with Data ####
    ssdo.obtainData(ssdo.oidName, fieldList, minNumObs = 1, dateStr = True) 

    #### Run Analysis ####
    mc = MedianCenter(ssdo, weightField = weightField,
                      caseField = caseField, attFields = attFields)

    #### Create Output ####
    mc.createOutput(outputFC)
Пример #15
0
    def validateRaster(self, ssdoCoords):

        printOHSSubject(84439, addNewLine=False)
        envMask = ARCPY.env.mask
        maskExists = False
        if envMask:
            try:
                descMask = ARCPY.Describe(envMask)
                maskExists = True
            except:
                maskExists = False

        if not envMask or not maskExists:
            #### Use Convex Hull ####
            msg = ARCPY.GetIDMessage(84440)
            ARCPY.SetProgressor("default", msg)
            printOHSAnswer(msg)
            boundaryFC = UTILS.returnScratchName("tempCH_FC")
            UTILS.minBoundGeomPoints(ssdoCoords,
                                     boundaryFC,
                                     geomType="CONVEX_HULL",
                                     spatialRef=self.ssdo.spatialRef)
            self.boundaryFC = boundaryFC
            self.cleanUpList.append(boundaryFC)

        self.maskExists = maskExists
Пример #16
0
 def __init__(self, ssdo, weightsFile):
     #### Set Initial Attributes ####
     UTILS.assignClassAttr(self, locals())
     self.wPath, self.wName = OS.path.split(weightsFile)
     name, ext = OS.path.splitext(weightsFile.upper())
     self.wExt = ext.strip(".")
     self.setWeights()
 def __init__(self, ssdo, weightsFile):
     #### Set Initial Attributes ####
     UTILS.assignClassAttr(self, locals())
     self.wPath, self.wName = OS.path.split(weightsFile)
     name, ext = OS.path.splitext(weightsFile.upper())
     self.wExt = ext.strip(".")
     self.setWeights()
Пример #18
0
    def report(self):
        """Reports the results from exploratory regression analysis."""

        #### Set Title ####
        title = self.label

        #### Column Labels ####
        labs = [ARCPY.GetIDMessage(84021), ARCPY.GetIDMessage(84249),
                ARCPY.GetIDMessage(84042), ARCPY.GetIDMessage(84036),
                ARCPY.GetIDMessage(84284), ARCPY.GetIDMessage(84292),
                ARCPY.GetIDMessage(84286)]
        r2Info = [ labs ]

        #### Adjusted R2, Sorted Highest to Lowest with ID Tie Breaks ####
        header = ARCPY.GetIDMessage(84287)
        numRes = UTILS.ssRange(len(self.bestR2Res))
        r2Data = []
        for i in numRes:
            r2Val = self.bestR2Vals[i]
            idVal = int(self.bestR2Res[i].split(":")[-1])
            r2Data.append((r2Val, idVal))
        r2Data = NUM.array(r2Data, dtype = [('r2', float), ('ids', int)])
        r2SortedInds = r2Data.argsort(order = ('r2', 'ids'))
        sortIndex = reversed(r2SortedInds)
        for ind in sortIndex:
            olsID = self.bestR2Res[ind]
            olsRes = self.olsResults[olsID]
            olsOut = olsRes.report(formatStr = "%0.2f")
            r2Info.append(olsOut)

        r2Report = UTILS.outputTextTable(r2Info, header = header,
                                         justify = masterJustify)

        #### Passing Models ####
        header = ARCPY.GetIDMessage(84288)
        passList = [ labs ]
        r2Values = []
        olsIDs = []
        for olsID in self.passBools:
            olsRes = self.olsResults[olsID]
            r2Values.append(olsRes.r2)
            olsIDs.append(olsID)
        sortIndex = NUM.argsort(r2Values).tolist()
        sortIndex.reverse()
        for ind in sortIndex:
            olsID = olsIDs[ind]
            olsRes = self.olsResults[olsID]
            olsOut = olsRes.report(formatStr = "%0.6f")
            passList.append(olsOut)

        passingReport = UTILS.outputTextTable(passList, header = header)

        #### Print Report ####
        starMess = ARCPY.GetIDMessage(84289) * 78
        finalReport = [starMess, title, r2Report, passingReport]
        finalReport = "\n".join(finalReport)
        finalReport = finalReport + "\n"
        ARCPY.AddMessage(finalReport)

        return finalReport
Пример #19
0
    def report(self, fileName = None):
        """Reports the Median Center results as a message or to a file.

        INPUTS:
        fileName {str, None}: path to a text file to populate with results
        """

        header = ARCPY.GetIDMessage(84190)
        columns = [ARCPY.GetIDMessage(84191), ARCPY.GetIDMessage(84192), 
                   ARCPY.GetIDMessage(84193)]
        if self.attFields:
            for attField in self.attFields:
                columns.append(ARCPY.GetIDMessage(84194).format(attField))
        results = [ columns ]
        for case in self.uniqueCases:
            if not self.caseField:
                strCase = "ALL"
            else:
                strCase = UTILS.caseValue2Print(case, self.caseIsString)
            medX, medY = self.medianCenter[case]
            rowResult = [ strCase, LOCALE.format("%0.6f", medX),
                          LOCALE.format("%0.6f", medY) ]
            if self.attFields:
                for attInd, attField in enumerate(self.attFields):
                    medAtt = self.attCenter[case][attInd]
                    rowResult.append(LOCALE.format("%0.6f", medAtt))
            results.append(rowResult)

        outputTable = UTILS.outputTextTable(results, header = header)
        if fileName:
            f = open(fileName, "w")
            f.write(outputTable)
            f.close()
        else:
            ARCPY.AddMessage(outputTable)
Пример #20
0
def setupMeanCenter():
    """Retrieves the parameters from the User Interface and executes the
    appropriate commands."""

    inputFC = ARCPY.GetParameterAsText(0)
    outputFC = ARCPY.GetParameterAsText(1)
    weightField = UTILS.getTextParameter(2, fieldName=True)
    caseField = UTILS.getTextParameter(3, fieldName=True)
    dimField = UTILS.getTextParameter(4, fieldName=True)

    fieldList = []
    if weightField:
        fieldList.append(weightField)

    if caseField:
        fieldList.append(caseField)

    if dimField:
        fieldList.append(dimField)

    ssdo = SSDO.SSDataObject(inputFC, templateFC=outputFC, useChordal=False)
    ssdo.obtainData(ssdo.oidName, fieldList, minNumObs=1, dateStr=True)

    mc = MeanCenter(ssdo,
                    weightField=weightField,
                    caseField=caseField,
                    dimField=dimField)

    mc.createOutput(outputFC)
Пример #21
0
    def __init__(self, allVarNames, numChoose, ssdo,
                 weightMatrix, weightsType = "SWM",
                 minR2 = .5, maxCoef = .01, maxVIF = 5.0,
                 minJB = .1, minMI = .1, silent = False):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())

        #### Set Label ####
        self.numVars = len(self.allVarNames)

        self.label = ARCPY.GetIDMessage(84283).format(numChoose, self.numVars)
        if numChoose <= 2:
            self.eachAppears = 1
        else:
            self.eachAppears = nChooseK(self.numVars - 2, numChoose - 2)

        #### Set Result Structures ####
        self.varSignDict = {}
        self.signDict = {}
        self.vifDict = {}
        for varName in self.allVarNames:
            self.varSignDict[varName] = [0, 0]
            self.signDict[varName] = [0, 0]
            self.vifDict[varName] = [0, []]

        self.olsResults = {}
        self.bestR2Vals = []
        self.bestR2Res = []
        self.passTable = []
        self.passBools = []
        self.r2Residuals = NUM.empty((self.ssdo.numObs, 3), dtype = float)
        self.allJBPass = UTILS.compareFloat(0.0, self.minJB, rTol = .00000001)
        self.allMIPass = UTILS.compareFloat(0.0, self.minMI, rTol = .00000001)
        self.miVals = []
Пример #22
0
    def report(self, fileName=None):
        """Reports the Central Feature results as a message or to a file.

        INPUTS:
        fileName {str, None}: path to a text file to populate with results.
        """

        header = ARCPY.GetIDMessage(84200)
        columns = [
            ARCPY.GetIDMessage(84191),
            ARCPY.GetIDMessage(84201),
            ARCPY.GetIDMessage(84202)
        ]
        results = [columns]
        for case in self.uniqueCases:
            if not self.caseField:
                strCase = "ALL"
            else:
                strCase = UTILS.caseValue2Print(case, self.caseIsString)
            cfOIDs, minSumDist = self.cf[case]
            cfOIDs = [str(i) for i in cfOIDs]
            cfOIDs = ", ".join(cfOIDs)
            rowResult = [strCase, cfOIDs, LOCALE.format("%0.6f", minSumDist)]
            results.append(rowResult)

        outputTable = UTILS.outputTextTable(results, header=header)
        if fileName:
            f = UTILS.openFile(fileName, "w")
            f.write(outputTable)
            f.close()
        else:
            ARCPY.AddMessage(outputTable)
Пример #23
0
    def __init__(self, ssdo, varName, wType, weightsFile = None, 
                 concept = "EUCLIDEAN", rowStandard = True, threshold = None,
                 exponent = 1.0, displayIt = False):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())

        #### Assess Whether SWM File Being Used ####
        self.swmFileBool = False 
        if weightsFile:
            weightSuffix = weightsFile.split(".")[-1].lower()
            self.swmFileBool = (weightSuffix == "swm")

        ##### Warn Inverse Distance if Geographic Coord System ####
        #if wType in [0, 7]:
        #    WU.checkGeographicCoord(self.ssdo.spatialRefType,
        #                            WU.wTypeDispatch[wType])

        #### Initialize Data ####
        self.initialize()

        #### Construct Based on SWM File or On The Fly ####
        self.construct()

        #### Calculate General G ####
        self.calculate()
def setUniqueIDField(ssdo, weightsFile):
    """Replace SSUTILITIES.setUniqueIDField to support flexible weights file 
    headers."""
    if weightsFile == None:
        return ssdo.oidName

    weightsSuffix = weightsFile.split(".")[-1].lower()
    swmFileBool = (weightsSuffix == "swm")

    if swmFileBool:
        return UTILS.setUniqueIDField(ssdo, weightsFile)

    fo = UTILS.openFile(weightsFile, "r")
    header = fo.readline().strip()
    headerItems = header.split(" ")

    if len(headerItems) == 1 and weightsSuffix == "gal":
        return ssdo.oidName

    elif len(headerItems) > 1:
        for item in headerItems:
            if not item.isdigit() and item.lower() != "unknown" \
               and len(item) > 0:
                masterField = item
                # check to see if in ssdo
                for fieldName, fieldObj in ssdo.allFields.items():
                    if fieldObj.baseName.upper() == masterField.upper():
                        return masterField

    msg = "Header is not valid in Weights file (%s)." % weightsFile
    ARCPY.AddWarning(msg)
Пример #25
0
    def doPoint2Poly(self):

        #### Initial Data Assessment ####
        printOHSSection(84428, prependNewLine=True)
        printOHSSubject(84431, addNewLine=False)
        self.ssdo.obtainData(self.ssdo.oidName)
        self.checkIncidents(self.ssdo.numObs)
        if len(self.ssdo.badRecords):
            ARCPY.AddMessage("\n")
        #################################

        #### Checking Polygon Message ####
        printOHSSubject(84430, addNewLine=False)

        #### Spatial Join (Hold Messages) ####
        outputFieldMaps = "EMPTY"
        tempFC = UTILS.returnScratchName("SpatialJoin_TempFC")
        self.cleanUpList.append(tempFC)
        joinWithSpatialRef = UTILS.funWithSpatialRef(ANA.SpatialJoin,
                                                     self.ssdo.spatialRef,
                                                     outputFC=tempFC)
        joinWithXY = UTILS.funWithXYTolerance(joinWithSpatialRef,
                                              self.ssdo.distanceInfo)
        joinWithXY(self.polygonFC, self.ssdo.inputFC, tempFC,
                   "JOIN_ONE_TO_ONE", "KEEP_ALL", outputFieldMaps)

        #### Set VarName, MasterField, AnalysisSSDO ####
        self.createAnalysisSSDO(tempFC, "JOIN_COUNT")
    def doPoint2Poly(self):

        #### Initial Data Assessment ####
        printOHSSection(84428, prependNewLine = True)
        printOHSSubject(84431, addNewLine = False)
        self.ssdo.obtainData(self.ssdo.oidName)
        self.checkIncidents(self.ssdo.numObs)
        if len(self.ssdo.badRecords):
            ARCPY.AddMessage("\n")
        #################################

        #### Checking Polygon Message ####
        printOHSSubject(84430, addNewLine = False)

        #### Spatial Join (Hold Messages) ####
        outputFieldMaps = "EMPTY"
        tempFC = UTILS.returnScratchName("SpatialJoin_TempFC")
        self.cleanUpList.append(tempFC)
        joinWithSpatialRef = UTILS.funWithSpatialRef(ANA.SpatialJoin,
                                                     self.ssdo.spatialRef,
                                                     outputFC = tempFC)
        joinWithXY = UTILS.funWithXYTolerance(joinWithSpatialRef,
                                              self.ssdo.distanceInfo)
        joinWithXY(self.polygonFC, self.ssdo.inputFC, tempFC,
                   "JOIN_ONE_TO_ONE", "KEEP_ALL",
                   outputFieldMaps)

        #### Set VarName, MasterField, AnalysisSSDO ####
        self.createAnalysisSSDO(tempFC, "JOIN_COUNT")
Пример #27
0
    def setStudyArea(self):
        """Sets the study area for the nearest neighbor stat."""

        #### Attribute Shortcuts ####
        ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84248))
        ssdo = self.ssdo

        if self.studyArea == None:
            #### Create Min Enc Rect ####
            studyAreaFC = UTILS.returnScratchName("regularBound_FC")
            clearedMinBoundGeom = UTILS.clearExtent(UTILS.minBoundGeomPoints)
            clearedMinBoundGeom(ssdo.xyCoords,
                                studyAreaFC,
                                geomType="RECTANGLE_BY_AREA",
                                spatialRef=ssdo.spatialRef)
            polyInfo = UTILS.returnPolygon(studyAreaFC,
                                           spatialRef=ssdo.spatialRefString,
                                           useGeodesic=ssdo.useChordal)
            studyAreaPoly, studyArea = polyInfo
            UTILS.passiveDelete(studyAreaFC)

            if studyArea == None:
                #### Invalid Study Area ####
                ARCPY.AddIDMessage("Error", 932)
                raise SystemExit()

            self.studyArea = studyArea
Пример #28
0
    def report(self, fileName = None):
        """Reports the Standard Distance results as a message or to a file.

        INPUTS:
        fileName {str, None}: path to a text file to populate with results
        """

        header = ARCPY.GetIDMessage(84224)
        columns = [ARCPY.GetIDMessage(84191), ARCPY.GetIDMessage(84211),
                   ARCPY.GetIDMessage(84212), ARCPY.GetIDMessage(84225),
                   ARCPY.GetIDMessage(84226)]
        results = [columns]
        for case in self.uniqueCases:
            if not self.caseField:
                strCase = "ALL"
            else:
                strCase = UTILS.caseValue2Print(case, self.caseIsString)
            meanX, meanY = self.meanCenter[case]
            rowResult = [ strCase, LOCALE.format("%0.6f", meanX),
                          LOCALE.format("%0.6f", meanY),
                          LOCALE.format("%0.6f", self.sd[case]),
                          LOCALE.format("%0.1f", self.stdDeviations) ]
            results.append(rowResult)

        outputTable = UTILS.outputTextTable(results, header = header)
        if fileName:
            f = UTILS.openFile(fileName, "w")
            f.write(outputTable)
            f.close()
        else:
            ARCPY.AddMessage(outputTable)
Пример #29
0
    def report(self, fileName = None):
        """Reports the Central Feature results as a message or to a file.

        INPUTS:
        fileName {str, None}: path to a text file to populate with results.
        """

        header = ARCPY.GetIDMessage(84200)
        columns = [ARCPY.GetIDMessage(84191), ARCPY.GetIDMessage(84201), 
                   ARCPY.GetIDMessage(84202)]
        results = [ columns ]
        for case in self.uniqueCases:
            if not self.caseField:
                strCase = "ALL"
            else:
                strCase = UTILS.caseValue2Print(case, self.caseIsString)
            cfOIDs, minSumDist = self.cf[case]
            cfOIDs = [ str(i) for i in cfOIDs ]
            cfOIDs = ", ".join(cfOIDs)
            rowResult = [ strCase, 
                          cfOIDs,
                          LOCALE.format("%0.6f", minSumDist) ]
            results.append(rowResult)

        outputTable = UTILS.outputTextTable(results, header = header)
        if fileName:
            f = UTILS.openFile(fileName, "w")
            f.write(outputTable)
            f.close()
        else:
            ARCPY.AddMessage(outputTable)
Пример #30
0
    def createCoefficientTable(self, tableName):
        """Creates Output Coefficient Database Table for OLS.

        INPUTS:
        tableName (str): catalog path to the output table
        """

        #### Set Progressor ####
        ARCPY.AddMessage(ARCPY.GetIDMessage(84071))
        ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84071))
        outPath, outName = OS.path.split(tableName)

        #### Set Up Field Names and Types ####
        inputFields = UTILS.getFieldNames(olsCoefFieldNames, outPath)
        inputTypes = [
            "TEXT", "DOUBLE", "DOUBLE", "DOUBLE", "DOUBLE", "DOUBLE", "DOUBLE",
            "DOUBLE", "DOUBLE"
        ]

        #### Set Up Input Data ####
        inputData = []
        coefList = list(self.coef.flatten())
        for rowInd, rowVal in enumerate(coefList):
            inputData.append(
                (self.varLabels[rowInd], rowVal, self.seCoef[rowInd],
                 self.tStats[rowInd], self.pVals[rowInd],
                 self.seCoefRob[rowInd], self.tStatsRob[rowInd],
                 self.pValsRob[rowInd], self.coefSTD[rowInd]))

        #### Write Coefficient Table ####
        UTILS.createOutputTable(tableName, inputFields, inputTypes, inputData)
Пример #31
0
def setupStandardDistance():
    """Retrieves the parameters from the User Interface and executes the
    appropriate commands."""

    inputFC = ARCPY.GetParameterAsText(0)
    outputFC = ARCPY.GetParameterAsText(1)
    stdDeviations = ARCPY.GetParameterAsText(2).upper().replace(" ", "_")  
    weightField = UTILS.getTextParameter(3, fieldName = True)
    caseField = UTILS.getTextParameter(4, fieldName = True)           

    fieldList = []
    if weightField:
        fieldList.append(weightField)
    if caseField:
        fieldList.append(caseField)

    stdDeviations = circleDict[stdDeviations]

    #### Create a Spatial Stats Data Object (SSDO) ####
    ssdo = SSDO.SSDataObject(inputFC, templateFC = outputFC,
                             useChordal = False)

    #### Populate SSDO with Data ####
    ssdo.obtainData(ssdo.oidName, fieldList, minNumObs = 2, dateStr = True) 

    #### Run Analysis ####
    sd = StandardDistance(ssdo, weightField = weightField,
                          caseField = caseField, 
                          stdDeviations = stdDeviations)
    
    #### Create Output ####
    sd.createOutput(outputFC)
Пример #32
0
    def __init__(self,
                 ssdo,
                 varName,
                 outputFC,
                 wType,
                 weightsFile=None,
                 concept="EUCLIDEAN",
                 rowStandard=True,
                 threshold=None,
                 exponent=1.0,
                 permutations=None,
                 applyFDR=False):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())

        #### Assess Whether SWM File Being Used ####
        self.swmFileBool = False
        if weightsFile:
            weightSuffix = weightsFile.split(".")[-1].lower()
            self.swmFileBool = (weightSuffix == "swm")

        #### Warn Inverse Distance if Geographic Coord System ####
        #if wType in [0, 7]:
        #    WU.checkGeographicCoord(self.ssdo.spatialRefType,
        #                            WU.wTypeDispatch[wType])

        #### Create Shape File Boolean for NULL Values ####
        self.outShapeFileBool = UTILS.isShapeFile(outputFC)

        #### Initialize Data ####
        self.initialize()

        #### Construct Based on SWM File or On The Fly ####
        self.construct()
Пример #33
0
def setupKFunction():
    """Retrieves the parameters from the User Interface and executes the
    appropriate commands."""

    inputFC = ARCPY.GetParameterAsText(0)
    outputTable = ARCPY.GetParameterAsText(1)
    nIncrements = ARCPY.GetParameter(2)
    permutations = ARCPY.GetParameterAsText(3).upper().replace(" ", "_")
    displayIt = ARCPY.GetParameter(4)                   
    weightField = UTILS.getTextParameter(5, fieldName = True)            
    begDist = UTILS.getNumericParameter(6)               
    dIncrement = UTILS.getNumericParameter(7)              
    edgeCorrection = ARCPY.GetParameterAsText(8).upper().replace(" ", "_")              
    studyAreaMethod = ARCPY.GetParameterAsText(9).upper().replace(" ", "_")             
    studyAreaFC = UTILS.getTextParameter(10)                

    #### Resolve Table Extension ####
    if ".dbf" not in OS.path.basename(outputTable):
        dirInfo = ARCPY.Describe(OS.path.dirname(outputTable))
        if dirInfo == "FileSystem":
            outputTable = outputTable + ".dbf"
    
    #### Resolve Remaining Parameters ####
    if nIncrements > 100:
        nIncrements = 100

    if edgeCorrection == "NONE" or edgeCorrection == "#": 
        edgeCorrection = None
    elif edgeCorrection == "SIMULATE_OUTER_BOUNDARY_VALUES": 
        edgeCorrection = "Simulate"
    elif edgeCorrection == "REDUCE_ANALYSIS_AREA": 
        edgeCorrection = "Reduce"
    else: 
        edgeCorrection = "Ripley"
   
    if permutations == "0_PERMUTATIONS_-_NO_CONFIDENCE_ENVELOPE":
        permutations = 0
    elif permutations == "99_PERMUTATIONS": 
        permutations = 99
    elif permutations == "999_PERMUTATIONS": 
        permutations = 999
    else: 
        permutations = 9

    if studyAreaMethod == "USER_PROVIDED_STUDY_AREA_FEATURE_CLASS":
        studyAreaMethod = 1
    else:
        studyAreaMethod = 0

    k = KFunction(inputFC, outputTable = outputTable,
                  nIncrements = nIncrements, permutations = permutations,
                  weightField = weightField, begDist = begDist, 
                  dIncrement = dIncrement, edgeCorrection = edgeCorrection,
                  studyAreaMethod = studyAreaMethod, studyAreaFC = studyAreaFC)

    k.report()
    k.createOutput(outputTable, displayIt = displayIt)
Пример #34
0
    def __init__(self, ssdoBase, ssdoCand, fieldNames,
                 similarType = 'MOST_SIMILAR',
                 matchMethod = 'ATTRIBUTE_VALUES',
                 numResults = 10, appendFields = []):

        UTILS.assignClassAttr(self, locals())
        self.k = len(self.fieldNames)
        self.validateNumResults()
        self.initialize()
        self.solve()
Пример #35
0
    def __init__(self, ssdo, depVarName, indVarNames, patW, useHAC=True):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())

        #### Initialize Data ####
        self.initialize()

        #### Calculate Statistic ####
        self.calculate()
    def cleanUp(self):
        #### Delete Temp Structures ####
        for tempItem in self.cleanUpList:
            UTILS.passiveDelete(tempItem)
        
        #### Reset Extent ####
        ARCPY.env.extent = self.startExtent

        #### Final Line Print ####
        ARCPY.AddMessage("\n")
Пример #37
0
    def cleanUp(self):
        #### Delete Temp Structures ####
        for tempItem in self.cleanUpList:
            UTILS.passiveDelete(tempItem)

        #### Reset Extent ####
        ARCPY.env.extent = self.startExtent

        #### Final Line Print ####
        ARCPY.AddMessage("\n")
Пример #38
0
    def __init__(self, ssdo, concept="EUCLIDEAN", studyArea=None):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())

        #### Set Study Area ####
        self.setStudyArea()

        #### Calculate ####
        self.calculate()
Пример #39
0
    def __init__(self, ssdo, concept = "EUCLIDEAN", studyArea = None):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())

        #### Set Study Area ####
        self.setStudyArea()

        #### Calculate ####
        self.calculate()
Пример #40
0
    def __init__(self, ssdo, depVarName, indVarNames, patW, useHAC = True):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())

        #### Initialize Data ####
        self.initialize()

        #### Calculate Statistic ####
        self.calculate()
Пример #41
0
    def __init__(self, ssdo, y, weightsMatrix, weightsType="SWM", silent=True):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())

        #### Construct Based on SWM File or On The Fly ####
        self.construct()

        #### Calculate Moran's I ####
        self.calculate()
Пример #42
0
    def createOutputTable(self):
        """Create output table for a given set of results."""

        #### Message and Progressor ####
        msg = ARCPY.GetIDMessage(84008)
        ARCPY.AddMessage(msg)
        ARCPY.SetProgressor("default", msg)

        #### Create/Finalize Output Table Name ####
        UTILS.createOutputTable(self.outputTable, self.outFieldNames,
                                self.outFieldTypes, self.tableResults)
Пример #43
0
    def __init__(self, ssdo, y, weightsMatrix, weightsType = "SWM",
                 silent = True):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())

        #### Construct Based on SWM File or On The Fly ####
        self.construct()

        #### Calculate Moran's I ####
        self.calculate()
    def createOutputTable(self):
        """Create output table for a given set of results."""

        #### Message and Progressor ####
        msg = ARCPY.GetIDMessage(84008)
        ARCPY.AddMessage(msg)
        ARCPY.SetProgressor("default", msg)

        #### Create/Finalize Output Table Name ####
        UTILS.createOutputTable(self.outputTable, self.outFieldNames,
                                self.outFieldTypes, self.tableResults)
Пример #45
0
    def createCoefficientReport(self):
        """Creates a formatted summary table of the OLS
        coefficients."""

        #### Table Title ####
        header =  ARCPY.GetIDMessage(84075)
        aFoot = ARCPY.GetIDMessage(84080)
        bFoot = ARCPY.GetIDMessage(84086)
        cFoot = ARCPY.GetIDMessage(84103)
        coefColLab = ARCPY.GetIDMessage(84049) + " " + aFoot
        probColLab = ARCPY.GetIDMessage(84055) + " " + bFoot
        robColLab = ARCPY.GetIDMessage(84102) + " " + bFoot
        vifColLab = ARCPY.GetIDMessage(84284) + " " + cFoot

        #### Column Labels ####
        total = [[ARCPY.GetIDMessage(84068), coefColLab,
                  ARCPY.GetIDMessage(84051), ARCPY.GetIDMessage(84053),
                  probColLab, ARCPY.GetIDMessage(84097),
                  ARCPY.GetIDMessage(84101), robColLab]]

        if self.vif:
            total[0].append(vifColLab)

        #### Loop Through Explanatory Variables ####
        for row in UTILS.ssRange(self.k):
            #### Variable Name ####
            rowVals = [self.varLabels[row]]

            #### Standard Values ####
            rowVals.append(UTILS.formatValue(self.coef[row, 0]))
            rowVals.append(UTILS.formatValue(self.seCoef[row]))
            rowVals.append(UTILS.formatValue(self.tStats[row]))
            rowVals.append(UTILS.writePVal(self.pVals[row], padNonSig = True))

            #### Robust Values ####
            rowVals.append(UTILS.formatValue(self.seCoefRob[row]))
            rowVals.append(UTILS.formatValue(self.tStatsRob[row]))
            rowVals.append(UTILS.writePVal(self.pValsRob[row],
                                           padNonSig = True))

            #### VIF ####
            if self.vif:
                if row == 0:
                    rowVIF = ARCPY.GetIDMessage(84092)
                else:
                    rowVIF = self.vifVal[(row - 1)]
                    if abs(rowVIF) > 1000:
                        rowVIF = "> 1000.0"
                    else:
                        rowVIF = LOCALE.format("%0.6f", rowVIF)
                rowVals.append(rowVIF)

            #### Append Row to Result List ####
            total.append(rowVals)

        #### Finalize Coefficient Table ####
        self.coefTable = UTILS.outputTextTable(total, header = header,
                                               pad = 1, justify = "right")
        self.coefRaw = total
Пример #46
0
    def __init__(self, id, varNames, coef, pVals, vifVals,
                 r2, aic, jb, bp, allMIPass = False):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())
        self.pVals = NUM.array(pVals)
        self.varNameArray = NUM.array(self.varNames)
        self.miPVal = None
        self.k = len(varNames)

        #### Create Model to Print ####
        self.createModel()
Пример #47
0
    def setAnalysisSSDO(self, tempFC, varName):
        #### Initial Data Assessment ####
        printOHSSection(84428, prependNewLine=True)

        self.varName = varName
        self.analysisSSDO = self.ssdo
        self.masterField = UTILS.setUniqueIDField(self.analysisSSDO)
        if UTILS.renderType[self.ssdo.shapeType.upper()]:
            stringShape = ARCPY.GetIDMessage(84502)
        else:
            stringShape = ARCPY.GetIDMessage(84501)

        #### Assure Enough Features (Q) ####
        printOHSSubject(84429, addNewLine=False)
        self.analysisSSDO.obtainDataGA(self.masterField, [self.varName])
        if len(self.analysisSSDO.badRecords):
            ARCPY.AddMessage("\n")
        if self.analysisSSDO.numObs < 30:
            ARCPY.AddIDMessage("ERROR", 1571, '30', stringShape)
            self.cleanUp()
            raise SystemExit()

        msg = ARCPY.GetIDMessage(84485).format(self.analysisSSDO.numObs)
        printOHSAnswer(msg)

        #### Errors and Warnings ####
        printOHSSubject(84432, addNewLine=False)
        y = self.analysisSSDO.fields[self.varName].returnDouble()
        yVar = NUM.var(y)

        #### Zero Variance ####
        if NUM.isnan(yVar) or yVar <= 0.0:
            ARCPY.AddIDMessage("ERROR", 1575)
            self.cleanUp()
            raise SystemExit()

        #### Analysis Var Description ####
        msg = ARCPY.GetIDMessage(84446).format(self.varName)
        printOHSAnswer(msg, addNewLine=False)
        printWeightAnswer(y)

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

        #### Raster Boundary ####
        if self.outputRaster:
            self.validateRaster(self.analysisSSDO.xyCoords)
Пример #48
0
    def __init__(self,
                 name,
                 type,
                 data=None,
                 alias=None,
                 nullable=True,
                 precision=None,
                 scale=None,
                 length=None,
                 required=False,
                 domain=None):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())
    def createOutput(self, outputTable):
        """Creates Moran's I Step Output Table.

        INPUTS
        outputTable (str): path to the output table
        """

        #### Allow Overwrite Output ####
        ARCPY.env.overwriteOutput = 1

        #### Get Output Table Name With Extension if Appropriate ####
        outputTable, dbf = UTILS.returnTableName(outputTable)

        #### Set Progressor ####
        ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84008))

        #### Delete Table If Exists ####
        UTILS.passiveDelete(outputTable)

        #### Create Table ####
        outPath, outName = OS.path.split(outputTable)
        try:
            DM.CreateTable(outPath, outName)
        except:
            ARCPY.AddIDMessage("ERROR", 541)
            raise SystemExit()

        #### Add Result Fields ####
        self.outputFields = []
        for field in iaFieldNames:
            fieldOut = ARCPY.ValidateFieldName(field, outPath)
            UTILS.addEmptyField(outputTable, fieldOut, "DOUBLE")
            self.outputFields.append(fieldOut)

        #### Create Insert Cursor ####
        try:
            insert = DA.InsertCursor(outputTable, self.outputFields)
        except:
            ARCPY.AddIDMessage("ERROR", 204)
            raise SystemExit()

        #### Add Rows to Output Table ####
        for testIter in xrange(self.nIncrements):
            insert.insertRow(self.giResults[testIter])

        #### Clean Up ####
        del insert

        return outputTable, dbf
Пример #50
0
    def getMoranStats(self):
        self.sumMoranRuns = 0
        self.sumMoranPass = 0
        miValues = []
        miModels = []
        miSorted = NUM.array([(0.0, 0.0), (0.0, 0.0), (0.0, 0.0)], 
                             dtype = [('mi', float), ('r2', float)])
        for resKey, resHandler in UTILS.iteritems(self.resultDict):
            for olsKey, olsRes in UTILS.iteritems(resHandler.olsResults):
                miValue = olsRes.miPVal
                if miValue is not None:
                    numRes = len(miValues)
                    if numRes < 3:
                        miValues.append(miValue)
                        miModels.append(olsRes)
                    else:
                        if numRes == 3:
                            miSorted['mi'] = miValues
                            miSorted['r2'] = [ ols.r2 for ols in miModels ]

                        minIndex = miSorted.argsort(order = ('mi', 'r2'))[0]
                        minValue = miValues[minIndex]
                        valueSame = UTILS.compareFloat(minValue, miValue)
                        update = False
                        if valueSame:
                            if olsRes.r2 > miModels[minIndex].r2:
                                update = True
                        else:
                            if minValue < miValue:
                                update = True
                        if update:
                            miValues[minIndex] = miValue
                            miModels[minIndex] = olsRes
                            miSorted['mi'][minIndex] = miValue
                            miSorted['r2'][minIndex] = olsRes.r2
                    self.sumMoranRuns += 1
                    if miValue > self.minMI:
                        self.sumMoranPass += 1

        miOrder = list(miSorted.argsort(order = ('mi', 'r2')))
        #miOrder = list(NUM.argsort(miValues))
        miOrder.reverse()
        self.miReportRows = []
        for miIndex in miOrder:
            try:
                miResult = miModels[miIndex]
                self.miReportRows.append(miResult.report(orderType = 2))
            except:
                pass
Пример #51
-1
    def copy2FC(self, outputFC):
        """Copies self to an output feature class.

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

        UTILS.addEmptyField(outputFC, self.name, self.type,
                            alias = self.alias,
                            nullable = self.nullable,
                            precision = self.precision,
                            scale = self.scale,
                            length = self.length,
                            required = self.required,
                            domain = self.domain)