개발일지

[postgreSQL] 원격으로 shp 파일 넣기

송채채 2023. 10. 18. 18:26

넣으려는 데이터베이스에 접속하고 익스텐션 꼭 설치

1. CREATE EXTENSION postgis;

shp2pgsql 사용해서 shp 파일 업로드

2. shp2pgsql -c -D -s 5179 -W cp949 {file_path} {table_name} | psql -U {user_name} -d {db_name}

-c: 테이블 생성

-a: 이미 테이블이 있는 경우면 -c대신 -a사용

 

결과

geom 컬럼이 내가 보던 geometry 형식이랑 달라서 당황했는데, 관련 블로그 글을 보니 다른 표준 형식이라고 함

 

보통 polygon((0 0, 1 0, 1 1, 01, 0 0)) 이런 형태는 WKT라고 부름

 

애초에 shp2pgsql로 업로드 할때 WKT로 할 수 없나?

"-w"를 넣으면 된다고 하는데 똑같이 들어감..

shp2pgsql -c -D -s 5179 -W cp949 -w {file_path} {table_name} | psql -U {user_name} -d {db_name}

https://pamyferret.tistory.com/29

 

[ PostgreSql ] PostGIS 함수와 geometry 컬럼 타입 사용하기

http://postgis.net/docs/manual-2.0/ PostGIS 2.0 Manual Abstract PostGIS is an extension to the PostgreSQL object-relational database system which allows GIS (Geographic Information Systems) objects to be stored in the database. PostGIS includes support for

pamyferret.tistory.com

 

https://m.blog.naver.com/ilsan_ilsan/221497823431

 

[오픈소스GIS] WKB, WKT 이해 / postGIS에서의 변환, 입출력

이전에 shp2pgsql을 통해 shp파일을 postgresql에 올려 보고, 올렸을 때 생기는 geom컬럼이 postGIS에서...

blog.naver.com

 

반응형