sparql-examples

A set of SPARQL examples

View the Project on GitHub Adafede/sparql-examples

wd_taxa_statistics

rq turtle/ttl

Taxa statistics.

Use at


PREFIX mwapi: <https://www.mediawiki.org/ontology#API/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT
(xsd:integer(?count_) AS ?count)
(CONCAT("Total taxa with ", ?description_) AS ?description)
WHERE {
    BIND("haswbstatement:P31=Q16521" AS ?constraint)
    VALUES (?description_ ?property_query_term) {
        ("or without identifier" "")
    # All current (2023-11-06) taxonomic IDs listed
    # Only the ones with at least 100,000 IDs kept
    # Full query still runs but slow
        ("IUCN taxon ID" "P627")
        ("NCBI taxonomy ID" "P685")
    # ("BHL page ID" "P687")
        ("ITIS TSN" "P815")
        ("Encyclopedia of Life ID" "P830")
        ("BioLib taxon ID" "P838")
    # ("Fossilworks taxon ID" "P842")
        ("GBIF taxon ID" "P846")
        ("WoRMS-ID for taxa" "P850")
    # ("FishBase species ID" "P938")
    # ("MSW ID" "P959")
        ("Tropicos ID" "P960")
        ("IPNI plant ID" "P961")
        ("MycoBank taxon name ID" "P962")
        ("PlantList-ID" "P1070")
    # ("ICTV virus ID" "P1076")
    # ("AlgaeBase URL" "P1348")
        ("Index Fungorum ID" "P1391")
        ("GRIN URL" "P1421")
    # ("Flora of North America taxon ID" "P1727")
    # ("Bradley and Fletcher checklist number" "P1743")
    # ("Agassiz checklist number" "P1744")
    # ("VASCAN ID" "P1745")
    # ("ZooBank ID for name or act" "P1746")
    # ("Flora of China ID" "P1747")
    # ("Watson & Dallwitz family ID" "P1761")
    # ("USDA PLANTS ID" "P1772")
    # ("GrassBase ID" "P1832")
        ("Fauna Europaea ID" "P1895")
    # ("Dyntaxa ID" "P1939")
    # ("conifers.org ID" "P1940")
    # ("LPSN URL" "P1991")
    # ("Plazi ID" "P1992")
    # ("German cattle breed ID" "P2024")
    # ("Avibase ID" "P2026")
        ("African Plant Database ID" "P2036")
    # ("CITES Species+ ID" "P2040")
    # ("Xeno-canto species ID" "P2426")
    # ("Panarctic Flora ID" "P2434")
    # ("Species Profile and Threats Database ID" "P2455")
    # ("BugGuide taxon ID" "P2464")
        ("New Zealand Organisms Register ID" "P2752")
    # ("Index Hepaticarum ID" "P2794")
    # ("Australasian Pollen and Spore Atlas Code" "P2809")
    # ("ARKive ID" "P2833")
    # ("BacDive ID" "P2946")
    # ("EPPO Code" "P3031")
    # ("ButMoth ID" "P3060")
        ("LepIndex ID" "P3064")
    # ("Catalogue of Life in Taiwan ID" "P3088")
    # ("Internet Bird Collection species ID" "P3099")
    # ("Flora of Australia ID (old)" "P3100")
    # ("FloraBase ID" "P3101")
    # ("Plantarium ID" "P3102")
    # ("Tela Botanica ID" "P3105")
    # ("NSW Flora ID" "P3130")
        ("iNaturalist taxon ID" "P3151")
        ("TAXREF ID" "P3186")
        ("NBN System Key" "P3240")
    # ("World Spider Catalog ID" "P3288")
    # ("Vlinderstichting ID" "P3322")
    # ("FAO 2007 genetic resource ID" "P3380")
    # ("Butterflies and Moths of North America ID" "P3398")
    # ("Nederlands Soortenregister ID" "P3405")
    # ("Calflora ID" "P3420")
    # ("eBird taxon ID" "P3444")
    # ("Euring number" "P3459")
        ("WCSPF ID" "P3591")
    # ("Araneae Spider ID" "P3594")
        ("BOLD Systems taxon ID" "P3606")
    # ("Wildflowers of Israel ID" "P3746")
    # ("Flora of Israel Online plant ID" "P3795")
    # ("ADW taxon ID" "P4024")
    # ("PalDat plant ID" "P4122")
    # ("Titan ID" "P4125")
    # ("CNPS ID" "P4194")
    # ("PfaF ID" "P4301")
    # ("FOIH taxon ID" "P4311")
    # ("Indian Foundation for Butterflies ID" "P4433")
    # ("ABA bird ID" "P4526")
    # ("BTO five-letter code" "P4567")
    # ("DORIS ID" "P4630")
    # ("Wiki Aves bird ID" "P4664")
    # ("Guide to North American Birds ID" "P4715")
    # ("uBio ID" "P4728")
    # ("Ecocrop ID" "P4753")
    # ("MONA ID" "P4758")
    # ("BTO Birds of Britain ID" "P4798")
        ("Fauna Europaea New ID" "P4807")
    # ("Phasmida Species File ID" "P4855")
    # ("CONABIO ID" "P4902")
    # ("Amphibians of India ID" "P5003")
    # ("AmphibiaWeb Species ID" "P5036")
        ("Plants of the World online ID" "P5037")
        ("IRMNG ID" "P5055")
    # ("FloraCatalana ID" "P5179")
    # ("GONIAT taxon ID" "P5216")
    # ("Tree of Life Web Project ID" "P5221")
    # ("BirdLife taxon ID" "P5257")
    # ("Czech NDOP taxon ID" "P5263")
    # ("AntWeb ID" "P5299")
    # ("Amphibian Species of the World ID" "P5354")
    # ("Tierstimmenarchiv ID" "P5397")
    # ("The Reptile Database ID" "P5473")
    # ("Global Invasive Species Database ID" "P5626")
    # ("iNaturalist observation ID" "P5683")
    # ("Invasive Species Compendium Datasheet ID" "P5698")
    # ("Lepidoptera of Belgium ID" "P5862")
    # ("Enciclovida ID" "P5864")
    # ("VicFlora ID" "P5945")
    # ("NT Flora ID" "P5953")
    # ("APNI ID" "P5984")
    # ("Center for Biological Diversity ID" "P6003")
    # ("SeaLifeBase ID" "P6018")
    # ("Species at Risk public registry ID" "P6019")
    # ("Hymenoptera Online taxon ID" "P6021")
    # ("Oiseaux.net ID" "P6025")
    # ("Hypericum MySpecies ID" "P6028")
    # ("ECOS ID" "P6030")
    # ("CMS ID" "P6033")
    # ("Plant Finder ID (Missouri Botanical Garden)" "P6034")
    # ("C.V. Starr Virtual Herbarium ID" "P6035")
    # ("Wild Herps ID" "P6036")
        ("Australian Faunal Directory ID" "P6039")
    # ("BirdLife Australia ID" "P6040")
    # ("John J. Audubon's Birds of America ID" "P6041")
    # ("Echinoid Directory ID" "P6042")
    # ("Espèces Envahissantes Outre-mer ID" "P6043")
    # ("FEIS ID" "P6044")
    # ("Global Raptor Information Network ID" "P6045")
    # ("MNHN taxon ID" "P6046")
    # ("Neotropical Birds ID" "P6047")
    # ("New Zealand Birds Online ID" "P6048")
    # ("NOAA Fisheries Species Directory ID" "P6049")
    # ("Orthoptera Species File ID" "P6050")
    # ("Sea Slug Forum ID" "P6051")
    # ("Cockroach Species File ID" "P6052")
    # ("Coreoidea Species File ID" "P6053")
    # ("GT IBMA ID" "P6054")
    # ("Mantodea Species File ID" "P6055")
    # ("Red List of South African Plants ID" "P6056")
    # ("Systematic Catalog of Culicidae ID" "P6057")
    # ("Plant Parasites of Europe ID" "P6061")
    # ("Map of Life ID" "P6092")
    # ("AfroMoths ID" "P6093")
    # ("FloraWeb ID" "P6094")
    # ("FLOW ID" "P6096")
    # ("Info Flora ID" "P6098")
    # ("Mushroom Observer ID" "P6101")
    # ("Michigan Flora ID" "P6103")
        ("Observation.org ID" "P6105")
    # ("Portal to the Flora of Italy ID" "P6114")
    # ("Central African Plants ID" "P6115")
    # ("Threatened Species Link ID" "P6128")
    # ("Alabama Plant Atlas ID" "P6137")
    # ("Virtual Guide to the Flora of Mongolia ID" "P6139")
    # ("Verspreidingsatlas.nl ID" "P6142")
    # ("Atlas of Florida Plants ID" "P6159")
    # ("Invasive Plant Atlas of the United States ID" "P6161")
    # ("NAS ID" "P6163")
    # ("Cal-IPC ID" "P6176")
        ("EUNIS ID for species" "P6177")
    # ("SEINet ID" "P6209")
    # ("Flora of Wisconsin ID" "P6227")
    # ("Danmarks svampeatlas ID" "P6268")
    # ("Weeds in Ontario ID" "P6285")
    # ("ODNR Division of Wildlife ID" "P6289")
    # ("IFPNI species ID" "P6341")
    # ("The White-files species ID" "P6347")
    # ("Lace Bugs Database ID" "P6349")
    # ("Psyl'list species ID" "P6376")
    # ("COOL species ID" "P6408")
    # ("Global Species ID" "P6433")
    # ("Strepsiptera database species ID" "P6481")
    # ("Brentidae of the world species ID" "P6485")
    # ("Illustrated catalog of Tessaratomidae species ID" "P6487")
    # ("ScaleNet ID" "P6516")
    # ("FrogMAP ID" "P6704")
    # ("Flora of Australia ID (new)" "P6756")
        ("eBiodiversity ID" "P6864")
    # ("ATRF ID" "P6904")
    # ("SA Flora ID" "P6933")
    # ("Australian Faunal Directory publication ID" "P6982")
    # ("Taxonomicon ID" "P7066")
    # ("Australian Marine Algal Name Index ID" "P7090")
    # ("Belgian Species List ID" "P7202")
        ("Insects (Insecta) of the World ID" "P7224")
    # ("Pilze Deutschland ID" "P7254")
    # ("Moose Deutschland ID" "P7255")
    # ("National Marine Biological Library ID" "P7472")
    # ("NZPCN ID" "P7496")
    # ("Flowers of India ID" "P7546")
    # ("Finnish Biodiversity Information Facility's Species List ID" "P7552")
        ("World Flora Online ID" "P7715")
    # ("Microworld ID" "P7743")
    # ("AnimalBase ID" "P7905")
    # ("AGROVOC ID" "P8061")
    # ("Psocodea Species File ID" "P8145")
    # ("DPVweb ID" "P8164")
    # ("Queensland Biota ID" "P8468")
    # ("Australian Weed ID" "P8469")
    # ("Native Plants Database ID" "P8660")
        ("NBIC taxon ID" "P8707")
    # ("BHL name ID" "P8724")
    # ("Royal Horticultural Society plant ID" "P8765")
    # ("Bioweb Ecuador ID" "P8792")
    # ("edition humboldt digital Flora ID" "P8892")
    # ("ZOBODAT taxon ID" "P8915")
    # ("Australian Fungi ID" "P9076")
    # ("Australian Lichen ID" "P9093")
        ("Open Tree of Life ID" "P9157")
    # ("NParks Flora & Fauna Web ID" "P9243")
    # ("Washington Flora Checklist ID" "P9408")
    # ("OregonFlora taxon ID" "P9423")
    # ("Washington Rare Plant Field Guide ID" "PDF version)" "P9460")
    # ("Oregon Flora Image Project ID" "P9501")
    # ("MyBIS species ID" "P9503")
    # ("Danish 2010 redlist ID" "P9576")
    # ("Microlepidoptera.nl ID" "P9580")
    # ("SOR bird ID" "P9595")
    # ("ToateAnimalele ID" "P9596")
    # ("Moths and Butterflies of Europe and North Africa ID" "P9608")
    # ("Dutch Caribbean Species Register ID" "P9649")
    # ("Burke Herbarium Image Collection ID" "P9654")
    # ("Idaho Species ID" "P9684")
    # ("Montana Field Guide species ID" "P9685")
    # ("E-Fauna BC species ID" "P9690")
    # ("E-Flora BC species ID" "P9691")
    # ("Pladias ID" "P9741")
    # ("Palynodata taxa ID" "P9799")
    # ("izeltlabuak.hu ID" "P9839")
    # ("Endemia.nc animal taxon ID" "P9876")
    # ("NZTCS ID" "P9889")
    # ("Hardy's Guide to Marine Gastropods URL" "P9908")
    # ("Vietherb species ID" "P9932")
    # ("Washington Rare Plant Field Guide ID (Web version)" "P9967")
    # ("Arachne.org.au ID" "P10003")
    # ("Birdata ID" "P10007")
    # ("NWT Species ID" "P10064")
    # ("All About Birds ID" "P10191")
    # ("NatureServe Explorer ID" "P10243")
    # ("Washington Native Plant Society Plant Directory ID" "P10331")
    # ("New York Flora Atlas ID" "P10333")
    # ("Gardens Navigator ID" "P10366")
    # ("Index to Organism Names ID" "P10420")
    # ("Madrean Discovery Expeditions Flora Database ID" "P10528")
    # ("Madrean Discovery Expeditions Fauna Database ID" "P10529")
    # ("Australian Reptile Online Database ID" "P10534")
    # ("Leafsnap ID" "P10538")
    # ("Virginia Tech Dendrology Factsheets ID" "P10561")
        ("Catalogue of Life ID" "P10585")
    # ("Reflora ID" "P10701")
    # ("North Carolina Extension Gardener Plant Toolbox ID" "P10709")
    # ("Invasive.org species ID" "P10711")
    # ("CPNI ID" "P10778")
    # ("PlantFiles taxon ID" "P10791")
    # ("Garden.org Plants Database ID" "P10792")
    # ("Woody Plants Database ID" "P10793")
    # ("Macaulay Library taxon ID" "P10794")
    # ("Great Plant Picks ID" "P10833")
    # ("UK Beetles ID" "P10835")
    # ("Paleobiology Database ID" "P10907")
    # ("AEDA taxonomic keyword ID" "P10921")
    # ("ZOBODAT publication ID" "P10931")
    # ("Rare Plant Fact Sheets ID" "P10943")
    # ("Garden Plant Finder ID" "P11022")
    # ("Hesperomys taxon ID" "P11043")
    # ("Colorado Plant Database ID" "P11044")
    # ("UConn Plant Database ID" "P11067")
    # ("Biota Information System of New Mexico species ID" "P11076")
    # ("Naturbasen species ID" "P11078")
    # ("Woody Plants Database cultivar ID" "P11082")
    # ("Maryland Plant Atlas ID" "P11083")
    # ("Maryland Biodiversity Project species ID" "P11084")
    # ("eGardenGo plant ID" "P11087")
    # ("Nebraska Invasive Species Program species ID" "P11092")
    # ("Illinois Plants ID" "P11114")
    # ("Louisiana Plant ID" "P11189")
    # ("Lygaeoidea Species File ID" "P11311")
    # ("GLANSIS ID" "P11583")
    # ("World Arachnid Catalog ID" "P11803")
    # ("KPU Plant Database ID" "P11824")
    # ("Plant Finder ID (Chicago Botanic Garden)" "P11829")
    # ("World Auchenorrhyncha Database ID" "P12057")
    # ("FloraVeg.EU taxon ID" "P12100")
    # ("Vascular Plants of Iowa species ID" "P12113")
    # ("Flora of New Jersey Project atlas ID" "P12114")
    }
    BIND(CONCAT(?property_query_term, " ", ?constraint) AS ?search_query)
    SERVICE wikibase:mwapi {
        bd:serviceParam wikibase:endpoint "www.wikidata.org" ;
        wikibase:api "Search" ;
        wikibase:limit "once" ;
        mwapi:srsearch ?search_query;
        mwapi:srlimit "1".
        ?count_ wikibase:apiOutput "//searchinfo[1]/@totalhits".
    }
}
ORDER BY DESC(?count)

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?constraint")
  v7("?count")
  v6("?count_"):::projected 
  v7("?description")
  v3("?description_"):::projected 
  v4("?property_query_term")
  v5("?search_query")
  c4(["www.wikidata.org"]):::literal 
  c13(["//searchinfo#91;1#93;/@totalhits"]):::literal 
  c11(["1"]):::literal 
  c2([http://www.bigdata.com/rdf#serviceParam]):::iri 
  c8(["once"]):::literal 
  c6(["Search"]):::literal 
  bind0[/"'haswbstatement:P31=Q16521'"/]
  bind0 --as--o v2
  bind1[/VALUES ?description_ ?property_query_term/]
  bind1-->v3
  bind1-->v4
  bind10(["or without identifier"])
  bind10 --> bind1
  bind11([""])
  bind11 --> bind1
  bind12(["IUCN taxon ID"])
  bind12 --> bind1
  bind13(["P627"])
  bind13 --> bind1
  bind14(["NCBI taxonomy ID"])
  bind14 --> bind1
  bind15(["P685"])
  bind15 --> bind1
  bind16(["ITIS TSN"])
  bind16 --> bind1
  bind17(["P815"])
  bind17 --> bind1
  bind18(["Encyclopedia of Life ID"])
  bind18 --> bind1
  bind19(["P830"])
  bind19 --> bind1
  bind110(["BioLib taxon ID"])
  bind110 --> bind1
  bind111(["P838"])
  bind111 --> bind1
  bind112(["GBIF taxon ID"])
  bind112 --> bind1
  bind113(["P846"])
  bind113 --> bind1
  bind114(["WoRMS-ID for taxa"])
  bind114 --> bind1
  bind115(["P850"])
  bind115 --> bind1
  bind116(["Tropicos ID"])
  bind116 --> bind1
  bind117(["P960"])
  bind117 --> bind1
  bind118(["IPNI plant ID"])
  bind118 --> bind1
  bind119(["P961"])
  bind119 --> bind1
  bind120(["MycoBank taxon name ID"])
  bind120 --> bind1
  bind121(["P962"])
  bind121 --> bind1
  bind122(["PlantList-ID"])
  bind122 --> bind1
  bind123(["P1070"])
  bind123 --> bind1
  bind124(["Index Fungorum ID"])
  bind124 --> bind1
  bind125(["P1391"])
  bind125 --> bind1
  bind126(["GRIN URL"])
  bind126 --> bind1
  bind127(["P1421"])
  bind127 --> bind1
  bind128(["Fauna Europaea ID"])
  bind128 --> bind1
  bind129(["P1895"])
  bind129 --> bind1
  bind130(["African Plant Database ID"])
  bind130 --> bind1
  bind131(["P2036"])
  bind131 --> bind1
  bind132(["New Zealand Organisms Register ID"])
  bind132 --> bind1
  bind133(["P2752"])
  bind133 --> bind1
  bind134(["LepIndex ID"])
  bind134 --> bind1
  bind135(["P3064"])
  bind135 --> bind1
  bind136(["iNaturalist taxon ID"])
  bind136 --> bind1
  bind137(["P3151"])
  bind137 --> bind1
  bind138(["TAXREF ID"])
  bind138 --> bind1
  bind139(["P3186"])
  bind139 --> bind1
  bind140(["NBN System Key"])
  bind140 --> bind1
  bind141(["P3240"])
  bind141 --> bind1
  bind142(["WCSPF ID"])
  bind142 --> bind1
  bind143(["P3591"])
  bind143 --> bind1
  bind144(["BOLD Systems taxon ID"])
  bind144 --> bind1
  bind145(["P3606"])
  bind145 --> bind1
  bind146(["Fauna Europaea New ID"])
  bind146 --> bind1
  bind147(["P4807"])
  bind147 --> bind1
  bind148(["Plants of the World online ID"])
  bind148 --> bind1
  bind149(["P5037"])
  bind149 --> bind1
  bind150(["IRMNG ID"])
  bind150 --> bind1
  bind151(["P5055"])
  bind151 --> bind1
  bind152(["Australian Faunal Directory ID"])
  bind152 --> bind1
  bind153(["P6039"])
  bind153 --> bind1
  bind154(["Observation.org ID"])
  bind154 --> bind1
  bind155(["P6105"])
  bind155 --> bind1
  bind156(["EUNIS ID for species"])
  bind156 --> bind1
  bind157(["P6177"])
  bind157 --> bind1
  bind158(["eBiodiversity ID"])
  bind158 --> bind1
  bind159(["P6864"])
  bind159 --> bind1
  bind160(["Insects (Insecta) of the World ID"])
  bind160 --> bind1
  bind161(["P7224"])
  bind161 --> bind1
  bind162(["World Flora Online ID"])
  bind162 --> bind1
  bind163(["P7715"])
  bind163 --> bind1
  bind164(["NBIC taxon ID"])
  bind164 --> bind1
  bind165(["P8707"])
  bind165 --> bind1
  bind166(["Open Tree of Life ID"])
  bind166 --> bind1
  bind167(["P9157"])
  bind167 --> bind1
  bind168(["Catalogue of Life ID"])
  bind168 --> bind1
  bind169(["P10585"])
  bind169 --> bind1
  bind2[/"concat(?property_query_term,' ',?constraint)"/]
  v4 --o bind2
  v2 --o bind2
  bind2 --as--o v5
  subgraph s1["http://wikiba.se/ontology#mwapi"]
    style s1 stroke-width:4px;
    c2 --"wikibase:endpoint"-->  c4
    c2 --"wikibase:api"-->  c6
    c2 --"wikibase:limit"-->  c8
    c2 --https://www.mediawiki.org/ontology#API/srsearch-->  v5
    c2 --https://www.mediawiki.org/ontology#API/srlimit-->  c11
    v6 --"wikibase:apiOutput"-->  c13
  end
  bind3[/"http://www.w3.org/2001/XMLSchema#integer(?count_)"/]
  v6 --o bind3
  bind3 --as--o v7
  bind4[/"concat('Total taxa with ',?description_)"/]
  v3 --o bind4
  bind4 --as--o v7