在 Windows10 上将 OSM 文件导入 PostGis

Import OSM file to PostGis on Windows10

你能帮我把 planet.osm 文件导入我的 PostGist 数据库吗?我是这方面的新手,我只找到了 linux.

的教程

有一些命令,但我不知道如何使用...我将不胜感激一些逐步教程。如果它对我们来说是帮助我的重要信息,我正在使用 GeoServer。谢谢指教。

编辑: 我用了 osm2pgsql -s -U postgres -d nameofdatabase name.osm 但没有成功,因为我没有找到数据库的错误。

我用了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)。步骤是这样的:

  • 创建新数据库:create database db_for_osm
  • 在您的数据库中创建 Postgis 扩展。在SQLcreate extension postgis
  • 现在您可以运行 OGR2OGR。打开“OSGEO4W shell”。这将打开一个命令 window,其中包含所有 环境变量设置。该命令将类似于 ogr2ogr -f PostgreSQL PG:"dbname='db_for_osm' host='localhost' port='5432' user='myuser' password='mypassword'" planet.osm.pbf

我的大型上传需要几天时间才能完成,所以请做好准备,因为这会花费很长时间 - 我建议你先在一个小区域进行测试 - 为了我为这个答案所做的测试,我下载了一个来自 Mapzen 的城市。