官术网_书友最值得收藏!

  • Mastering PostGIS
  • Dominik Mikiewicz Michal Mackiewicz Tomasz Nycz
  • 250字
  • 2021-07-02 22:52:24

Importing multiple rasters

Let's import a directory of rasters now. We have four files with the file name mask gray_50m_partial*.tif. In order to import all the files at once, we'll issue the following command:

raster2pgsql -s 4326 -C -l 2,4 -I -F -t 2700x2700 gray_50m_partial*.tif data_import.gray_50m_partial | psql -h localhost -p 5434 -U postgres -d mastering_postgis

You should see a similar output:

Processing 1/4: gray_50m_partial_bl.tif
BEGIN
CREATE TABLE
CREATE TABLE
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
Processing 2/4: gray_50m_partial_br.tif
(...)
Processing 3/4: gray_50m_partial_tl.tif
(...)
Processing 4/4: gray_50m_partial_tr.tif
(...)
CONTEXT: PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
NOTICE: Adding maximum extent constraint
CONTEXT: PL/pgSQL function addrasterconstraints(name,name,name,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean,boolean) line 53 at RETURN
addrasterconstraints
----------------------
t
(1 row)

addoverviewconstraints
------------------------
t
(1 row)

addoverviewconstraints
------------------------
t
(1 row)

COMMIT

The command used to import multiple rasters was very similar to the one we used to import a single file. The difference was a filename mask used in place of a filename: gray_50m_partial*.tif. If we had used a bit more griddy pattern such as *.tif, all the TIF files present in a directory would be imported.

When processing multiple files, one can pipe the output to psql without the connection info specified as psql params, but in such a case, equivalent environment variables will have to be set (on Windows, use the set command, and on Linux, export):

set PGPORT=5434
set PGHOST=localhost
set PGUSER=postgres
set PGPASSWORD=somepass
set PGDATABASE=mastering_postgis
raster2pgsql -s 4326 -C -l 2,4 -I -F -t 2700x2700 gray_50m_partial*.tif data_import.gray_50m_partial | psql
主站蜘蛛池模板: 安乡县| 千阳县| 固原市| 孟村| 托克逊县| 甘德县| 英吉沙县| 连江县| 安图县| 赣州市| 阳原县| 竹山县| 巴青县| 通榆县| 浦北县| 兰坪| 济宁市| 顺义区| 灵武市| 乐陵市| 凤山市| 虹口区| 宾阳县| 清水县| 灵宝市| 张家口市| 紫金县| 三门峡市| 正安县| 青海省| 岳阳市| 鲜城| 鄂尔多斯市| 栾川县| 通道| 米易县| 遂平县| 调兵山市| 平度市| 黑龙江省| 镇巴县|