登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
在TrajStat中进行轨迹聚类要求每条轨迹都有同样的节点数(某些轨迹可能因为气象数据等原因没有计算全),但是TrajStat中没有现成的节点数检查功能,暂时也懒得增加。可以通过写一个MeteoInfoLab小脚本来进行轨迹节点数检查。
下面的脚本打印出每条轨迹的节点数:
 - # Open trjactory shape file
- print 'Open trajectory shape file ...'
- trajfn = 'D:/Temp/traj/Sample/JiuquanSpr.shp'
- trajLayer = shaperead(trajfn)
- # Chek endpoint number of each trajectory
- print 'Chek endpoint number of each trajectory...'
- idx = 0
- for tline in trajLayer.shapes():
- t = trajLayer.cellvalue('Date', idx)
- h = trajLayer.cellvalue('Hour', idx)
- t.replace(hour=h)
- print t.strftime('%Y-%m-%d %H') + ': %i' % tline.getPointNum()
- idx += 1
- print 'Finish...'
也可以设定一个“正确”的节点数,检查每条轨迹的节点数是否正确,打印出有问题的轨迹:
 - # Open trjactory shape file
- print 'Open trajectory shape file ...'
- trajfn = 'D:/Temp/traj/Sample/JiuquanSpr.shp'
- trajLayer = shaperead(trajfn)
- # Chek endpoint number of each trajectory
- print 'Chek endpoint number of each trajectory...'
- # Set a correct number and print the trajectories with more or less endpoints
- epn = 73
- idx = 0
- n = 0
- for tline in trajLayer.shapes():
- if tline.getPointNum() != 73:
- t = trajLayer.cellvalue('Date', idx)
- h = trajLayer.cellvalue('Hour', idx)
- t.replace(hour=h)
- print t.strftime('%Y-%m-%d %H') + ': %i' % tline.getPointNum()
- n += 1
- idx += 1
- if n == 0:
- print 'All trajectories have same endpoint number!'
|