本文整理汇总了Python中Polygon.minx方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.minx方法的具体用法?Python Polygon.minx怎么用?Python Polygon.minx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon
的用法示例。
在下文中一共展示了Polygon.minx方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readShpPolygon
# 需要导入模块: import Polygon [as 别名]
# 或者: from Polygon import minx [as 别名]
def readShpPolygon(layer,fileName):# parameter fileName is the pathfile name without extension
indexName = fileName + '.shx'
shpFile = open(indexName,"rb")
fileLength = os.path.getsize(indexName)
polygonNum = (fileLength-100)/8
recordsOffset = []
print fileName
starttime = time.clock()
shpFile.seek(0)
s = shpFile.read(fileLength)
shpFile.close()
layer.minx, layer.miny, layer.maxx, layer.maxy = struct.unpack("<dddd",s[36:68])
pointer = 100
for i in range(0,polygonNum):
offset = struct.unpack('>i',s[pointer:pointer+4])
recordsOffset.append(offset[0]*2)
pointer += 8
shpFile.close()
shpFile = open(fileName+'.shp',"rb")
shpFile.seek(24)
s = shpFile.read(4)
header = struct.unpack(">i",s)
fileLength = header[0]*2
shpFile.seek(0)
s = shpFile.read(fileLength)
shpFile.close()
for offset in recordsOffset:
x, y = [], []
polygon = Polygon()
pointer = offset + 8 + 4
polygon.minx,polygon.miny,polygon.maxx,polygon.maxy = struct.unpack('dddd',s[pointer:pointer+32])
pointer = offset + 8 + 36
polygon.numParts, polygon.numPoints = struct.unpack('ii',s[pointer:pointer+8])
pointer += 8
str = ''
for i in range(polygon.numParts):
str = str+'i'
polygon.partsIndex = struct.unpack(str,s[pointer:pointer+polygon.numParts*4])
pointer += polygon.numParts*4
for i in range(polygon.numPoints):
pointx, pointy = struct.unpack('dd',s[pointer:pointer+16])
x.append(pointx)
y.append(pointy)
pointer+=16
polygon.x, polygon.y = x, y
layer.features.append(polygon)
ts = time.clock()-starttime
print ' %f seconds' % (ts)