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


Python SSUtilities.caseValue2Print方法代码示例

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


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

示例1: report

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import caseValue2Print [as 别名]
    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)
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:37,代码来源:MedianCenter.py

示例2: report

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import caseValue2Print [as 别名]
    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)
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:33,代码来源:StandardDistance.py

示例3: report

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import caseValue2Print [as 别名]
    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)
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:33,代码来源:CentralFeature.py

示例4: __init__

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import caseValue2Print [as 别名]
    def __init__ (self, ssdo, weightField = None, caseField = None, 
                  attFields = None):

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

        #### Set Data ####
        self.xyCoords = self.ssdo.xyCoords

        #### Verify Weights ####
        if weightField:
            self.weights = self.ssdo.fields[weightField].returnDouble()

            #### Report Negative Weights ####
            lessThanZero = NUM.where(self.weights < 0.0)
            if len(lessThanZero[0]):
                self.weights[lessThanZero] = 0.0
                ARCPY.AddIDMessage("Warning", 941)

            #### Verify Weight Sum ####
            self.weightSum = self.weights.sum()
            if not self.weightSum > 0.0: 
                ARCPY.AddIDMessage("ERROR", 898)
                raise SystemExit()
        else:
            self.weights = NUM.ones((self.ssdo.numObs,))

        #### Set Case Field ####
        if caseField:
            caseType = ssdo.allFields[caseField].type.upper()
            self.caseIsString = caseType == "STRING"
            self.caseVals = self.ssdo.fields[caseField].data
            cases = NUM.unique(self.caseVals)
            if self.caseIsString:
                self.uniqueCases = cases[NUM.where(cases != "")]
            else:
                self.uniqueCases = cases
        else:
            self.caseIsString = False
            self.caseVals = NUM.ones((self.ssdo.numObs, ), int)
            self.uniqueCases = [1]

        #### Set Result Dict ####
        medianCenter = COLL.defaultdict(NUM.array)

        if attFields:
            attCenter = COLL.defaultdict(NUM.array)

        #### Keep Track of Bad Cases ####
        badCases = []

        #### Calculate Results ####
        for case in self.uniqueCases:
            indices = NUM.where(self.caseVals == case)
            numFeatures = len(indices[0])
            xy = self.xyCoords[indices]
            w = self.weights[indices]
            weightSum = w.sum()
            if (weightSum != 0.0) and (numFeatures > 0):

                #### Calculate Median Center ####
                medX, medY, iters = calcMedianCenter(xy, w)
                medianCenter[case] = (medX, medY)
                if attFields:
                    attMeds = []
                    for attField in attFields:
                        attCaseVals = ssdo.fields[attField].returnDouble()
                        attCaseVals = attCaseVals[indices] 
                        attMed = STATS.median(attCaseVals, weights = w)
                        attMeds.append(attMed)
                    attMeds = NUM.array(attMeds)
                    attCenter[case] = attMeds
            else:
                badCases.append(case)

        #### Report Bad Cases ####
        nCases = len(self.uniqueCases)
        nBadCases = len(badCases) 
        badCases.sort()
        if nBadCases:
            cBool = self.caseIsString
            if not self.caseIsString:
                badCases = [UTILS.caseValue2Print(i, cBool) for i in badCases]
            ERROR.reportBadCases(nCases, nBadCases, badCases, 
                                 label = caseField)   

        #### Sorted Case List ####
        caseKeys = medianCenter.keys()
        caseKeys.sort()
        self.caseKeys = caseKeys

        #### Set Attributes ####
        self.medianCenter = medianCenter
        self.badCases = badCases
        self.caseField = caseField
        self.attFields = attFields
        self.weightField = weightField
        if attFields:
            self.attCenter = attCenter
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:101,代码来源:MedianCenter.py

示例5: createOutput

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import caseValue2Print [as 别名]
    def createOutput(self, outputFC):
        """Creates an Output Feature Class with the Standard Distances.

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

        #### Validate Output Workspace ####
        ERROR.checkOutputPath(outputFC)

        #### Shorthand Attributes ####
        ssdo = self.ssdo
        caseField = self.caseField

        #### Increase Extent if not Projected ####
        if ssdo.spatialRefType != "Projected":
            sdValues = self.sd.values()
            if len(sdValues):
                maxRadius = max(sdValues)
                largerExtent = UTILS.increaseExtentByConstant(ssdo.extent, 
                                                    constant = maxRadius)
                largerExtent = [ LOCALE.str(i) for i in largerExtent ]
                ARCPY.env.XYDomain = " ".join(largerExtent)

        #### Create Output Feature Class ####
        ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84003))
        outPath, outName = OS.path.split(outputFC)

        try:
            DM.CreateFeatureclass(outPath, outName, "POLYGON", 
                                  "", ssdo.mFlag, ssdo.zFlag, 
                                  ssdo.spatialRefString)
        except:
            ARCPY.AddIDMessage("ERROR", 210, outputFC)
            raise SystemExit()

        #### Add Fields to Output FC ####
        dataFieldNames = UTILS.getFieldNames(sdFieldNames, outPath)
        shapeFieldNames = ["[email protected]"]
        for fieldName in dataFieldNames:
            UTILS.addEmptyField(outputFC, fieldName, "DOUBLE")

        caseIsDate = False
        if caseField:
            fcCaseField = ssdo.allFields[caseField]
            validCaseName = UTILS.validQFieldName(fcCaseField, outPath)
            caseType = UTILS.convertType[fcCaseField.type]
            UTILS.addEmptyField(outputFC, validCaseName, caseType)
            dataFieldNames.append(validCaseName)
            if caseType.upper() == "DATE":
                caseIsDate = True

        #### Write Output ####
        badCaseRadians = []
        allFieldNames = shapeFieldNames + dataFieldNames
        rows = DA.InsertCursor(outputFC, allFieldNames)
        for case in self.caseKeys:

            #### Get Results ####
            xVal, yVal = self.meanCenter[case]
            radius = self.sd[case]

            #### Create Empty Polygon Geomretry ####
            poly = ARCPY.Array()

            #### Check for Valid Radius ####
            radiusZero = UTILS.compareFloat(0.0, radius, rTol = .0000001)
            radiusNan = NUM.isnan(radius)
            radiusBool = radiusZero + radiusNan
            if radiusBool:
                badRadian = 6
                badCase = UTILS.caseValue2Print(case, self.caseIsString)
                badCaseRadians.append(badCase)
            else:
                badRadian = 0

                #### Calculate a Point For Each ####
                #### Degree in Circle Polygon ####
                for degree in NUM.arange(0, 360):  
                    try:
                        radians = NUM.pi / 180.0 * degree
                        pntX = xVal + (radius * NUM.cos(radians))
                        pntY = yVal + (radius * NUM.sin(radians))
                        pnt = ARCPY.Point(pntX, pntY, ssdo.defaultZ)
                        poly.add(pnt)
                    except:
                        badRadian += 1
                        if badRadian == 6:
                            badCase = UTILS.caseValue2Print(case, 
                                               self.caseIsString)
                            badCaseRadians.append(badCase)
                            break

            if badRadian < 6:
                #### Create and Populate New Feature ####
                poly = ARCPY.Polygon(poly, None, True)
                rowResult = [poly, xVal, yVal, radius]

                if caseField:
                    caseValue = case.item()
#.........这里部分代码省略.........
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:103,代码来源:StandardDistance.py

示例6: __init__

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import caseValue2Print [as 别名]
    def __init__(self, ssdo, weightField = None, caseField = None, 
                 stdDeviations = 1.0):

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

        #### Set Data ####
        self.xyCoords = self.ssdo.xyCoords

        #### Verify Weights ####
        if weightField:
            self.weights = self.ssdo.fields[weightField].returnDouble()

            #### Report Negative Weights ####
            lessThanZero = NUM.where(self.weights < 0.0)
            if len(lessThanZero[0]):
                self.weights[lessThanZero] = 0.0
                ARCPY.AddIDMessage("Warning", 941)

            #### Verify Weight Sum ####
            self.weightSum = self.weights.sum()
            if not self.weightSum > 0.0: 
                ARCPY.AddIDMessage("ERROR", 898)
                raise SystemExit()
        else:
            self.weights = NUM.ones((self.ssdo.numObs,))

        #### Set Case Field ####
        if caseField:
            caseType = ssdo.allFields[caseField].type.upper()
            self.caseIsString = caseType == "STRING"
            self.caseVals = self.ssdo.fields[caseField].data
            cases = NUM.unique(self.caseVals)
            if self.caseIsString:
                self.uniqueCases = cases[NUM.where(cases != "")]
            else:
                self.uniqueCases = cases
        else:
            self.caseIsString = False
            self.caseVals = NUM.ones((self.ssdo.numObs, ), int)
            self.uniqueCases = [1]

        #### Set Result Dict ####
        meanCenter = COLL.defaultdict(NUM.array)
        sd = COLL.defaultdict(float)

        #### Keep Track of Bad Cases ####
        badCases = []

        #### Calculate Mean Center and Standard Distance ####
        for case in self.uniqueCases:
            indices = NUM.where(self.caseVals == case)
            numFeatures = len(indices[0])
            xy = self.xyCoords[indices]
            w = self.weights[indices]
            w.shape = numFeatures, 1
            weightSum = w.sum()
            if (weightSum != 0.0) and (numFeatures > 2):
                xyWeighted = w * xy

                #### Mean Center ####
                centers = xyWeighted.sum(0) / weightSum
                meanCenter[case] = centers

                #### Standard Distance ####
                devXY = xy - centers
                sigXY = (w * devXY**2.0).sum(0)/weightSum 
                sdVal = (MATH.sqrt(sigXY.sum())) * stdDeviations
                sd[case] = sdVal
            else:
                badCases.append(case)
                
        #### Report Bad Cases ####
        nCases = len(self.uniqueCases)
        nBadCases = len(badCases) 
        badCases.sort()
        if nBadCases:
            cBool = self.caseIsString
            if not self.caseIsString:
                badCases = [UTILS.caseValue2Print(i, cBool) for i in badCases]
            ERROR.reportBadCases(nCases, nBadCases, badCases, 
                                 label = caseField)   
        
        #### Sorted Case List ####
        caseKeys = sd.keys()
        caseKeys.sort()
        self.caseKeys = caseKeys

        #### Set Attributes ####
        self.meanCenter = meanCenter
        self.sd = sd
        self.badCases = badCases
        self.caseField = caseField
        self.stdDeviations = stdDeviations
        self.weightField = weightField
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:97,代码来源:StandardDistance.py

示例7: __init__

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

#.........这里部分代码省略.........
            self.caseVals = NUM.ones((self.ssdo.numObs, ), int)
            self.uniqueCases = [1]

        #### Set Result Dict ####
        meanCenter = COLL.defaultdict(NUM.array)
        se = COLL.defaultdict(float)

        #### Keep Track of Bad Cases ####
        badCases = []

        #### Calculate Mean Center and Standard Distance ####
        for case in self.uniqueCases:
            indices = NUM.where(self.caseVals == case)
            numFeatures = len(indices[0])
            xy = self.xyCoords[indices]
            w = self.weights[indices]
            w.shape = numFeatures, 1
            weightSum = w.sum()
            if (weightSum != 0.0) and (numFeatures > 2):
                xyWeighted = w * xy

                #### Mean Center ####
                centers = xyWeighted.sum(0) / weightSum
                meanX, meanY = centers
                meanCenter[case] = centers

                #### Standard Ellipse ####
                devXY = xy - centers
                flatW = w.flatten()
                sigX = (flatW * devXY[:,0]**2.0).sum()  
                sigY = (flatW * devXY[:,1]**2.0).sum()
                sigXY = (flatW * devXY[:,0] * devXY[:,1]).sum()
                denom = 2.0 * sigXY
                diffXY = sigX - sigY
                sum1 = diffXY**2.0 + 4.0 * sigXY**2.0

                if not abs(denom) > 0:
                    arctanVal = 0.0
                else:
                    tempVal = (diffXY + NUM.sqrt(sum1)) / denom
                    arctanVal = NUM.arctan(tempVal)

                if arctanVal < 0.0: 
                    arctanVal += (NUM.pi / 2.0)

                sinVal = NUM.sin(arctanVal)
                cosVal = NUM.cos(arctanVal)
                sqrt2 = NUM.sqrt(2.0)
                sigXYSinCos = 2.0 * sigXY * sinVal * cosVal
                seX = (sqrt2 *
                       NUM.sqrt(((sigX * cosVal**2.0) - sigXYSinCos +
                                 (sigY * sinVal**2.0)) / 
                                  weightSum) * stdDeviations)

                seY = (sqrt2 *
                       NUM.sqrt(((sigX * sinVal**2.0) + sigXYSinCos +
                                 (sigY * cosVal**2.0)) / 
                                  weightSum) * stdDeviations)
                
                #### Counter Clockwise from Noon ####
                degreeRotation = 360.0 - (arctanVal * 57.2957795)  
                
                #### Convert to Radians ####
                radianRotation1 = UTILS.convert2Radians(degreeRotation)

                #### Add Rotation ####
                radianRotation2 = 360.0 - degreeRotation
                if seX > seY:
                    radianRotation2 += 90.0
                    if radianRotation2 > 360.0: 
                        radianRotation2 = radianRotation2 - 180.0

                se[case] = (seX, seY, degreeRotation, 
                            radianRotation1, radianRotation2)
            else:
                badCases.append(case)

        #### Report Bad Cases ####
        nCases = len(self.uniqueCases)
        nBadCases = len(badCases)
        badCases.sort()
        if nBadCases:
            cBool = self.caseIsString
            if not self.caseIsString:
                badCases = [UTILS.caseValue2Print(i, cBool) for i in badCases]
            ERROR.reportBadCases(nCases, nBadCases, badCases, 
                                 label = caseField)   
        
        #### Sorted Case List ####
        caseKeys = se.keys()
        caseKeys.sort()
        self.caseKeys = caseKeys

        #### Set Attributes ####
        self.meanCenter = meanCenter
        self.se = se
        self.badCases = badCases
        self.caseField = caseField
        self.stdDeviations = stdDeviations
        self.weightField = weightField
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:104,代码来源:StandardEllipse.py

示例8: createOutput

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import caseValue2Print [as 别名]
    def createOutput(self, outputFC):
        """Creates an Output Feature Class with the Standard Distances.

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

        #### Validate Output Workspace ####
        ERROR.checkOutputPath(outputFC)

        #### Shorthand Attributes ####
        ssdo = self.ssdo
        caseField = self.caseField

        #### Increase Extent if not Projected ####
        if ssdo.spatialRefType != "Projected":
            seValues = self.se.values()
            if len(seValues):
                maxSE = NUM.array([ i[0:2] for i in seValues ]).max()
                largerExtent = UTILS.increaseExtentByConstant(ssdo.extent,
                                                        constant = maxSE)
                largerExtent = [ LOCALE.str(i) for i in largerExtent ]
                ARCPY.env.XYDomain = " ".join(largerExtent)

        #### Create Output Feature Class ####
        ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84003))
        outPath, outName = OS.path.split(outputFC)

        try:
            DM.CreateFeatureclass(outPath, outName, "POLYGON", 
                                  "", ssdo.mFlag, ssdo.zFlag, 
                                  ssdo.spatialRefString)
        except:
            ARCPY.AddIDMessage("ERROR", 210, outputFC)
            raise SystemExit()

        #### Add Fields to Output FC ####
        dataFieldNames = UTILS.getFieldNames(seFieldNames, outPath)
        shapeFieldNames = ["[email protected]"]
        for fieldName in dataFieldNames:
            UTILS.addEmptyField(outputFC, fieldName, "DOUBLE")

        caseIsDate = False
        if caseField:
            fcCaseField = ssdo.allFields[caseField]
            validCaseName = UTILS.validQFieldName(fcCaseField, outPath)
            caseType = UTILS.convertType[fcCaseField.type]
            UTILS.addEmptyField(outputFC, validCaseName, caseType)
            dataFieldNames.append(validCaseName)
            if caseType.upper() == "DATE":
                caseIsDate = True

        #### Write Output ####
        badCaseRadians = []
        allFieldNames = shapeFieldNames + dataFieldNames
        rows = DA.InsertCursor(outputFC, allFieldNames)
        for case in self.caseKeys:

            #### Get Results ####
            xVal, yVal = self.meanCenter[case]
            seX, seY, degreeRotation, radianR1, radianR2 = self.se[case]
            seX2 = seX**2.0
            seY2 = seY**2.0

            #### Create Empty Polygon Geomretry ####
            poly = ARCPY.Array()

            #### Check for Valid Radius ####
            seXZero = UTILS.compareFloat(0.0, seX, rTol = .0000001)
            seXNan = NUM.isnan(seX)
            seXBool = seXZero + seXNan
            seYZero = UTILS.compareFloat(0.0, seY, rTol = .0000001)
            seYNan = NUM.isnan(seY)
            seYBool = seYZero + seYNan
            if seXBool or seYBool:
                badRadian = 6
                badCase = UTILS.caseValue2Print(case, self.caseIsString)
                badCaseRadians.append(badCase)
            else:
                badRadian = 0
                cosRadian = NUM.cos(radianR1)
                sinRadian = NUM.sin(radianR1)

                #### Calculate a Point For Each ####
                #### Degree in Ellipse Polygon ####                
                for degree in NUM.arange(0, 360): 
                    try:
                        radians = UTILS.convert2Radians(degree)
                        tanVal2 = NUM.tan(radians)**2.0
                        dX = MATH.sqrt((seX2 * seY2) /
                                      (seY2 + (seX2 * tanVal2)))
                        dY = MATH.sqrt((seY2 * (seX2 - dX**2.0)) /
                                       seX2)

                        #### Adjust for Quadrant ####
                        if 90 <= degree < 180:
                            dX = -dX
                        elif 180 <= degree < 270:
                            dX = -dX
                            dY = -dY
#.........这里部分代码省略.........
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:103,代码来源:StandardEllipse.py


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