I'm looking for an api/service/db that contains the surface area of every city in the world.

For example, http://en.wikipedia.org/wiki/London, the box on the right contains that information.

I've searched but was unable to found anything useful. Google doesn't seems to have any API for that and I don't want to parse Wikipedia. Even paid services are fine!

  • Welcome to GIS SE. Please can you be more specific. What exactly do you mean by "surface area"? What exactly is "the box on the right"? Please use the edit button to modify your question. – Martin F Jan 30 '15 at 4:52
  • I mean the surface area (ie, London Urban is 671.0 sq mi) and the box on the right is well, that box on the right that contains the data about the wikipedia entry (ie, for cities contains, geo details, population, administrative info etc...). – GneGneGne Feb 17 '15 at 10:41

You don't actually need to parse Wikipedia. It's already parsed and structured as Linked Open Data by DBPedia.

For instance, you can get the area of London with this HTTP query:


Corresponding to (SPARQL syntax):

PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
SELECT ?areaTotalKm2
     :London dbpedia2:areaTotalKm ?areaTotalKm2

Giving you this JSON result:

{ "head": { "link": [], "vars": ["areaTotalKm2"] },
  "results": { "distinct": false, "ordered": true, "bindings": [
    { "areaTotalKm2": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "1572" }} ] } }

And that's what you need to parse.

However, if you try with Paris, you won't get the area from the property areaTotalKm (weird!). You actually need to query several (optional) area properties to increase the effectiveness of your query.

This is a more generic version of the aforementioned query:

PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbp2: <http://dbpedia.org/ontology/> 
PREFIX pp: <http://dbpedia.org/ontology/PopulatedPlace/>

SELECT ?areaTotalKm2 ?areaTotalm2 ?area
    OPTIONAL { :Paris pp:area ?area } 
    OPTIONAL { :Paris dbp2:areaTotal ?areaTotalm2 }
    OPTIONAL { :Paris dbpedia2:areaTotalKm ?areaTotalKm2 }

Try your own queries at http://dbpedia.org/snorql/

  • For place names with spaces, use an underscore. But don't expect to get a lot of hits. "Reno" returns nothing. "Jalalabad" returns nothing. Roughly 90% of the place names I check in this manner come up blank. – argyle Dec 29 '16 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.