【问题标题】:Problem in reading Mapbox vector tile pbf using OGR使用 OGR 读取 Mapbox 矢量平铺 pbf 的问题
【发布时间】:2019-01-07 13:51:24
【问题描述】:

我想将 Geoserver 中创建的 pbf 矢量切片转换为 GeoJson 格式。为此,我使用了这个link,它没有提供太多关于如何操作的说明。我在 Linux 终端中使用ogrinfo 6449_traffic.vector.pbf 进行了测试,结果出现以下错误:

Unable to open datasource `6449_traffic.vector.pbf' with the following drivers.
  -> PCIDSK
  -> netCDF
  -> JP2OpenJPEG
  -> PDF
  -> ESRI Shapefile
  -> MapInfo File
  -> UK .NTF
  -> OGR_SDTS
  -> S57
  -> DGN
  -> OGR_VRT
  -> REC
  -> Memory
  -> BNA
  -> CSV
  -> NAS
  -> GML
  -> GPX
  -> LIBKML
  -> KML
  -> GeoJSON
  -> Interlis 1
  -> Interlis 2
  -> OGR_GMT
  -> GPKG
  -> SQLite
  -> OGR_DODS
  -> ODBC
  -> WAsP
  -> PGeo
  -> MSSQLSpatial
  -> OGR_OGDI
  -> PostgreSQL
  -> MySQL
  -> OpenFileGDB
  -> XPlane
  -> DXF
  -> CAD
  -> Geoconcept
  -> GeoRSS
  -> GPSTrackMaker
  -> VFK

如何使用此工具或任何替代工具将 mvt.pbf 文件转换为 GeoJson?

【问题讨论】:

    标签: mapbox geojson vector-tiles


    【解决方案1】:

    我遇到了同样的问题,这个https://github.com/mapbox/pbf 为我工作。您需要 2 个文件:

    • 架构文件(通常是.proto 文件)
    • 数据文件(您的.pbf 文件)

    首先,您需要将.proto 转换为.jspbf Schema.proto > Schema.js

    然后您可以读取或写入 pbf,为此您需要执行一些 javascript 和 html 代码并从 Web 浏览器启动。或者,如果你想从终端启动,使用node,这样(data_extractor.js):

    // Imports
    var fs = require("fs");
    var Pbf = require('pbf');
    var Vector_Tile = require('./Schema.js').Tile;
    // *Tile* is the exported object of my schema file. You need to check what is yours.
    
    // Read the .pbf
    var pbf = new Pbf(fs.readFileSync('./ogrinfo 6449_traffic.vector.pbf'));
    var obj = Vector_Tile.read(pbf);
    console.log(obj)
    
    • 然后在终端上运行:node data_extractor.js

    【讨论】:

      猜你喜欢
      • 2016-01-27
      • 2022-06-29
      • 2015-10-06
      • 2017-01-21
      • 2010-09-25
      • 2016-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多