我有一些使用 gdaltools python 模塊將 geojson 文件轉(zhuǎn)換為 postgis 的 python 代碼。ogr = gdaltools.ogr2ogr()ogr.set_encoding("UTF-8")print("Setting Input")ogr.set_input(file_name, srs="EPSG:4326")gdaltools.Wrapper.BASEPATH = os.environ['GDAL_PATH']print("Setting Conn")conn = gdaltools.PgConnectionString(host=os.environ['DB_HOST'], port=os.environ['DB_PORT'], dbname=os.environ['DB_NAME'], user=os.environ['DB_USERNAME'], password=os.environ['DB_PASSWORD'], schema=str(self.table_prefix) + "_" + str(code))print("Setting Output")ogr.set_output(conn, table_name=table, srs="EPSG:27700")print("OGR Execute")ogr.execute()GeoJSON 包含類型為點(diǎn)的幾何圖形"geometry": { "type": "Point", "coordinates": [ -1.0600739160455448, 51.53592123798526 ]}從數(shù)據(jù)庫導(dǎo)出數(shù)據(jù)時(shí),我看到的是它似乎從 geojson 中的 Point 類型轉(zhuǎn)換為數(shù)據(jù)庫中的 Multipoint 類型。將幾何圖形從一個(gè)表加載到另一個(gè)表時(shí) - 沒有轉(zhuǎn)換 - 我收到以下錯(cuò)誤:Geometry type (MultiPoint) does not match column type (Point)關(guān)于 ogr2ogr 為什么從 Point 投射到 Multipoint 的任何想法?
2 回答

慕容708150
TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超4個(gè)贊
實(shí)際上,該模塊有一種處理這個(gè)的方法并不明顯,在 pygdaltools 模塊中,任何將要發(fā)送到 PostgreSQL 或 Postgis 的幾何圖形都會(huì)自動(dòng)設(shè)置為 MULTIPOINT。要覆蓋它,請(qǐng)?zhí)砑右韵麓a ogr.geom_type = 'POINT'
添加回答
舉報(bào)
0/150
提交
取消