OpenStreetMap coloring map tiles by state,zipcode polygons C# WPF

I would like to create a map from C# VS2013 WPF desktop application (not web application) with OpenStreetMap on win7.

This a colored map with US states colorized differently.

This can be shown in the attachment below.

example colorized map

I am new to WPF and handle the map tiles from XAML.

It seems to be very hard to find state or zip code borders from the map tiles and do coloring on them. I know that adding a colored map tile layer on the map may be working. But I would like to see some code examples to follow so that I can implement my design based on it.

Are there some open source C# code that have done the similar things ?

Any help would be appreciated.

You should be getting the boundaries from the map, not from somebody’s rendered tiles. There are many alternative rendered tiles, and details of their styling can, and do, change with time.

I’m assuming that US zip codes are mapped as areas. In the UK, copyright on that data means that only the centre points are available.

This is the outline for Washington State: Note that it is built from parts of the boundaries of smaller entities.

Boundaries could be specified directly as a closed way, as a relation with ways as members, as here, or as a relation with ways and relations as members, as for the USA as a whole:

There are probably tools that will resolve the relations into a set of polygons (e.g. the USA has disjoint polygons, for Hawaii, Alaska, etc.). The rendering tools may well be able to render a map with these features coloured directly from the map, although they may need help in selecting the colours.

Thanks for your answer.

What kinds of tools that can find the administrative areas and do the coloring ?

How to find the state or zip-code polygon from the relation number such as 148838 for washington state ?

What is the relation number for New York State ?

Are there APIs that can find the polygons ?


    polygon_area = find_polygon(state_name, zip_code)

I am new to OSM map tiles coloring or handling issues.

Any help would be appreciated.

Cross post:

It was a multipost, which is worse than a cross post (with a USENET crosspost, you can see the answer in all the forums), but it has been closed on Stackoverflow because it violates a policy.

To get all the data, for an administrative or postal region (at least in the UK they are not closely related) by obtaining its identity and then using the full get API You will need to apply this recursively if there are any relations in the result.

Given the small number of states, the easiest way of finding the relation is to do a Nominatim map search for each one on the OSM home page.

For the postcode, you probably want to use the overpass API That might also be better for the states, as it has more powerful recursive trees.

I’m not sure that there will be tools to automatically select colours.

There are services for creating “shapefiles” from OSM data: However, in your case, you might want to run you own OSM renderer. I assume, but don’t know for certain, that that is capable of shading complex relations like US states. I assume you will need to pre-assign colours using some other algorithm.

Incidentally, starting with a requirement to use the Microsoft .NET ecosystem, may prove seriously constraining, as the cheapest solution is likely to involve modifying open source tools that have not been written in .NET languages.

Another cross-post:

The webpage of … 3id.2Ffull

is blank.

The web page I referenced is not blank. Also you you have pasted the contracted display name for the page, not the full URI that you would get if you actually followed the link.

With hot links off, the URL is

If you need Admin Boundaries of the world, goto, select the boundaries, choose an export format (lower left) and click Export.

That’s all.


There is another application for Postal Boundaries, but only for germany. Because the Postcode-data in osm is not very good.

Shortcut: All States of the USA: