如何使用带点的gdal_网格

2024-06-10 16:13:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用gdal_网格制作一些三维曲面的立面模型。在

我可以通过以下命令使用geojson文件来完成:

ds2 = gdal.Grid('outputfile.tif', 'inputfile.geojson', format = 'GTiff', algorithm = 'linear:radius=0')

这个工作很好,但我希望能够为每个功能单独做它。我可以遍历geojson文件并获取每个特性,但是有没有一种方法可以使用全球电网只有要点,例如:

^{pr2}$

因此,我的问题是:

  1. 我能用吗全球电网用点代替geojson??在
  2. 在哪里可以看到我可以使用哪些输入参数全球网格??在

Tags: 文件模型命令format网格geojson电网grid
1条回答
网友
1楼 · 发布于 2024-06-10 16:13:04

这就是我解决问题的方法。这也许不是最优雅的解决方案,但似乎奏效了。 我从geojson文件(作为字典)加载曲面,获取第一个特性,然后将其转换为json字符串。在

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')

相关问题 更多 >