# Places in the Bible

After taking another look at Robert Rouse's github repo I noticed a very interesting dataset that I want to play with.

```
import math
import pandas as pd
from shapely.geometry import Point
CSV_DATA_ROOT = "https://raw.githubusercontent.com/souliberty/MetaV/master/CSV/"
places = pd.read_csv("{}PlaceMarks.csv".format(CSV_DATA_ROOT))
places.head(20)
```

So what can we do with a CSV of Bible places with latitude and longitude? Map historical Bible distances from each other! Enter `shapely`

.

The first thing we have to do is convert the latitude and longitudes to points. Let's start with 2 locations that still exist today so we can easily verify our calculations, Rome and the Adriatic Sea. Google maps tells us these 2 locations are roughly 201.21 miles apart. Let's see if we can calculate the same.

```
rome = places[places['Label'] == 'Rome']
adriatic_sea = places[places['Label'] == 'Adriatic Sea']
# Now we need to turn these places into shapely points using latitude and longitude
rome_p = Point(float(rome['Latitude']), float(rome['Longitude']))
adriatic_sea_p = Point(float(adriatic_sea['Latitude']), float(adriatic_sea['Longitude']))
distance = adriatic_sea_p.distance(rome_p)
print(distance)
```

Well that doesn't look right. And it shouldn't as the distance function gives us the exact distance between the 2 points in POINTS not in miles which is what we want so let's keep cranking. To get the distance we're more familiar with (a great-circle distance) we'll need to use a slightly more complex formula. We'll be using the law of cosines I won't go into detail about the math but you can read about it on the Wikipedia.

```
distance_km = math.acos(math.sin(math.radians(rome_p.x)) * math.sin(math.radians(adriatic_sea_p.x)) +
math.cos(math.radians(rome_p.x)) * math.cos(math.radians(adriatic_sea_p.x))
* math.cos(math.radians(adriatic_sea_p.y) - math.radians(rome_p.y))) * 6371
# turn km into miles
distance = distance_km * 0.62
print("{0:.4f} km".format(distance_km))
print("{0:.4f} miles".format(distance))
```

As you can see, we get pretty close to what I got on google (let's blame the bad data on my inability to click on the exact spot correctly). So now let's make it easier to look up these locations by putting this stuff in functions.

```
def find_distance(location1, location2):
place1 = places[places['Label'] == location1]
place2 = places[places['Label'] == location2]
# Now we need to turn these places into shapely points using latitude and longitude
place1_p = Point(float(place1['Latitude']), float(place1['Longitude']))
place2_p = Point(float(place2['Latitude']), float(place2['Longitude']))
distance = place2_p.distance(place1_p)
distance_km = math.acos(math.sin(math.radians(place1_p.x)) * math.sin(math.radians(place2_p.x)) +
math.cos(math.radians(place1_p.x)) * math.cos(math.radians(place2_p.x))
* math.cos(math.radians(place2_p.y) - math.radians(place1_p.y))) * 6371
# turn km into miles
distance = distance_km * 0.62
print("{} is {:.2f} km and {:.2f} miles from {}".format(location1, distance_km, distance, location2))
find_distance('Seba', 'Uzal')
find_distance('Raamah', 'Sephar')
find_distance('Seba', 'Sephar')
find_distance('Raamah', 'Seba')
find_distance('Sinai', 'Pathros')
```

So that's working well. But what can we do with this stuff? Well I've gone ahead and purchased bibleplaces.org and over the coming weeks (time and 3 month old baby permitting) I will be building a small site that will let everyone figure out the distance between any 2 Bible locations and enhance your Bible reading by adding some context to those unknown forgotten places of the past. There will be a follow up blog post once the site is ready!

## Comments

Comments powered by Disqus