网络技术分享
个人经验记录

下载OSM数据,使用 osm2pgsql 导入至PostgreSQL(PostGIS),安装GeoServer并绑定数据(一)

前提:

1、已安装 PostgreSQL

PostgreSQL 10 安装详细步骤 https://www.macs.vip/archives/55

2、已安装PostGIS 2.5.0 安装详细步骤

PostGIS 2.5.0 安装详细步骤 https://www.macs.vip/archives/54

进入正题:

一、下载 osm2pgsql

下载地址:https://download.csdn.net/download/antma/10780636

下载后打开有x64和Win32两个文件夹,x64如下,我已将default.style放进去的,后面会用到:

二、下载 osm数据

中国数据下载:http://download.geofabrik.de/asia/china.html

其他地区自行选择,有点慢,建议科学上网。

三、修改PostgreSQL配置

修改 pg_hba.conf (路径:…PostgreSQL10data)

将原 md5 改为 trust

pg_hba.conf

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

四、导入至postgreSQL中

导入命令(导入到 osm_test 库中):

osm2pgsql -d osm_test -U postgres -P 5432 -C 12000 -S"C:UsersmacsDesktoposm2pgsqlx64default.style" china-latest.osm.pbf

导入中:

导入成功:

-C 12000 是为了处理 Node cache size is too small to fit all nodes. Please increase cache size 错误的。

五、预览

导入成功后,打开 pgAdmin 即可看到多了4张表:

下一步进行安装 GeoServer 并绑定数据。

下载OSM数据,使用 osm2pgsql 导入至PostgreSQL(PostGIS),安装GeoServer并绑定数据(二)

赞(0) 打赏
未经允许不得转载:老麻 » 下载OSM数据,使用 osm2pgsql 导入至PostgreSQL(PostGIS),安装GeoServer并绑定数据(一)

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册