For location based service, I try to use postgresql with postgis.

You can download postgis from here.

http://postgis.net/source

It is recommended that you need to download and compile yourself since there are many packages dependencies need to be done.

Here is a tutorial which is very handy if you are using ubuntu12.04/mint13 or its derived ones.

=================8X----------------------------------X8============================

http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS20Ubuntu1204src

How to install PostGIS 2.0 on Ubuntu 12.04 LTS (precise) from source

Prerequisites

Several components are needed, which can either be built from source or installed from pre-built packages, as shown below.

Install prerequisite packages using:

sudo apt-get install build-essential postgresql-9.1 postgresql-server-dev-9.1 libxml2-dev libproj-dev libjson0-dev xsltproc docbook-xsl docbook-mathml

Optional package for raster support (this is required if you want to build the PostgreSQL extensions):

sudo apt-get install libgdal1-dev

Build GEOS 3.3.x

PostGIS 2.0 requires GEOS >= 3.3.2 for topology support, however Ubuntu 12.04 only has GEOS 3.2.2 available in packages, so it needs to be built from source. If you don't need topology, you don't need to build this component, but it is highly recommended.

There are multiple ways to build GEOS, but this is the simplest:

wget http://download.osgeo.org/geos/geos-3.3.9.tar.bz2
tar xfj geos-3.3..tar.bz2
cd geos-3.3.
./configure
make
sudo make install
cd ..

[NEW ADDED]

Since there will be another package which needs a higher version.

So you need to install    gdal-config ( version 1.8.0+). By default ubuntu 12.04 is of 1.7.3

http://www.gdal.org/

download the source codes and compile as you want.

cd {the_souce_codes_folder}

sudo ./configure --prefix=/usr/local/

sudo make

sudo make install

sudo ldconfig

Then you may compile the postgis package.

Build PostGIS

wget http://download.osgeo.org/postgis/source/postgis-2.0.6.tar.gz
tar xfz postgis-2.0..tar.gz
cd postgis-2.0.

PostGIS 2.0 can be configured to disable topology or raster components, using the configure flags --without-raster and/or --without-topology. The default is to build both. Note that raster is required for the extension installation method for PostgreSQL.

./configure
make
sudo make install
sudo ldconfig
sudo make comments-install

Lastly, enable the command-line tools to work from your shell:

sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql
sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp
sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql

Spatially enabling a database

With PostgreSQL 9.1, there are two methods to add PostGIS functionality to a database: using extensions, or using enabler scripts.

PostGIS Extension for PostgreSQL

Spatially enabling a database using extensions is a new feature of PostgreSQL 9.1.

Connect to your database using pgAdmin or psql, and run the following commands. To add postgis with raster support:

CREATE EXTENSION postgis;

To add topology support, a second extension can be created on the database:

CREATE EXTENSION postgis_topology;

Enabler Scripts / Template

Enabler scripts can be used to either build a template, or directly spatially enable a database. This method is older than the extension method, but is required if the raster support is not built.

The following example creates a template, which can be re-used for creating multiple spatially-enabled databases. Or if you just want to make one spatially enabled database, you can modify the commands for your needs.

PostGIS:

sudo -u postgres createdb template_postgis
sudo -u postgres psql -d template_postgis -c "UPDATE pg_database SET datistemplate=true WHERE datname='template_postgis'"
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis_comments.sql

with raster support:

sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/rtpostgis.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/raster_comments.sql

with topology support:

sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology_comments.sql

See also

=================8X----------------------------------X8============================

In the database console, try these!!

Connect to your database with psql or PgAdmin. Run the following SQL:

-- Enable PostGIS (includes raster)
CREATE EXTENSION postgis;
-- Enable Topology
CREATE EXTENSION postgis_topology;
-- fuzzy matching needed for Tiger
CREATE EXTENSION fuzzystrmatch;
-- Enable US Tiger Geocoder
CREATE EXTENSION postgis_tiger_geocoder;

For spatial objects!

-- Create table with spatial column
CREATE TABLE mytable (
id SERIAL PRIMARY KEY,
geom GEOMETRY(Point, 26910),
name VARCHAR(128)
); -- Add a spatial index
CREATE INDEX mytable_gix
ON mytable
USING GIST (geom); -- Add a point
INSERT INTO mytable (geom) VALUES (
ST_GeomFromText('POINT(0 0)', 26910)
); -- Query for nearby points
SELECT id, name
FROM mytable
WHERE ST_DWithin(
geom,
ST_GeomFromText('POINT(0 0)', 26910),
1000
);

If you system alerts that "

gis=# create extension fuzzystrmatch;
ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/fuzzystrmatch.control": No such file or directory

"

, try to

sudo apt-get install postgresql-contrib-9.1 -y

then , you will see something:

gis=# create extension fuzzystrmatch;
CREATE EXTENSION
gis=# create extension postgis_tiger_geocoder;
CREATE EXTENSION
gis=#

notice the 'gis' is the name of the database.

deb packages download and their installation order:

geos_3.4.2-1_amd64.deb http://pan.baidu.com/s/1c08JynA

