Jump to content

Research in programming Wikidata/Subjects of Russia

From Wikiversity

This article is devoted to the study of the most important properties of the object "The Subjects of Russia". Using the implementation of SPARQL-queries, data about the number of instances of the "Oblast of Russia", about the number of all currently existing subjects of the Russian Federation (oblast of Russia, republics, federal city of Russia, the region, autonomous okrug, autonomous regions, former administrative-territorial units) were received, the graph of neighboring subjects of the Russian Federation and countries was constructed, and the map with the population of certain subjects of the Russian Federation was drawn. Moreover, it was considered the task about fullness of property "shares border with". Also, fields with properties in the Wikidata were replenished. Reader will get acquainted with computer treatment of Wikidata and visualization of information about Russian districts.

List of oblast of Russia

[edit | edit source]

Let's create a list of all oblasts of Russia.

# List of `instances of` "oblast of Russia"
SELECT ?region ?regionLabel
WHERE
{
    ?region wdt:P31 wd:Q835714. # instance of "oblast of Russia"
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}
}

> SPARQL запрос, 48 results on 2017, 46 results on 2021.

👍> The most complete and elaborate oblast of Russia on the Wikidata are: Moskow oblas, Tumen oblast, Kursk oblast

👎> Almost empty and uninformative oblast of Russia turned out to be: Chita oblast, Kostroma oblast, Orenburg oblast.

Subjects of Russian Federation

[edit | edit source]

Let’s build a list of all the subjects of Russia. Let us select the following objects in Wikidata: republics, territories, regions, cities of federal significance, autonomous regions and autonomous districts

Used:

# List of `instances of` "subjects of Russia" 
SELECT ?subject ?subjectLabel ?typeLabel
WHERE
{  
  VALUES ?type {wd:Q835714   # Oblast of Russia
                wd:Q41162    # Republic of Russia
                wd:Q183342   # Federal city of Russia
                wd:Q831740   # Krai of Russia
                wd:Q309166   # Autonomus oblast of Russia
                wd:Q184122}  # Autonomus okrug of Russia
  ?subject wdt:P31 ?type.  # Selecting the type of object
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}
}

SPARQL запрос, 85 results on 2017, 86 results on 2021.

To build the script 13.2 and to verify the results obtained, the following information is needed:

  • According to the Constitution of the Russian Federation, Russia consists of 85 subjects — republics, territories, regions, cities of federal significance, autonomous regions, autonomous districts.
  • This task does not take into account subjects that are not currently part of the Russian Federation (for example, Chita region (Q182902)), because they are not instances of objects «Oblast of Russia» (Q835714), «Republic of Russia» (Q41162), «Federal city of Russia» (Q183342), «Krai of Russia» (Q831740), «Autonomus oblast of Russia» (Q309166), «Autonomus okrug of Russia» (Q184122), and belong to the object «Former administrative-territorial unit» (Q19953632). (We get 86 objects after executing a SPARQL query).
  • According to category data «Federal subjects of Russia» of the English Wikipedia, there are also 85 subjects of the Russian Federation.

Neighboring subjects

[edit | edit source]

Let`s create the graph of neighboring subjects of Russian Federation with property "shares border with".

Used:

# Graph of "subjects of Russia" `shares border with`. 
#defaultView:Graph
SELECT * WHERE {
  {
    SELECT ?subject ?subjectLabel ?rgb ?subjects ?subjectsLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
      VALUES ?type {
        wd:Q835714
        wd:Q41162
        wd:Q183342
        wd:Q831740
        wd:Q309166
        wd:Q184122
      }
      ?subject wdt:P31 ?type.
    }
  }
  UNION
  {
    SELECT ?subject ?subjectLabel ?rgb ?subjects ?subjectsLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
      VALUES ?type {
        wd:Q835714
        wd:Q41162
        wd:Q183342
        wd:Q831740
        wd:Q309166
        wd:Q184122
      }
      ?subjects wdt:P31 ?type.
      ?auto_okrug wdt:P31 wd:Q184122;
        wdt:P47 ?subjects.
      BIND(IF(?auto_okrug != "", "9932CC", IF(?rgb != "", ?rgb, "FFFFFF")) AS ?rgb)
      BIND(IF(?auto_okrug != "", ?auto_okrug, ?subjects) AS ?subject)
      BIND(IF(?auto_okrug != "", ?auto_okrugLabel, ?subjectsLable) AS ?subjectLable)
    }
  }
  UNION
  {
    SELECT ?subject ?subjectLabel ?rgb ?subjects ?subjectsLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
      VALUES ?type {
        wd:Q835714
        wd:Q41162
        wd:Q183342
        wd:Q831740
        wd:Q309166
        wd:Q184122
      }
      ?subjects wdt:P31 ?type.
      ?auto_oblast wdt:P31 wd:Q309166;
        wdt:P47 ?subjects.
      BIND(IF(?auto_oblast != "", "ced685", IF(?rgb != "", ?rgb, "FFFFFF")) AS ?rgb)
      BIND(IF(?auto_oblast != "", ?auto_oblast, ?subjects) AS ?subject)
      BIND(IF(?auto_oblast != "", ?auto_oblastLabel, ?subjectsLable) AS ?subjectLable)
    }
  }
  UNION
  {
    SELECT ?subject ?subjectLabel ?rgb ?subjects ?subjectsLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
      VALUES ?type {
        wd:Q835714
        wd:Q41162
        wd:Q183342
        wd:Q831740
        wd:Q309166
        wd:Q184122
      }
      ?subjects wdt:P31 ?type.
      ?krai wdt:P31 wd:Q831740;
        wdt:P47 ?subjects.
      BIND(IF(?krai != "", "7495db", IF(?rgb != "", ?rgb, "FFFFFF")) AS ?rgb)
      BIND(IF(?krai != "", ?krai, ?subjects) AS ?subject)
      BIND(IF(?krai != "", ?kraiLabel, ?subjectsLable) AS ?subjectLable)
    }
  }
  UNION
  {
    SELECT ?subject ?subjectLabel ?rgb ?subjects ?subjectsLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
      VALUES ?type {
        wd:Q835714
        wd:Q41162
        wd:Q183342
        wd:Q831740
        wd:Q309166
        wd:Q184122
      }
      ?subjects wdt:P31 ?type.
      ?fed_city wdt:P31 wd:Q183342;
        wdt:P47 ?subjects.
      BIND(IF(?fed_city != "", "e8a2e8", IF(?rgb != "", ?rgb, "FFFFFF")) AS ?rgb)
      BIND(IF(?fed_city != "", ?fed_city, ?subjects) AS ?subject)
      BIND(IF(?fed_city != "", ?fed_cityLabel, ?subjectsLable) AS ?subjectLable)
    }
  }
  UNION
  {
    SELECT ?subject ?subjectLabel ?rgb ?subjects ?subjectsLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
      VALUES ?type {
        wd:Q835714
        wd:Q41162
        wd:Q183342
        wd:Q831740
        wd:Q309166
        wd:Q184122
      }
      ?subjects wdt:P31 ?type.
      ?republic wdt:P31 wd:Q41162;
        wdt:P47 ?subjects.
      BIND(IF(?republic != "", "7FFF00", IF(?rgb != "", ?rgb, "FFFFFF")) AS ?rgb)
      BIND(IF(?republic != "", ?republic, ?subjects) AS ?subject)
      BIND(IF(?republic != "", ?republicLabel, ?subjectsLable) AS ?subjectLable)
    }
  }
  UNION
  {
    SELECT ?subject ?subjectLabel ?rgb ?subjects ?subjectsLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
      VALUES ?type {
        wd:Q835714
        wd:Q41162
        wd:Q183342
        wd:Q831740
        wd:Q309166
        wd:Q184122
      }
      ?subjects wdt:P31 ?type.
      ?oblast wdt:P31 wd:Q835714;
        wdt:P47 ?subjects.
      BIND(IF(?oblast != "", "e87b7b", IF(?rgb != "", ?rgb, "FFFFFF")) AS ?rgb)
      BIND(IF(?oblast != "", ?oblast, ?subjects) AS ?subject)
      BIND(IF(?oblast != "", ?oblastLabel, ?subjectsLable) AS ?subjectLable)
    }
  }
}

SPARQL query, 467 results on 2017, 482 results on 2021.

Using the BIND command (lines 31–35) in query, we write the value to a variable, provided that the variable responsible for subjects of a certain type is non-empty. For example, in lines 31–32, a color is written to the variable ?rgb, provided that ?oblast is not empty. At the same time, if the variable ?rgb already contains a value, then we leave it to exclude color mashing. The number of records received is formed by adding the number of neighboring territories for all subjects of Russia. The result of the script is a graph displaying neighboring subjects. Moreover, different types of subjects have vertices of different colors, for example, the republics are green, and the edges are blue. A part of the graph is shown in figure.


Regions of Russia in Siberia and the Far East for 2021. A fragment of the graph of neighboring subjects of Russia, built according to the query. Republics — green nodes (Yakutia). Autonomous Okrugs — purple nodes (Chukotka Autonomous Okrug). Edges — blue nodes (Khabarovsk Krai). Areas — pink nodes (Amur region). Autonomous regions — green-colored nodes (Jewish Autonomous Region).

Let’s build a map on which the subjects of Russia bordering with foreign countries are indicated in color. The darker color indicates subjects with a larger number of border countries, the lighter — with a smaller number of border countries. (SPARQL query)

# Map of countries around Russia with the number of neighboring regions of Russia
#defaultView:Map{"hide":["?shape", "?rgb"], "layer": "?regionLabel"}
SELECT ?region ?regionLabel ?count ?shape ?rgb
{
  {
    SELECT ?region (COUNT(DISTINCT ?country) AS ?count)
    WHERE {
      VALUES ?type {
        wd:Q835714  # oblasts of Russia - 9 neighbours
        wd:Q41162   # republic of Russia - 4
        wd:Q183342  # federal city of Russia has no foreign neighbours
        wd:Q831740  # krai of Russia - 4
        wd:Q309166  # autonomous oblast of Russia - 1
        wd:Q184122   # autonomous okrug of Russia - 1
      }
      ?region wdt:P31 ?type.
  
      # Russian region share border with some territory of foreign country
      ?region wdt:P47 [ wdt:P17 ?country].
      FILTER (?country != wd:Q159) # foreign country is not Russia
    }
    GROUP BY ?region
    HAVING ((COUNT(?country)) > 0)
  }
  ?region wdt:P3896 ?shape.
  BIND(IF(?count = 3 , "6c2eab", IF(?count = 2 , "9b77bf", IF(?count = 1 , "c6b2db", "f5cbce"))) AS ?rgb)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }  
}

The result of the query is shown in the figure.

Map of the subjects of Russia bordering on foreign countries, 2021. The map is based on the data received by the query.

Let’s build a map on which foreign countries bordering on the subjects of Russia are indicated in color. The darker color indicates the countries with a larger number of border subjects of Russia, the lighter — with a smaller number of border subjects of Russia (SPARQL query).

# Map of countries around Russia with the number of neighboring regions of Russia
#defaultView:Map{"hide":["?shape", "?rgb"], "layer": "?countryLabel"}
SELECT ?country ?countryLabel ?count ?shape ?rgb WHERE {
  {
    SELECT ?country (COUNT(DISTINCT ?region) AS ?count) WHERE {
      VALUES ?type {
        wd:Q835714
        wd:Q41162
        wd:Q183342
        wd:Q831740
        wd:Q309166
        wd:Q184122
      }
      ?region wdt:P31 ?type.
      ?region wdt:P47 [ wdt:P17 ?country].
      FILTER (?country != wd:Q159) # foreign country is not Russia
    }
    GROUP BY ?country
    HAVING ((COUNT(?region)) > 0 )
  }
  ?country wdt:P3896 ?shape.
  BIND(IF(?count > 9 , "4B0082", IF(?count > 5 , "800080", IF(?count > 2 , "8B008B", IF(?count > 1 , "9400D3", IF(?count > 0 , "DA70D6", "f5cbce"))))) AS ?rgb)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

The result of the query is shown in the figure.

Map of foreign countries bordering the subjects of Russia, 2021. The map is based on the data received by the query.

Fullness of Wikidata

[edit | edit source]

Let’s build a list of subjects of Russia with an empty property shares border with (P47) (borders with), that is, we will try to find such subjects that do not share border with anyone.

Used:

# List of "subjects of Russia" without `shares border with`. 
SELECT ?subject ?subjectLabel ?sharesBorderWith ?sharesBorderWithLabel
WHERE
{
  VALUES ?type {wd:Q835714   # Oblast of Russia
                    wd:Q41162    # Republic of Russia
                    wd:Q183342   # Federal city of Russia
                    wd:Q831740   # Krai of Russia
                    wd:Q309166   # Autonomus oblast of Russia
                    wd:Q184122}  # Autonomus okrug of Russia
  
  ?subject wdt:P31 ?type.
  
  FILTER EXISTS {?subject wdt:P17 wd:Q159; wdt:P31 ?type}
  MINUS { ?subject  wdt:P47 [] } . #Shares border with 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}
   
}

SPARQL-запрос, zero results on 2017, 1 results on 2021.

Using the FILTER command (line 16), we exclude objects that are not located on the territory of Russia. Then, using MINUS (line 20), we select objects whose property «shares border with» (P47) is not filled. Thus, the «shares border with» (P47) property is filled on Wikidata for all subjects of Russia.

Population

[edit | edit source]

Let’s mark the subjects of the Russian Federation on the map, dividing them into six groups by population. Subjects belonging to the same group will be displayed on the map in the same color. For the query we need the properties «coordinates» (P625) and «population» (P1082).

  • Subjects with a population less than 500,000 are painted in blue
  • Subjects with a population more than 500,000, but less than 1,000,000 are painted in orange
  • Subjects with a population more than 1,000,000, but less than 3,000,000 are painted in green
  • Subjects with a population more than 3,000,000, but less than 8,000,000 are painted in red
  • Subjects with a population more than 8,000,000, but less than 10,000,000 are painted in white
  • Subjects with a population more than 10,000,000 are painted in purple
#Map of `population` "subject of Russia"
#Version 2021
#defaultView:Map
SELECT DISTINCT ?subject ?subjectLabel ?population ?coord ?layer
{
  {
    { ?subject wdt:P31 wd:Q835714 } UNION  # Oblast of Russia
    { ?subject wdt:P31 wd:Q41162 } UNION  # Republic of Russia
    { ?subject wdt:P31 wd:Q183342 } UNION  # Federal city of Russia
    { ?subject wdt:P31 wd:Q831740 } UNION  # Krai of Russia
    { ?subject wdt:P31 wd:Q309166 } UNION # Autonomus oblast of Russia
    { ?subject wdt:P31 wd:Q184122 } # Autonomus okrug of Russia
  }   
  ?subject wdt:P625 ?coord; wdt:P1082 ?population.
  
  FILTER NOT EXISTS {?subject wdt:P31 wd:Q19953632}  # former administrative territorial entity
  BIND(
    IF(?population < 500000, "< 500000",
    IF(?population < 1000000, "500000 - 1000000",
    IF(?population < 3000000, "1000000 - 3000000",
    IF(?population < 8000000, "3000000 - 8000000",
    IF(?population < 10000000, "8000000 - 10000000",
    "> 10000000")))))
    AS ?layer).
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "ru,en,[AUTO_LANGUAGE]"}
}
ORDER BY ?population

SPARQL query version 2017 85 results on 2017.

SPARQL query version 2021 86 results on 2021.

The result of the script is represented in the figure below.

Population map by subjects of Russia, 2021. The subjects are divided into six groups by population and marked with different colors depending on the group the subject belongs to. The map is based on the data received by the query

Future work

[edit | edit source]
  1. Arrange all subjects of Russian Federation by order of decreasing the number of territories which they border. On the basis of the data obtained, write your own opinion why some subjects have more neighbors, but others have less.
  2. Find the subjects of Russian Federation which border with foreign countries. Mark these subjects on the map.
  3. Group all subjects of Russian Federation according to the time zones they are located. Determine the total population for each group and then build a bubble diagram.
  4. Count the number of subjects of the Russian Federation in federal districts. Output the result, for example, in bubble chart.
  5. Make a histogram of the population of the subjects of the Russian Federation.
  6. Create a graph of water bodies (seas, lakes or rivers) for the subjects of the Russian Federation.

1 This subject, located in the north-west of Russia, was appeared in 1923. It borders with Leningrad, Vologda, Arkhangelsk and Murmansk oblast. Also it borders with Finland in the west.
Select the flag of the subject from the description you read.

2 Choose the represented entities which are currently part of the Russian Federation, and which are not.

Yes No
Adygeya republic
Kamchatka krai
Chita oblast
Chukotka autonomus region

3 There is a speech about the flag of which subject?
«The flag of this subject is a rectangular panel with a ratio of width to length of 2: 3, red color with a two-sided image in the upper corner of the main element of the emblem of this subject - the Saint George the Victorious. The overall width of the image of the main element of the emblem on the flag of this subject is 1/5 of the length of the flag».



Keys (SPARQL queries):

References

[edit | edit source]


  • "Конституция Российской Федерации, Глава 3, статья 65" [Constitution of Russian Federation]. Legal literature. 2014. Retrieved May 9, 2017.
  • "Статья на сайте Authorea" [Article on the site Authorea]. 2017. Retrieved May 9, 2017.
  • Zinchenko T. "Subjects of Russia". ProWD. Retrieved 2021-09-28. {{cite web}}: Unknown parameter |datepublished= ignored (help)