本文整理汇总了Python中SSUtilities.standardDistanceCutoff方法的典型用法代码示例。如果您正苦于以下问题:Python SSUtilities.standardDistanceCutoff方法的具体用法?Python SSUtilities.standardDistanceCutoff怎么用?Python SSUtilities.standardDistanceCutoff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSUtilities
的用法示例。
在下文中一共展示了SSUtilities.standardDistanceCutoff方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: knnDecision
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import standardDistanceCutoff [as 别名]
def knnDecision(ssdo):
"""If no peak autocorrelation distance is found, then return the average
at which all features have a desired set of nearest neighbors. This value
is scaled to be larger than 3 and no larger than 30. If computed value is
larger than 1 standard distance, then return the standard distance
instead.
INPUTS:
ssdo (class): instance of Spatial Stats Data Object
"""
numNeighs = int(ssdo.numObs * .05)
if numNeighs < minNumNeighsSet:
numNeighs = minNumNeighsSet
if numNeighs > maxNumNeighsSet:
numNeighs = maxNumNeighsSet
#### KNN Subject ####
msg = ARCPY.GetIDMessage(84463)
ARCPY.SetProgressor("step", msg, 0, ssdo.numObs, 1)
printOHSSubject(84463, addNewLine = False)
#### Create k-Nearest Neighbor Search Type ####
gaTable = ssdo.gaTable
gaSearch = GAPY.ga_nsearch(gaTable)
gaSearch.init_nearest(0.0, numNeighs, 'euclidean')
neighDist = ARC._ss.NeighborDistances(gaTable, gaSearch)
N = len(gaTable)
distances = NUM.empty((N, ), float)
#### Find All Nearest Neighbor Distance ####
for row in xrange(N):
distances[row] = neighDist[row][-1][-1]
ARCPY.SetProgressorPosition()
#### Make Sure it is not Larger Than Standard Distance ####
meanDist = distances.mean()
if ssdo.useChordal:
distValue = meanDist
distanceStr = ssdo.distanceInfo.printDistance(distValue)
msg = ARCPY.GetIDMessage(84464).format(numNeighs, distanceStr)
else:
sd = UTILS.standardDistanceCutoff(ssdo.xyCoords)
if meanDist > sd:
distValue = sd
distanceStr = ssdo.distanceInfo.printDistance(distValue)
msg = ARCPY.GetIDMessage(84465).format(distanceStr)
else:
distValue = meanDist
distanceStr = ssdo.distanceInfo.printDistance(distValue)
msg = ARCPY.GetIDMessage(84464).format(numNeighs, distanceStr)
#### KNN/STD Answer ####
printOHSAnswer(msg)
return distValue
示例2: initialize
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import standardDistanceCutoff [as 别名]
def initialize(self):
"""Populates the instance of the Spatial Statistics Data
Object (SSDataObject) and resolves a default distance threshold
if none given.
"""
#### Shorthand Attributes ####
ssdo = self.ssdo
varName = self.varName
self.master2Order = ssdo.master2Order
masterField = ssdo.masterField
concept = self.concept
#### Populate SSDO with Data ####
field = ssdo.fields[varName]
self.y = field.returnDouble()
self.numObs = ssdo.numObs
gaExtent = UTILS.get92Extent(ssdo.extent)
#### Set Envelope or Slice ####
if ssdo.useChordal:
softMaxExtent = ssdo.sliceInfo.maxExtent
hardMaxExtent = ARC._ss.get_max_gcs_distance(ssdo.spatialRef)
maxExtent = min(softMaxExtent, hardMaxExtent)
else:
env = UTILS.Envelope(ssdo.extent)
maxExtent = env.maxExtent
#### Set Maximum Distance Allowed ####
extentBool = (self.begDist != None) or (self.dIncrement != None) or ssdo.useChordal
if extentBool:
#### If User Provides Either Input, Set to 75% Max Extent ####
self.maxDistance = maxExtent * 0.75
self.allDefaults = False
else:
#### Set to Diameter of Standard Distance ####
self.maxDistance = UTILS.standardDistanceCutoff(ssdo.xyCoords)
self.allDefaults = True
minimumRadius = (maxExtent * .001)
#### Determine Starting Distance ####
if self.begDist != None and self.begDist > self.maxDistance:
ARCPY.AddIDMessage("WARNING", 929)
self.begDist = None
self.calculatedBegDist = self.begDist == None
self.calculatedIncDist = self.dIncrement == None
if self.calculatedBegDist or self.calculatedIncDist:
outlierInfo = UTILS.LocationInfo(ssdo,
concept = self.concept,
stdDeviations = self.stdDeviations,
includeCoincident = self.includeCoincident,
silentThreshold = True)
threshold = outlierInfo.threshold
avgDist = outlierInfo.avgDist
if self.begDist == None:
self.begDist = threshold
if self.dIncrement == None:
self.dIncrement = avgDist
#### Negative Values Not Valid ####
if self.begDist < 0:
ARCPY.AddIDMessage("ERROR", 933)
raise SystemExit()
#### Beginning Distance is too Small ####
if self.begDist < minimumRadius:
ARCPY.AddIDMessage("ERROR", 897, self.begDist)
raise SystemExit()
#### Determine All Distance Cutoffs ####
cutoffs = UTILS.createCutoffsStep(self.begDist, self.dIncrement,
self.nIncrements)
#### Check Cutoff Values ###
countMaxSet = (cutoffs > self.maxDistance).sum()
if countMaxSet:
#### Throw Warning if ANY Distances Larger than Max Extent ####
if (not self.calculatedBegDist) and (not self.calculatedIncDist):
ARCPY.AddIDMessage("WARNING", 1285, countMaxSet, self.nIncrements)
cutoffs = UTILS.createCutoffsMaxDist(self.begDist, self.maxDistance,
self.nIncrements)
self.dIncrement = cutoffs[1] - cutoffs[0]
#### Print Threshold Distance ####
stepMax = cutoffs[-1]
thresholdStr = ssdo.distanceInfo.printDistance(self.begDist)
threshBool = self.calculatedBegDist
if threshBool and not self.silent:
ARCPY.AddIDMessage("WARNING", 853, thresholdStr)
if self.begDist > (maxExtent * 0.51) \
and not self.calculatedBegDist:
ARCPY.AddIDMessage("WARNING", 934)
elif stepMax > maxExtent \
and not self.calculatedIncDist:
ARCPY.AddIDMessage("WARNING", 935)
#.........这里部分代码省略.........