gdal_1.11.1-1_amd64.deb  http://pan.baidu.com/s/1pJ5Fi1l

postgis_2.1.4-1_amd64.deb http://pan.baidu.com/s/1ntJWv6h

Happy hacking!

PostgreSQL9.1 with PostGIS 2.1.4 for mapping coordinates on linux/ubuntu 已经打包成deb 可下载的更多相关文章

  1. postgresql9.5 run 文件linux安装后配置成开机服务

    网上出现的比较多安装方法要么是源码安装,要么是yum安装,我发觉都要配置很多属性,比较麻烦,所以现在我在centos7长用 run文件来安装 http://get.enterprisedb.com/p ...

  2. Geoserver+Postgresql+PostGIS 进行数据发布

    1.postgressql+postgis安装 由于我已经安装了,因此没法进行截图,给出下载地址 下载地址:https://www.postgresql.org/ 记得一定要下载edu的版本 因为这个 ...

  3. 【转】windows和linux中搭建python集成开发环境IDE

    本系列分为两篇: 1.[转]windows和linux中搭建python集成开发环境IDE 2.[转]linux和windows下安装python集成开发环境及其python包 3.windows和l ...

  4. PostgreSQL-安装9.2

    一.环境 VM虚拟机 NAME="Ubuntu" VERSION="12.04.4 LTS, Precise Pangolin" 二.过程  1.安装make ...

  5. MANIFEST.INF!JAR规范中

    MANIFEST.INF!JAR规范中 META-INF 目录中内容心得.顺带整理了网上资料,提供地址 标签: jarjava产品sunantapache 2012-03-31 17:09 2768人 ...

  6. (01)odoo8.0_Ubuntu14.04源码安装

    作者:陈伟明联系 :  QQ 942923305 | 微信 toby942923305E-mail: toby2chen@hotmail.com============================ ...

  7. Ubuntu14.04安装PostpreSQL9.3.5记录

    安装参考:http://www.postgresql.org/download/linux/ubuntu/ y@y:~$ sudo apt-get install postgresql-9.3 pos ...

  8. windows和linux在建筑python集成开发环境IDE

    http://blog.csdn.net/pipisorry/article/details/39854707 使用的系统及软件 Ubuntu / windows Python 2.7 / pytho ...

  9. 基于数据库的自动化生成工具,自动生成JavaBean、自动生成数据库文档等(v4.1.2版)

            目录:            第1版:http://blog.csdn.net/vipbooks/article/details/51912143            第2版:htt ...

随机推荐

  1. MVC验证05-自定义验证规则、验证2个属性值不等

    原文:MVC验证05-自定义验证规则.验证2个属性值不等 本文体验2个属性值不等.即当一个属性输入值,另外一个属性输入的值不能和第一个属性值相等.相关文章包括: MVC验证01-基础.远程验证   M ...

  2. protobuf-net-data

    protobuf-net http://www.codeproject.com/Articles/642677/Protobuf-net-the-unofficial-manual https://g ...

  3. win7访问xp共享访问不了

    这个问题不是一天两天了,经历几次了,所以记下来. 1. 一些XP对用户权限作了特殊的优化设置.限制了只有guest用户才能用于做局域网共享用户. 2. 大多数时候,需要设置一个密码,才能用于访问. 3 ...

  4. Appium Server源码分析之作为Bootstrap客户端

    Appium Server拥有两个主要的功能: 它是个http服务器,它专门接收从客户端通过基于http的REST协议发送过来的命令 他是bootstrap客户端:它接收到客户端的命令后,需要想办法把 ...

  5. 在Eclipse发展Webapp部署过程,缓存的位置

    介绍: 在Eclipse进行Web发展,通常直接在项目Eclipse集成Tomcat发展.那Webapp部署在那里?是否在高速缓冲存储器的位置,可以切换? 1.  查看当前的Webapp项目缓存位置 ...

  6. 分区表在安装系统(MBR)丢失或损坏

    操作系统能识别出硬盘中的各个不同的分区,是靠硬盘分区表(MBR)来识别的. 硬盘分区表中记录了各个分区的位置和大小以及类型等信息,假设这个分区表破坏了,那么这块硬盘里面的分区就会丢失.系统是无法在浏览 ...

  7. 三个创建WebStorm项目的方法

    WebStorm项目代表一个完整的解决方案和定义项目范围设置.而重点则是代码完成.代码重构.代码风格等. 因此在建立项目时,WebStorm可以通过三个方面来完成:下载远程项目.复制控制存储库项目和直 ...

  8. 使用 C# 进行 Outlook 2007 编程

    原文:使用 C# 进行 Outlook 2007 编程 探讨如何使用 C# 编程语言生成 Outlook 识别的应用程序和 Outlook 外接程序. 请从"Add References&q ...

  9. 题注Oracle数据库的网络连接原理

    版权声明:本文博客原创文章,博客,未经同意,不得转载.

  10. C#实现文档转换成PDF

    网上有很多将doc.ppt.xls等类型的文档转换成pdf的方法,目前了解到的有两大类: 1.使用虚拟打印机将doc.ppt.xls等类型的文档 2.使用OFFICE COM组件 我采用了第二种方法实 ...