简单学习OSM(OpenStreetMap)文件格式的最基础结构

article/2025/8/26 16:26:18

目标

获取一个最简单的OSM文件,并学习其最基础的结构。

获取OSM数据的步骤

操作很简单:
进入官网:https://www.openstreetmap.org/
点击左上角的 “导出” 按钮。
在这里插入图片描述
然后,填入坐标范围,点击按钮即可导出osm文件:
在这里插入图片描述
当然,直接填坐标范围是不直观的,为此,可以点击 “手动选择不同的区域”,这样即可手动选择范围了:
在这里插入图片描述

学习OSM文件格式的最基础结构

Wiki上有关于OSM格式的简单介绍,可见附录。不过这里将通过例子来学习:

例1:最简单的例子

在这里插入图片描述
导出后的osm文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.8.8 (2798843 spike-07.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/"><bounds minlat="31.3618700" minlon="121.8012200" maxlat="31.3620700" maxlon="121.8015200"/><node id="7603536329" visible="true" version="1" changeset="86368470" timestamp="2020-06-08T19:00:07Z" user="Reboot01" uid="9856191" lat="31.3618772" lon="121.8012886"/><node id="7603536330" visible="true" version="1" changeset="86368470" timestamp="2020-06-08T19:00:07Z" user="Reboot01" uid="9856191" lat="31.3619399" lon="121.8014870"/><node id="7603536331" visible="true" version="1" changeset="86368470" timestamp="2020-06-08T19:00:07Z" user="Reboot01" uid="9856191" lat="31.3620542" lon="121.8014375"/><node id="7603536332" visible="true" version="1" changeset="86368470" timestamp="2020-06-08T19:00:07Z" user="Reboot01" uid="9856191" lat="31.3619915" lon="121.8012390"/><way id="813970381" visible="true" version="1" changeset="86368470" timestamp="2020-06-08T19:00:07Z" user="Reboot01" uid="9856191"><nd ref="7603536329"/><nd ref="7603536330"/><nd ref="7603536331"/><nd ref="7603536332"/><nd ref="7603536329"/><tag k="building" v="yes"/></way>
</osm>

可以看到有以下信息:

  • 经度(longitude)和纬度(latitude)缩写为lonlat
  • bounds节点记录了这个文件的范围
  • 4个node节点代表了4个位置。
  • way节点引用了node节点(通过id),以这样的方式表示出了一个范围。以此可见way节点并不仅表示“路(way)”。
  • tag指出了这个way节点是一个建筑(building)

例2:不同的way

在这里插入图片描述
这里就出现了多个way节点,并且根据tag可以区分出各自的种类:
在这里插入图片描述
比如这里不仅有建筑,还有操场,和跑道。

例3:relation的一个例子

在这里插入图片描述
这是横沙岛的一个边界。可以在文件中找到一个relation节点,它指明了自己的边界包含了哪些way节点:
在这里插入图片描述

总结

结合这些简单的例子,以及Wiki的介绍,我学到关于OSM文件的一些最基础的结构:

  1. 每个node节点代表空间中的一个位置,具有经纬度属性。
  2. way节点引用了node,以有序列表的方式定义了一个范围。
  3. relation节点(关系)引用了way节点(wiki指出还可能引用node或其他relation)作为成员(member),并且指出了每个成员在这个关系中所扮演的角色。
  4. 每个节点都可能包含tag属性,来附带上额外的信息。

附录:Wiki上关于OSM格式的介绍

Wiki地址:https://en.wikipedia.org/wiki/OpenStreetMap

OpenStreetMap uses a topological data structure, with four core elements (also known as data primitives):

  • Nodes are points with a geographic position, stored as coordinates (pairs of a latitude and a longitude) according to WGS 84.[106] Outside of their usage in ways, they are used to represent map features without a size, such as points of interest or mountain peaks.
  • Ways are ordered lists of nodes, representing a polyline, or possibly a polygon if they form a closed loop. They are used both for representing linear features such as streets and rivers, and areas, like forests, parks, parking areas and lakes.
  • Relations are ordered lists of nodes, ways and relations (together called "members"), where each member can optionally have a "role" (a string). Relations are used for representing the relationship of existing nodes and ways. Examples include turn restrictions on roads, routes that span several existing ways (for instance, a long-distance motorway), and areas with holes.
  • Tags are key-value pairs (both arbitrary strings). They are used to store metadata about the map objects (such as their type, their name and their physical properties). Tags are not free-standing, but are always attached to an object: to a node, a way or a relation. A recommended ontology of map features (the meaning of tags) is maintained on a wiki. New tagging schemes can always be proposed by a popular vote of a written proposal in OpenStreetMap wiki, however, there is no requirement to follow this process. There are over 89 million different kinds of tags in use as of June 2017.[107]

http://chatgpt.dhexx.cn/article/yqaTbsZS.shtml

相关文章

OSM(OpenStreetMap)使用简述

0.背景 基于开源的地图制作工具osm以及开源的仿真引擎CARLA完成交通场景仿真场景的搭建。 1.构建OSM场景 https://www.openstreetmap.org/#map16/31.2808/121.1690 1.1.搜索关键字 1.2. 手动选择不同的区域 1.3.导出 导出为osm文件 2.osm->xodr OpenStreetMap 格式文件…

OSM数据内容解析

OSM数据内容解析 数据简介 OpenStreetMap&#xff08;简称OSM&#xff0c;中文是公开地图&#xff09;&#xff0c;这是一个网上地图协作计划&#xff0c;目标是创造一个内容自由且能让所有人编辑的世界地图。是一款由网络大众共同打造的免费开源、可编辑的地图服务。 OSM采…

OSM下载路网数据

OpenStreetMap&#xff08;简称OSM&#xff0c;中文是公开地图&#xff09;是一个网上地图协作计划&#xff0c;目标是创造一个内容自由且能让所有人编辑的世界地图。 本文介绍如何使用OSM免费下载路网数据。如想直接获取全国路网数据&#xff0c;可见文末&#xff01; OSM地…

python第三方库pygame的使用

作用&#xff1a;pygame一般用来做游戏 注意&#xff1a;1.在使用pygame提供的功能之前&#xff0c;需要调用init方法 2.在游戏结束前需要调用 quit 方法 pygame中的各个函数&#xff1a; 1.pygame.init()&#xff1a;该函数在使用pygame时进行初始化&#xff0c;只有引用了该…

Py之pygame:Python的pygame库的简介、安装、使用方法详细攻略

Py之pygame&#xff1a;Python的pygame库的简介、安装、使用方法详细攻略 目录 pygame库的简介 pygame库的安装 pygame库的使用方法 pygame库的简介 PyPoice是SDL多媒体库的Python包装模块。它包含Python函数和类&#xff0c;这些类和类允许使用SDL对CDROM、音频和视频输出、…

python3安装pygame出错(输入“pip3 install pygame“,安装pygame模块报错)

使用pip3 install pygame,安装出错 自己已经更换源镜像&#xff0c;但总是在执行到最后一步的时候报错&#xff0c;通过网上的方法安装&#xff0c;总是出现两个配置无法被找到&#xff0c;向下执行的时候出现错误&#xff0c;最后以第一种方式安装成功。 执行&#xff1a; p…

【Pygame基本使用】

pygame是什么 pygame是跨平台Python模块&#xff0c;专门为电子游戏设计&#xff0c;包含图像、声音等&#xff1b;简单的说它是别人已经编写好的程序&#xff0c;并放在了一个类似库里&#xff0c;专门给别人使用的&#xff1b; pygame的图形接口 https://www.jianshu.com/p…

python Pygame的具体使用讲解

一、实验介绍 1.1 实验内容 在本节课中&#xff0c;我们将讲解Pygame的常用对象及其操作&#xff0c;包括图形、动画、文字、音频等&#xff0c;确保同学们对Pygame有一个基础的了解&#xff0c;同时为后续课程做好准备。 Pygame图形Pygame动画Pygame文字Pygame音频Pygame事…

Pygame 官方文档 - 中译版

pygame 文档 Pygame之家【Pygame Home】 帮助内容【Help Contents】 指导索引【Reference Index】最有用的东西 【Most useful stuff】Color | display | draw | event | font | image | key | locals mixer | mouse | Rect | Surface | time | music | pygame 高级的东西【…

pygame入门

pygame入门 文章目录 pygame入门说明一、pygame的安装二、pygame模块概览三、pygame的“hello world”四、事件理解事件事件检索处理鼠标事件处理键盘事件事件过滤产生事件 五、显示全屏显示改变窗口尺寸复合模式其他 六、字体创建font对象使用字体中文字体 七、颜色八、图像使…

pygame下载(非常详细)

pygame安装 第一次安装pygame&#xff0c;从网上查了很多资料&#xff0c;各种方式都有&#xff0c;我发现了一种很简单的方法&#xff0c;不用去官网找&#xff0c;直接输入命令就能下载&#xff0c;希望能给大家提供一些参考&#xff01; 打开终端 1、winR 打开终端&#…

Pygame是什么

Python 是当下最为火热,且功能最为全面的一门编程语言。Python 之所以深受大家喜爱, 除了可以被应用到“人工智能”领域之外,还可以延伸到数据分析、Web 开发、自动化测试、自然语言处理、游戏开发等各个领域。这一切的实现得益于 Python 有一个强大的第三方库,这个第三方库…

【pygame游戏开发】这几个经典游戏,勾起了少年的快乐

给大家分享几个好玩有趣的小游戏&#xff0c;既提升了学习的兴趣&#xff0c;又提升了学习效率&#xff0c;告别枯燥的学习。 一、飞机大战 1、源码部分 模块导入 import sys import cfg import pygame from modules import *游戏界面 def GamingInterface(num_player, scr…

python-颜色识别

使用Python来做颜色识别&#xff0c;使用了openCV import cv2 import numpy as np import time class ColorTac(object):def colorTacing(self):print(-*-COLOR TACKING MODE-*-)print(you can input:blue,red,yellow,green,purple.and must input one)color input("Col…

android颜色识别

写的一个关于颜色识别的小功能。识别主要颜色。 思路&#xff1a;遍历像素点&#xff0c;找出出现次数最多的像素值作为主要颜色。 采用的方法有&#xff1a; 1.调用摄像头&#xff0c;拍照&#xff0c;裁剪&#xff0c;压缩。 2.找出色值。 3.转换成hsv空间&#xff0c;进行颜…

颜色及图片识别原理,颜色识别传感器介绍

光及颜色 1.光&#xff1a;是人类眼睛可以看见的一种电磁波&#xff0c;也称可见光谱。在科学上的定义&#xff0c;光是指所有的电磁波谱。光是由光子为基本粒子组成&#xff0c;具有粒子性与波动性&#xff0c;称为波粒二象性&#xff0c;一般人的眼睛所能接受的光的波长在380…

颜色识别总结

颜色检测 1、目标检测detr 【End-to-End Object Detection with Transformers】 论文解读 源码复现 2、目标检测deformable detr 【DEFORMABLE DETR: DEFORMABLE TRANSFORMERS FOR END-TO-END OBJECT DETECTION】 论文解读 源码复现 3、目标检测mmdet中的deformable detr …

Python-OpenCV实现简单的颜色识别(对红色和蓝色识别并输出)

摄像头识别红色和蓝色并框选&#xff0c;当该颜色为摄像头屏幕上大多数颜色时打印出该颜色的名称 新手学习笔记&#xff0c;第一次写博客&#xff0c;若有错误还请指出&#xff08; ~_ &#xff09;~ 1.调包 import cv2 import numpy as np from matplotlib import pyplot as…

Python3识别判断图片主要颜色并和颜色库进行对比的方法

【更新】主要提供两种方案&#xff1a; 方案一&#xff1a;&#xff08;参考网上代码&#xff0c;感觉实用性不是很强&#xff09;使用PIL截取图像&#xff0c;然后将RGB转为HSV进行判断&#xff0c;统计判断颜色&#xff0c;最后输出RGB值 方案二&#xff1a;使用opencv库函…

【Python 之HSV颜色识别】

Python 之HSV颜色识别 前言一、HSV颜色模型二、黄色识别三、使用步骤1.引入库2.处理图片3.识别结果 总结 前言 汽车自动驾驶&#xff0c;需要颜色识别&#xff0c;如黄色/红色车道线&#xff0c;蓝色车牌。 本文从HSV颜色模型出发&#xff0c;提供一种识别黄色车道线的方法供参…