osm-topology
БесплатноБез исполняемых скриптовНе проверенOSM Topology Skill
от plurigrid★ 73 звезды на GitHubОб этом скилле
OSM Topology Skill
OpenStreetMap graph analysis: road networks, routing, and topological structure with GF(3) coloring.
Trigger
- OpenStreetMap data processing
- Road network analysis, routing
- Graph-based geographic queries
- Street network topology
GF(3) Trit: -1 (Validator)
Validates topological consistency of geographic networks.
OSM Data Model
OSM uses three primitives:
- Nodes: Points with lat/lon
- Ways: Ordered lists of nodes (roads, boundaries)
- Relations: Groups of nodes/ways (routes, multipolygons)
DuckDB OSM Integration
-- Read OSM PBF files (requires osm extension)
-- Install from: https://github.com/duckdb/duckdb_osm
-- Alternative: Use pre-processed Parquet
CREATE TABLE osm_nodes AS
SELECT * FROM read_parquet('osm_nodes.parquet');
CREATE TABLE osm_ways AS
SELECT * FROM read_parquet('osm_ways.parquet');
-- Schema for colored OSM data
CREATE TABLE osm_network (
way_id BIGINT,
name VARCHAR,
highway_type VARCHAR,
geometry GEOMETRY,
node_ids BIGINT[],
-- Topology
start_node BIGINT,
end_node BIGINT,
length_m DOUBLE,
-- GF(3) coloring
seed BIGINT,
gay_color VARCHAR,
gf3_trit INTEGER
);
Graph Extraction
import duckdb
import networkx as nx
def extract_road_graph(osm_parquet_path):
"""Extract road network as colored graph."""
conn = duckdb.connect()
conn.execute("INSTALL spatial; LOAD spatial;")
# Load ways with road tags
conn.execute(f"""
CREATE TABLE roads AS
SELECT
way_id,
tags->>'name' as name,
tags->>'highway' as highway,
nodes,
ST_Length_Spheroid(ST_MakeLine(
LIST_TRANSFORM(nodes, n -> ST_Point(n.lon, n.lat))
)) as length_m
FROM read_parquet('{osm_parquet_path}')
WHERE tags->>'highway' IS NOT NULL
""")
# Build graph
G = nx.DiGraph()
roads = conn.execute("""
SELECT way_id, nodes, length_m, highway FROM roads
""").fetchall()
for way_id, nodes, length, highway in roads:
for i in range(len(nodes) - 1):
n1, n2 = nodes[i], nodes[i+1]
# Color edge from way_id
seed = way_id & 0x7FFFFFFFFFFFFFFF
hue = seed % 360
trit = 1 if (hue < 60 or hue >= 300) else (0 if hue < 180 else -1)
G.add_edge(n1['id'], n2['id'],
way_id=way_id,
length=length / (len(nodes) - 1),
highway=highway,
trit=trit)
# Add reverse for bidirectional roads
if highway not in ('motorway', 'motorway_link'):
G.add_edge(n2['id'], n1['id'],
way_id=way_id,
length=length / (len(nodes) - 1),
highway=highway,
trit=trit)
return G
Topological Validation
def validate_network_topology(G):
"""
Validate OSM network topology.
Returns list of issues with GF(3) classification.
"""
issues = []
# Check connectivity
if not nx.is_weakly_connected(G):
components = list(nx.weakly_connected_components(G))
issues.append({
'type': 'disconnected',
'count': len(components),
'trit': -1, # Validation failure
'severity': 'high'
})
# Check for dead ends
dead_ends = [n for n in G.nodes() if G.degree(n) == 1]
if dead_ends:
issues.append({
'type': 'dead_ends',
'count': len(dead_ends),
'nodes': dead_ends[:10],
'trit': 0, # Ergodic (may be intentional)
'severity': 'low'
})
# Check for self-loops
self_loops = list(nx.selfloop_edges(G))
if self_loops:
issues.append({
'type': 'self_loops',
'count': len(self_loops),
'trit': -1, # Validation failure
'severity': 'medium'
})
# Check for duplicate edges
multi_edges = [(u, v) for u, v in G.edges() if G.number_of_edges(u, v) > 1]
if multi_edges:
issues.append({
'type': 'multi_edges',
'count': len(multi_edges),
'trit': -1,
'severity': 'medium'
})
return issues
def gf3_balance_check(G):
"""Check if edge trits are GF(3) balanced per node."""
imbalanced = []
for node in G.nodes():
edges = list(G.edges(node, data=True))
trit_sum = sum(e[2].get('trit', 0) for e in edges)
if trit_sum % 3 != 0:
imbalanced.append({
'node': node,
'trit_sum': trit_sum,
'edge_count': len(edges)
})
return {
'total_nodes': G.number_of_nodes(),
'imbalanced_count': len(imbalanced),
Установить osm-topology в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл osm-topology?
OSM Topology Skill
Как установить скилл osm-topology?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл osm-topology запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic