Research in programming Wikidata/Subjects of Russia
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]- Item: Oblast of Russia (Q835714)
- Property: instances of (P31)
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:
- item oblast of Russia(Q835714).
- item republic of Russia(Q41162).
- item federal city of Russia(Q183342).
- item krai of Russia(Q831740).
- item autonomus oblast of Russia(Q309166).
- item autonomus okrug of Russia(Q184122).
- item former administrative-territorial entity(Q19953632).
- property instance of (P31)
# 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:
- item oblast of Russia(Q835714).
- item republic of Russia(Q41162).
- item federal city of Russia(Q183342).
- item krai of Russia(Q831740).
- item autonomus oblast of Russia(Q309166).
- item autonomus okrug of Russia(Q184122).
- item former administrative-territorial entity(Q19953632).
- property instance of (P31).
- property share border with (P47).
# 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.
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.
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.
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:
- item oblast of Russia(Q835714).
- item republic of Russia(Q41162).
- item federal city of Russia(Q183342).
- item krai of Russia(Q831740).
- item autonomus oblast of Russia(Q309166).
- item autonomus okrug of Russia(Q184122).
- item former administrative-territorial entity(Q19953632).
- property instance of (P31).
- property share border with (P47).
# 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.
Future work
[edit | edit source]- 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.
- Find the subjects of Russian Federation which border with foreign countries. Mark these subjects on the map.
- 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.
- Count the number of subjects of the Russian Federation in federal districts. Output the result, for example, in bubble chart.
- Make a histogram of the population of the subjects of the Russian Federation.
- Create a graph of water bodies (seas, lakes or rivers) for the subjects of the Russian Federation.
Test
[edit | edit source]
Keys (SPARQL queries):
- borders and date of occurrence of the subjects,
- subjects, which are in Russian Federation.
- falgs of the subjects.
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)