Make a Choropleth Map for dummies

Hello :slight_smile:

First, excuse me if my explanations are confused, I’m a neophyte with OSM data and geomatic in general.

I am trying to make a Choropleth Map of Spain in order to see for each city some data:
For exemple:

  • Display the city in green if there are more men than women in the city
  • Else, display the city in red

To do this, I would like to have a GeoJSON file with the boundaries of each city, and then display the GeoJSON file with Openlayers.

Now, I have a list of OSM relations corresponding to each city in Spain but I don’t know what to do now.
In your opinion how could I create this GeoJSON file ?

Is there another way to make a choropleth map (for a city scale) ?

Thank you for your help ! :slight_smile:
aGlumLieu

Maybe some hints aare at help.osm.org … searching for choropleth gaves a result:

https://help.openstreetmap.org/questions/8982/how-to-do-color-coding-for-states-in-openstreetmaps

Thank you stephan75 !
Actually, it was not what I was looking for : I know how to create my GeoJSON file of administrative boundaries for a country scale, but not for a city scale.

I tried another method :

I start from a .osm file of spain (geofabrik.de)
I use “osmosis” to filter data just to take the right administrative boundaries but I have some trouble.

I made this request:

When I try to display the filtered file with Maperitive I get something like this:

I am not able to get all the boundaries: For each admin_level that I try, the boundaries who are sea-side or ocean-side do not appear.

How you explain that ? Did I do something wrong ?


Another example: If I extract only the country borders of Spain

I get this :

I’m not able to get all the boundary, and I can’t explain it … :confused:

Thank you all in advance :slight_smile: !

Probably boundaries are missing those members which are also coastlines but it is just a guess.

OSM model of handling boundaries with relations is theoretically ingenious. Only troubles are that relations tend to go broken and it is hard to build valid polygons from the relations for further use. Administrative boundaries are so widely used that there might be place for a service which builds and validates the boundaries periodically and saves them to for example shapefiles. There is already such a system running for creating land polygons http://openstreetmapdata.com/data/land-polygons and coastlines http://openstreetmapdata.com/data/coastlines
and a similar service for preprocessing admin boundaries would be nice to have till OSM starts to handle polygons better http://wiki.openstreetmap.org/wiki/The_Future_of_Areas.

Would the NUTS3 areas suit for your purpose http://forum.openstreetmap.org/viewtopic.php?id=24858 ?. However, I fear that they do not go to municipality level. IGN seems to have an open WFS service but if I interpret it right it contains also only NUTS3 regions.

The GetCapabilities document of the IGN service is at
http://www.idee.es/IGN-WFS-EGM/ogcwebservice?service=WFS&version=1.1.0&request=GetCapabilities
Kosmo GIS has lots of Spanish GIS servers in the WFS server menu, try if some of those delivers also municipality borders. Kosmo is at http://opengis.es/ Some of the preloaded server addresses seem to be old. Ask from the Kosmo mailing list about working ones.

IMHO it is **not ** a so good idea to use Maperitive as a control rendering tool to see whether your filtered data is complete or not, unless you are very familiar with Maperitive’s rendering rule style files.

Try to load your filtered OSM data in JOSM to see all elements and the remaining tags on each element.

I hope your OSM file is not to big for that.

Thanks for both of you :slight_smile: !

@JRA : I tried to filter my data with administrative boundaries and coastline, but the result is not as expected.
Thanks for your explanations of the OSM model, It’s really helpfull for a neophyte :slight_smile:
NUTS3 areas would suit perfectly for what I want to do, but I hope achieving a clean city scale! If I notable to do it, I will use NUTS3 .

@stephan75: Your right I’m a beginner with Maperitive, thanks for the advice !

@Both: I think I have found a solution.

There is a great tool (made by jocelynj) which extract an OSM relation perfectly, and convert it in GeoJson, Poly, Jpg, WKT.
This tools is available on Github (https://github.com/jocelynj/osm-polygons-generation)

I’m trying to host this tool in order to make all the request I need. As I have a list of each city (and the ID of its relation), I think it would suit perfectly to my project!

How I want to proceed :

1 - Make my 8000 request, one for each relation ID in my list ( one ID = one city).
Extract the resulat as GeoJSON files.

  1. In order to reduce the weight of the GeoJSON files, I make a script (not finished yet) which cut the coordinates with a precision of 3 decimals (42.438 instead of 42.438139300000003)

  2. Use a script like MapShaper to reduce properly the number of used points

  3. Then, we’ll see

I will show you the result (good or bad) if your interested :slight_smile:

Ps: I have some trouble to use jocelynj’s tools: All the files of the project are in .py, and I don’t how to host it on my computer and display it on the WebBrowser. I’m going to open a new topic on the forum to ask help !