Using Google Maps, I'd like to create draggable polygons (on the fly) of country boundaries (they don't need to be particularly precise). Something similar to this, but for countries. So I want the boundaries in decimal degrees, but I can only find the data in .shp or kml/kmz files via sites like:



... but I'm unsure about how I go about extracting decimal coordinates from those data sources.

How do I solve this problem?


The application you linked uses a background file http://econym.org.uk/gmap/states.xml for the coordinates with the following content:

 <state name="Wyoming" colour="#ff0088">
 <point lat="41.0037" lng="-104.0556"/>
 <point lat="44.9949" lng="-104.0584"/>
 <point lat="44.9998" lng="-111.0539"/>
 <point lat="40.9986" lng="-111.0457"/>
 <point lat="41.0006" lng="-104.0556"/>

You can load the shapefiles from Natural Earth into QGIS, and save them as KML in EPSG:4326 (that's the degree format you want)

The border information inside the KML file looks like:

  <Polygon><outerBoundaryIs><LinearRing><coordinates>166.318054,-78.314743 166.290253,-78.310562 166.142761,-78.278076 166.11972,-78.270294 166.098358,-78.255569 166.140533,-78.237808 166.160858,-78.232239 166.188873,-78.220291 166.196686,-78.213913 166.198303,-78.207245 166.188324,-78.173355 166.183899,-78.166397 166.165558,-78.160019 166.13974,-78.154724 166.112213,-78.150558 166.089447,-78.142517 166.072754,-78.135025 166.063873,-78.121124 166.065552,-78.114746 166.08136,-78.101959 166.105804,-78.098068 166.134735,-78.100845 166.279694,-78.115005 166.408051,-78.137802 166.60141,-78.166397 166.686127,-78.177505 166.752228,-78.20668 166.76944,-78.214447 166.77417,-78.221115 166.766663,-78.227524 166.74527,-78.239746 166.606689,-78.262222 166.506104,-78.27446 166.434692,-78.284454 166.414703,-78.290024 166.372528,-78.308075 166.352203,-78.313629 166.318054,-78.314743</coordinates></LinearRing></outerBoundaryIs></Polygon>

So you have to do a bit of text processing to get the coordinates from one format to the other.

| improve this answer | |

Decimal degrees is not depended on file format but on projection system. The files you have are already in decimal degrees WGS84 projection system.

Google can read kml files and display them on map. For google maps api see https://developers.google.com/maps/documentation/javascript/layers#KMLLayers

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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