개발

GPKG > PostgreSQL 로 convert

내공얌냠 2021. 9. 24. 17:00

진행중..

PostgreSQL 로 gpkg 를 업로드 하려면 postgis 라는 extended 가 필요해서 설치한다.

brew install postgis

http://postgis.net/install/

 

PostGIS — Installation

Getting Started These instructions are for PostgreSQL 9.1 and higher, PostGIS 2.2 and higher that is compiled with raster support. Note: if you have postgis, without raster support, you can not use CREATE EXTENSION. Refer to PostGIS install. Enabling PostG

postgis.net

 

퇴근시간 안 막히려면 설치만 하고 가야겠다.. 설치완료!

그 다음은 이 확장 기능으르 써서 디비를 만들고, ogr2ogr? 명령어 써서 풀면 된다고 한다. 

연결할 db 명이 test 이고 gpkg 파일을 뒤에 써준다.

psql 에서 create extension postgis; 로 확장 기능? 쓴다고 해주고 버전확인해본다

이후 다른 터미널에서 (나는 gpkg가 있는 폴더 내에서 진행했다.) ogr2ogr 명령어로 db명만 입력해서 명령어 때리니까

psql postgres		// psql 접속

\connect test

create extension postgis;

select postgis_full_version();

\dt

ogr2ogr -f PostgreSQL "PG:dbname=test" peak1.gpkg	// psql 밖에서 다른 터미널에서 진행.

\dt				// 다시 psql 로 돌아와서 진행

없었는데 생겼습니다.

파란색 스크롤 친 부분이 없었는데 아래 부분 /dt 에는 테이블이 보여집니다 ㅎㅎ

select 가 잘 안됩니다;; pgAdmin4 를 설치해야겠습니다..

 

References

https://postgis.net/workshops/postgis-intro/creating_db.html

 

4. Creating a Spatial Database — Introduction to PostGIS

4.1. PgAdmin PostgreSQL has a number of administrative front-ends. The primary one is psql, a command-line tool for entering SQL queries. Another popular PostgreSQL front-end is the free and open source graphical tool pgAdmin. All queries done in pgAdmin c

postgis.net

https://skipperkongen.dk/2018/03/13/how-to-create-a-world-wide-postgresql-database-of-administrative-regions/

 

How to create a world-wide PostgreSQL database of administrative regions – Skipperkongen

The GADM database contains geographical data for administrative regions, e.g. countries, regions and municipalities. As always, once you have the data in the right format, it is easy to import it into a database. The data is available from GADM in several

skipperkongen.dk

https://newbedev.com/uploading-geopackage-contents-to-postgresql

 

Programming tutorials | Newbedev

Checkout new tutorials and guides for programming languages Javascript, Python, Java, Golang, C++, PHP

newbedev.com

https://gdal.org/drivers/vector/pg.html

 

PostgreSQL / PostGIS — GDAL documentation

PostgreSQL / PostGIS Driver short name PostgreSQL Build dependencies PostgreSQL client library (libpq) This driver implements support for access to spatial tables in PostgreSQL extended with the PostGIS spatial data support. Some support exists in the driv

gdal.org

 

728x90
반응형