Skip to content

Instantly share code, notes, and snippets.

@jinto
Forked from juniorz/install_postgis_osx.sh
Last active December 17, 2015 11:39
Show Gist options
  • Select an option

  • Save jinto/5604278 to your computer and use it in GitHub Desktop.

Select an option

Save jinto/5604278 to your computer and use it in GitHub Desktop.
# 현재 가장 잘 동작하는 버전인듯
# postgres는 설치했다고 가정하자.
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
# 환경변수에 LC_COLLATE=C 이거 있는지 확인
#1. Install PostGIS
brew install postgis
#2. Create a template to be used on creating GIS-enabled databases
createdb template_postgis2
createlang plpgsql template_postgis2
#[Mac OSX] Import Postgis Data
psql -d template_postgis2 -f /usr/local/Cellar/postgis/2.0.2/share/postgis/postgis.sql
psql -d template_postgis2 -f /usr/local/Cellar/postgis/2.0.2/share/postgis/spatial_ref_sys.sql
# If you want Raster support
psql -d template_postgis2 -f /usr/local/Cellar/postgis/2.0.2/share/postgis/rtpostgis.sql
psql -d template_postgis2 -f /usr/local/Cellar/postgis/2.0.2/share/postgis/topology.sql
psql -d template_postgis2 -c "GRANT ALL ON geometry_columns TO PUBLIC;"
psql -d template_postgis2 -c "GRANT ALL ON geography_columns TO PUBLIC;"
psql -d template_postgis2 -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
createdb training -T template_postgis2
#Test if works
psql -d template_postgis2 -c "SELECT postgis_full_version();"
# 나는 이녀석을 참고했다.
# http://linfiniti.com/2012/05/installing-postgis-2-0-on-ubuntu/
#
# 환경변수에 LC_COLLATE=C 이거 있는지 확인
#1. Install PostgreSQL postgis and postgres
sudo dpkg --purge postgis postgresql-9.1-postgis
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:sharpie/for-science # To get GEOS 3.3.2
sudo apt-add-repository ppa:sharpie/postgis-nightly
sudo apt-get update
sudo apt-get install postgresql-9.1-postgis
#2. Create a template to be used on creating GIS-enabled databases
createdb -E UTF8 template_postgis2
createlang -d template_postgis2 plpgsql
psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis2'"
psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.1/postgis.sql
psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.1/spatial_ref_sys.sql
psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.1/rtpostgis.sql
psql -d template_postgis2 -c "GRANT ALL ON geometry_columns TO PUBLIC;"
psql -d template_postgis2 -c "GRANT ALL ON geography_columns TO PUBLIC;"
psql -d template_postgis2 -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
createdb training -T template_postgis2
#Test if works
psql -d template_postgis2 -c "SELECT postgis_full_version();"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment