Meteoinfo,PSCF2Grid

# Get PSCF layer
mf = miapp.getMapDocument().getActiveMapFrame()
layerName = 'winterPSCF.shp'
layer = mf.getMapView().getLayer(layerName)

# Get grid x/y data
sn = layer.getShapeNum()
xn = 0
oldx = 0.0
for shp in layer.getShapes():
	x = shp.getPoints().get(0).X	
	if xn == 0:
		oldx = x		
	else:
		if x < oldx:
			break
		else:
			oldx = x
	xn += 1

yn = sn / xn
print 'Total number: ' + str(sn)
print 'X number: ' + str(xn)
print 'Y number: ' + str(yn)

idx = sn - xn
shp = layer.getShapes().get(idx)
point = shp.getExtent().getCenterPoint()
minx = point.X
miny = point.Y
rpoint = layer.getShapes().get(idx + 1).getExtent().getCenterPoint()
xdelta = rpoint.X - minx
tpoint = layer.getShapes().get(idx - xn).getExtent().getCenterPoint()
ydelta = tpoint.Y - miny

# Create GridData and set value
print 'Create GridData and set value...'
gData = GridData(minx, xdelta, xn, miny, ydelta, yn)
fieldName = 'WPSCF'
for i in range(0, yn):
	for j in range(0, xn):
		idx = (yn - i - 1) * xn + j
		v = layer.getCellValue(fieldName, idx)
		gData.data[i][j] = v

# Output GridData file
print 'Output GridData file...'
outfn = 'D:/0303HYSPLITDoc/Meteoinfo_out/cs20132019/cluster/winter/pscf.dat'
gData.saveAsSurferASCIIFile(outfn)

print 'Finished!'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值