0. 说在前面的话
最近在接触OSM(OpenStreeMap)数据,根据介绍PostGresql的PostGis模块是众多Gis数据的默认数据库。 于是... ...
1. PostGresql的安装
具体的PostGresql安装就不再这里介绍了,推荐一篇文章写的很详细:http://www.v5cn.cn/?p=167
文章中介绍的软件很是有用推荐:
2. OSM数据导入PostGresql
1. 下载osm2pgsql 在第一步已经提供下载地址。
2. 最好设定一下PostGresql的环境变量,很简单的。设置jdk 一样 将 PostGresql 中的bin目录添加到PATH中
创建OSM数据库 createdb -U postgres -E UTF8 osm
添加PostGIS功能到数据库psql -U postgres -d osm -f “你Postgresql安装路径\share\contrib\postgis-2.1\postgis.sql”
添加EPSG: 900913支持 psql -U postgres -d osm -f “本地的文件路径\900913.sql”
添加hstore模式 create extension hstore;
osm2pgsql.exe -k -d osm -U postgres -S d:\maps\default.style d:\maps\map.osm
3. 期间可能会报一个错误(整了我两天郁闷死了)
使用我第一步推荐的文章有一个错误: 会照成一个错误(如下) 。 使用了器推荐的create extension hstore; 依然报错
release notes: 'Windows version built by Dominik Perpeet <http://www.customdebug.com/osm2pgsql/index.html>'
Using projection SRS 900913 (Spherical Mercator)
Error reading style file line 151 (fields=4)
flag 'phstore' is invalid in non-hstore mode
Error occured,cleaning up
@H_404_134@解决方案
@H_502_138@Hi,About phstore type,I think you can either cut those lines off the stylefile or use osm2pgsql in hstore more by adding -k into the command.