[英]How do I use gdal_grid with points
我使用gdal_grid来制作一些3d表面的高程模型。
我可以使用带有此命令的geojson文件来执行此操作:
ds2 = gdal.Grid('outputfile.tif', 'inputfile.geojson', format = 'GTiff', algorithm = 'linear:radius=0')
这很好,但我希望能够单独为每个功能做到这一点。 我可以遍历geojson文件并获取每个功能,但有没有办法只使用gdal.Grid点,例如:
[[12.135253194446484, 55.590235278979236, 44.500800000000005],
[12.136885609925141, 55.58968131535586, 44.500800000000005],
[12.149742647277185, 55.59946751368944, 89.5008],
[12.14443275453964, 55.601269628832526, 89.5008],
[12.135253194446484, 55.590235278979236, 44.500800000000005]]
因此,我的问题是:
这就是我解决问题的方法。 它可能不是最优雅的解决方案,但似乎有效。 我从geojson文件(作为字典)加载表面,获取第一个功能,然后将其转换为json-string。
with open(surfaceFileName,'r') as file:
data = json.load(file)
# the first feature:
dataJson = json.dumps(data['features'][0]['geometry'])
# this feature as geojson-string
featureJson = """{"type":"FeatureCollection",
"features": [
{"type": "Feature",
"geometry": """+dataJson+""",
"properties": {}
}]}"""
# Using gdal_grid:
ds2 = gdal.Grid('test10py.tif', featureJson, format = 'GTiff', algorithm = 'linear:radius=0')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.