Chapter 2. PostGIS 설치

Table of Contents
2.1. 짧은 설명
2.2. 소스를 컴파일하고 설치하기
2.2.1. 소스 획득
2.2.2. 설치 요구사항
2.2.3. 설정
2.2.4. 빌드
2.2.5. PostGIS Extensions 빌드 및 배포
2.2.6. 테스트
2.2.7. 설치
2.3. 주소 표준화 도구 설치 및 활용
2.4. Installing, Upgrading Tiger Geocoder, and loading data
2.4.1. Tiger Geocoder Enabling your PostGIS database
2.4.2. 주소 표준화 도구를 TIGER 지오코딩 도구와 함께 사용
2.4.3. Required tools for tiger data loading
2.4.4. Upgrading your Tiger Geocoder Install and Data
2.5. 설치 과정에서 흔히 발생하는 문제들

이 장에서는 PostGIS 설치에 요구되는 모든 과정을 설명합니다.

2.1. 짧은 설명

사용자의 검색 경로에 모든 의존성이 설정되어 있을 때 컴파일하려면:

tar -xvzf postgis-3.4.3dev.tar.gz
cd postgis-3.4.3dev
./configure
make
make install

PostGIS가 설치되면, PostGIS를 사용하고자 하는 모든 데이터베이스 각각에서 활성화하거나 (Section 3.3, “공간 데이터베이스 생성”)업그레이드(Section 3.4, “Upgrading spatial databases”)해야 합니다.

2.2. 소스를 컴파일하고 설치하기

[Note]

현재 많은 OS 시스템들이 PostgreSQL/PostGIS용 사전 구축된 패키지를 포함하고 있습니다. 많은 경우, 최신 버전이 필요하거나 패키지 관리자인 경우가 아니라면 컴파일할 필요가 없습니다.

This section includes general compilation instructions, if you are compiling for Windows etc or another OS, you may find additional more detailed help at PostGIS User contributed compile guides and PostGIS Dev Wiki.

Pre-Built Packages for various OS are listed in PostGIS Pre-built Packages

만약 윈도우 사용자라면 Stackbuilder 또는 PostGIS Windows download site 를 통해 안정적인 버전을 받을 수 있습니다. 또 1~2주에 한 번 혹은 뭔가 특이한 일이 일어날 경우 빌드를 하는 very bleeding-edge windows experimental builds 가 있습니다. 사용자는 이를 통해 진행중인 PostGIS 배포본을 실행해볼 수 있습니다.

The PostGIS module is an extension to the PostgreSQL backend server. As such, PostGIS 3.4.3dev requires full PostgreSQL server headers access in order to compile. It can be built against PostgreSQL versions 12 - 16. Earlier versions of PostgreSQL are not supported.

Refer to the PostgreSQL installation guides if you haven't already installed PostgreSQL. https://www.postgresql.org .

[Note]

GEOS 기능성을 위해 PostgreSQL설치 시 표준 C++ 라이브러리를 명확하게 링크해야 할 수도 있습니다.

LDFLAGS=-lstdc++ ./configure [YOUR OPTIONS HERE]

이것은 구 버전 개발 도구 이용시 거짓 C++ 예외 상호작용을 피하기 위한 방법입니다. 만약 사용자가 이상한 문제(백엔드가 갑자기 끊어진다거나 또는 비슷한 증상)를 겪는다면 PostgreSQL을 다시 컴파일해야 할 수도 있습니다.

다음은 PostGIS 소스를 설정하고 취합하는 단계를 설명합니다. 리눅스 사용자를 위한 설명이므로 윈도우 또는 맥 사용자에겐 해당되지 않습니다.

2.2.1. 소스 획득

PostGIS 소스 압축파일을 다운로드 웹사이트 https://postgis.net/stuff/postgis-3.4.3dev.tar.gz 에서 다운로드하십시오.

wget https://postgis.net/stuff/postgis-3.4.3dev.tar.gz
tar -xvzf postgis-3.4.3dev.tar.gz
cd postgis-3.4.3dev

이 명령어를 실행하면 현재 작업 디렉토리에 postgis-3.4.3dev (이)라는 명칭의 디렉터리가 생길 것입니다.

다른 방법으로는, svn 저장소 http://svn.osgeo.org/postgis/trunk/ 에서 소스를 체크아웃(checkout)할 수 있습니다.

git clone https://git.osgeo.org/gitea/postgis/postgis.git postgis
cd postgis
sh autogen.sh
    

설치를 계속하려면 새로 만든 postgis-3.4.3dev 디렉터리로 이동합니다.

./configure

2.2.2. 설치 요구사항

PostGIS를 빌드하고 사용하기 위해서는 다음과 같은 요구사항들을 만족해야 합니다.

필수 사항

  • PostgreSQL 12 - 16. A complete installation of PostgreSQL (including server headers) is required. PostgreSQL is available from https://www.postgresql.org .

    For a full PostgreSQL / PostGIS support matrix and PostGIS/GEOS support matrix refer to https://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS

  • GNU C 컴파일러(gcc). PostGIS를 컴파일하기 위해 그 밖에 다른 ANSI C 컴파일러들을 사용할 수 있으나 gcc 로 컴파일했을 경우 오류가 훨씬 적게 발생합니다.

  • GNU Make(gmake 또는 make). 많은 시스템들에서 GNU make 는 make의 기본 버전입니다. make -v를 통해 버전을 확인하십시오. 다른 버전의 make는 PostGIS Makefile을 제대로 처리하지 못 할 수도 있습니다.

  • Proj reprojection library. Proj 6.1 or above is required. The Proj library is used to provide coordinate reprojection support within PostGIS. Proj is available for download from https://proj.org/ .

  • GEOS geometry library, version 3.6 or greater, but GEOS 3.12+ is required to take full advantage of all the new functions and features. GEOS is available for download from https://libgeos.org .

  • LibXML2, version 2.5.x or higher. LibXML2 is currently used in some imports functions (ST_GeomFromGML and ST_GeomFromKML). LibXML2 is available for download from https://gitlab.gnome.org/GNOME/libxml2/-/releases.

  • JSON-C 0.9 또는 이후 버전. JSON-C는 현재 ST_GeomFromGeoJson 함수를 통해 GeoJSON을 임포트하는 데 사용되고 있습니다. JSON-C는 https://github.com/json-c/json-c/releases/ 에서 다운로드할 수 있습니다.

  • GDAL, version 2+ is required 3+ is preferred. This is required for raster support. https://gdal.org/download.html.

  • 이 파라미터는 현재 작동되지 않습니다. 패키지가 PostgreSQL 설치 경로에만 설치될 것이기 때문입니다. 해당 버그를 추적하려면 http://trac.osgeo.org/postgis/ticket/635 를 참조하십시오.

