gdal_grid.py
849 Bytes
# coding=utf-8
#author: 4N
#createtime: 2022/3/4
#email: nheweijun@sina.com
from osgeo import gdal
from osgeo import ogr
from osgeo.ogr import *
fn = "PG: user=%s password=%s host=%s port=%s dbname=%s " % ("postgres","chinadci","172.26.60.101","5432","ceshi")
driver = ogr.GetDriverByName("PostgreSQL")
if driver is None:
raise Exception("打开PostgreSQL驱动失败,可能是当前GDAL未支持PostgreSQL驱动!")
ds:DataSource = driver.Open(fn, 1)
layer:Layer = ds.GetLayerByName("BeijingBusStops")
# dd = gdal.Grid('outcome.tif',"J:\Data\矢量数据\北京\北京公交线路和公交站点shp\stops\BeijingBusStops.shp",algorithm = 'linear:radius=0')
# layers='test',
opts = gdal.GridOptions()
dd = gdal.Grid('outcome.tif',ds,layers=['BeijingBusStops'],algorithm = 'linear:radius=0')