Coordinates

When I am out and about in our beautiful nick of the woods I take photoes as often as I don’t forget to shlepp the camera. Currently I am working on a little collection of landscape pics that work nicely as desktops.

Late afternoon winter-skies near my home

Late afternoon winter-skies near my home

I would also like to get people interested in our neighbouring Kellerwald National Park and provide those who are interested with coordinates linked to the pictures.

In the absence of a GPS unit, which I currently can’t afford, I have to take those cordinates off an Ordinance Survey map that of course gives them in the traditional notation of Degrees + Minutes + Seconds adjusted to Potsdam Datum.

For a street address you can do a reverse geocode on Google Maps. Alas there are not a lot of street addresses in the middle of a National Park. Map and arithmetic will have to do.

Conversion is easy. The formula is Degrees+(Minutes / 60)+(Seconds / 3600) and, you guessed it, I have a little script that can do the work.

Meet geodumper:

#!/bin/bash


# read the cords from stdin and
# store them in array
read -e -p "Lat: " -a latdump
read -e -p "Lon: " -a londump


# send the values for minutes and seconds through bc
# with precision set to 6 decimal places
declat=$(echo "scale=6; (${latdump[2]}/60)+(${latdump[3]}/3600)" | bc)
declon=$(echo "scale=6; (${londump[2]}/60)+(${londump[3]}/3600)" | bc)


# southern lats and western lons need to
# be expressed as negative values
if [[ ${latdump[0]} == 's' ]]
then
latdump[1]=$((${latdump[1]} * -1))
fi
if [[ ${londump[0]} == 'w' ]]
then
londump[1]=$((${londump[1]} * -1))
fi

# concat and dump to stdout
echo "${latdump[1]}$declat ${londump[1]}$declon"
exit;

Usage:
At the "Lat" prompt enter n or s followed by Degrees Minutes Seconds separated by white space. Same for the "Lon" prompt but with e or w before Degrees Minutes Seconds

Example:
Lat: n 51 10 9
Lon: e 8 8 24

Easy as pie and the result is weapons grade – if you can read coords off a map.

Advertisements

About dozykraut

Proud member of Hillbilly's on Linux, promoting open source redneckism in remote parts of the Milky Way.
This entry was posted in Bash and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s