선택 사항

  • Section 2.1, “짧은 설명” 에 설명된 대로 사용자가 사용하길 원하는 드라이버를 활성화하는 작업도 잊지 마십시오.

  • shapefile 로더 shp2pgsql-gui 를 컴파일하기 위한 GTK(GTK+2.0, 2.8+ 필요). http://www.gtk.org/.

  • SFCGAL, version 1.3.1 (or higher), 1.4.1 or higher is recommended and required to be able to use all functionality. SFCGAL can be used to provide additional 2D and 3D advanced analysis functions to PostGIS cf Section 7.21, “SFCGAL 함수”. And also allow to use SFCGAL rather than GEOS for some 2D functions provided by both backends (like ST_Intersection or ST_Area, for instance). A PostgreSQL configuration variable postgis.backend allow end user to control which backend he want to use if SFCGAL is installed (GEOS by default). Nota: SFCGAL 1.2 require at least CGAL 4.3 and Boost 1.54 (cf: https://sfcgal.org) https://gitlab.com/sfcgal/SFCGAL/.

  • In order to build the Section 11.1, “주소 표준화 도구” you will also need PCRE http://www.pcre.org (which generally is already installed on nix systems). Section 11.1, “주소 표준화 도구” will automatically be built if it detects a PCRE library, or you pass in a valid --with-pcre-dir=/path/to/pcre during configure.

  • To enable ST_AsMVT protobuf-c library 1.1.0 or higher (for usage) and the protoc-c compiler (for building) are required. Also, pkg-config is required to verify the correct minimum version of protobuf-c. See protobuf-c. By default, Postgis will use Wagyu to validate MVT polygons faster which requires a c++11 compiler. It will use CXXFLAGS and the same compiler as the PostgreSQL installation. To disable this and use GEOS instead use the --without-wagyu during the configure step.

  • CUnit(CUnit). 회기 검증을 하는 데 필요합니다. http://cunit.sourceforge.net/

  • DocBook(xsltproc)은 문서를 발행할 때 필요합니다. DocBook은 http://www.docbook.org/ 에서 다운로드할 수 있습니다.

  • DBLatex(dblatex)는 PDF 형식의 문서를 발행할 때 필요합니다. DBLatex는 http://dblatex.sourceforge.net/ 에서 다운로드할 수 있습니다.

  • ImageMagick(convert)은 문서에 사용되는 이미지를 생성하는 데 필요합니다. ImageMagick은 http://www.imagemagick.org/ 에서 다운로드할 수 있습니다.

2.2.3. 설정

대부분의 리눅스 설치에서 첫 번째 단계는 소스 코드를 빌드하는 데 사용할 Makefile을 생성하는 것입니다. 셸 스크립트를 실행해서 Makefile을 작성합니다.

./configure

추가 파라미터 없이 사용하면, 이 명령은 자동적으로 PostGIS 소스코드를 사용자 시스템에 빌드하는 데 필요한 필수 구성 요소들과 라이브러리의 위치를 확인하려 합니다. ./configure 명령어의 가장 흔한 사용법이긴 하지만, 이 스크립트는 비표준적인 위치에 있는 필수 라이브러리와 프로그램들에 대한 몇몇 파라미터를 받습니다.

다음은 가장 많이 사용되는 파라미터들만 나열한 목록입니다. 전체 목록은 --help 또는 --help=short 파라미터를 사용하십시오.

--with-library-minor-version

Starting with PostGIS 3.0, the library files generated by default will no longer have the minor version as part of the file name. This means all PostGIS 3 libs will end in postgis-3. This was done to make pg_upgrade easier, with downside that you can only install one version PostGIS 3 series in your server. To get the old behavior of file including the minor version: e.g. postgis-3.0 add this switch to your configure statement.

--prefix=PREFIX

PostGIS 라이브러리와 SQL 스크립트가 설치될 경로입니다. 기본적으로 PostgreSQL가 설치된 경로와 같은 곳에 설치됩니다.

[Caution]

이 파라미터는 현재 작동되지 않습니다. 패키지가 PostgreSQL 설치 경로에만 설치될 것이기 때문입니다. 해당 버그를 추적하려면 http://trac.osgeo.org/postgis/ticket/635 를 참조하십시오.

--with-pgconfig=FILE

PostgreSQL은 PostGIS 같은 확장 프로그램이 PostgreSQL 설치 디렉토리의 위치를 확인하게 해주는 pg_config 라는 유틸리티를 제공합니다. PostGIS 빌드 시 대상이 될 특정 PostgreSQL 설치 디렉터리를 사용자가 직접 설정하려면 이 파라미터(--with-pgconfig=/path/to/pg_config)를 사용하십시오.

--with-gdalconfig=FILE

GDAL은 래스터 지원을 위한 기능을 제공하는 필수 라이브러리로, GDAL 설치 디렉터리의 위치를 확인하는 소프트웨어 설치를 활성화하기 위한 gdal-config를 지원합니다. PostGIS 빌드 시 대상이 될 특정 GDAL 설치 디렉터리를 사용자가 직접 설정하려면 이 파라미터(--with-gdalconfig=/path/to/gdal-config)를 사용하십시오.

--with-geosconfig=FILE

GEOS는 필수 도형 라이브러리로, GEOS 설치 디렉터리의 위치를 확인하는 소프트웨어 설치를 활성화하기 위한 geos-config라는 유틸리티를 제공합니다. PostGIS 빌드 시 대상이 될 특정 GEOS 설치 디렉터리를 사용자가 직접 설정하려면 이 파라미터(--with-geosconfig=/path/to/geos-config)를 사용하십시오.

--with-xml2config=FILE

LibXML은 GeomFromKML/GML 프로세스를 진행하기 위해 필요한 라이브러리입니다. 일반적으로 libxml을 설치하면 찾을 수 있지만, 설치하지 않았거나 특정 버전을 사용하기 바랄 경우 LibXML 설치 디렉터리의 위치를 확인하는 소프트웨어 설치를 활성화하기 위해 xml2-config라는 설정 파일에 PostGIS의 위치를 지정해야 합니다. PostGIS 빌드 시 대상이 될 특정 LibXML 설치 디렉터리를 사용자가 직접 설정하려면 이 파라미터(--with-xml2config=/path/to/xml2-config)를 사용하십시오.

--with-projdir=DIR

Proj4는 PostGIS 필수 재투영 라이브러리입니다. PostGIS 빌드 시 대상이 될 특정 Proj4 설치 디렉터리를 사용자가 직접 설정하려면 이 파라미터(--with-projdir=/path/to/projdir)를 사용하십시오.

--with-libiconv=DIR

iconv 설치 경로

--with-jsondir=DIR

JSON-C 는 MIT-라이선스의 JSON 라이브러리로, PostGIS의 ST_GeomFromJSON 지원에 필요합니다. PostGIS 빌드 시 대상이 될 특정 JSON-C 설치 디렉터리를 사용자가 직접 설정하려면 이 파라미터(--with-jsondir=/path/to/jsondir)를 사용하십시오.

--with-pcredir=DIR

PCRE 는 BSD-라이선스의 펄 호환 가능 정규 표현식 라이브러리로, address_standardizer 확장 프로그램이 필요합니다. PostGIS 빌드 시 대상이 될 특정 PCRE 설치 디렉터리를 사용자가 직접 설정하려면 이 파라미터(--with-pcredir=/path/to/pcredir)를 사용하십시오.

--with-gui

데이터 임포트 GUI 컴파일(GTK+2.0 필요). shp2pgsql-gui의 shp2pgsql에 대한 그래픽 인테페이스를 생성합니다.

--without-raster

래스터 지원 설치

--without-topology

Disable topology support. There is no corresponding library as all logic needed for topology is in postgis-3.4.3dev library.

--with-gettext=no

기본적으로 PostGIS는 gettext 지원을 감지해서 함께 컴파일하지만, 로더의 파손을 야기하는 비호환성 문제가 발생할 경우 이 명령어로 gettext 지원을 완전히 비활성화시킬 수 있습니다. 이런 방법으로 설정을 변경해서 문제를 해결하는 예는 버그 티켓 http://trac.osgeo.org/postgis/ticket/748 을 참조하십시오. 주의: gettext 지원을 끈다고 해서 별다른 문제는 없습니다. gettext 지원은 아직 문서화되지도 않았고 검증중에 있는 GUI 로더 용 국제 도움말/라벨 지원에 사용됩니다.

--with-sfcgal=PATH

기본적으로 PostGIS는 이 스위치 없이는 sfcgal 지원과 함께 설치되지 않습니다. PATH 는 sfcgal-config를 가리키는 대체 경로를 지정하도록 해주는 선택적인 인자입니다.

--without-phony-revision

Disable updating postgis_revision.h to match current HEAD of the git repository.

[Note]

PostGIS를 SVN 저장소 에서 얻었다면, 먼저 다음 스크립트를 실행하십시오.

./autogen.sh

이 스크립트는 configure 스크립트를 생성하는데, 이 스크립트는 PostGIS의 사용자 지정 설치를 위해 이용됩니다.

만약 tar 파일 형태로 PostGIS를 얻었다면 이미 configure 가 생성되었기 때문에 ./autogen.sh 를 실행할 필요는 없습니다.

2.2.4. 빌드

일단 Makefile이 생성되면 PostGIS 빌드 작업은 실행만큼이나 쉽습니다.

make

산출물의 마지막 줄에 "PostGIS was built successfully. Ready to install."이란 문장이 보여야 합니다.

As of PostGIS v1.4.0, all the functions have comments generated from the documentation. If you wish to install these comments into your spatial databases later, run the command which requires docbook. The postgis_comments.sql and other package comments files raster_comments.sql, topology_comments.sql are also packaged in the tar.gz distribution in the doc folder so no need to make comments if installing from the tar ball. Comments are also included as part of the CREATE EXTENSION install.

make comments

PostGIS 2.0 버전부터 소개되었습니다. 빠른 참조 또는 학습용 유인물에 적합한 참조 자료(cheat sheet) html 파일을 생성합니다. 파일 생성에 xsltproc가 필요하며, doc 폴더 안에 다음topology_cheatsheet.html, tiger_geocoder_cheatsheet.html, raster_cheatsheet.html, postgis_cheatsheet.html 4개의 파일을 생성할 것입니다.

html 및 pdf 형식으로 미리 만들어진 파일들을 PostGIS / PostgreSQL Study Guides 에서 다운로드받을 수 있습니다.

make cheatsheets

2.2.5. PostGIS Extensions 빌드 및 배포

PostgreSQL 9.1 이상을 사용 중이라면 PostGIS extentions은 자동적으로 빌드 및 설치됩니다.

소스 저장소로부터 생성할 경우에는, 먼저 function descriptions 부터 빌드해야 합니다. docbook을 설치하셨다면 빌드할 수 있고, 다음 명령을 통해 수동으로 생성할 수도 있습니다:

make comments

만약 사용자가 tar 파일 배포본을 이용해 빌드한다면 미리 빌드된 것이 tar 파일과 함께 배포됨으로 comments를 따로 빌드할 필요가 없습니다.

만약 PostgreSQL 9.1을 기반으로 빌드 중이라면 extensions은 설치 과정의 일환으로 자동 빌드될 것입니다. 만약 필요하다면 extensions 폴더로부터의 빌드하거나 또는 다른 서버에서 필요한 파일을 복사할 수 있습니다.

cd extensions
cd postgis
make clean
make
export PGUSER=postgres #overwrite psql variables
make check #to test before install
make install
# to test extensions
make check RUNTESTFLAGS=--extension
[Note]

make check uses psql to run tests and as such can use psql environment variables. Common ones useful to override are PGUSER,PGPORT, and PGHOST. Refer to psql environment variables

extension 파일은 OS에 상관없이 PostGIS버전만 같으면 적용에 문제가 없습니다. 그러므로 PostGIS binaries가 설치된 서버에 확장 파일만 복사해도 문제가 없습니다.

만약 extension을 수동으로 또는 다른 서버에 설치하고 싶으면 다음 파일들을 사용자의 PostgreSQL 설치경로의 PostgreSQL / share / extension 폴더에 있는 extensions 폴더에서 복사하여 PostGIS가 설치되지 않은 서버에 필요한 바이너리 파일들을 넣어 주십시오.

  • 이것들이 지정되지 않은 경우 설치할 수 있는 extension 의 버전 등의 정보를 나타내는 제어 파일입니다. postgis.control, postgis_topology.control.

  • 각 extension의 /sql 폴더에 모든 파일들이 있습니다. 다음 파일들은 postgreSQL의 share/extension 폴더의 루트에 복사 되어야 함에 주의하십시오. extensions/postgis/sql/*.sql, extensions/postgis_topology/sql/*.sql

이렇게 한 다음, 사용자는 사용 가능한 extensions으로 postgis, postgis_topology 을 PgAdmin -> extensions에서 볼 수 있을 것입니다.

만약 psql을 이용 중이라면 다음의 쿼리를 실행함으로써 확인할 수 있습니다.

SELECT name, default_version,installed_version
FROM pg_available_extensions WHERE name LIKE 'postgis%' or name LIKE 'address%';

             name             | default_version | installed_version
------------------------------+-----------------+-------------------
 address_standardizer         | 3.4.3dev         | 3.4.3dev
 address_standardizer_data_us | 3.4.3dev         | 3.4.3dev
 postgis                      | 3.4.3dev         | 3.4.3dev
 postgis_raster               | 3.4.3dev         | 3.4.3dev
 postgis_sfcgal               | 3.4.3dev         |
 postgis_tiger_geocoder       | 3.4.3dev         | 3.4.3dev
 postgis_topology             | 3.4.3dev         |
(6 rows)

만약 사용자가 쿼리하는 데이터베이스에 extension이 설치되어 있다면, 사용자는 installed_version 컬럼에서 이름을 볼 수 있습니다. 만약 아무 레코드도 없다면 서버에 postgis extension이 전혀 설치되어 있지 않음을 뜻합니다. PgAdmin III 1.14이상 버전에서는 데이터베이스 탐색 트리의 extensions에서 마우스 오른쪽 버튼 클릭을 통해 업그레이드 또는 삭제를 허용합니다.

extension이 이용 가능한 상태라면 pgAdmin extension 인터페이스 또는 다음의 sql 명령을 실행함으로써 선택한 데이터베이스 안에 postgis extension을 설치할 수 있습니다:

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_raster;
CREATE EXTENSION postgis_sfcgal;
CREATE EXTENSION fuzzystrmatch; --needed for postgis_tiger_geocoder
--optional used by postgis_tiger_geocoder, or can be used standalone
CREATE EXTENSION address_standardizer;
CREATE EXTENSION address_standardizer_data_us;
CREATE EXTENSION postgis_tiger_geocoder;
CREATE EXTENSION postgis_topology;

PSQL에서 다음 명령어를 사용하면 어떤 버전을 설치했는지, 어떤 스키마로 설치했는지 알 수 있습니다.

\connect mygisdb
\x
\dx postgis*
List of installed extensions
-[ RECORD 1 ]-------------------------------------------------
Name        | postgis
Version     | 3.4.3dev
Schema      | public
Description | PostGIS geometry, geography, and raster spat..
-[ RECORD 2 ]-------------------------------------------------
Name        | postgis_raster
Version     | 3.0.0dev
Schema      | public
Description | PostGIS raster types and functions
-[ RECORD 3 ]-------------------------------------------------
Name        | postgis_tiger_geocoder
Version     | 3.4.3dev
Schema      | tiger
Description | PostGIS tiger geocoder and reverse geocoder
-[ RECORD 4 ]-------------------------------------------------
Name        | postgis_topology
Version     | 3.4.3dev
Schema      | topology
Description | PostGIS topology spatial types and functions
[Warning]

spatial_ref_sys, layer, topology 확장 테이블은 백업되지 않습니다. 이것들은 postgis 또는 postgis_topology extension이 백업이 될 경우에만 백업이 가능합니다. 이는 전체 데이터베이스가 백업될 때에만 발생한다고 볼 수 있습니다. PosgGIS 2.0.1에서는 데이터베이스 백업시 srid 레코드만이 백업됩니다. 이와 관한 문제를 발견하면 trac 티켓을 발행해주십시오. extension 테이블의 구조들은 CREATE EXTENSION과 함께 생성되기 때문에 백업되지 않습니다. 이러한 방식은 PostgreSQL extension 모델에 적용되기 때문에 조치를 취할 수 있는 방법이 없습니다.

우리의 멋진 확장 프로그램 시스템 없이 3.4.3dev 을 설치했다면, 먼저 다음 업그레이드 스크립트를 실행해서 확장 프로그램 기반 최신 버전으로 변경할 수 있습니다: postgis_upgrade_22_minor.sql,raster_upgrade_22_minor.sql,topology_upgrade_22_minor.sql.

CREATE EXTENSION postgis FROM unpackaged;
CREATE EXTENSION postgis_raster FROM unpackaged;
CREATE EXTENSION postgis_topology FROM unpackaged;
CREATE EXTENSION postgis_tiger_geocoder FROM unpackaged;

2.2.6. 테스트

만약 PostGIS 빌드를 테스트하고 싶다면, 실행하십시오.

make check

위 명령어는 활성 PostgreSQL 데이터베이스 바탕으로 생성된 라이브러리를 이용하여 다양한 확인과 회귀 테스트를 실행할 것입니다.

[Note]

PostgreSQL, GEOS, 또는 Proj4를 표준이 아닌 경로에 설치한 경우, LD_LIBRARY_PATH 환경 변수에 해당 라이브러리 경로를 설정해주어야 합니다.

[Caution]

현재, make check 검사들을 실시할 때에는 PATHPGPORT 환경 변수를 따릅니다. PostgreSQL의 설정 매개변수인 --with-pgconfig에 명시되어 있어도 이것을 적용하지 않습니다. 따라서, PostgreSQL 설치시의 환경설정과 일치하도록 PATH를 수정해주십시오.

If successful, make check will produce the output of almost 500 tests. The results will look similar to the following (numerous lines omitted below):

CUnit - A unit testing framework for C - Version 2.1-3
     http://cunit.sourceforge.net/

        .
        .
        .

Run Summary:    Type  Total    Ran Passed Failed Inactive
              suites     44     44    n/a      0        0
               tests    300    300    300      0        0
             asserts   4215   4215   4215      0      n/a
Elapsed time =    0.229 seconds

        .
        .
        .

Running tests

        .
        .
        .

Run tests: 134
Failed: 0


-- if you build with SFCGAL

        .
        .
        .

Running tests

        .
        .
        .

Run tests: 13
Failed: 0

-- if you built with raster support

        .
        .
        .

Run Summary:    Type  Total    Ran Passed Failed Inactive
              suites     12     12    n/a      0        0
               tests     65     65     65      0        0
             asserts  45896  45896  45896      0      n/a


        .
        .
        .

Running tests

        .
        .
        .

Run tests: 101
Failed: 0

-- topology regress

.
.
.

Running tests

        .
        .
        .

Run tests: 51
Failed: 0

-- if you built --with-gui, you should see this too

     CUnit - A unit testing framework for C - Version 2.1-2
     http://cunit.sourceforge.net/

        .
        .
        .

Run Summary:    Type  Total    Ran Passed Failed Inactive
              suites      2      2    n/a      0        0
               tests      4      4      4      0        0
             asserts      4      4      4      0      n/a

postgis_tiger_geocoderaddress_standardizer 확장 프로그램은 현재 표준 PostgreSQL 설치검사(installcheck)만을 지원합니다. 이 확장 프로그램들을 테스트하려면 다음을 실행하십시오. 주의: 이미 PostGIS 코드 폴더의 루트에서 make install을 실행했다면 다시 실행할 필요는 없습니다.

address_standardizer의 경우:

cd extensions/address_standardizer
make install
make installcheck
          

다음과 같은 결과가 나와야 합니다:

============== dropping database "contrib_regression" ==============
DROP DATABASE
============== creating database "contrib_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== running regression test queries        ==============
test test-init-extensions     ... ok
test test-parseaddress        ... ok
test test-standardize_address_1 ... ok
test test-standardize_address_2 ... ok

=====================
 All 4 tests passed.
=====================

TIGER 지오코딩 도구의 경우, 사용자의 PostgreSQL 인스턴스 안에서 PostGIS 및 fuzzystrmatch 확장 프로그램을 이용할 수 있는지 확인하십시오. address_standardizer 지원이 되도록 PostGIS를 빌드했다면 address_standardizer 테스트도 함께 실행될 것입니다.

cd extensions/postgis_tiger_geocoder
make install
make installcheck
          

다음과 같은 결과가 나와야 합니다:

============== dropping database "contrib_regression" ==============
DROP DATABASE
============== creating database "contrib_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== installing fuzzystrmatch               ==============
CREATE EXTENSION
============== installing postgis                     ==============
CREATE EXTENSION
============== installing postgis_tiger_geocoder      ==============
CREATE EXTENSION
============== installing address_standardizer        ==============
CREATE EXTENSION
============== running regression test queries        ==============
test test-normalize_address   ... ok
test test-pagc_normalize_address ... ok

=====================
All 2 tests passed.
=====================

2.2.7. 설치

PostGIS 설치를 위해서 다음을 입력하십시오.

make install

이것은 --prefix 설정 파라미터에 정의된 하위 경로에 PostGIS 설치 파일을 복사할 것입니다.

  • 로더(loader)와 덤퍼 바이너리 들은 [prefix]/bin에 설치됩니다.

  • postgis.sql와 같은 SQL 파일들은 [prefix]/share/contrib에 설치됩니다.

  • PostGIS 라이브러리들은 [prefix]/lib에 설치됩니다.

만약 기존에 postgis_comments.sql, raster_comments.sql 파일을 생성하기 위해 make comments 명령어를 실행한 적이 있으시다면, 다음을 실행해 sql 파일을 설치하십시오.

make comments-install

[Note]

xsltproc의 적용 이후 일반적인 설치로부터 postgis_comments.sql, raster_comments.sql, topology_comments.sql는 분리되었습니다.

2.3. 주소 표준화 도구 설치 및 활용

address_standardizer 확장 프로그램은 별도로 다운로드해야 하는 별도의 패키지였습니다. PostGIS 2.2 버전부터는 내장되어 있습니다. 이 확장 프로그램이 무슨 일을 하고 사용자의 필요에 따라 어떻게 설정하는지에 대한 자세한 정보는 Section 11.1, “주소 표준화 도구” 를 참조하십시오.

이 표준화 도구는 Normalize_Address 대신 PostGIS 용으로 패키징된 TIGER 지오코딩 도구(geocoder)와 함께 쓰일 수 있습니다. 이렇게 대신 사용하는 방법은 Section 2.4.2, “주소 표준화 도구를 TIGER 지오코딩 도구와 함께 사용” 을 참조하십시오. 주소 표준화 도구를 사용자의 다른 지오코딩 도구를 위한 구성 요소(building block)로 사용하거나, 주소를 더 쉽게 비교하기 위해 사용자 주소를 표준화하는 데 사용할 수도 있습니다.

주소 표준화 도구는 PCRE에 의존성을 갖습니다. PCRE는 많은 유닉스 파생 시스템에 일반적으로 이미 설치되어 있지만, http://www.pcre.org 에서 최신 버전을 다운로드할 수 있습니다. Section 2.2.3, “설정” 과정에서 PCRE를 찾았다면, 주소 표준화 도구 확장 프로그램을 자동적으로 빌드할 것입니다. 사용자가 사용하고자 하는 PCRE를 따로 설치한 경우, 설정 파라미터 --with-pcredir=/path/to/pcre/path/to/pcre 부분에 사용자의 PCRE include 및 lib 디렉터리의 루트 폴더를 입력하십시오.

윈도우 사용자의 경우 PostGIS 2.1 이상 버전 번들은 이미address_standardizer와 함께 패키징되어 있으므로 컴파일할 필요없이 바로 CREATE EXTENSION 단계로 건너뛸 수 있습니다.

설치를 완료했다면 사용자 데이터베이스에 연결해서 SQL을 실행할 수 있습니다:

CREATE EXTENSION address_standardizer;

다음 테스트에는 어떤 rules, gaz, 또는 lex 테이블도 필요없습니다.

SELECT num, street, city, state, zip
 FROM parse_address('1 Devonshire Place PH301, Boston, MA 02109');

다음과 같은 결과가 나와야 합니다:

num |         street         |  city  | state |  zip
-----+------------------------+--------+-------+-------
 1   | Devonshire Place PH301 | Boston | MA    | 02109

2.4. Installing, Upgrading Tiger Geocoder, and loading data

Extras like Tiger geocoder may not be packaged in your PostGIS distribution. If you are missing the tiger geocoder extension or want a newer version than what your install comes with, then use the share/extension/postgis_tiger_geocoder.* files from the packages in Windows Unreleased Versions section for your version of PostgreSQL. Although these packages are for windows, the postgis_tiger_geocoder extension files will work on any OS since the extension is an SQL/plpgsql only extension.

2.4.1. Tiger Geocoder Enabling your PostGIS database

  1. These directions assume your PostgreSQL installation already has the postgis_tiger_geocoder extension installed.

  2. PSQL, pgAdmin 또는 다른 도구를 통해 사용자 데이터베이스에 연결해서 다음 SQL 명령어를 실행하십시오. 이미 PostGIS가 설치된 데이터베이스에 설치하는 경우, 첫 번째 단계를 수행할 필요는 없다는 사실을 주의하십시오. 이미 fuzzystrmatch 확장 프로그램이 설치되어 있다면 이 두 번째 단계도 수행할 필요가 없습니다.

    CREATE EXTENSION postgis;
    CREATE EXTENSION fuzzystrmatch;
    CREATE EXTENSION postgis_tiger_geocoder;
    --this one is optional if you want to use the rules based standardizer (pagc_normalize_address)
    CREATE EXTENSION address_standardizer;

    이미 postgis_tiger_geocoder 확장 프로그램을 설치했고 최신 버전으로 업데이트만 하고자 할 경우:

    ALTER EXTENSION postgis UPDATE;
    ALTER EXTENSION postgis_tiger_geocoder UPDATE;

    tiger.loader_platformtiger.loader_variables 에 사용자 지정 항목을 만들었거나 변경한 경우 이 테이블들도 업데이트해야 할 수도 있습니다.

  3. 제대로 설치되었는지 확인하려면 사용자 데이터베이스에 다음 SQL을 실행하십시오:

    SELECT na.address, na.streetname,na.streettypeabbrev, na.zip
            FROM normalize_address('1 Devonshire Place, Boston, MA 02109') AS na;

    다음과 같은 결과가 나와야 합니다:

    address | streetname | streettypeabbrev |  zip
    ---------+------------+------------------+-------
               1 | Devonshire | Pl               | 02109
  4. tiger.loader_platform 테이블에 사용자의 실행 파일과 서버의 경로를 새 레코드로 생성하십시오.

    예를 들어 sh 규약(convention)을 따르는 debbie라는 프로파일을 생성하려면 다음과 같이 해야 합니다.

    INSERT INTO tiger.loader_platform(os, declare_sect, pgbin, wget, unzip_command, psql, path_sep,
                       loader, environ_set_command, county_process_command)
    SELECT 'debbie', declare_sect, pgbin, wget, unzip_command, psql, path_sep,
               loader, environ_set_command, county_process_command
      FROM tiger.loader_platform
      WHERE os = 'sh';

    그 다음 debbie의 pg, unzip,shp2pgsql, PSQL 등의 경로 위치에 맞도록 declare_sect 열의 경로를 편집하십시오.

    loader_platform 테이블을 편집하지 않을 경우, 각 항목의 흔히 있는(common case) 위치만을 담게 되며 스크립트가 생생된 후 생성된 스크립트를 직접 편집해야 할 것입니다.

  5. As of PostGIS 2.4.1 the Zip code-5 digit tabulation area zcta5 load step was revised to load current zcta5 data and is part of the Loader_Generate_Nation_Script when enabled. It is turned off by default because it takes quite a bit of time to load (20 to 60 minutes), takes up quite a bit of disk space, and is not used that often.

    To enable it, do the following:

    UPDATE tiger.loader_lookuptables SET load = true WHERE table_name = 'zcta520';

    If present the Geocode function can use it if a boundary filter is added to limit to just zips in that boundary. The Reverse_Geocode function uses it if the returned address is missing a zip, which often happens with highway reverse geocoding.

  6. 서버의 루트, 또는 서버에 충분히 빠른 네트워크로 연결된 경우 사용자 PC의 루트에 gisdata 라는 폴더를 생성하십시오. 이 폴더로 TIGER 파일을 다운로드해서 처리할 것입니다. 서버의 루트에 폴더를 만드는 게 마음에 안 들거나, 또는 단순히 다른 폴더로 변경하고 싶다면, tiger.loader_variables 테이블의 staging_fold 항목을 편집하십시오.

  7. gisdata 폴더 또는 사용자가 staging_fold 에 지정한 폴더 안에 temp라는 폴더를 생성하십시오. 다운로드한 TIGER 데이터를 로더가 이 temp 폴더에 압축해제할 것입니다.

  8. Then run the Loader_Generate_Nation_Script SQL function make sure to use the name of your custom profile and copy the script to a .sh or .bat file. So for example to build the nation load:

    psql -c "SELECT Loader_Generate_Nation_Script('debbie')" -d geocoder -tA 
    > /gisdata/nation_script_load.sh
  9. Run the generated nation load commandline scripts.

    cd /gisdata
    sh nation_script_load.sh
  10. After you are done running the nation script, you should have three tables in your tiger_data schema and they should be filled with data. Confirm you do by doing the following queries from psql or pgAdmin

    SELECT count(*) FROM tiger_data.county_all;
    count
    -------
      3234
    (1 row)
    SELECT count(*) FROM tiger_data.state_all;
    count
    -------
        56
    (1 row)
    

    This will only have data if you marked zcta520 to be loaded

    SELECT count(*) FROM tiger_data.zcta5_all;
    count
    -------
      37371
    (1 row)
    
  11. By default the tables corresponding to bg, tract, tabblock20 are not loaded. These tables are not used by the geocoder but are used by folks for population statistics. If you wish to load them as part of your state loads, run the following statement to enable them.

    UPDATE tiger.loader_lookuptables SET load = true WHERE load = false AND lookup_name IN('tract', 'bg', 'tabblock20');

    Alternatively you can load just these tables after loading state data using the Loader_Generate_Census_Script

  12. For each state you want to load data for, generate a state script Loader_Generate_Script.

    [Warning]

    DO NOT Generate the state script until you have already loaded the nation data, because the state script utilizes county list loaded by nation script.

  13. psql -c "SELECT Loader_Generate_Script(ARRAY['MA'], 'debbie')" -d geocoder -tA 
    > /gisdata/ma_load.sh
  14. 생성된 명령어 스크립트를 실행하십시오.

    cd /gisdata
    sh ma_load.sh
  15. 모든 데이터를 로딩한 다음 또는 어떤 정지 지점에서 모든 TIGER 테이블을 분석해서 (상속된 통계를 포함한) 통계(stat)를 업데이트하는 것이 좋습니다.

    SELECT install_missing_indexes();
    vacuum (analyze, verbose) tiger.addr;
    vacuum (analyze, verbose) tiger.edges;
    vacuum (analyze, verbose) tiger.faces;
    vacuum (analyze, verbose) tiger.featnames;
    vacuum (analyze, verbose) tiger.place;
    vacuum (analyze, verbose) tiger.cousub;
    vacuum (analyze, verbose) tiger.county;
    vacuum (analyze, verbose) tiger.state;
    vacuum (analyze, verbose) tiger.zip_lookup_base;
    vacuum (analyze, verbose) tiger.zip_state;
    vacuum (analyze, verbose) tiger.zip_state_loc;

2.4.2. 주소 표준화 도구를 TIGER 지오코딩 도구와 함께 사용

사용자들의 많은 불평 가운데 하나는 주소 정규화 도구 Normalize_Address 함수가 지오코딩 작업 전 준비 과정에서 주소를 정규화한다는 것입니다. 정규화 도구는 완벽하지 않아 그 불완전함을 수정하려면 막대한 노력이 필요합니다. 그래서 우리는 훨씬 나은 주소 표준화 도구 엔진을 가진 또다른 프로젝트와 통합시켰습니다. 이 새로운 address_standardizer를 이용하려면, Section 2.3, “주소 표준화 도구 설치 및 활용” 에 설명된 대로 확장 프로그램을 컴파일해서 사용자 데이터베이스에 확장 프로그램으로 설치하십시오.

postgis_tiger_geocoder 를 설치했던 데이터베이스에 이 확장 프로그램을 설치했다면, Normalize_Address 대신 Pagc_Normalize_Address 를 이용할 수 있습니다. 이 확장 프로그램은 TIGER 유무와 상관없이 동작하므로, 국제 주소와 같은 다른 데이터 소스와 함께 사용할 수 있습니다. 실제로 TIGER 지오코딩 도구 확장 프로그램은 rules table ( tiger.pagc_rules) , gaz table (tiger.pagc_gaz), 그리고 lex table (tiger.pagc_lex) 자체 수정 버전과 함께 패키징되어 있습니다. 사용자 자신의 필요에 따라 이들을 추가하고 업데이트해서 표준화 작업 과정을 향상시킬 수 있습니다.

2.4.3. Required tools for tiger data loading

인구조사 웹사이트에서 필요한 주의 데이터를 다운로드 받습니다. 압축을 풀면 주 단위로 별개의 세트로 이뤄져 있습니다. 각 주 테이블은 tiger스키마 정의에 따라 접속 및 쿼리 할 수 있고, Drop_State_Tables_Generate_Script를 다시 불러오거나 삭제하는 등의 작업을 실시할 수 있습니다.

데이터를 로딩하기 위해서는 다음과 같은 도구들이 필요합니다:

  • 인구조사 웹사이트에서 받은 압축 파일을 풀기 위한 툴

    Unix 계열 시스템에서는 대부분 unzip으로 해제할 수 있습니다.

    윈도우의 경우, 무료 압축/압축해제 툴인 7-zip이 http://www.7-zip.org/에서 다운로드 가능합니다.

  • PostGIS 기본 설치시 설치되는 shp2pgsql 명령

  • 웹 다운로드 툴인 wget은 대부분의Unix/Linux 시스템에 설치되어 있습니다.

    윈도우를 사용 중이면 http://gnuwin32.sourceforge.net/packages/wget.htm에서 다운로드 가능합니다.

If you are upgrading from tiger_2010, you'll need to first generate and run Drop_Nation_Tables_Generate_Script. Before you load any state data, you need to load the nation wide data which you do with Loader_Generate_Nation_Script. Which will generate a loader script for you. Loader_Generate_Nation_Script is a one-time step that should be done for upgrading (from a prior year tiger census data) and for new installs.

사용자의 플랫폼에서 사용자가 지정한 행정구역 데이터를 로드하는 스크립트를 생성하려면 Loader_Generate_Script 를 참조하십시오. 이 데이터들을 개별적으로 로드할 수 있다는 점을 기억하십시오. 사용자가 지정한 모든 행정구역을 한번에 로드하지 않아도 됩니다. 필요할 때마다 로드할 수 있습니다.

원하는 데이터가 로딩이 된 후 Install_Missing_Indexes에서 설명된 대로 다음을 실행하십시오:

SELECT install_missing_indexes();

실행이 잘되는지 확인하려면 Geocode를 이용하여 해당 주의 주소를 변환시켜 보십시오.

2.4.4. Upgrading your Tiger Geocoder Install and Data

First upgrade your postgis_tiger_geocoder extension as follows:

ALTER EXTENSION postgis_tiger_geocoder UPDATE;

다음으로 모든 nation 테이블을 drop 하고 새로 불러옵니다. 이 SQL 문장으로 drop 스크립트를 만듭니다. 자세한 내용은 다음을 참고하십시오. Drop_Nation_Tables_Generate_Script

SELECT drop_nation_tables_generate_script();

생성된 drop SQL 문장을 실행하십시오.

이 SELECT 구문으로 nation load 스크립트를 생성합니다. 자세한 내용을 다음을 참고하십시오. Loader_Generate_Nation_Script

윈도우용

SELECT loader_generate_nation_script('windows'); 

unix/linux 용

SELECT loader_generate_nation_script('sh');

Refer to Section 2.4.1, “Tiger Geocoder Enabling your PostGIS database” for instructions on how to run the generate script. This only needs to be done once.

[Note]

You can have a mix of different year state tables and can upgrade each state separately. Before you upgrade a state you first need to drop the prior year state tables for that state using Drop_State_Tables_Generate_Script.

2.5. 설치 과정에서 흔히 발생하는 문제들

인스톨이나 업그레이드 시 잘 되지 않을 경우 확인해야 할 몇 가지 사항은 아래와 같습니다.

  1. PostgreSQL 12 또는 그 보다 최신 버전을 설치하셨는지 체크하십시오. 현재 작동하고 계시는 PostgreSQL의 버전과 동일한 PostgreSQL 소스 버전을 바탕으로 컴파일하였는지 확인해주십시오. (Linux) 배포본이 이미 PostgreSQL이 설치된 경우 중복 설치가 될 수 있고, 또는 이전에 설치한 사실을 잊어버렸을 수도 있습니다. PostGIS는 PostgreSQL 12 또는 그 이상 버전에서 작동되므로 구 버전을 이용 시 예상하지 못한 에러들이 발생할 수 있습니다. 어떤 PostgreSQL 버전이 작동하고 있는지 확인하기 위해서는 psql을 통하여 데이터베이스에 접속해 다음의 쿼리를 실행하십시오:

    SELECT version();

    RPM 방식이라면 다음과 같은 rpm 커맨드로 이전 설치 패키지의 존재를 확인할 수 있습니다: rpm -qa | grep postgresql

  2. 만약 업그레이드가 실패하면 기존 PostGIS설치 버전으로 복원하셔야 합니다.

    SELECT postgis_full_version();

또한 PostreSQL, Proj4 라이브러리 및 GEOS 라이브러리에 대한 버전과 경로에 대한 설정이 올바른지 확인하십시오.

  1. 설정은 postgis_config.hh 파일을 생성하기 위해 사용됩니다. POSTGIS_PGSQL_VERSION, POSTGIS_PROJ_VERSION and POSTGIS_GEOS_VERSION 변수가 정확한지 확인하십시오.