mattritchey commited on
Commit
b40c740
1 Parent(s): 43ed1d9

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +45 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Tue Feb 7 12:41:28 2023
4
+
5
+ @author: mritchey
6
+ """
7
+
8
+ import gradio as gr
9
+
10
+ def greet(name):
11
+ return "Hello " + name + "!"
12
+
13
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
14
+
15
+ demo.launch()
16
+
17
+
18
+ #Lat Lon
19
+ import gradio as gr
20
+ import streamlit as st
21
+ import pandas as pd
22
+ from geopy.extra.rate_limiter import RateLimiter
23
+ from geopy.geocoders import Nominatim
24
+
25
+ def geocode(address):
26
+ try:
27
+ address2 = address.replace(' ', '+').replace(',', '%2C')
28
+ df = pd.read_json(
29
+ f'https://geocoding.geo.census.gov/geocoder/locations/onelineaddress?address={address2}&benchmark=2020&format=json')
30
+ results = df.iloc[:1, 0][0][0]['coordinates']
31
+ lat, lon = results['y'], results['x']
32
+ except:
33
+ geolocator = Nominatim(user_agent="GTA Lookup")
34
+ geocode = RateLimiter(geolocator.geocode, min_delay_seconds=1)
35
+ location = geolocator.geocode(address)
36
+ lat, lon = location.latitude, location.longitude
37
+ return f'{round(lat,7)}, {round(lon,7)}'
38
+
39
+ with gr.Blocks() as demo:
40
+ address = gr.Textbox(label="Address")
41
+ output = gr.Textbox(label="Lat, Lon")
42
+ greet_btn = gr.Button("Get Lat, Lon")
43
+ greet_btn.click(fn=geocode, inputs=address, outputs=output)
44
+
45
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ geopy==2.2.0
2
+ gradio==3.17.1
3
+ pandas==1.5.2
4
+ streamlit==1.13.0