本文整理汇总了Python中layer.Layer.Wrook方法的典型用法代码示例。如果您正苦于以下问题:Python Layer.Wrook方法的具体用法?Python Layer.Wrook怎么用?Python Layer.Wrook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类layer.Layer
的用法示例。
在下文中一共展示了Layer.Wrook方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rimap
# 需要导入模块: from layer import Layer [as 别名]
# 或者: from layer.Layer import Wrook [as 别名]
def rimap(n, N = 30, alpha = [0.01,0.3], sigma = [1.1,1.4], dt = 0.1,
pg = 0.01, pu = 0.05, su = 0.315, boundary = ""):
"""Creates an irregular maps
:param n: number of areas
:type n: integer
:param N: number of points sampled from each irregular polygon (MR-Polygon)
:type N: integer
:param alpha: min and max value to sampled alpha; default is (0.1,0.5)
:type alpha: List
:param sigma: min and max value to sampled sigma; default is (1.2,1.5)
:type sigma: List
:param dt: time delta to be used to create irregular polygons (MR-Polygons)
:type dt: Float
:param pg: parameter to define the scaling factor of each polygon before being introduced as part of the irregular map
:type pg: Float
:param pu: parameter to define the probability of increase the number of areas of each polygon before being introduced into the irregular map
:type pu: Float
:param su: parameter to define how much is increased the number of areas of each polygon before being introduced into the irregular map
:type su: Float
:param boundary: Initial irregular boundary to be used into the recursive irregular map algorithm
:type boundary: Layer
:rtype: Layer
:return: RI-Map instance
**Examples** ::
import clusterpy
lay = clusterpy.rimap(1000)
lay.exportArcData("rimap_1000")
"""
rm = rim(n, N, alpha, sigma, dt, pg, pu, su, boundary)
areas = rm.carteAreas
areas = fixIntersections(areas)
Wqueen,Wrook, = weightsFromAreas(areas)
layer = Layer()
layer.areas = areas
layer.Wqueen = Wqueen
layer.Wrook = Wrook
layer.shpType = 'polygon'
layer.name = "rimap_" + str(len(areas))
layer.fieldNames = ["Id","nw"]
layer.Y = {}
for i in Wrook:
layer.Y[i] = [i,len(Wrook[i])]
return layer
示例2: createGrid
# 需要导入模块: from layer import Layer [as 别名]
# 或者: from layer.Layer import Wrook [as 别名]
#.........这里部分代码省略.........
Create a grid of ten by ten points.::
import clusterpy
points = clusterpy.createGrid(10,10)
Create a grid of ten by ten points on the bounding box (0,0,100,100).::
import clusterpy
points = clusterpy.createGrid(10, 10, lowerLeft=(0, 0), upperRight=(100, 100))
"""
print "Creating grid"
if lowerLeft != None and upperRight != None:
ymin = lowerLeft[1]
ymax = upperRight[1]
xmin = lowerLeft[0]
xmax = upperRight[0]
areaHeight = float(ymax - ymin) / nRows
areaWidth = float(xmax - xmin) / nCols
else:
ymin = 0
xmin = 0
xmax = 10*nCols
ymax = 10*nRows
areaHeight = 10
areaWidth = 10
nyPoints = nRows
nxPoints = nCols
N = nyPoints*nxPoints
Y = {}
acty = ymax
actx = xmin
map = []
wr = {}
wq = {}
# Creating the wr matrix writh towrer criterium
disAreas = [0, nxPoints - 1, (N-nxPoints), N - 1]
wr[0] = [1, nyPoints]
wr[nxPoints - 1] = [nxPoints - 2, 2 * nxPoints - 1]
wr[N - nxPoints] = [N - nxPoints - nxPoints, N - nxPoints + 1]
wr[N - 1] = [N - 2, N - 1 - nxPoints]
wq[0] = [1, nxPoints, nxPoints + 1]
wq[nxPoints - 1] = [nxPoints - 2, nxPoints + nxPoints - 1,
nxPoints + nxPoints - 2]
wq[N - nxPoints] = [N - nxPoints - nxPoints, N - nxPoints + 1,
N - nxPoints - nxPoints + 1]
wq[N - 1] = [N - 2, N - 1 - nxPoints, N - 1 - nxPoints - 1]
verticalBorderAreas = []
for i in range(1, nxPoints - 1): #Asigning the neighborhood of the corner Areas
wr[i * nxPoints] = [i * nxPoints - nxPoints, i * nxPoints + 1,
i * nxPoints + nxPoints]
wr[nxPoints * i + nxPoints - 1] = [nxPoints * i - 1,
nxPoints * i + nxPoints - 2, nxPoints * i + 2 * nxPoints - 1]
wq[i * nxPoints] = [i * nxPoints - nxPoints, i * nxPoints - nxPoints + 1,
i * nxPoints + 1,i * nxPoints + nxPoints, i * nxPoints + nxPoints + 1]
wq[nxPoints * i + nxPoints - 1] = [nxPoints * i - 1, nxPoints * i - 2,
nxPoints * i + nxPoints - 2, nxPoints * i + 2 * nxPoints - 1,
nxPoints * i + 2 * nxPoints - 2]
disAreas = disAreas + [i * nxPoints, nxPoints * i + nxPoints - 1]
disAreas = disAreas + range(1, nxPoints - 1) + range((N - nxPoints) + 1, N - 1)
for i in range(1, nxPoints - 1): # Asigning the neighborhood of the side Areas
wr[i]=[i - 1, i + nxPoints, i + 1]
wq[i]=[i - 1, i + nxPoints - 1, i + nxPoints, i + nxPoints + 1, i + 1]
for i in range((N - nxPoints) + 1, N - 1):
wr[i]=[i - 1, i - nxPoints, i + 1]
wq[i]=[i - 1, i - nxPoints - 1, i - nxPoints, i - nxPoints + 1, i + 1]
cont = 0
for i in range(nyPoints): #Creating de clusterPy areas
nexty = acty - areaHeight
for j in range(nxPoints):
nextx = actx + areaWidth
x1 = tuple([actx, acty])
x2 = tuple([nextx, acty])
x3 = tuple([nextx, nexty])
x4 = tuple([actx, nexty])
x5 = tuple([actx, acty])
area = [x1, x2, x3, x4, x5]
map.append([area])
actx = nextx
if cont not in disAreas: # Asigning the rest of the neighborhoods
wr[cont]=[cont - 1, cont - nxPoints, cont + 1, cont + nxPoints]
wq[cont]=[cont - 1, cont - nxPoints - 1, cont - nxPoints,
cont - nxPoints + 1, cont + 1, cont + nxPoints - 1,
cont + nxPoints, cont + nxPoints + 1]
cont = cont + 1
acty = nexty
actx = xmin
for i in range(N):
Y[i]=[i]
layer = Layer()
layer.Y = Y
layer.fieldNames = ['ID']
layer.areas = map
layer.Wrook = wr
layer.Wqueen = wq
layer.Wqueen, layer.Wrook, = weightsFromAreas(layer.areas)
layer.shpType = 'polygon'
layer.name = 'root'
layer._defBbox()
print "Done"
return layer