# SPARQL/WIKIDATA Precision, Units and Coordinates

The data on WIKIDATA contains more info than only the triples. For a full description see Wikidata:Glossary.
Values on Wikidata often have additional info like precision, units etc. Wikidata's solution for almost everything is more triples. And it means more prefixes.

### Entities

For entities there is no additional information.

### Strings

For strings there is no additional information.

### Time

Try it!
The prefix p: points to a statement node.
The prefix psv: within a statement node retrieves a time node. The wikibase:timeValue within the time node retrieves the time. The wikibase:timePrecision within a time node retrieves the precision of the time.
    The codes for precision are 0: billion years, 1: hundred million years, 3: million years, 4: hundred thousand years, 5: ten thousand years, 6: millennium, 7: century, 8: decade, 9: year, 10: month, 11: day, 12: hour, 13: minute, 14: second.
The wikibase:timeTimezone within a time node retrieves the timezone, as an offset from UTC in minutes. The wikibase:timeCalendarModel within a time node retrieves the calendar, a common used value is proleptic Gregorian calendar (Q1985727).
Comment on filtering on dates. On filtering dates the code ^^xsd:dateTime should be added, like:

### Monolingual texts

For monolingual text there is no additional information. The text is represented as a string literal with language tag. It has only simple value.
Try it!

### Coordinates

Try it!
The prefix p: points to a statement node.
The prefix ps: within a statement node for a coordinate retrieves the full coordinate, like Point(2.1749 41.3834).
The prefix psv: within a statement node retrieves a coordinate node. The wikibase:geoLongitude within the coordinate node retrieves the longitude value. The wikibase:geoLatitude within a coordinate node retrieves the latitude value. The wikibase:geoGlobe within a coordinate node retrieves the globe object. For coordinates on earth it will be Earth (Q2). The wikibase:geoPrecision within a coordinate node retrieves the precision of the coordinate values, measured in degrees. Multiply by 111000 to convert to meters.
Here an example of mountains not located on Earth.
Try it!

### Quantities

Try it!
The prefix p: points to a statement node.
The prefix psv: within a statement node retrieves a value node. The wikibase:quantityAmount within the value node retrieves a quantity value. The wikibase:quantityUnit within a value node retrieves a unit. Not all quantities have units. The wikibase:quantityLowerBound and wikibase:quantityUpperBound can be used to indicate the precision.
Within the Unit you can retrieve the statement for converting the unit to the SI unit etc. See in the example the length of the Mississippi River is in miles, and can be converted to SI units. The conversion could also be needed if some lengths are in meters and some in kilometers to so.
Some variables are used only for demonstration. Without those the query will be:
Try it!
The code can be abbreviated a lot with the [ ] syntax by eliminating the variables for the nodes and unused variables.
Try it!

#### Normalised units

Instead of converting by SPARQL code as above the units can be converted automatically by using prefix psn: (normalised) instead of psv:.
Try it!
The prefix psv: within a statement node retrieves a value node. The prefix psn: within a statement node retrieves a normalised value node. Note that a query with psn: will give you only the values with units presents in this list.
Notice that the units changed from km and miles into meters, and that the values are all calculated accordingly. Also the lower- and upper-bound values change accordingly. The precision now is in meters.
Normalized quantity values are value nodes that are parallel to the original data nodes but represented in base units. They are connected to their parent nodes by predicates with prefix having "v" replaced with "n" - i.e. psn:, prn: (for references) and pqn: (for qualifiers).
The code can be abbreviated a lot with the [ ] syntax by eliminating the variables for the nodes and unused variables.
Try it!

### Summary

| item | Statement node | Value node |
| p:Pxxx | | |
| | psv:Pxxx or psn:Pxxx (normalised) | |
| | | Time values |
| | | wikibase:timeValue |
| | | wikibase:timePrecision |
| | | wikibase:timeTimezone |
| | | wikibase:timeCalendarModel |
| | | Coordinate values |
| | | wikibase:geoLongitude |
| | | wikibase:geoLatitude |
| | | wikibase:geoGlobe |
| | | wikibase:geoPrecision |
| | | Quantity values |
| | | wikibase:quantityAmount |
| | | wikibase:quantityUnit |
| | | wikibase:quantityLowerBound |
| | | wikibase:quantityUpperBound |
| | | wikibase:quantityAmount |
* ↑ You can see, by example, that these 2 queries don't give exactly the same values. Some values are missing in the second one. #Humans with height > 2,25 m SELECT ?taillem ?item WHERE {?item wdt:P31 wd:Q5 ; p:P2048 [psv:P2048 ?t ] . ?t wikibase:quantityAmount ?taille . ?t wikibase:quantityUnit/p:P2370/psv:P2370 [wikibase:quantityAmount ?conversion ; wikibase:quantityUnit wd:Q11573] . BIND(?taille * ?conversion AS ?taillem). filter(?taillem > 2.25) } order by desc (?taillem) Try it! #Humans with height > 2,25 m SELECT ?taille ?item WHERE {?item wdt:P31 wd:Q5 ; p:P2048/psn:P2048 [wikibase:quantityAmount ?taille ]. filter(?taille > 2.25) } order by desc (?taille) Try it!