You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ArangoDB导入OSM路网失败求助:节点无法展开、无边缘显示

Fixing ArangoDB OSM Data Import Issues (Monaco Map)

Hey there! Let’s get your OSM road network imported properly into ArangoDB so you can run those algorithm analyses. I’ll break this down into clear, actionable steps based on the osm-2-graph tool you’re using.

1. Pre-Import: Verify Your JSON Files

The osm-2-graph tool outputs JSON Lines (jsonl) format—each line is a separate node or edge document. Double-check your files:

  • nodes.json: Each line should look like {"_key": "1234", "lat": 43.73, "lon": 7.42, ...}
  • edges.json: Each line must include _from and _to fields pointing to node keys, e.g., {"_key": "5678", "_from": "nodes/1234", "_to": "nodes/9012", "highway": "residential", ...}

If your files are wrapped in a top-level array ([{}, {}, ...]), you’ll need to convert them to jsonl first—arangoimp won’t parse array-format JSON correctly for bulk imports.

2. Create Database & Collections (Critical!)

Before importing, set up your database and collections in ArangoDB:

  • Create a new database (e.g., monaco_osm) via the web UI or ArangoShell.
  • Create a vertex collection named nodes (for OSM nodes).
  • Create an edge collection named edges—this is non-negotiable! Edge collections are specifically designed to store relationships between vertices, and ArangoDB won’t recognize edges stored in regular collections.

You can also create collections directly via arangoimp using flags (see below), but doing it manually first helps avoid mistakes.

3. Run arangoimp Commands

Use these exact commands to import your files. Replace placeholders like your_password with your actual ArangoDB credentials, and adjust file paths as needed.

Import Nodes

arangoimp \
  --file /path/to/your/nodes.json \
  --collection nodes \
  --type jsonl \
  --server.database monaco_osm \
  --server.username root \
  --server.password your_password

Import Edges

The --create-collection-type edge flag is key here—it ensures the collection is treated as an edge collection:

arangoimp \
  --file /path/to/your/edges.json \
  --collection edges \
  --type jsonl \
  --server.database monaco_osm \
  --server.username root \
  --server.password your_password \
  --create-collection-type edge

4. Validate the Import

After running the commands, confirm the data is correctly imported using ArangoShell:

  • Check node count:
    db.nodes.count()
    
  • Check edge count:
    db.edges.count()
    
  • Verify edge references: Run a quick query to ensure edges point to existing nodes:
    db.edges.limit(5).toArray()
    
    Look for valid _from and _to values (e.g., nodes/1234) that match node keys in the nodes collection.

5. Fix the Global Network View

If you still don’t see edges in the web UI’s network view:

  1. Open the Graphs section in the ArangoDB web UI.
  2. Create a new graph (e.g., monaco_road_network).
  3. Add the nodes collection as the vertex collection.
  4. Add the edges collection as the edge collection (make sure it’s selected as an edge type).
  5. Save the graph and open its network view—you should now see nodes connected by edges.

Common Pitfalls to Avoid

  • Mismatched collection names: Ensure the _from/_to values in edges exactly match the vertex collection name (e.g., nodes/1234 not node/1234).
  • Incorrect file format: Always use jsonl type for osm-2-graph outputs—arangoimp defaults to this, but double-check the --type flag.
  • Permission issues: Make sure the user running arangoimp has write access to the target database and collections.

内容的提问来源于stack exchange,提问作者user3478108

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:20:13