12. April 2016

PostgreSQL/PostGIS

$ su - postgres
$ createdb <dbname>
$ psql
=# \c <dbname>
=# CREATE EXTENSION postgis;
=# SELECT postgis_full_version();
=# \q
$ for i in *.shp; do shp2pgsql -I -s 4269 $i ${i%.shp} > ${i%.shp}.sql; done  
    # evtl. -W "latin1"
$ for i in *.sql; do psql -d <dbname> -f $i; done

$ dropdb <dbname>

Go to QGIS, connect to created postgis database.

# sync; /etc/init.d/postgresql stop; echo 1 > /proc/sys/vm/drop_caches; /etc/init.d/postgresql start
  • apt-get install postgis pgadmin3

Trying to follow

Doing

postgres@localhost $ psql
\password
Enter password: ...
...

and

$ cd /usr/share/postgresql/9.4/contrib/postgis-2.1
$ psql -d mygis -f postgis.sql
$ psql -d mygis -f spatial_ref_sys.sql