Last active
August 8, 2020 14:29
-
-
Save bitner/7d1f4926c497e19f3bdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION public.geocode_google(IN inaddress text, OUT address text, OUT longitude double precision, OUT latitude double precision) | |
RETURNS record AS | |
$BODY$ | |
from geopy.geocoders import GoogleV3 | |
geolocator = GoogleV3() | |
try: | |
address, (latitude, longitude) = geolocator.geocode(inaddress,timeout=1,exactly_one=True) | |
return address, longitude, latitude | |
except: | |
return None, None, None | |
$BODY$ | |
LANGUAGE plpythonu VOLATILE | |
COST 100; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment