Skip to content

Commit

Permalink
start geocoding ancient samples
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmeaton committed Nov 12, 2020
1 parent 729d50e commit a740d08
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
34 changes: 16 additions & 18 deletions docs/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,26 @@ geocoding can be provided afterwards if desired "Country:Province:Foci".

Place names should be compatible with Nominatim as implemented in GeoPy.

```python
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="plague-phylogeography")
place_name = "Armenia:Shirak Province"
country_address = place_name.split(":")[0]
province_address = ":".join(place_name.split(":")[0:2])

# Geocode at country level
location = geolocator.geocode(country_address, language="en",)
print(location.address)
> 'Armenia'
print(location.latitude, location.longitude)
Example: Country

```bash
python workflow/scripts/geocode.py "Armenia"
```

> Armenia
> 40.7696272 44.6736646
# Geocode at province level
location = geolocator.geocode(province_address, language="en",)
print(location.address)
> 'Shirak Province, Armenia'
print(location.latitude, location.longitude)
> 40.918594 43.8403536
Example: Province

```bash
python workflow/scripts/geocode.py "Armenia:Shirak Province"
```

> Armenia
> 40.7696272 44.6736646
> Shirak Province, Armenia
> 40.918594 43.8403536
## Genomic Alignment

### Modern Assembly Remote
Expand Down
Binary file modified results/sqlite_db/yersinia_pestis_db.sqlite
Binary file not shown.
21 changes: 21 additions & 0 deletions workflow/scripts/geocode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Module Import
import sys
from geopy.geocoders import Nominatim

args = sys.argv
place_name = args[1]

geolocator = Nominatim(user_agent="plague-phylogeography")
country_address = place_name.split(":")[0]
province_address = ":".join(place_name.split(":")[0:2])

# Geocode at country level
location = geolocator.geocode(country_address, language="en",)
print(location.address)
print(location.latitude, location.longitude)

# Geocode at province level
if len(place_name.split(":")) > 1:
location = geolocator.geocode(province_address, language="en",)
print(location.address)
print(location.latitude, location.longitude)

0 comments on commit a740d08

Please sign in to comment.