# How to export a shapefile through the Wikimapia API?

I am trying to download a kml file from Wikimapia containing information on quaters (districts), the very same information that is nicely available on Wikimapia. What I want to get at the end of the day is a shapefile containing as many polygons as there are districts in Milan to use in my GIS.

This is my URL for the query I pasted in my web browser.

http://api.wikimapia.org/?function=box&key=[mykey]&lon_min=8.936&lat_min=45.282&lon_max=9.421&lat_max=45.652&format=kml&category=quarters


From this I get a tiny kml.part file, that I then rename .kml. The file doesn't open in Google Earth or QGIS. If I open it with a text editor I can just few lines of xml, but no information concerning my geometries...

Am I doing something logically wrong?

-
I cant see any solution for exporting the shapefiles from Wikimapia. Can you be more specific –  user10863 Oct 10 '12 at 11:27

The solution is to use category=5339 (instead of category=quarters) in your URL.

http://api.wikimapia.org/?function=box&key=insert_key_here&lon_min=9.05&lat_min=45.38&lon_max=9.28&lat_max=45.54&format=kml&count=1000&category=5339


This list of Wikimapia categories definitely helped out (thanks @LarsVegas).

Searching for the word 'quarters' in the list of categories did the trick.

I also added count=1000 just in case there are more than 50 quarters (the number of features returned defaults to 50 if you don't specify a count, see http://wikimapia.org/api/)

-
@Francesco if this helps you, please accept the answer. Thanks. –  Rayner Oct 10 '12 at 13:35
This worked. Thank you. –  Francesco Oct 18 '12 at 23:05

By a look at the wiki for API box I think you need to change your code either to (replace key and the coordinates with your own of course):

http://api.wikimapia.org/?function=box&bbox=37.617188,55.677586,37.70507,55.7271128format=kml&key=KEY


or

http://api.wikimapia.org/?function=box&lon_min=37.617188&lat_min=55.677586&lon_max=37.70507&lat_max=55.7271128&format=kml&key=KEY


There is also an example of how your result file is suppose to look like. Something I'm not sure about is the category. Maybe you should check the complete list so you can use an ID or try it without using this parameter to see if you get a valid result then.

-
Doesn't look any different than the URL in the question. –  Rayner Oct 5 '12 at 11:08
Posted the 2nd example twice. Edited my answer. –  LarsVegas Oct 5 '12 at 11:12
Francesco's URL is fine. I tried to get it to show those quarters in Google Earth and it just doesn't want to do it. –  Rayner Oct 5 '12 at 11:25
What happens if you leave the category parameter be? –  LarsVegas Oct 5 '12 at 11:27
One interesting thing though is 2827 (quarters) isn't on that category list. The API is in beta . . . I suppose that may have something to do with it. –  Rayner Oct 5 '12 at 11:35

Perhaps the Global Administrative Boundaries of the world would be of use also. This is a shapefile of most political districts of the world.

-