Wikidata:Mapframe-autozoom

Mapframe map can position and zoom automatically and show an item on the map if there is a way or relation with the requested wikidata id in OpenStreetMap. The problem currently is that it is not possible to check in template/Lua code if the tag exists so map still needs to be tuned case by case. This also means that you cannot automate the in-wiki error detection. Other practical problems are that there is no easy way to get a full list of wikidata items that have a wikidata tag in OpenStreetMap and it is impossible to read this kind of information using SPARQL too.

One solution for these problems is to save an indication of wikidata tag in Openstreetmap to Wikidata. This has been proposed before in different forms and most of the proposals have problems with OSM numeric identifiers which are not stable. In the proposal "Alternative 2" this is solved using a combination of OSM tags as a unique selector which is how OSM does permanent linking.

Solution for storing needed information for OSM autozoom edit

Alternative 1 edit

This would be mostly bot operated work.

  1. Add OpenStreetMap relation ID (P402) to items which are tagged in OSM using OSM wikidata tag values.
  2. Store OSM wikidata tag value to qualifier Wikidata item of this property (P1629) of OpenStreetMap relation ID (P402).
  3. Remove OpenStreetMap relation ID (P402) values which are pointing to OSM relations that don't exist.
  4. Validate existing OpenStreetMap relation ID (P402) links using Wikidata item of this property (P1629) values and OSM dumps.
  5. Manually fix errors based on step #4

In the future when the technical issues are solved and OSM data can be directly used from SPARQL and Scribunto then P402 is redundant and can be dropped.

Not viable, because OpenStreetMap relation ID (P402) covers only 2/3 of the OSM items supported by MapFrame.

Alternative 2 edit

  1. Create a new property OpenStreetMap object selector which stores unique OSM tag combination for the item per OSM: Overpass_API/Permanent_ID
    • Technically the format would be: rel[network="BAB"]["ref"="A 540"] OR [network="BAB"]["ref"="A 540"] (see Overpass API QL)
    • Url formatter: http://overpass-api.de/api/interpreter?data=[out:custom];$1;out;
    • Because a working selector will return a result with a backlink to Wikidata we can simplify things and use regexp constraint to limit values to be in format ["wikidata"="Q1234"]
    • If selector is allowed to be something else than wikidata tag then there would be optional qualifier Wikidata item of this property (P1629)
  2. Copy data from OpenStreetMap relation ID (P402) to new property
  3. Populate new property using OSM wikidata -tags
  4. Keep property values and OSM synced/validated with bot

Alternative 3 edit

  1. Create a new property WIWOSM status which stores just type of the WIWOSM link. Possible values node, way, ref and not_a_single_location.

Example map with autozoom edit

{{#if:{{Data|item=Q1757|property=p402|qualifier=p1629}}|
<mapframe text="" width="300" height="300">
[
  {
    "type": "ExternalData",
    "service": "geoshape",
    "ids": "Q1757",
    "properties": {
        "stroke": "#555555",
        "stroke-opacity": 1,
        "stroke-width": 0.5,
        "fill": "#8aad18",
        "fill-opacity": 0.2,
    }
  }
]
</mapframe>
|
<mapframe text="" width="300" height="300" zoom="13">
[
  {
    "type": "ExternalData",
    "service": "geoshape",
    "ids": "Q1757",
    "properties": {
        "stroke": "#555555",
        "stroke-opacity": 1,
        "stroke-width": 0.5,
        "fill": "#8aad18",
        "fill-opacity": 0.2,
    }
  }
]
</mapframe>
}}

Questions edit

  • Does the Openstreetmap licence allow this? Not an issue with alternative 2
  • Mapframe supports ways and relations. OpenStreetMap relation ID (P402) stores only OSM relations. (2/3 of all supported ids in OSM) Not an issue with alternative 2
  • Amount of work?
Based on open street map taginfo for Wikidata tag numbers are following:
Type Number of objects Number of values
All 966406 0.02% 787840
Node 496268 0.40% 467660
Way 197669 0.04% 139275
Relation 272469 5.16% 266885

Total number of coordinate location (P625) uses: 5180818.

Mapping documentation in Wikidata edit

Openstreetmap documentation edit

Terminology edit

Node
Single point in space defined by its latitude, longitude and node id. Mapframe doesn't use nodes and coordinate data is stored as coordinate location (P625) values in Wikidata.
Way
A way is an ordered list of nodes which normally also has at least one tag or is included within a relation.
Relation
Ordered list of one or more nodes, ways and/or relations as members which is used to define logical or geographic relationships between other elements.

Tools edit

How to get all wikidata tags from Openstreetmap edit

Using planet.osm dump. Requires hours and 300 GB space.

 # Load Planet.osm (38GB)
 wget https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf

 # Convert to o5m for faster handling (+80GB)
 osmconvert ./planet-latest.osm.pbf -o=planet-latest.o5m

 # Get latest changes (+80GB)
 osmupdate planet-latest.o5m planet-latest-updated.o5m

 # Keep only things with Wikidata -tag 
 osmfilter planet-latest-updated.o5m --ignore-dependencies --keep="wikidata=" -o=planet-latest-updated-only-wikidata.o5m

 # Convert to human readable format
 osmconvert planet-latest-updated-only-wikidata.o5m > planet-latest-updated-only-wikidata.osm.xml
Utils used

Older related proposals edit

Phabricator edit