File talk:Flags – Wikidata-tagged flags on flagpoles in OpenStreetMap as of 30 June 2020.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Steps to reproduce[edit]

To create the bar chart:

  1. Open Sophox in a very large window or use Firefox's Responsive Design Mode to force the window to be very large.
  2. Run this Sophox query, which is a federated SPARQL query that calls out to the Wikidata Query Service.
  3. Export the query results as SVG.
  4. Import the resulting SVG file into the poster SVG file. Replace the colors with darker colors.
  5. Switch to the Table view and export the query results as JSON.
  6. Run the following jq command to extract the flag image URLs as cURL commands to download them:
    jq -r $'map(select(.image))[] | "curl -L \'" + .image + "\' -o \'" + .name + ".svg\'"' query.json
    
    (Omit any non-SVG images.)
  7. The ASEAN flag is unfree and can't be included in this public domain work. Download w:File:Flag of ASEAN.svg but remove the unfree ASEAN logo from the center of the flag. Only part of the field shows up on the chart anyways, because so few ASEAN flags have been mapped, relatively speaking.
  8. Reduce the width of each bar.
  9. Import each flag, downsize it, and position it over a point just below the corresponding bar's top-left corner. If the flag uses any clipping masks or relies on the document boundary to clip the image, open the flag's SVG file separately, create a document-wide clipping mask, group all the objects, and copy the object group into the poster SVG file.

To create the map:

  1. Run this OverpassQL query to get every Wikidata-tagged flagpole in OpenStreetMap.
  2. Export the query results as GeoJSON, then run the following jq command to massage the flag:type tag:
    jq '.features | map(.properties.type = (.properties["flag:type"] | strings | match("^[^;]+").string))' export.geojson > flags.geojson
    
  3. Use a GeoJSON editor or geojson-clipping to union the results with this GeoJSON file of country boundaries from Natural Earth.
  4. Save the following style file as style.json:
    {
        "commercial": {
            "fill": "#6b94b0",
            "stroke": "#323232",
            "weight": 0.1,
            "opacity": 0.25
        },
        "military": {
            "fill": "#d26b5f",
            "stroke": "#610c03",
            "weight": 0.1,
            "opacity": 0.25
        },
        "municipal": {
            "fill": "#d39651",
            "stroke": "#633501",
            "weight": 0.1,
            "opacity": 0.25
        },
        "national": {
            "fill": "#95b957",
            "stroke": "#3a5212",
            "weight": 0.1,
            "opacity": 0.25
        },
        "other": {
            "fill": "#d5c65c",
            "stroke": "#645800",
            "weight": 0.1,
            "opacity": 0.25
        },
        "regional": {
            "fill": "#9d6b9e",
            "stroke": "#412242",
            "weight": 0.1,
            "opacity": 0.25
        },
        "religious": {
            "fill": "#75b0a6",
            "stroke": "#1c4841",
            "weight": 0.1,
            "opacity": 0.25
        },
        "Country": {
            "stroke": "#808080",
            "weight": 0.1
        },
        "Dependency": {
            "stroke": "#808080",
            "weight": 0.1
        },
        "Indeterminate": {
            "stroke": "#808080",
            "weight": 0.1
        },
        "Sovereign country": {
            "stroke": "#808080",
            "weight": 0.1
        }
    }
    
  5. Run the following geojson2svg command to convert the GeoJSON file to SVG:
    geojson2svg -i map.geojson -s style.json -t type > flags_map.geojson
    
  6. Import the resulting SVG file into the poster SVG file.

Inkscape fails to convert the SVG to PDF correctly – most or all of the flags go missing. Instead, use Cairo to convert the SVG to PDF.

– Minh Nguyễn 💬 18:16, 2 July 2020 (UTC)[reply]