Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit Italy provinces #131

Closed
jsanz opened this issue Oct 22, 2019 · 3 comments
Closed

Revisit Italy provinces #131

jsanz opened this issue Oct 22, 2019 · 3 comments
Assignees

Comments

@jsanz
Copy link
Member

jsanz commented Oct 22, 2019

South Sardinia got the ISO code so I added it, but the old Sicily provinces are still listed under the Region so the I had to tweak the previous query to return all the 107 boundaries

     #defaultView:MapRegions
    SELECT ?id ?iso_3166_2 ?istat ?label_en ?label_it
    WHERE {
      SERVICE <https://query.wikidata.org/sparql> {
        {
          SELECT 
            ?id
            (SAMPLE(?id2) AS ?id2) 
            (SAMPLE(?iso_3166_2) AS ?iso_3166_2) 
            (SAMPLE(?istat) AS ?istat) 
            (SAMPLE(REPLACE(?label_en, "Province of ", "")) as ?label_en)
            (SAMPLE(REPLACE(?label_it, "provincia di ", "")) as ?label_it)
            WHERE { {
            VALUES (?entity) {
              (wd:Q38)
            }
            ?entity (wdt:P150/wdt:P150) ?id.
            ?id wdt:P300 ?iso_3166_2.
            MINUS {
              ?id (wdt:P576|wdt:P582) ?end.
              FILTER(?id NOT IN(
              wd:Q16112,
              wd:Q16150,
              wd:Q16154,
              wd:Q16166,
              wd:Q16208,
              wd:Q16227,
              wd:Q16251,
              wd:Q16277,
              wd:Q16288,
              wd:Q16184,
              wd:Q16247,
              wd:Q16293,
              wd:Q16294
              ))
            }
            OPTIONAL { ?id wdt:P635 ?istat. }
            OPTIONAL {
              ?id rdfs:label ?label_en.
              FILTER((LANG(?label_en)) = "en")
            }
            OPTIONAL {
              ?id rdfs:label ?label_it.
              FILTER((LANG(?label_it)) = "it")
            }
          } UNION {
            # ISO Code IT-AO refers to a province that no longer exists. The GeoLite2 IP database lists cities from the Aosta Valley
            # regiohn so we'll use the region boundaries for the IT-AO code.
            VALUES ?entity { wd:Q38 }
            ?entity wdt:P150 ?id .
            FILTER ( ?id = wd:Q1222 )
            VALUES ?iso_3166_2 { "IT-AO" }
            OPTIONAL { ?id wdt:P635 ?istat. }
            OPTIONAL {
              ?id rdfs:label ?label_en.
              FILTER((LANG(?label_en)) = "en")
            }
            OPTIONAL {
              ?id rdfs:label ?label_it.
              FILTER((LANG(?label_it)) = "it")
            }
          } UNION {
            # Sicily comunes
            ?id wdt:P31/wdt:P279*  wd:Q21190155.
            ?id wdt:P300 ?iso_3166_2.
            
            OPTIONAL { ?id wdt:P635 ?istat. }
            OPTIONAL {
              ?id rdfs:label ?label_en.
              FILTER((LANG(?label_en)) = "en")
            }
            OPTIONAL {
              ?id rdfs:label ?label_it.
              FILTER((LANG(?label_it)) = "it")
            }
          } UNION {
            # Sicily metropolitan cities
            VALUES (?id) {
              (wd:Q20795016)
              (wd:Q20991250)
              (wd:Q20991246)
            }
            ?id wdt:P300 ?iso_3166_2.
            
            OPTIONAL { ?id wdt:P635 ?istat. }
            OPTIONAL {
              ?id rdfs:label ?label_en.
              FILTER((LANG(?label_en)) = "en")
            }
            OPTIONAL {
              ?id rdfs:label ?label_it.
              FILTER((LANG(?label_it)) = "it")
            }
          }
          }
          GROUP BY ?id
        }
      }
    }
@jsanz jsanz self-assigned this Oct 22, 2019
@jsanz
Copy link
Member Author

jsanz commented Oct 22, 2019

@nickpeihl please let me know your thoughts on this approach, seems a bit clunky to me but I haven't found a better way to get all the boundaries 🤔

@nickpeihl
Copy link
Member

@jsanz Your query works well. Some of the issue comes from the contains administrative territorial entity property on Sicily which contains a list of former provinces instead of the Metropolitan cities that succeeded them. However, I am hesitant to make such a large change without local knowledge.

Let's use your method for now and come back to this later.

@jsanz
Copy link
Member Author

jsanz commented Nov 19, 2019

This issue was fixed at #135

@jsanz jsanz closed this as completed Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants