PostGIS
切換深色/淺色/自動模式 - PostGIS 空間資料庫 切換深色/淺色/自動模式 - PostGIS 空間資料庫 切換深色/淺色/自動模式 - PostGIS 空間資料庫 返回首頁 - PostGIS 空間資料庫

如何匯入/匯出光柵資料?

匯入資料

您可以透過 raster2pgsql(是 PostGIS 分配的一部分)或透過 gdal_translate(是 GDAL 的一部分)來匯入光柵資料。

raster2pgsql 通常較易於載入,因為 控制載入的選項 是直接公開的。

匯出資料

gdal_translate 程式通常較易於匯出光柵資料。

PGHOST=localhost \
PGPORT=5432 \
PGUSER=postgres \
PGPASSWORD=password \
gdal_translate \
    -of PNG \
    -outsize 10% 10% \
    "PG:dbname=db table=tbl" \
    foo.png

您也可以在匯出中使用 SQL「where」子句,將要置於「where」之後的篩選條件新增到您的連線字串。請注意,篩選條件中的單引號已使用巧妙的技術處理過。

PGHOST=localhost \
PGPORT=5432 \
PGUSER=postgres \
PGPASSWORD=password \
gdal_translate \
    -of PNG \
    -outsize 10% 10% \
    "PG:dbname=db table=tbl where='filename=\'abcd.sid\'' " \
    outfile.png

您也可以在「where」子句中使用空間篩選條件。

PGHOST=localhost \
PGPORT=5432 \
PGUSER=postgres \
PGPASSWORD=password \
gdal_translate \
    -of PNG \
    -outsize 10% 10% \
    "PG:dbname=db table=tbl where='ST_Intersects(rast, ST_SetSRID(ST_Point(-71.0,42.3),4326))' " \
    outfile.png