博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ubuntu12下安装PostGIS
阅读量:4132 次
发布时间:2019-05-25

本文共 3017 字,大约阅读时间需要 10 分钟。

1. Before we begin, you should uninstall your existing postgis packages: 卸载掉原有的postgis和postgresql-9.1-postgis

sudo dpkg --purge postgis postgresql-9.1-postgis

sudo apt-get install postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1 postgresql-doc-9.1 pgadmin3

sudo apt-get install uuid libgnomeprintui2.2-0 oidentd libdbd-pg-perl

2. Then add a new repository and install PostGIS from there
sudo apt-add-repository ppa:sharpie/for-science  # To get GEOS 3.3.2sudo apt-add-repository ppa:sharpie/postgis-nightlysudo apt-get updatesudo apt-get install postgresql-9.1-postgis

3. Next we should create a new template database (optional but recommended).
sudo su postgres -c'createdb -E UTF8 -U postgres template_postgis2'sudo su postgres -c'createlang -d template_postgis2 plpgsql;'sudo su postgrespsql -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.sqlpsql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.1/spatial_ref_sys.sqlpsql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.1/rtpostgis.sqlpsql -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
4. Ok now we can load a raster (see sample data download below):
sudo su postgres -c'raster2pgsql -s 4326 srtm_4326.tif | psql training'
--raster2pgsql -s 4326 srtm_4326.tif | psql training
sudo su postgres -c'shp2pgsql -s 4326 -d -g geom -I places.shp places| psql training'
5. Good – now our spatial database is ready to use – and has raster support! Here is a nice example of what you can do. The query looks up the altitude from the SRTM raster for each place listed using the ST_Value
sudo su postgres
psql training

select ST_Value(rast, geom, true) from places, srtm_4326;

Next steps - start these steps logged in as your user account:NOTE: you do not have to use the same password for the system and PostgreSQL user accounts that share the same name.

$ sudo passwd postgresEnter new UNIX password: Retype new UNIX password: passwd: password updated successfully$ sudo -s -u postgrespostgres$ psqlpsql (9.1.3)Type "help" for help.postgres=# \password postgresEnter new password: Enter it again: postgres=# \qpostgres$
If you're going to want to connect to the PostgreSQL database using your own account (so you don't have to fool around with 'postgres'), you may want to do this:

$USER$ sudo -s -u postgrespostgres$ createuser --superuser $USER     ---- note: createuser is a command line tool to create a PostgreSQL user, not a system account  postgres$ createdb $USERpostgres$ psqlpsql (9.1.3)Type "help" for help.postgres=# \password $USEREnter new password: Enter it again: postgres=# \qpostgres$ exit$USER$ psqlpsql (9.1.3)Type "help" for help.$USER=#                        ---- voila!

转载地址:http://urbvi.baihongyu.com/

你可能感兴趣的文章
如何使用 systemd 中的定时器
查看>>
git命令速查表
查看>>
linux进程监控和自动重启的简单实现
查看>>
OpenFeign学习(三):OpenFeign配置生成代理对象
查看>>
OpenFeign学习(四):OpenFeign的方法同步请求执行
查看>>
OpenFeign学习(六):OpenFign进行表单提交参数或传输文件
查看>>
Ribbon 学习(二):Spring Cloud Ribbon 加载配置原理
查看>>
Ribbon 学习(三):RestTemplate 请求负载流程解析
查看>>
深入理解HashMap
查看>>
XML生成(一):DOM生成XML
查看>>
XML生成(三):JDOM生成
查看>>
Ubuntu Could not open lock file /var/lib/dpkg/lock - open (13:Permission denied)
查看>>
collect2: ld returned 1 exit status
查看>>
C#入门
查看>>
C#中ColorDialog需点两次确定才会退出的问题
查看>>
数据库
查看>>
nginx反代 499 502 bad gateway 和timeout
查看>>
linux虚拟机安装tar.gz版jdk步骤详解
查看>>
python实现100以内自然数之和,偶数之和
查看>>
python数字逆序输出及多个print输出在同一行
查看>>