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: http://www.openstreetmap.org/relation/165479 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: http://www.openstreetmap.org/relation/148838

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 ?

Example,

    polygon_area = find_polygon(state_name, zip_code)
    polygon_area.doColoring("red")

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

Any help would be appreciated.

Cross post: http://stackoverflow.com/questions/34107754/openstreetmap-coloring-the-map-tiles-by-state-zip-code-polygons-from-c-sharp-vs

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 http://wiki.openstreetmap.org/wiki/API_v0.6#Full:GET.2Fapi.2F0.6.2F.5Bway.7Crelation.5D.2F.23id.2Ffull 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 http://wiki.openstreetmap.org/wiki/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: http://wiki.openstreetmap.org/wiki/Shapefiles 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: https://gis.stackexchange.com/questions/172790/openstreetmap-coloring-the-map-tiles-by-state-zip-code-polygons-from-c-vs-2013

Thanks,
The webpage of
http://wiki.openstreetmap.org/wiki/API_ … 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

http://wiki.openstreetmap.org/wiki/API_v0.6#Full:_GET_.2Fapi.2F0.6.2F.5Bway.7Crelation.5D.2F.23id.2Ffull

If you need Admin Boundaries of the world, goto https://osm.wno-edv-service.de/boundaries, select the boundaries, choose an export format (lower left) and click Export.

That’s all.

Regards
walter

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:
https://osm.wno-edv-service.de/boundaries?zoom=3&lat=43.50488&lon=-124.45835&layers=0BT&selected=148838_161950_1116270_162018_161646_165475_161961_165794_162110_162069_162050_161957_306001_166563_162116_122586_161816_161650_161644_161655_224922_63512_162112_61315_165789_165471_161943_161638_162115_161648_165473_67213_224951_162014_61320_224045_161653_162061_161645_165476_162109_392915_224040_161652_161838_114690_161993_60759_224042_165479_162068_165466_161991