概述
背景;因为opendrive是自动驾驶使用的较多的数据格式,想把地图数据shp格式转换成opendrive格式的,但是网上没有现成的转换脚本,所以打算先从shp格式转到osm格式,再从osm格式转换到opendrive格式。(网上相关资料非常少)
其实shp转换为osm格式方式挺多的:本文选贼用Shp2osm脚本来转换。
![
There are multiple tools for converting shapefiles into .osm format suitable for importing. These include:
Merkaartor — simply import the shp, export the osm.xml.
shp2osm (and polyshp2osm) — require some programming skill, but very flexible
shp-to-osm.jar — less flexible, but requires only a simple configuration file
shape2osm — a Python script that will convert a POINT shapefile to OSM XML
PostGISconvert shp to osm using grass and gpsbabel
Load the shapefile into PostGIS first, using shp2pgsql (feature of PostGIS) May be helpful as first conversion step
ogr2osm (ogr2osm) — a new script to convert any OGR supported vector format into .osm format, with emphasis in converting polygon boundaries into relations
Using QGIS & GPX Editor to convert to GPX
1) Menu "Plugins/ Manage Plugins..." enable ,,GPS Tools".2) Menu "Plugins/GPS Tools/Create new GPS layer"3) Select feature(s) in the default layer. Copy, paste into a GPS tracks layer, save the changed layer.4) In GPX Editor open the gpx file. Menu "Edit/ OpenStreetMap Tools/ Anonymize time".MapCreator-Toolset: ShapeToOsmTool — This C#-OpenSource tool converts a set of shape files to an osm file, applying specific conversion rules defined in a dedicated XML conversion rule file.The tool is simple and flexible.
The tool can convert many layers (represented by many shape files) to one OSM output file.
The tool supports the following geometries: Polygon, LineString and Point. A Polygon will be mapped to a Closed OSM Way, a LineString to a OSM Way and a Point to a OSM Node.
With certain limits the tool can convert geometry types (Polygon to Point, LineString to Point), if so wanted.
The tool supports a flexible Tag generation. The Tag values can be constant or read out of the shape file fields.
SHPtoOSMBoundaries python script. If the SHP contains Administrative Boundaries and you want to transform them into OSM in order to autogenerate and join the multiple boundary relations before importing.
相关资料:
https://zhuanlan.zhihu.com/p/360377363
https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf
https://zhuanlan.zhihu.com/p/393715053
https://blog.csdn.net/Gary_888/article/details/91572141
方法:
按照博客中的方法来执行https://blog.csdn.net/Gary_888/article/details/91572141。
我会报错:
此时生成的.osm文件大小是0KB,很明显是错的*。按照博客中解决此方法,发现在终端中输入ppm根本打不开perl package manager的gui界面,使用ppm install Geo::ShapeFile安装时,也会报如下错误:
经过百番查找资料解决问题,发现输入命令:cpan Geo::ShapeFile可以安装。
然后再次输入转换命令就可以了
FOR /R .\ %G IN (*.shp) DO shp2osm.pl "%~dpnG" > "%~dpnG.osm"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)