Wikidata:WikiProject Mineralogy/Queries

This is page that gathers useful and interesting queries.

Maintenance edit

# List all items that are a subclass of mineral and are missing a picture statement
SELECT ?item ?itemLabel WHERE {
	?item wdt:P279* wd:Q7946 .
	filter not exists { ?item wdt:P18 ?x } .
  	SERVICE wikibase:label {
		bd:serviceParam wikibase:language "en" .
	}
}
Try it!
# List all items that are in the subclass-tree of mineral
SELECT ?item ?itemLabel WHERE {
	?item wdt:P279* wd:Q7946 .
  	SERVICE wikibase:label {
		bd:serviceParam wikibase:language "en" .
	}
}
Try it!
# List all items that have 'mineral series' in property 'named after'
SELECT ?item ?itemLabel WHERE {
	?item wdt:P138* wd:Q3965281 .
  	SERVICE wikibase:label {
		bd:serviceParam wikibase:language "en" .
	}
}
Try it!
#Author name strings 
SELECT ?item ?itemLabel
{
  ?item wdt:P2093 "Jane Doe" .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!

Example, gadolinite-(Ce): cerium dominant analogue of gadolinite-(Y); translates to 'named after', cerium, gadolinite-REE, 'mineral series'.

# List all items that have a named after (P138) mineral series (Q24241569)
SELECT ?item ?itemLabel (GROUP_CONCAT(?namedAfterItemLabel; separator=', ') AS ?namedAfter) WHERE {
  ?item wdt:P138 wd:Q24241569; wdt:P138 ?namedAfterItem .
  OPTIONAL {
    ?namedAfterItem rdfs:label ?namedAfterItemLabel .
    FILTER(LANG(?namedAfterItemLabel) = 'en') .
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?item ?itemLabel
Try it!

Notes: Mineralogical Society of America (MSA), Handbook of Mineralogy (HOM) and mindat.org are avoided as reference. It is assumed that the description of the type specimen cites the naming rationale, if this is untrue then it is the 'type locality' (the only name cited in the description in this case). One exception is suhailite: Andalusia has old names of arabic origin and Suhail is the old arabic name for Fuengirola. Another exception is the Chinese literature before Deng Xiaoping: 'type localities' and so 'naming localities' were considered state secrets. Reference, before 1896: A Dictionary of the Names of Minerals. Consider that some items have more than one name. Alsace was once part of the German Empire; Trieste and Tyrol was once part of the Austro-Hungary Empire. Sadamisaki Peninsula is called Misaki Peninsula (misakiite). Valais (French) is Wallis (German), wallisite. Vulcano is Hiera (ancient Greek), hietatite; or Therasia (θηρασια, warm earth), therasiaite. Sardinia is Ichnusa (Ιχνουσσα, Ancient Greek), ichnusaite.

# List all items that have a named after (P138) naming locality (Q22815296)
SELECT ?item ?itemLabel (GROUP_CONCAT(?namedAfterItemLabel; separator=', ') AS ?namedAfter) WHERE {
  ?item wdt:P138 wd:Q22815296; wdt:P138 ?namedAfterItem .
  OPTIONAL {
    ?namedAfterItem rdfs:label ?namedAfterItemLabel .
    FILTER(LANG(?namedAfterItemLabel) = 'en') .
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?item ?itemLabel
Try it!
# List all items that have a main subject (P921) type description (earth sciences) (Q56241591)
SELECT ?item ?itemLabel (GROUP_CONCAT(?namedAfterItemLabel; separator=', ') AS ?namedAfter) WHERE {
  ?item wdt:P921 wd:Q83353; wdt:P50 ?namedAfterItem .
  OPTIONAL {
    ?namedAfterItem rdfs:label ?namedAfterItemLabel .
    FILTER(LANG(?namedAfterItemLabel) = 'en') .
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?item ?itemLabel
Try it!
# List all items that have a named after (P138) naming region (Q28837448)
SELECT ?item ?itemLabel (GROUP_CONCAT(?namedAfterItemLabel; separator=', ') AS ?namedAfter) WHERE {
  ?item wdt:P138 wd:Q28837448; wdt:P138 ?namedAfterItem .
  OPTIONAL {
    ?namedAfterItem rdfs:label ?namedAfterItemLabel .
    FILTER(LANG(?namedAfterItemLabel) = 'en') .
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?item ?itemLabel
Try it!
# List all items that have a named after (P138) chemical composition (Q1263816)
SELECT ?item ?itemLabel (GROUP_CONCAT(?namedAfterItemLabel; separator=', ') AS ?namedAfter) WHERE {
  ?item wdt:P138 wd:Q1263816; wdt:P138 ?namedAfterItem .
  OPTIONAL {
    ?namedAfterItem rdfs:label ?namedAfterItemLabel .
    FILTER(LANG(?namedAfterItemLabel) = 'en') .
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?item ?itemLabel
Try it!
# List all subject of: mineralogy AND species nova
SELECT ?item  WHERE {
   ?item wdt:P921 wd:Q83353 .
   ?item wdt:P921 wd:Q27652812 .
}
Try it!
# List all items without IMA Mineral Symbol
SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q12089225.
      MINUS {
        ?item p:P10113 ?statement1.
        ?statement1 (ps:P10113) _:anyValueP10113.
      }
    }
  }
}
Try it!
#List all valid minerals
SELECT ?min ?minLabel ?imaLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  VALUES ?ima {wd:Q13406835 wd:Q13406846 wd:Q13406860 wd:Q13406872} # A, G, Rn, Rd
  ?min wdt:P31 wd:Q12089225.
  ?min wdt:P579 ?ima.
  # OPTIONAL { ?cawiki schema:about ?min; schema:inLanguage "ca"; schema:isPartOf <https://ca.wikipedia.org/> }
  # FILTER (!BOUND(?cawiki))
} ORDER BY ?minLabel
Try it!
# List all subject of: mineralogy AND type description
SELECT ?item  WHERE {
   ?item wdt:P921 wd:Q83353 .
   ?item wdt:P921 wd:Q56241591 .
}
Try it!


German description
# List all items that are a subclass of mineral and are missing a label in German
SELECT ?item ?itemLabel WHERE {
	?item wdt:P279* wd:Q7946 .
	filter not exists { ?item rdfs:label ?missinglabel filter (lang(?missinglabel) = "de") } .
  	SERVICE wikibase:label {
		bd:serviceParam wikibase:language "en" .
	}
}
Try it!
# List all items with mineral in the German label
SELECT ?item ?itemDescription WHERE {
  ?item wdt:P279* wd:Q7946;
        schema:description ?itemDescription.
  FILTER(CONTAINS(?itemDescription, " Mineral"))
  FILTER(LANG(?itemDescription)="de")
}
LIMIT 5000
Try it!

Type localities edit

Notes (list of show mines): most type localities are historical, past status. Meteorites were collected; Ivigtut cryolite deposit is empty (even the jetty and the dumps were sorted a second time); Mount Vesuvius is quiet, but volcanoes are waking up worldwide (2019-2029); Karnasurt underground mine (the Palitra pegmatite (7 by 1.5 m) was possibly removed); Michael Mine, Weiler/ Southern part (adit is inaccessible and the dump has been landscaped), Silbereckle mine/ Northern part (adit is visible); New Cliffe Hill granite quarry (the 'copper lode' and associated secondary mineralisation was removed in the late 1990's); the Crestmore quarries were used by the Riverside Portland Cement Company; Jacupiranga open pit mines apatite for agricultural use, it delivers calcareous rock for the cement production as well (it uses flotation as an enrichment step); Kintore opencut, Broken Hill South mine swallowed the old Kintore shaft, the Block 10 mine, almost the Central mine (Block 9) and a portion of the [Broken] Proprietary mine workings (Blocks 9-11); Block 14 opencut, Broken Hill swallowed much of the British mine (Blocks 15 & 16), and the Proprietary mine; Falun copper mine, Cap Garonne and Gonzen are museum mines; Tsumeb is only extracting specimens for mineral collectors; etc. On the other side, new mineral species can be found in San Juan Co., UT; wayneburnhamite was found in the Crestmore quarries and hitachiite was found in the Hitachi mine. Economical viable ore and the source of new minerals (contact zones) are actually on different locations. The workload gets smaller by using a low resolution (sometimes up to county level; instead of up to mine level), the use of the MinDat database as reference was avoided since the 1st half of 2017. Caution: Glocker E F (1847) redefined the names rocksalt and halite (ancient Greek for rocksalt/ "Steinsalz"); Vauquelin L N (1798) redefined emerald and beryl; Scheele C W (1779) redefined galena (Bleiglanz), molybdenite and graphite; Albertus Magnus redefined spinel, spinel; almandine, granat; rubi, corundum, etc.; these papers are not a full description of a type specimen from a type locality.


# List all items that have a type locality
select ?item ?itemLabel ?imaLabel ?locLabel where
{
  ?item wdt:P579 ?ima .
  ?item wdt:P2695 ?loc .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} ORDER BY ?item
Try it!
# Find all mineral type localities and sort them by most minerals defined
SELECT ?locality ?name (COUNT(DISTINCT ?mineral) AS ?count)
WHERE
{
    ?mineral wdt:P579 ?status .
    ?mineral wdt:P2695 ?locality .          # Where a locality statement exists
   
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "en" .
        ?locality rdfs:label ?name
    }
}
GROUP BY ?locality ?name
ORDER BY DESC(?count)
Try it!


# Find all mineral type localities and which you can render as a map
SELECT ?locality ?name ?location
WHERE
{
    ?mineral wdt:P579 ?status .
    ?mineral wdt:P2695 ?locality .          # Where a locality statement exists
   
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "en" .
        ?locality rdfs:label ?name
    }
     ?locality wdt:P625 ?location 
}
GROUP BY ?locality ?name ?location
Try it!
# Find all mineral type localities that are meteorites and sort them by defined minerals
SELECT ?locality ?name (COUNT(DISTINCT ?mineral) AS ?count)
WHERE
{
    ?mineral wdt:P579 ?status .
    ?mineral wdt:P2695 ?locality .    # Where a locality statement exists
    ?locality wdt:P31 ?thing .        # Where the locality is the instance of a thing (helper)
    ?thing wdt:279* wd:Q60186 .       # And the thing is in the subclass tree of meteorite (Should also work if p31 = iron meteorite for example)
  
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "en" .
        ?locality rdfs:label ?name
    }
}
GROUP BY ?locality ?name
ORDER BY DESC(?count)
Try it!

Showcase edit

#Minerals and their commons colors
#defaultView:Graph
SELECT DISTINCT ?mineral ?mineralLabel ?rgb ?color ?colorLabel
WHERE
{
  ?mineral wdt:P279* wd:Q7946 ;
           wdt:P462 ?color .
  ?color wdt:P465 ?rgb .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!
# examle with selected minerals 
SELECT  ?sg ?sgLabel ?sgImage    ?group ?groupLabel  ?groupDescription ?item ?itemLabel ?itemDescription ?itemImage
WHERE  {
  VALUES ?item {wd:Q108147097 wd:Q1117109 wd:Q114584875 wd:Q13292920 wd:Q13322207 wd:Q1614643 wd:Q1656448 wd:Q19810681}   
  ?item    wdt:P279   ?group.
  ?group   wdt:P279 ?sg.
  OPTIONAL {?item wdt:P18 ?itemImage.}
  OPTIONAL {?group wdt:P18 ?groupImage.}
  OPTIONAL {?sg wdt:P18 ?sgImage.}
  SERVICE wikibase:label{ bd:serviceParam wikibase:language "sr". }
}
Try it!