Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where is the Square Kilometer attribute? #820

Open
mtekman opened this issue Nov 8, 2022 · 4 comments
Open

Where is the Square Kilometer attribute? #820

mtekman opened this issue Nov 8, 2022 · 4 comments

Comments

@mtekman
Copy link

mtekman commented Nov 8, 2022

Hello,

First of all: thank you for this incredible resource, it really unites a lot of great metrics into one place and saved me a lot of trouble.

My issue is that I can't find this attribute anywhere, and I can't calculate it reliably from the area attribute in the polygon data.

If I look at the 5 year old file, then I can see this attribute listed, but then if I take the latest file this feature is no longer listed there.

I see from the wikidata scripts that this information isn't pulled from Wikidata, is there a reason for this? Is there no attribute in Wikidata for this?

Thanks again

@ImreSamu
Copy link
Collaborator

ImreSamu commented Nov 8, 2022

Is there no attribute in Wikidata for this?

there is an attribute: Property:P2046 ( area "area occupied by an object" )
be careful: any area units allowed! ( acre, hectare, square kilometre, square mile, square centimetre, ... )

IMHO: Any wikidata property data can be easily linked via wikidata ID, but you need some programming knowledge.

@mtekman
Copy link
Author

mtekman commented Nov 8, 2022

Thanks for the speedy response!

So I've been playing a little with the SPARQL wikidata querying and I put together a little snippet that pulls country area data and apparently standardizes them into common units of area:

SELECT ?country ?countryLabel ?countryArea
WITH {
  SELECT DISTINCT *
  WHERE {
    # Instances of country
    ?country wdt:P31 wd:Q3624078.
    # Get the area of the country
    # Use the psn: prefix to normalize the values to a common unit of area
    ?country p:P2046/psn:P2046/wikibase:quantityAmount ?countryArea.
  }
} AS %i
WHERE {
  INCLUDE %i
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
} ORDER BY ASC(?countryArea)

Run here

For Andorra (470 sq km), it gives a value of 468000000 so I think the unit is meters.

Could this be used?

@ImreSamu
Copy link
Collaborator

ImreSamu commented Nov 8, 2022

Could this be used?

You can request/review a query here: https://www.wikidata.org/wiki/Wikidata:Request_a_query
( for a perfect query ( with area units ) )

IMHO: there are multiple lines (values) for some country.

@mtekman
Copy link
Author

mtekman commented Nov 8, 2022

Thank's I've posted there for review+feedback, and then if successful - I'll try to make a PR against the query_template in the fetch_wikidata.py script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants