# Spatial Search
In this page, we illustrate two examples of spatial queries. Not only RsDA inventory, but also any other virtual museums, digital libraries, digital collections, databases, datasets, or digital catalogues (wd:Q1225034 wd:Q8513 wd:Q212805 wd:Q60474998 wd:Q1988927 wd:Q1172284) are targets of the queries.
## Mapping the resources
Get the coordinate from main subject, country, or narrative location (wdt:P921 wdt:P17 wdt:P840) information. Main subjects are not always spatial information, but if that has coordinate information (wdt:P625), that will be informative being mapped. For example, "Liancourt Rocks dispute" is a dispute; "2011 Egyptian revolution" is a revolution; but those have coordinate information.
```sparql
#defaultView:Map
SELECT distinct ?item ?itemLabel ?areaLabel ?coordinate
WHERE
{
values ?itemClass {wd:Q1225034 wd:Q8513 wd:Q212805 wd:Q60474998 wd:Q1988927 wd:Q1172284}
values ?pArea {wdt:P921 wdt:P17 wdt:P840}
?item wdt:P31 ?itemClass;
?pArea ?area.
?area wdt:P625 ?coordinate.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
```
## Query by country
This page lists up datasets related to each country. Most of the datasets put country information with country (P17) or main subject (P921) property. Such property information is accompanied by parentheses. Many countries don't have any related dataset. Please add information...
### Documentation of "Query by country"
SPARQL query for finding resources related to countries in Asia continent is:
```sparql
SELECT ?item ?itemLabel ?propertyLabel
WHERE
{
VALUES ?class
{wd:Q8513 wd:Q212805 wd:Q60474998 wd:Q1988927 wd:Q1172284}
?item wdt:P31 ?class;
?p ?country.
?property wikibase:directClaim ?p.
?country wdt:P31 wd:Q6256;
wdt:P30 wd:Q48.
MINUS { ?country wdt:P31 wd:Q3024240}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
```
However, this query timeouts. So we separate the query into two steps.
```sparql
SELECT ?country ?countryLabel
WHERE
{
?country wdt:P31 wd:Q6256;
wdt:P30 wd:Q48.
MINUS { ?country wdt:P31 wd:Q3024240}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
```
This query get the list of Asian (Q48) countries (Q6256) excluding historical country (Q3024240). Saving the list of 46 countries in JSON format and that data is loaded as options in pulldown menu. And then, use each QID to build the second sparql query below. This is a little bit different from a part of the original query above. Names of the multiple property labels are concatenated.:
```sparql
SELECT ?item (group_concat(distinct ?itemLabel; separator=" / ") as ?itemLabels) (group_concat(distinct ?propertyLabel; separator=", ") as ?propertyLabels)
WHERE
{
VALUES ?class
{wd:Q8513 wd:Q212805 wd:Q60474998 wd:Q1988927 wd:Q1172284}
?item wdt:P31 ?class;
?p wd:`+QID+`.
?property wikibase:directClaim ?p.
?item rdfs:label ?itemLabel.
?property rdfs:label ?propertyLabel.
FILTER(lang(?propertyLabel)='en')
}
group by ?item
```