Search code examples
coordinateskmlregion

Latlonaltbox for an entire country


I'm trying to create a region which covers Sweden. In the Region i placed a LatLonAltBox but I'm not sure what coordinates to put in. I've read the KML Reference guide on developer.google.com but it didn't make me any wiser.

Can someone explain how to look up the coordinates and show which coordinate goes where.

<LatLonBox>
    <north>90.0</north>
    <south>-90.0</south>
    <west>-180.0</west>
    <east>180.0</east>
</LatLonBox>

Solution

  • The <LatLonAltBox> should contain the max and min bounds for the given region such that north is the northern-most latitude, south is the southern-most latitude, east is the eastern-most longitude, and west is the western-most longitude.

    There are two ways to create a Region for a given area or country:

    1) One way is to open the world country KML overlay in Google Earth then copy the country feature (E.g. Sweden). This approach will extract the exact coordinates of the region.

    World Countries as Polygons. Next generation
    https://productforums.google.com/d/msg/gec-tools/rNjNRYbaWSI/5x5vfgxc0w0J

    To copy the Sweden geometry, press Ctrl-F to search for Sweden then right-mouse click on the placemark and select 'Copy'. This copies the KML into the clipboard.

    Next visit the Bounding Box tool and paste the polygon for Sweden into the text box.

    The generated line marks the 4-corner boundary points of Sweden in longitude-latitude pairs:

    <coordinates>
        11.11333,55.34,0
        11.11333,69.0603,0
        24.16701,69.0603,0
        24.16701,55.34,0
        11.11333,55.34,0 
    </coordinates>
    

    To make it readable you should insert new lines after each longitude-latitude pair. Now pick the largest and smallest longitude: 24.16701, 11.11 and largest/smallest latitude values: 69.0603, 55.34.

    Next, insert those values in appropriate tags in LatLonAltBox element as shown below:

    <Region>
      <LatLonAltBox>
        <north>69.0603</north>
        <south>55.34</south>
        <west>24.16701</west>
        <east>11.11</east>
      </LatLonAltBox>
    </Region>
    

    2) To create an arbitrary region In Google Earth there is a trick to create an ImageOverlay over the particular region on the map. Follow these steps:

    • In Add menu, click 'Image Overlay'.
    • Click 'Browse...' and pick any image
    • Stretch the image to cover the bounds of the particular region. NOTE: You may have to make the image semi-transparent to see the underlying map.
    • Click Location tab to see the bounds of the region.
    • When done click "OK" to save the image overlay.
    • Right-mouse click on the created image overlay, select "copy", and paste KML into a text editor.
    • The <LatLonBox> of the GroundOverlay (aka ImageOverlay) will be the values needed for a Region's LatLonAltBox. Rename element LatLonBox to LatLonAltBox and copy/paste into the Region of your target KML.