7

Is there a simple free REST API where I can send the name or code of a country and get in return geojson data which highlights it's borders ?

I'm writing an application where I will have a changing list of countries and I have to outline their surface/borders on a openlayers map.

I've perfected/learned how to do it using sample geojson from this github but I haven't been able to find a RESTful api which serves me similar data?

Does anyone know of such a service, bonus points if I can send multiple country names at once so I don't need to make a lot of calls.

3 Answers 3

5

If you do not find any it is not difficult to set up your own. Install Geoserver and you can get geojson out from WFS with requests like

http://demo.opengeo.org/geoserver/wfs?service=wfs&version=1.0.0&request=getfeature&typename=topp:states&outputformat=application/json&propertyname=STATE_NAME,the_geom&CQL_FILTER=STATE_NAME=%27Illinois%27

You just need to install world_boundaries shapefile into your server or save it into PostGIS database and you have a pretty rest-alike service for country borders.

4

ThePlacename.com has an api that returns place borders in GeoJSON format: http://theplacename.com/restapi

0

I've perfected/learned how to do it using sample geojson from this github but I haven't been able to find a RESTful api which serves me similar data?

Why would you want this as a REST interface? A pinch of JavaScript would filter that GeoJSON file down to specific countries. Remember, GeoJSON is JSON is JavaScript, and FeatureCollections are just arrays. They are malleable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.