在Windows10上将OSM文件导入PostGis [英] Import OSM file to PostGis on Windows10

查看:336
本文介绍了在Windows10上将OSM文件导入PostGis的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以帮助我将planet.osm文件导入到我的PostGist数据库吗?我是新来的,我发现仅针对linux的教程.

can you help me with importing planet.osm file to my PostGist db? I am new in this and I found tutorials only for linux.

有一些命令,但我不知道它的用法...我将不胜感激某些分步教程.如果正在使用的重要信息对我们有帮助,我正在使用GeoServer.感谢您的建议.

There are some commands, but I do not know how use it ... I will be grateful for some step by step tutorial. I'm using GeoServer if it is important information for us to help me. Thanks for advices.

我使用了osm2pgsql -s -U postgres -d nameofdatabase name.osm 但未成功,因为我在未找到数据库的情况下出错.

edit: I used osm2pgsql -s -U postgres -d nameofdatabase name.osm but unsuccessful because I have error with no database found.

推荐答案

我使用了 OGR2OGR 来在Windows上以pbf格式导入osm数据(Windows 10,带Postgis 2.3的Posgres 9.6).您可以从QGIS随附的"OSgeo42 shell"中使用OGR2OGR,也可以在此处单独获得 Osgeo4w ).步骤如下:

I used OGR2OGR to import osm data in pbf format on Windows (Windows 10, Posgres 9.6 with Postgis 2.3). You can use OGR2OGR from the "OSgeo42 shell", which comes with QGIS or you can get Osgeo4w separately here). The steps are something like this:

  • 创建一个新数据库:create database db_for_osm
  • 在您的数据库中创建Postgis扩展名.在SQL create extension postgis
  • 现在您可以运行OGR2OGR.打开"OSGEO4W shell".这将打开一个命令窗口,其中包含所有 环境变量集.该命令将类似于 ogr2ogr -f PostgreSQL PG:"dbname='db_for_osm' host='localhost' port='5432' user='myuser' password='mypassword'" planet.osm.pbf
  • Create a new database: create database db_for_osm
  • Create Postgis extension in your db. In SQL create extension postgis
  • Now you can run OGR2OGR. Open the "OSGEO4W shell". This will open a command window with all the environment variables set. The command will be something like ogr2ogr -f PostgreSQL PG:"dbname='db_for_osm' host='localhost' port='5432' user='myuser' password='mypassword'" planet.osm.pbf

我的大量上传完成了几天,因此准备好花很长时间-我建议您先在一个小区域内进行测试-为此测试所做的测试是我从以下城市下载的 Mapzen .

My large upload took a couple of days to complete, so be prepared for this to take a long time - I suggest you do a test with a small region first - for the test I did for this answer I downloaded a city from Mapzen.

这篇关于在Windows10上将OSM文件导入PostGis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