[FOSSGIS-Talk] Flosm
Claas Leiner
claas.leiner at gkg-kassel.de
So Jun 14 19:00:36 CEST 2020
Hallo Jörg,
Mit der QGIS-Erweiterung QuickOSM ist es recht einfach, bestimmte
Inhalte aus OSM als Vekktordaten ins QGIS zu laden:
Erweiterungen > Erweiterungen installieren
nach QuickOSM suchen und herunterladen.
Du kannst die Inhalte grafisch auswählen. Allerdings funktioniert das
nicht für größere Datenmengen.
QuickOSM aufrufen:
Kraftwerke:
Schnelle Abfrage >
key = power
value = generator
HauptLeitungen:
Schnelle Abfrage >
key = power
value = line
NebenLeitungen:
Schnelle Abfrage >
key = power
value = minor_line
---------------
Komplexe Vorgegensweise.
Daten aus den OSM-Rohdaten extrahieren. Sinnvoll wenn es um große
Gebiete geht
die OSM-Rohdaten sind z.B. über die Geofabrik verfügbar:
https://download.geofabrik.de/
Die entsprechende PBF-Datei kann mit qgis geöffnet werden, die
Extraktion der entsprechenden Inhalte ist nicht ganz trivial.
Die Attributierung wird hier erklärt:
https://wiki.openstreetmap.org/wiki/DE:Map_Features#Energieversorgung
Beim direkten Laden setzt QGIS allerdings nicht sämtliche relevanten
tags direkt in Attributspalten um. Dazu muss man die osmconf.ini anpassen:
Win:
QGIS_Installationspfad\share\gdal\osmconf.ini
Linux:
/usr/share/gdal/osmconf.ini
In der Rubrik [points] müssen die attributes um die Werte
power,generator, generator:source, generator:method,
generator:output:electricity
ergänzt werden
In der Rubrik [lines ]müssen die attributes um die Werte
power,voltage,cables
ergänzt werden.
Große PBF-Dateien ins QGIS zu laden kann allerdings sehr langsam sein
und am Ende zur Kapitulation des Programms führen.
Mit ogr2ogr in der OSGeoShell lässt sich aus den Rohdaten ein Geopackage
erstellen, welches einfach in QGIS zu verarbeiten ist:
ogr2ogr --config OGR_SQLITE_SYNCHRONOUS off --config OSM_CONFIG_FILE
osmconf.ini -f "GPKG" -nln kraftwerk -gt unlimited -s_srs EPSG:4326
-t_srs EPSG:25832 -skipfailures -s_srs EPSG:4326 -t_srs EPSG:25833
-skipfailures ziel.gpkg quelle.pbf -sql "select
name,voltage,generator_method,generator_source,generator_output_electricity
from points where power = 'generator'"
ogr2ogr --config OGR_SQLITE_SYNCHRONOUS off --config OSM_CONFIG_FILE
osmconf.ini -f "GPKG" -update -nln leitungen -gt unlimited -s_srs
EPSG:4326 -t_srs EPSG:25832 -skipfailures -s_srs EPSG:4326 -t_srs
EPSG:25832 -skipfailures ziel.gpkg quelle.pbf -sql "select
name,type,man_made,power,voltage,cables from lines where power in
('line','minor_line')"
Über --config OSM_CONFIG_FILE osmconf.ini wird auf die angepasste
osmconf.ini im selben Verzeichnis wie die Importdaten verwiesen.
Ohne --config OSM_CONFIG_FILE osmconf.ini wird die osmconf.ini aus der
QGIS-Installation verwiesen. Ich hänge eine Beispiel-OSM.conf.ini an.
Zugegeben:
Wenn Du noch nicht mit ogr2ogr gearbeitet hast, ist das ganze recht
kryptisch. Vie
Viele Grüße,
Claas
--
-----------------------------------------
GKG-Kassel - Dr.-Ing. Claas Leiner
QGIS-Support und mehr
Geodatenservice, Kartenwerkstatt &
GIS-Schule Kassel
Wilhelmshöher Allee 304 E
34131 Kassel
Tel. 0561/56013445
claas.leiner at gkg-kassel.de
----------------------------------------
http://www.gkg-kassel.de
----------------------------------------
Unterstützen Sie QGIS
QGIS-DE e.V. | http://qgis.de
QGIS Projekt | http://qgis.org/de/site/
-------------- nächster Teil --------------
#
# Configuration file for OSM import
#
# put here the name of keys for ways that are assumed to be polygons if they are closed
# see http://wiki.openstreetmap.org/wiki/Map_Features
closed_ways_are_polygons=aeroway,amenity,boundary,building,craft,geological,historic,landuse,leisure,military,natural,office,place,shop,sport,tourism,waterway,riverbank
# comment to avoid laundering of keys ( ':' turned into '_' )
attribute_name_laundering=yes
# uncomment to report all nodes, including the ones without any (significant) tag
#report_all_nodes=yes
# uncomment to report all ways, including the ones without any (significant) tag
#report_all_ways=yes
[points]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no
# keys to report as OGR fields
attributes=name,name:en,name:de,barrier,highway,railway,railway:turnout_side,public_transport,ref,address,is_in,place,building,natural,ele,alt,man_made,power,generator,voltage,population,leisure,amenity,office,tourism,shop,craft,healthcare,social_facility,addr:housenumber,generator:source,generator:method,generator:output:electricity,height:hub,height,wheelchair,shelter
# keys that, alone, are not significant enough to report a node as a OGR point
unsignificant=created_by,converted_by,source,time,ele,attribution
# keys that should NOT be reported in the "other_tags" field
ignore=created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes
[lines]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no
# keys to report as OGR fields
attributes=name,name:en,name:de,highway,tunnel,bridge,waterway,aerialway,barrier,man_made,railway,power,voltage,cables,ref,oneway,sidewalk,substance,type
# type of attribute 'foo' can be changed with something like
#foo_type=Integer/Real/String/DateTime
# keys that should NOT be reported in the "other_tags" field
ignore=created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
other_tags=yes
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes
#computed_attributes must appear before the keywords _type and _sql
computed_attributes=z_order
z_order_type=Integer
# Formula based on https://github.com/openstreetmap/osm2pgsql/blob/master/style.lua#L13
# [foo] is substituted by value of tag foo. When substitution is not wished, the [ character can be escaped with \[ in literals
z_order_sql="SELECT (CASE [highway] WHEN 'minor' THEN 3 WHEN 'road' THEN 3 WHEN 'unclassified' THEN 3 WHEN 'residential' THEN 3 WHEN 'tertiary_link' THEN 4 WHEN 'tertiary' THEN 4 WHEN 'secondary_link' THEN 6 WHEN 'secondary' THEN 6 WHEN 'primary_link' THEN 7 WHEN 'primary' THEN 7 WHEN 'trunk_link' THEN 8 WHEN 'trunk' THEN 8 WHEN 'motorway_link' THEN 9 WHEN 'motorway' THEN 9 ELSE 0 END) + (CASE WHEN [bridge] IN ('yes', 'true', '1') THEN 10 ELSE 0 END) + (CASE WHEN [tunnel] IN ('yes', 'true', '1') THEN -10 ELSE 0 END) + (CASE WHEN [railway] IS NOT NULL THEN 5 ELSE 0 END) + (CASE WHEN [layer] IS NOT NULL THEN 10 * CAST([layer] AS INTEGER) ELSE 0 END)"
[multipolygons]
# common attributes
# note: for multipolygons, osm_id=yes instantiates a osm_id field for the id of relations
# and a osm_way_id field for the id of closed ways. Both fields are exclusively set.
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no
# keys to report as OGR fields
#attributes=name,admin_level,de:regionalschluessel,postal_code,boundary,population
attributes=name,name:en,name:de,,type,aeroway,amenity,admin_level,de:regionalschluessel,postal_code,barrier,boundary,building,addr:housenumber,craft,geological,historic,land_area,landuse,leisure,amenity,public_transport,railway,man_made,military,natural,office,place,shop,sport,tourism,waterway
# keys that should NOT be reported in the "other_tags" field
ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes
[multilinestrings]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no
# keys to report as OGR fields
attributes=name,type
# keys that should NOT be reported in the "other_tags" field
ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes
[other_relations]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no
# keys to report as OGR fields
attributes=name,type
# keys that should NOT be reported in the "other_tags" field
ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes
Mehr Informationen über die Mailingliste FOSSGIS-Talk-Liste