关于postgis的安装使用

news/2024/7/9 22:19:08 标签: database, postgresql, comments, function, terminal, 数据库

关于Postgis的安装使用,建议参考官方手册 http://www.postgis.org/docs/ch02.html

------------------------------------------

创建控件数据库的参考:

createdb yourdatabase

createlang plpgsql yourdatabase

psql -d yourdatabase -f postgis.sql

psql -d yourdatabase -f postgis_comments.sql

psql -d yourdatabase -f spatial_ref_sys.sql

------------------------------------------------

 

2.5. Create a spatially-enabled database

The first step in creating a PostGIS database is to create a simple PostgreSQL database.

createdb [yourdatabase]

Many of the PostGIS functions are written in the PL/pgSQL procedural language. As such, the next step to create a PostGIS database is to enable the PL/pgSQL language in your new database. This is accomplish by the command

createlang plpgsql [yourdatabase]

Now load the PostGIS object and function definitions into your database by loading the postgis.sql definitions file (located in [prefix]/share/contrib as specified during the configuration step).

psql -d [yourdatabase] -f postgis.sql

For a complete set of EPSG coordinate system definition identifiers, you can also load the spatial_ref_sys.sql definitions file and populate the spatial_ref_sys table. This will permit you to perform ST_Transform() operations on geometries.

psql -d [yourdatabase] -f spatial_ref_sys.sql

If you wish to add comments to the PostGIS functions, the final step is to load the postgis_comments.sql into your spatial database. The comments can be viewed by simply typing \dd [function_name] from a psql terminal window.

psql -d [yourdatabase] -f postgis_comments.sql

2.6. Create a spatially-enabled database from a template

Some packaged distributions of PostGIS (in particular the Win32 installers for PostGIS >= 1.1.5) load the PostGIS functions into a template database called template_postgis. If the template_postgis database exists in your PostgreSQL installation then it is possible for users and/or applications to create spatially-enabled databases using a single command. Note that in both cases, the database user must have been granted the privilege to create new databases.

From the shell:

# createdb -T template_postgis my_spatial_db

From SQL:

postgres=# CREATE DATABASE my_spatial_db TEMPLATE=template_postgis

 

--------------------------------------------------------------

如果系统中没有存在template_postgis模板,需要自己手动创建,

$psql template1

template1=#create database template_postgis with template=template1;

template1=#update pg_database set datistemplate=TRUE where datname='template_postgis';

template1=#\c template_postgis

template_postgis=#create language plpgsql;

template_postgis=#\i /opt/locale/share/postgis/lwpostgis.sql;

template_postgis=#\i /opt/locale/share/postgis/spatial_ref_sys.sql;

template_postgis=#GRANT ALL ON geometry_columns TO PUBLIC;

template_postgis=#GRANT ALL ON spatial_ref_sys TO PUBLIC;

template_postgis=#VACUUM FREEZE;

template_postgis=#\q

对于用户,即可创建数据库

createdb test_gis_db -T template_postgis

dropdb test_gis_db

此部分参考 http://www.360doc.com/content/09/0220/11/1484_2597100.shtml

 

 

 

 

 


http://www.niftyadmin.cn/n/1054618.html

相关文章

Linux之常用命令【service】

补充说明 service命令 是Redhat Linux兼容的发行版中用来控制系统服务的实用工具,它以启动、停止、重新启动和关闭系统服务,还可以显示所有系统服务的当前状态。 语法 service(选项:具体服务的名称 [控制命令])(参数) 选项 -h:显示帮助信息&a…

jmeter测试数据库

转载于:https://www.cnblogs.com/arvin-feng/p/11110386.html

Python的time和datetime模块

Python的time和datetime模块 time 常用的有time.time()和time.sleep()函数。 import timeprint(time.time()) 1499305554.3239055 上面的浮点数称为UNIX纪元时间戳,是从1970年1月1日0点起到今天经过的秒数。可以看到后面有6位小数,使用round函数&#xf…

npm

npm init://初始化package.jsonnpm -D babel-cli 是 --save-dev的简写; npm i -g nodemon babel-cli:其中i是install的简写。 转载于:https://www.cnblogs.com/jkr666666/p/7928236.html

GPS侦听器gpsd

转自:http://www.ggiiss.com/gis/fb/2322.html gpsd的官方站点:http://www.catb.org/gpsd/#downloads 一、什么是GPSD GPSD是在Linux下实现动态获取GPS数据并发布到网络的一个服务引擎,它将获得的数据转至2947端口,使得…

NIO之Channel、Buffer

前言 Java NIO 由以下几个核心部分组成: 1 、Buffer 2、Channel 3、Selector 传统的IO操作面向数据流,意味着每次从流中读一个或多个字节,直至完成,数据没有被缓存在任何地方。 NIO操作面向缓冲区,数据从Channel读取到…

Luogu P1546 最短网络 Agri-Net

其实这道题根本没必要写,但为了测试vector堆优化的Prim试一发。 再次觉得Prim和Dijkstra很像,堆优化版本也差不多。 和Dijkstra一样,Prim也是在之前的dis点中选取一个最短的,但不同是Prim是最短边长,而Dijkstra是到达该…

易经读书笔记08水地比

亲比和谐、情投意合 象曰 地上有水,比;先王以建万国,亲诸侯。 水往低处流,而地势坤,故水亲之。比喻人与人之间的亲切辅助。比卦也是提醒高位的人,降低姿态,才能引来众水之比附,也就是…