def createTruthPixelPolyPickle(truthPoly, pickleLocation=''):
# returns dictionary with list of minX, maxX, minY, maxY
if pickleLocation=='':
extension = os.path.splitext(truthPoly)[1]
pickleLocation = truthPoly.replace(extension, 'PixPoly.p')
if truthPoly != '':
# get Source Line File Information
shapef = ogr.Open(truthPoly, 0)
truthLayer = shapef.GetLayer()
envList = []
for tmpFeature in truthLayer:
tmpGeom = tmpFeature.GetGeometryRef()
env = tmpGeom.GetEvnelope()
envList.append(env)
envArray = np.asarray(envList)
envelopeData = {'minX': envArray[:,0],
'maxX': envArray[:,1],
'minY': envArray[:,2],
'maxY': envArray[:,3]
}
with open(pickleLocation, 'wb') as f:
pickle.dump(envelopeData, f)
# get Source Line File Information
评论列表
文章目录