-
Notifications
You must be signed in to change notification settings - Fork 13
Adding lines geodata
Maxim Dubinin edited this page Mar 29, 2015
·
9 revisions
Go to Overpass turbo.
Zoom to city extent that encompasses the whole subway system.
Run Overpass query by copying and pasting query below and presssing Start:
<osm-script>
<query type="relation">
<has-kv k="route" v="subway"/>
<has-kv modv="not" k="proposed" v="yes"/>
<bbox-query {{bbox}}/>
</query>
<union>
<item/>
<recurse type="down"/>
</union>
<print mode="body"/>
</osm-script>
Export result as GeoJSON.
Open GeoJSON in QGIS. When it asks what to add, choose lines (not points).
Save new layer as ESRI Shapefile.
If needed, start editing geometries to:
- remove extra lines
- convert to single line if the routes are shared (keep double lines if they are not)
If needed, edit table of attributes to:
- remove all fields except two
- populate field NAME with line name, example:
Сокольническая линия
. In fact this is not used by the system and provided only for visualization purposes. - populate color field with hex for color, example:
#ed1b35
Save.
Save just edited layer as lines.geojson in a particular folder.
##Update First edit line names endings in lines.csv (if needed! Like in msk. If don't - skip those). Than OGR SQL JOIN them with GeoJSON version to add and populate colors field.
sed -i 's/кая/кая линия/g' lines.csv
sed -i 's/вая/вая линия/g' lines.csv
ogr2ogr -f GeoJSON lines.geojson lines2.geojson -nlt "LINESTRING" -sql "
SELECT n.name AS name,l.color AS color FROM OGRGeoJSON n
LEFT JOIN '/home/sim/work/metro4all/repo/data/msk/lines.csv'.lines l
ON n.name = l.name_ru
WHERE OGR_GEOMETRY='LINESTRING'"
in Windows:
ogr2ogr -f GeoJSON lines.geojson lines2.geojson -nlt "LINESTRING" -sql "SELECT n.name AS name,l.color AS color FROM OGRGeoJSON n LEFT JOIN 'lines.csv'.lines l ON n.name = l.name_ru WHERE OGR_GEOMETRY='LINESTRING'"