Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
ajl2718
commited on
Commit
·
c4e3285
1
Parent(s):
33e1b6a
Update with options for US states
Browse files
app.py
CHANGED
|
@@ -7,12 +7,16 @@ download('au_all_sm', 'saunteringcat/whereabouts-db')
|
|
| 7 |
download('au_all_lg', 'saunteringcat/whereabouts-db')
|
| 8 |
download('au_vic_lg', 'saunteringcat/whereabouts-db')
|
| 9 |
download('au_nsw_lg', 'saunteringcat/whereabouts-db')
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# create a matcher object
|
| 12 |
matcher1 = Matcher('au_all_sm')
|
| 13 |
matcher2 = Matcher('au_all_lg')
|
| 14 |
matcher3 = Matcher('au_vic_lg')
|
| 15 |
matcher4 = Matcher('au_nsw_lg')
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# function to geocode results
|
| 18 |
def geocode(addresses, db_name='au_all_sm', how='standard'):
|
|
@@ -24,6 +28,10 @@ def geocode(addresses, db_name='au_all_sm', how='standard'):
|
|
| 24 |
matcher = matcher3
|
| 25 |
elif db_name == 'au_nsw_lg':
|
| 26 |
matcher = matcher4
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
address_list = addresses.split('\n')
|
| 28 |
return matcher.geocode(address_list, how=how)
|
| 29 |
|
|
@@ -40,20 +48,24 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 40 |
gr.Markdown("Fast, accurate open source geocoding in Python")
|
| 41 |
gr.Markdown("""
|
| 42 |
[whereabouts](https://www.github.com/ajl2718/whereabouts) is an open source package for Python for fast and accurate geocoding within
|
| 43 |
-
your own environment. It currently supports geocoding for
|
|
|
|
|
|
|
| 44 |
gr.Markdown("""
|
| 45 |
```
|
| 46 |
pip install whereabouts
|
| 47 |
-
python -m whereabouts download
|
| 48 |
```
|
| 49 |
-
This demo shows whereabouts
|
| 50 |
""")
|
| 51 |
with gr.Row():
|
| 52 |
with gr.Column():
|
| 53 |
dropdown_choice = gr.Dropdown(choices=[("Australia - Small", "au_all_sm"),
|
| 54 |
("Australia - Large", "au_all_lg"),
|
| 55 |
("Victoria, Australia - Large", "au_vic_lg"),
|
| 56 |
-
("New South Wales, Australia - Large", "au_nsw_lg")
|
|
|
|
|
|
|
| 57 |
value="au_all_sm",
|
| 58 |
multiselect=False,
|
| 59 |
label="Database",
|
|
|
|
| 7 |
download('au_all_lg', 'saunteringcat/whereabouts-db')
|
| 8 |
download('au_vic_lg', 'saunteringcat/whereabouts-db')
|
| 9 |
download('au_nsw_lg', 'saunteringcat/whereabouts-db')
|
| 10 |
+
download('us_ca_sm', 'saunteringcat/whereabouts-db')
|
| 11 |
+
download('us_ma_sm', 'saunteringcat/whereabouts-db')
|
| 12 |
|
| 13 |
# create a matcher object
|
| 14 |
matcher1 = Matcher('au_all_sm')
|
| 15 |
matcher2 = Matcher('au_all_lg')
|
| 16 |
matcher3 = Matcher('au_vic_lg')
|
| 17 |
matcher4 = Matcher('au_nsw_lg')
|
| 18 |
+
matcher5 = Matcher('us_ca_sm')
|
| 19 |
+
matcher6 = Matcher('us_ma_sm')
|
| 20 |
|
| 21 |
# function to geocode results
|
| 22 |
def geocode(addresses, db_name='au_all_sm', how='standard'):
|
|
|
|
| 28 |
matcher = matcher3
|
| 29 |
elif db_name == 'au_nsw_lg':
|
| 30 |
matcher = matcher4
|
| 31 |
+
elif db_name == 'us_ca_sm':
|
| 32 |
+
matcher = matcher5
|
| 33 |
+
elif db_name == 'us_ma_sm':
|
| 34 |
+
matcher = matcher6
|
| 35 |
address_list = addresses.split('\n')
|
| 36 |
return matcher.geocode(address_list, how=how)
|
| 37 |
|
|
|
|
| 48 |
gr.Markdown("Fast, accurate open source geocoding in Python")
|
| 49 |
gr.Markdown("""
|
| 50 |
[whereabouts](https://www.github.com/ajl2718/whereabouts) is an open source package for Python for fast and accurate geocoding within
|
| 51 |
+
your own environment. It currently supports geocoding for all of Australia with some US states currently being built using OpenAddresses.
|
| 52 |
+
|
| 53 |
+
It uses duckDB to geocode 100s - 1000s of addresses per second based on an algorithm from [this paper](https://arxiv.org/abs/1708.01402)""")
|
| 54 |
gr.Markdown("""
|
| 55 |
```
|
| 56 |
pip install whereabouts
|
| 57 |
+
python -m whereabouts download us_ca_sm
|
| 58 |
```
|
| 59 |
+
This demo shows whereabouts with some example databases.
|
| 60 |
""")
|
| 61 |
with gr.Row():
|
| 62 |
with gr.Column():
|
| 63 |
dropdown_choice = gr.Dropdown(choices=[("Australia - Small", "au_all_sm"),
|
| 64 |
("Australia - Large", "au_all_lg"),
|
| 65 |
("Victoria, Australia - Large", "au_vic_lg"),
|
| 66 |
+
("New South Wales, Australia - Large", "au_nsw_lg"),
|
| 67 |
+
("California - Small", "us_ca_sm"),
|
| 68 |
+
("Massachusetts - Small", "us_ma_sm")],
|
| 69 |
value="au_all_sm",
|
| 70 |
multiselect=False,
|
| 71 |
label="Database",
|