本文整理汇总了Python中SSUtilities.nearestPoint方法的典型用法代码示例。如果您正苦于以下问题:Python SSUtilities.nearestPoint方法的具体用法?Python SSUtilities.nearestPoint怎么用?Python SSUtilities.nearestPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSUtilities
的用法示例。
在下文中一共展示了SSUtilities.nearestPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: permutateTable
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import nearestPoint [as 别名]
def permutateTable(self):
"""Permutates points in study area."""
#### Create New GA Table ####
newTable = GAPY.ga_table()
kTable = self.kTable
N = len(kTable)
newSimDict = {}
maxID = 0
c = 0
for i in xrange(N):
row = kTable[i]
id = row[0]
x,y = row[1]
point = (x, y)
if id in self.ids:
flag = 1
while flag:
dX = (RAND.random() * self.envelopeSA.lenX) \
+ self.minX
dY = (RAND.random() * self.envelopeSA.lenY) \
+ self.minY
point = (dX, dY)
if self.reduce:
inside = self.reducePath.contains_point((dX, dY))
else:
inside = self.studyAreaPath.contains_point((dX, dY))
if inside:
newTable.insert(id, point, 1.0)
flag = 0
else:
if self.simDict.has_key(id):
pass
else:
newTable.insert(id, point, 1.0)
newTable.flush()
del self.kTable, self.simDict
#### Distance from points to study area boundary ####
near, nearXY, nextNear = UTILS.nearestPoint(self.studyAreaPoly,
newTable)
#### Resolve Simulate Points ####
if self.simulate:
simTable = GAPY.ga_table()
tempN = len(newTable)
simID = self.maxID + 1
for i in xrange(tempN):
row = newTable[i]
id = row[0]
x,y = row[1]
simTable.insert(id, (x,y), 1.0)
if near[id] <= self.stepMax:
nearX, nearY = nearXY[id]
dX = nearX + (nearX - x)
dY = nearY + (nearY - y)
point = (dX, dY)
inside = self.studyAreaPath.contains_point((dX, dY))
if not inside:
simTable.insert(simID, point, 1.0)
newSimDict[simID] = id
simID += 1
del newTable
simTable.flush()
self.kTable = simTable
else:
self.kTable = newTable
#### Reassign Attributes ####
self.simDict = newSimDict
self.N = len(self.kTable)
self.near = near
self.nearXY = nearXY
self.nextNear = nextNear
示例2: setOriginalTable
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import nearestPoint [as 别名]
def setOriginalTable(self):
"""Finalizes original GA Table."""
#### Distance from points to study area boundary ####
ssdo = self.ssdo
near, nearXY, nextNear = UTILS.nearestPoint(self.studyAreaPoly,
self.ssdo.gaTable)
#### Create New GA Table ####
kTable = GAPY.ga_table()
#### Create Data Structures ####
ids = []
tempSim = {}
self.simDict = {}
weightDict = {}
weightVals = []
#### Pass Over Original GA Table ####
gaTable = self.ssdo.gaTable
N = len(gaTable)
maxID = 0
c = 0
for i in xrange(N):
row = gaTable[i]
id = row[0]
xy = row[1]
#### Inside Checks ####
inPoly = self.studyAreaPath.contains_point(xy)
onEdge = near[id] < self.xyTolerance
inside = inPoly or onEdge
#### Skip or Cont... Depending On Inside ####
keepResult = True
if not self.noEdge:
if not inside:
keepResult = False
if keepResult:
#### Weight Field ####
if self.weightField:
weight = row[2]
weightDict[id] = c
weightVals.append(weight)
else:
weight = 1.0
c += 1
#### Insert Into Table ####
kTable.insert(id, xy, weight)
#### Resolve Inside/Outside IDs ####
if self.reduce:
inReduced = self.reducePath.contains_point(xy)
if inReduced:
#### Inside Reduced Study Area ####
ids.append(id)
else:
if inside:
ids.append(id)
maxID = max(maxID, id)
#### Add Simulated Points ####
if self.simulate:
x,y = xy
if near[id] <= self.stepMax:
nearX, nearY = nearXY[id]
dX = nearX + (nearX - x)
dY = nearY + (nearY - y)
inside = self.studyAreaPath.contains_point((dX, dY))
onLine = near[id] < self.xyTolerance
outside = (not inside and not onLine)
if outside:
tempSim[id] = [ (dX, dY), weight ]
#### Resolve Simulated Points ####
simPointsOut = []
if self.simulate:
simID = maxID + 1
for origKey, origVals in tempSim.iteritems():
self.simDict[simID] = origKey
xy, weight = origVals
kTable.insert(simID, xy, weight)
simID += 1
simPointsOut.append(xy)
#### Check if All Features Are Outside Study Area ####
if len(ids) == 0:
ARCPY.AddIDMessage("ERROR", 1008)
raise SystemExit()
#### Finalize Table ####
kTable.flush()
self.weightVals = NUM.array(weightVals)
self.weightDict = weightDict
self.N = len(kTable)
self.ids = set(ids)
self.near = near
#.........这里部分代码省略.........