Name

AddRasterConstraints — Adds raster constraints to a loaded raster table for a specific column that constrains spatial ref, scaling, blocksize, alignment, bands, band type and a flag to denote if raster column is regularly blocked. The table must be loaded with data for the constraints to be inferred. Returns true if the constraint setting was accomplished and issues a notice otherwise.

Synopsis

boolean AddRasterConstraints(name rasttable, name rastcolumn, boolean srid=true, boolean scale_x=true, boolean scale_y=true, boolean blocksize_x=true, boolean blocksize_y=true, boolean same_alignment=true, boolean regular_blocking=false, boolean num_bands=true , boolean pixel_types=true , boolean nodata_values=true , boolean out_db=true , boolean extent=true );

boolean AddRasterConstraints(name rasttable, name rastcolumn, text[] VARIADIC constraints);

boolean AddRasterConstraints(name rastschema, name rasttable, name rastcolumn, text[] VARIADIC constraints);

boolean AddRasterConstraints(name rastschema, name rasttable, name rastcolumn, boolean srid=true, boolean scale_x=true, boolean scale_y=true, boolean blocksize_x=true, boolean blocksize_y=true, boolean same_alignment=true, boolean regular_blocking=false, boolean num_bands=true, boolean pixel_types=true, boolean nodata_values=true , boolean out_db=true , boolean extent=true );

설명

raster_columns 래스터 카탈로그에 정보를 표출하는 데 쓰이는, 래스터 열에 대한 제약조건들을 생성합니다. rastschema 는 해당 테이블이 속해 있는 테이블 스키마의 명칭입니다. srid 는 SPATIAL_REF_SYS 테이블에 있는 항목을 참조하는 정수형 값이어야만 합니다.

raster2pgsql 로더는 래스터 테이블을 등록하는 데 이 함수를 이용합니다.

입력할 유효한 제약조건 명칭에 대한 자세한 내용은 Section 9.2.1, “래스터 열 카탈로그” 를 참조하십시오.

  • blocksize 는 X 및 Y 블록 크기를 둘 다 설정합니다.

  • blocksize_x 는 X 타일(각 타일의 너비 픽셀 개수)을 설정합니다.

  • blocksize_y 는 Y 타일(각 타일의 높이 픽셀 개수)을 설정합니다.

  • extent 는 전체 테이블의 범위를 계산하고 제약조건을 적용합니다. 모든 래스터는 해당 범위 내에 들어와야만 합니다.

  • num_bands 는 밴드의 개수입니다.

  • pixel_types 각 밴드에 대해 픽셀 유형의 배열을 읽어 들입니다. 모든 밴드 N이 동일한 픽셀 유형을 가지도록 보장합니다.

  • regular_blocking 은 공간적 유일성 제약조건(어떤 두 래스터도 공간적으로 동일할 수 없습니다) 및 커버리지 타일 제약조건(래스터는 커버리지에 맞춰 정렬됩니다)을 설정합니다.

  • same_alignment ensures they all have same alignment meaning any two tiles you compare will return true for. Refer to ST_SameAlignment.

  • srid 는 모든 타일이 동일한 SRID를 가지도록 보장합니다.

  • 기타 -- 앞의 함수들이 입력받는 제약조건은 무엇이든 추가해주십시오.

[Note]

이 함수는 테이블에 이미 존재하는 데이터에 제약조건을 적용합니다. 따라서 이 함수가 작동하려면, 먼저 래스터 열을 생성한 다음 데이터를 로드해야만 합니다.

[Note]

사용자가 제약조건을 적용한 다음 추가 데이터를 로드해야 할 경우, 사용자 데이터의 범위가 변경된다면 DropRasterConstraints 함수를 실행하는 편이 좋습니다.

2.0.0 버전부터 사용할 수 있습니다.

예시: 데이터에 기반한 열에 가능한 한 모든 제약조건을 적용하기

CREATE TABLE myrasters(rid SERIAL primary key, rast raster);
INSERT INTO myrasters(rast)
SELECT ST_AddBand(ST_MakeEmptyRaster(1000, 1000, 0.3, -0.3, 2, 2, 0, 0,4326), 1, '8BSI'::text, -129, NULL);

SELECT AddRasterConstraints('myrasters'::name, 'rast'::name);


-- verify if registered correctly in the raster_columns view --
SELECT srid, scale_x, scale_y, blocksize_x, blocksize_y, num_bands, pixel_types, nodata_values
    FROM raster_columns
    WHERE r_table_name = 'myrasters';

 srid | scale_x | scale_y | blocksize_x | blocksize_y | num_bands | pixel_types| nodata_values
------+---------+---------+-------------+-------------+-----------+-------------+---------------
 4326 |       2 |       2 |        1000 |        1000 |         1 | {8BSI}      | {0}
        

예시: 단일 제약조건을 적용하기

CREATE TABLE public.myrasters2(rid SERIAL primary key, rast raster);
INSERT INTO myrasters2(rast)
SELECT ST_AddBand(ST_MakeEmptyRaster(1000, 1000, 0.3, -0.3, 2, 2, 0, 0,4326), 1, '8BSI'::text, -129, NULL);

SELECT AddRasterConstraints('public'::name, 'myrasters2'::name, 'rast'::name,'regular_blocking', 'blocksize');
-- get notice--
NOTICE:  Adding regular blocking constraint
NOTICE:  Adding blocksize-X constraint
NOTICE:  Adding blocksize-Y constraint

참고

Section 9.2.1, “래스터 열 카탈로그”, ST_AddBand, ST_MakeEmptyRaster, DropRasterConstraints, ST_BandPixelType, ST_SRID