File size: 1,476 Bytes
49c9801
7316a14
 
6961bab
99d5451
7316a14
99d5451
 
 
49c9801
7316a14
b71a362
 
 
 
7316a14
0fda97d
 
9f3256a
f1f31d2
49c9801
0fda97d
 
 
 
 
 
 
67a3177
b71a362
 
 
 
 
 
 
 
 
 
 
 
 
0fda97d
 
 
49c9801
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import gradio as gr
from whereabouts.utils import download
from whereabouts.Matcher import Matcher

# download the various address databases
download('au_all_sm', 'saunteringcat/whereabouts-db')
download('au_all_lg', 'saunteringcat/whereabouts-db')
download('au_vic_lg', 'saunteringcat/whereabouts-db')
download('au_nsw_lg', 'saunteringcat/whereabouts-db')

# create a matcher object
matcher1 = Matcher('au_all_sm')
matcher2 = Matcher('au_all_lg')
matcher3 = Matcher('au_vic_lg')
matcher4 = Matcher('au_all_sm')

# function to geocode results
def geocode(addresses):
    address_list = addresses.split('\n')
    return matcher1.geocode(address_list)

text_input = gr.Textbox(lines=2, label="Addresses to geocode (one row per address)")
json_output = gr.JSON(label="Output JSON data")

interface_geocoder = gr.Interface(
    fn=geocode,
    inputs=[text_input],
    outputs=[json_output],
    title="Geocode addresses using whereabouts",
    description="""
    Whereabouts is a freely available open-source geocoding package for Python. Currently it supports geocoding of Australian addresses, with more countries being added.
    This demo shows whereabouts in action. 

    The code is available on github:
    https://www.github.com/ajl2718/whereabouts

    Or you can install it using as follows
    ```
    pip install whereabouts
    python -m whereabouts download au_all_sm
    ```
    """
)

demo = gr.TabbedInterface([interface_geocoder], ["Geocoding"])
demo.launch()