Community Portal

Add countries to cities/islands

Created on Tuesday 18 May 2021, 02:59

Back to task list
  • ID
  • Project
    Metabolism of Cities Data Hub
  • Status
  • Priority
  • Type
    Programming work
  • Tags
    Data Hub Priority Plan 2021 General data hub improvements
  • Assigned to
    Paul Hoekman
  • Subscribers
    Paul Hoekman

You are not logged in

Log In Register

Please join us and let's build things, together!


We should have a link between cities/islands and countries. The best way to do this is by taking the gps coordinates and checking the global country file to determine which country this is in. However, we don't want a spatial lookup every time a country is displayed, so we should also save this in the reference space itself.

Discussion and updates

New task was created

Task was assigned to Paul Hoekman

Status change: Open → In Progress

Okay, this was done. Details:

  • The country is based on the boundary of the city. The system checks if the boundary is within country boundaries and sets the country accordingly.
  • If not, the system tries to get the country based on the centroid (center coordinates) of the city. This is sometimes needed for cities on the edge of the country where we might have more precise boundaries than those on national level, and a few bits may stick out.

There was a huge pain with some cities where the query to check the country caused a database error. I am not sure what causes it but have manually skipped those (Montreal, Singapore, and Samothraki). I have added comments in case, attached. At some point this should be further debugged. I will make a task for that. In general it all works well tough.

We should also have a feature to quickly add the GPS coordinates for our cities - not the shapefile but just the location - so that the country can be set.

Status change: In Progress → Completed