def set_location(self, lat, lon): self.lat = lat self.lon = lon place = geocoder.opencage([lat, lon], key='bcd0f9d2b4204fbd8d7bf301df1f920a', method='reverse') self.place = "%s, %s" % (place.city, place.country)
def test_issue_292(): g = geocoder.opencage( 'AirportClinic M - MediCare Flughafen München Medizinisches Zentrum', countrycode='DE', language='de', no_annotations=1) assert g.ok
def geocode(query): key = settings.OPENCAGE_API_KEY lang = settings.LANGUAGE_CODE if query: result = geocoder.opencage(query, key=key, params={'language': lang}) result.point = Point(result.xy, srid=4326) if result.xy else None return result
def parse_location(loc_str, api_key, is_name=True): """ Input: Location name or coordinates as string Returns {'lat': <float>, 'lng': <float>} if successful otherwise None Uses https://github.com/googlemaps/google-maps-services-python """ import time, pandas, geocoder logger = setup_logger(logging.INFO) if pandas.isnull(loc_str): return {'lat': None, 'lng': None} if is_name: loc = geocoder.opencage(loc_str, key=api_key) time.sleep(1.5) # no hit if loc.latlng is None: logger.info('NO LOCATION HIT: %s' % loc_str) return {'lat': None, 'lng': None} else: return {'lat': loc.latlng[0], 'lng': loc.latlng[1]} else: assert len(loc_str) == 2 lat, lng = loc_str lat_ = float(re.sub('N|S|W|E', '', lat)) lng_ = float(re.sub('N|S|W|E', '', lng)) if re.search('W', lng): lng_ *= -1 if re.search('S', lat): lat_ *= -1 return {'lat': lat_, 'lng': lng_}
def set_location(self, lat, lon): self.lat = lat self.lon = lon place = geocoder.opencage([lat, lon], key=settings.OPENCAGE_KEY, method='reverse') self.place = "%s, %s" % (place.city, place.country)
def geocode(query, annotations=False): key = settings.OPENCAGE_API_KEY lang = settings.LANGUAGE_CODE if query: params = {'language': lang} if not annotations: params.update({'no_annotations': int(not annotations)}) result = geocoder.opencage(query, key=key, params=params) result.point = Point(result.xy, srid=4326) if result.xy else None return result
def test_opencage(): """ Expected result : https://api.opencagedata.com/geocode/v1/json?q=Ottawa,Ontario&key=YOUR-API-KEY """ g = geocoder.opencage(location) assert g.ok assert g.country == 'ca' assert g.state == 'Ontario' assert g.state_code == 'ON' assert g.city == 'Ottawa' assert g.town == 'Ottawa'
def geocode_opencage(address): time.sleep(1) logger.info(u'geocode_opencage address: ' + address) g = geocoder.opencage(address, key=GEOCODING_KEYS['OpenCage']) res = g.json logger.info('geocode: ' + json.dumps(res, indent=4)) if res['status'] == 'OK' and 'lat' in res and 'lng' in res: return [res['lat'], res['lng']] else: raise ValueError('Could not add item: ' + res['status'])
def geocode_opencage(address): time.sleep(1) logger.info(u'geocode_opencage address: '+address) g = geocoder.opencage(address, key=GEOCODING_KEYS['OpenCage']) res = g.json logger.info('geocode: '+json.dumps(res, indent=4)) if res['status'] == 'OK' and 'lat' in res and 'lng' in res: return [res['lat'], res['lng']] else: raise ValueError('Could not add item: ' + res['status'])
def test_opencage_reverse(): """ Expected result : https://api.opencagedata.com/geocode/v1/json?q=45.4215296,-75.6971930&key=YOUR-API-KEY """ g = geocoder.opencage(ottawa, method='reverse') assert g.ok assert g.country == 'ca' assert g.state == 'Ontario' assert g.state_code == 'ON' assert g.city == 'Ottawa' assert g.street == 'O\'Connor Street' assert g.housenumber == '45'
def test_opencage_paid(): # Paid API keys can be set to unlimited and have rate limit information ommitted from the response url = 'http://api.opencagedata.com/geocode/v1/json?query=The+Happy+Goat%2C+Ottawa&limit=1&key=' + os.environ.get('OPENCAGE_API_KEY') data_file = 'tests/results/opencagedata_paid.json' with requests_mock.Mocker() as mocker, open(data_file, 'r') as input: mocker.get(url, text=input.read()) result = geocoder.opencage(address) assert result.ok osm_count, fields_count = result.debug()[0] assert osm_count >= 3 assert fields_count >= 15 assert result.remaining_api_calls == 999999 assert result.limit_api_calls == 999999
def test_opencage_address(): """ Expected result : https://api.opencagedata.com/geocode/v1/json?q=The+Happy+Goat,+Ottawa&key=YOUR-API-KEY """ g = geocoder.opencage(address) assert g.ok assert g.country == 'Canada' assert g.state == 'Ontario' assert g.state_code == 'ON' assert g.city == 'Ottawa' assert g.street == 'Wilbrod Street' assert g.housenumber == '317' assert g.postal == 'K1N 6K4'
def test_opencage_address(): """ Expected result : https://api.opencagedata.com/geocode/v1/json?q=The+Happy+Goat,+Ottawa&key=YOUR-API-KEY """ g = geocoder.opencage(address) assert g.ok assert g.country == 'ca' assert g.state == 'Ontario' assert g.state_code == 'ON' assert g.city == 'Ottawa' assert g.street == 'Wilbrod Street' assert g.housenumber == '317' assert g.postal == 'K1N 6K4'
def test_opencage_address(): """ Expected result : https://api.opencagedata.com/geocode/v1/json?q=The+Happy+Goat,+Ottawa&key=YOUR-API-KEY """ g = geocoder.opencage(address) assert g.ok assert g.country == 'Canada' assert g.state == 'Ontario' assert g.state_code == 'ON' assert g.city == 'Ottawa' assert g.street == 'Wilbrod Street' assert g.housenumber == '317' assert g.postal.startswith('K1N') assert (g.remaining_api_calls > 0 and g.remaining_api_calls != 999999) assert (g.limit_api_calls > 0 and g.remaining_api_calls != 999999)
def test_opencage(): """ Expected result : https://api.opencagedata.com/geocode/v1/json?q=Ottawa,Ontario&key=YOUR-API-KEY """ g = geocoder.opencage(location) assert g.ok assert len(g) == 1 assert g.country_code == 'ca' assert g.state == 'Ontario' assert g.state_code == 'ON' assert g.city == 'Ottawa' assert g.town == 'Ottawa' osm_count, fields_count = g.debug()[0] assert osm_count >= 3 assert fields_count >= 23
def geocode(query, country='', private=False, annotations=False, multiple=False): key = SiteConfiguration.get_solo().opencage_api_key lang = settings.LANGUAGE_CODE if not query: return params = {'language': lang} if not annotations: params.update({'no_annotations': int(not annotations)}) if private: params.update({'no_record': int(private)}) if country: params.update({'countrycode': country}) result = geocoder.opencage(query, key=key, params=params, maxRows=15 if multiple else 1) logging.getLogger('PasportaServo.geo').debug( "Query: %s\n\tResult: %s\n\tConfidence: %d", query, result, result.confidence) result.point = Point(result.xy, srid=SRID) if result.xy else None return result
def pricePredict(): if request.method == "POST": print(request.form) carpet_area = float(request.form["area"]) bedrooms = float(request.form["bedrooms"]) bathrooms = int(request.form["bathrooms"]) carpet_area = int(request.form["area"]) car_parking = int(request.form["car_parking"]) transaction = (request.form["transaction"]) if transaction == "Resale" or transaction == "resale": transaction = 0.0 else: transaction = 1.0 furnishing = request.form["furnishing"] if furnishing == "Furnished": furnishing = 3 elif furnishing == "Unfurnished": furnishing = 1 else: furnishing = 2 floor = float(request.form["floor"]) total_floors = float(request.form["total_floors"]) facing = (request.form["facing"]) #get facing code for el in dic: if facing == dic[el]: facing = el #get lat and long from address json_response = opencage(request.form["location"], key='cbc71a92fe6d4b28be97142b285a3693') json_response = json_response.json lat = float(json_response["raw"]["geometry"]["lat"]) lng = float(json_response["raw"]["geometry"]["lng"]) predicted_price = predict_price([[ carpet_area, bedrooms, bathrooms, car_parking, furnishing, transaction, floor, total_floors, lat, lng, facing ]]) print("Price", predict_price) return render_template("explore.html", result=round(predicted_price[0], 2)) else: return render_template("explore.html")
def test_opencage_multi_result(): g = geocoder.opencage(location, maxRows=5) assert len(g) > 1
def ajaxer(request): if request.is_ajax: latitude = request.GET.get('Latitude') longitude = request.GET.get('Longitude') loc = latitude + "," + longitude result = geocoder.opencage([latitude, longitude], key='088559509c004bdf968fe88db705b8a8', method='reverse') pprint(latitude) pprint(longitude) #print(result.city, result.state, result.country) # url = 'http://api.openweathermap.org/data/2.5/weather?q={}&units=metric&appid=f009f5c6a0f7ab4448e65aa4b5f3f0c5' # api.openweathermap.org/data/2.5/forecast/daily?q={city name},{country code}&cnt={cnt} url = "http://api.apixu.com/v1/forecast.json?key=d55a672ed2ea413691694833181811&q=" + latitude + "+" + longitude + "&days=7" # url = 'http://api.apixu.com/v1/forecast.json?key=d55a672ed2ea413691694833181811&q={latitude}{longitude}&days=7' # url = 'http://api.apixu.com/v1/forecast.json?key=d55a672ed2ea413691694833181811&q=Bangalore&days=7' # $.getJSON("https://api.apixu.com/v1/current.json?key=32df9829b4c84bfc994230724170803&q="+lat+","+lon, function (data) city_weather = requests.get(url.format(result.city)).json() pprint(city_weather) # pprint(all_data) weather = { # 'city': city_weather['name'], # 'country': city_weather['sys']['country'], # 'temperature': city_weather['main']['temp'], # 'description': city_weather['weather'][0]['description'], # 'icon': city_weather['weather'][0]['icon'], # 'humidity': city_weather['main']['humidity'], # 'pressure': city_weather['main']['pressure'], # 'sunrise': time_converter(city_weather['sys']['sunrise']), # 'sunset': time_converter(city_weather['sys']['sunset']), # 'wind_speed': city_weather['wind']['speed'], # 'dt_txt':city_weather['list'][4]['dt_txt'] 'city': city_weather['location']['name'], 'country': city_weather['location']['country'], 'temperature_c': city_weather['current']['temp_c'], 'description': city_weather['current']['condition']['text'], 'icon': city_weather['current']['condition']['icon'], 'humidity': city_weather['current']['humidity'], 'pressure': city_weather['current']['pressure_in'], 'temperature_f': city_weather['current']['temp_f'], 'wind_speed': city_weather['current']['wind_kph'], 'dt_txt': city_weather['location']['localtime'], 'region': city_weather['location']['region'], 'all_date1': city_weather['forecast']['forecastday'][1]['date'], 'all_date2': city_weather['forecast']['forecastday'][2]['date'], 'all_date3': city_weather['forecast']['forecastday'][3]['date'], 'all_date4': city_weather['forecast']['forecastday'][4]['date'], 'all_date5': city_weather['forecast']['forecastday'][5]['date'], 'all_date6': city_weather['forecast']['forecastday'][6]['date'], 'sunrise1': city_weather['forecast']['forecastday'][1]['astro']['sunrise'], 'sunrise2': city_weather['forecast']['forecastday'][2]['astro']['sunrise'], 'sunrise3': city_weather['forecast']['forecastday'][3]['astro']['sunrise'], 'sunrise4': city_weather['forecast']['forecastday'][4]['astro']['sunrise'], 'sunrise5': city_weather['forecast']['forecastday'][5]['astro']['sunrise'], 'sunrise6': city_weather['forecast']['forecastday'][6]['astro']['sunrise'], 'sunset1': city_weather['forecast']['forecastday'][1]['astro']['sunset'], 'sunset2': city_weather['forecast']['forecastday'][2]['astro']['sunset'], 'sunset3': city_weather['forecast']['forecastday'][3]['astro']['sunset'], 'sunset4': city_weather['forecast']['forecastday'][4]['astro']['sunset'], 'sunset5': city_weather['forecast']['forecastday'][5]['astro']['sunset'], 'sunset6': city_weather['forecast']['forecastday'][6]['astro']['sunset'], 'maxtemp1': city_weather['forecast']['forecastday'][1]['day']['maxtemp_c'], 'maxtemp2': city_weather['forecast']['forecastday'][2]['day']['maxtemp_c'], 'maxtemp3': city_weather['forecast']['forecastday'][3]['day']['maxtemp_c'], 'maxtemp4': city_weather['forecast']['forecastday'][4]['day']['maxtemp_c'], 'maxtemp5': city_weather['forecast']['forecastday'][5]['day']['maxtemp_c'], 'maxtemp6': city_weather['forecast']['forecastday'][6]['day']['maxtemp_c'], 'desc1': city_weather['forecast']['forecastday'][1]['day']['condition'] ['text'], 'desc2': city_weather['forecast']['forecastday'][2]['day']['condition'] ['text'], 'desc3': city_weather['forecast']['forecastday'][3]['day']['condition'] ['text'], 'desc4': city_weather['forecast']['forecastday'][4]['day']['condition'] ['text'], 'desc5': city_weather['forecast']['forecastday'][5]['day']['condition'] ['text'], 'desc6': city_weather['forecast']['forecastday'][6]['day']['condition'] ['text'], 'icon1': city_weather['forecast']['forecastday'][1]['day']['condition'] ['icon'], 'icon2': city_weather['forecast']['forecastday'][2]['day']['condition'] ['icon'], 'icon3': city_weather['forecast']['forecastday'][3]['day']['condition'] ['icon'], 'icon4': city_weather['forecast']['forecastday'][4]['day']['condition'] ['icon'], 'icon5': city_weather['forecast']['forecastday'][5]['day']['condition'] ['icon'], 'icon6': city_weather['forecast']['forecastday'][6]['day']['condition'] ['icon'], } # forecast_date = {'1': {},'2': {},'3': {},'4': {},'5': {},'6': {},} # i = 1 # for row in forecast_date: # forecast_date[row] = city_weather['forecast']['forecastday'][i]['date'] # i += 1 # dates = { # } # pprint(forecast) #pprint(weather) #return HttpResponse() return JsonResponse(weather)
def test_opencage_reverse(): g = geocoder.opencage(ottawa, method='reverse') assert g.ok
bClient = Request(bno, headers=bypass) bnoPage = urlopen(bClient) site_parse = soup(bnoPage, 'lxml') bnoPage.close() tables = site_parse.find("table", {"class": "waffle no-grid"}) tags = tables.findAll('tr') liegen = Nominatim(user_agent='*****@*****.**') csvfile = "COVID-19_world_cases_bnoNews.csv" headers = "Country,Latitude,Longitude,Cases,New Cases,Deaths,New Deaths,Percent of Deaths,Serious & Critical,Recovered\n" curacao = geocoder.opencage("Curaçao", key='bf1344578b6f462c9183655c80b12d1e') file = open(csvfile, "w") file.write(headers) for tag in tags[8:177]: pull = tag.findAll('td') locale = geocoder.opencage(pull[0].text, key='bf1344578b6f462c9183655c80b12d1e') file.write(pull[0].text + ", " + str(locale.latlng).strip('[]') + ", " + pull[1].text.replace(',', '') + ", " + pull[2].text.replace(',', '') + ", " + pull[3].text.replace(',', '') + ", " + pull[4].text.replace(',', '') + ", " + pull[5].text + ", " + pull[6].text.replace(',', '') + ", " + pull[7].text.replace(',', '') + "\n")
def test_opencage_reverse(): """ Expected result : https://api.opencagedata.com/geocode/v1/json?q=45.4215296,-75.6971930&key=YOUR-API-KEY """ g = geocoder.opencage(ottawa, method='reverse') assert g.ok
hospital = json.load(f) outlier = {} for k, v in hospital.items(): if v["lat"] <= 24 or v["lat"] >= 50 or v["lon"] <= -125 or v["lon"] >= -66: outlier[k] = v key = "69b0b463fd204efdaff0b1c444da8d19" corrected_k = [] i = 0 j = 0 for k, v in outlier.items(): result = geocoder.opencage(v["hospital_name"], key=key) print(i) print(result.country, result.city) print(v["lat"], result.lat) print(v["lon"], result.lng) if result.country == "United States" or result.country == "United States of America": if v["lat"] != result.lat and v["lon"] != result.lng: hospital[k]["lat"] = result.lat hospital[k]["lon"] = result.lng corrected_k.append(k) print("cnt:", j) j += 1 i += 1 outlier = {k: v for k, v in outlier.items() if k not in corrected_k}
# Now, we have the 2 new columns to store the latitude and longtitude of each city # We will use opencage geocoder to retrieve the coordinates # To get results from geocoder, please be sure to register and get an API key first # Get API from: # Google Maps API # Opencage # They are free but need it to access Google Maps data df = pd.read_csv('city_temp_raw.csv') c = 0 # Sets the initial row to get the coordinates of # We will now loop through the number of cities/location as based on the file # Use the length of the city as the parameter for range() # Reference: https://opencagedata.com/tutorials/geocode-in-python for c in range(0, len(df['City'])): result = geocoder.opencage(df['City'][c], key='f9eb598460d74976b143b0b4c99bbe13') y = result.latlng[0] x = result.latlng[1] df.set_value(c, 'lat', y) df.set_value(c, 'lon', x) del x del y c += 1 # We will now save the result of the dataframe to update the coordinates # You can save the file name to anything to want, but make sure to open this file # ...for the actual plotting as it contains the coordinates df.to_csv('city_temp.csv', index=False)
def test_opencage_language_param(): """ Expected result : https://api.opencagedata.com/geocode/v1/json=Ottawa,Ontario&key=YOUR-API-KEY&language=de """ g = geocoder.opencage(location, language='de') assert 'language=de' in g.url.split('&')
key = '!!this is where you put your opencage geocoding key!!' conf_dict = {} coord_dict = {} n = 0 for i in range(range_limit): # change the value of i to collect data for country[i] country = countries[i] for candidate in candidates: lat = "" lng = "" results = "" query = candidate + "," + country n += 1 g = geocoder.opencage(query, key='6907a9aca714494297c99944e0e6a694') json_object = g.json # access confidence and city as: # json_object["confidence"] json_object["city"] try: if "city" in json_object: city = json_object["city"] confidence = json_object["confidence"] if city == candidate and confidence >= confidence_bar: if city in conf_dict.keys(): if confidence > conf_dict[city]: conf_dict[city] = confidence coord_dict[city] = [ json_object["lat"], json_object["lng"] ] else:
def test_opencage(): g = geocoder.opencage(location) assert g.ok
def test_opencage_countrycode_param(): """ Expected result: https://api.opencagedata.com/geocode/v1/json?q=Ottawa,Ontario&key=YOUR-API-KEY&countrycode=ca" """ g = geocoder.opencage(location, countrycode='ca') assert 'countrycode=ca' in g.url.split('&')
def data_cleansing(df): # Fill NA in People Moving idx = pd.isnull(df['Baseline: People Moving']) df['Baseline: People Moving'][ idx] = 100 * df[idx]['Difference'] / df[idx]['Percent Change'] idx = pd.isnull(df['Crisis: People Moving']) df['Crisis: People Moving'][ idx] = df[idx]['Difference'] + df[idx]['Baseline: People Moving'] # Fill NA in Differene and Percent Change. idx = pd.isnull(df['Difference']) df['Difference'][idx] = df['Crisis: People Moving'][idx] - df[ 'Baseline: People Moving'][idx] idx = pd.isnull(df['Percent Change']) df['Percent Change'][ idx] = df['Difference'][idx] / df['Baseline: People Moving'][idx] * 100 # Find the median of the known z-score/baseline ratio, which is used for filling NAs in z score later on. df_z_calc = df[(pd.isnull(df['Standard (Z) Score']) == False) & (df['Crisis: People Moving'] - df['Baseline: People Moving'] == df['Difference']) & (df['Standard (Z) Score'] != 0) & (df['Baseline: People Moving'] > 0)] df_z_calc['sd over baseline'] = df_z_calc['Difference'] / df_z_calc[ 'Standard (Z) Score'] / df_z_calc['Baseline: People Moving'] sd_over_baseline = df_z_calc['sd over baseline'].median() # Tackle inconsisitency in People Moving and adjust z score based on new People Moving df['Baseline: People Moving'] = df['Crisis: People Moving'] - df[ 'Difference'] idx = (pd.isnull(df['Standard (Z) Score']) | idx) & (df['Baseline: People Moving'] != 0) df['Standard (Z) Score'][idx] = df['Difference'][idx] / ( sd_over_baseline * df['Baseline: People Moving'][idx]) # Fill unknown reagions lacking name and/or locaiton code is -1 with nearest neighbor fill_unknown_regions(df, 'Starting') fill_unknown_regions(df, 'Ending') # Fill unknown regions with OpenCage map. locations = {} for i in df[(df['Starting Region Name'] == '__') | (df['Ending Region Name'] == '__')].index: if df['Starting Region Name'].loc[i] == '__': geo_info = geocoder.opencage( [ df['Starting location lat'].loc[i], df['Starting location lon'].loc[i] ], method='reverse', key='8793bad49e134015a1010a75f0bb4a52').json try: df['Starting Region Name'].loc[ i] = geo_info['city'] + '_' + geo_info[ 'county'] + '_' + geo_info['state'] except KeyError: continue if df['Starting Region Name'].loc[i] in locations.keys(): df['Starting Location'].loc[i] = locations.get( df['Starting Region Name'].loc[i]) else: df['Starting Location'].loc[i] = max( df['Starting Location'].max(), df['Ending Location'].max()) + 1 locations.update({ df['Starting Region Name'].loc[i]: df['Starting Location'].loc[i] }) if df['Ending Region Name'].loc[i] == '__': geo_info = geocoder.opencage( [ df['Ending location lat'].loc[i], df['Ending location lon'].loc[i] ], method='reverse', key='8793bad49e134015a1010a75f0bb4a52').json try: df['Ending Region Name'].loc[ i] = geo_info['city'] + '_' + geo_info[ 'county'] + '_' + geo_info['state'] except KeyError: continue if df['Ending Region Name'].loc[i] in locations.keys(): df['Ending Location'].loc[i] = locations.get( df['Ending Region Name'].loc[i]) else: df['Ending Location'].loc[i] = max( df['Starting Location'].max(), df['Ending Location'].max()) + 1 locations.update({ df['Ending Region Name'].loc[i]: df['Ending Location'].loc[i] }) # drop duplicates (in terms of starting location and ending location) by keeping only the record with highest 'Crisis: People Moving' df.sort_values(by=['Crisis: People Moving'], ascending=False, inplace=True) df.drop_duplicates(subset=['Starting Region Name', 'Ending Region Name'], inplace=True) df = df[(df['Starting Region Name'] != '__') & (df['Ending Region Name'] != '__')] # replace location code -1 with unique numbers. df_start = df[['Starting Location', 'Starting Region Name' ]].rename(columns={ 'Starting Location': 'location', 'Starting Region Name': 'region name' }) df_end = df[['Ending Location', 'Ending Region Name' ]].rename(columns={ 'Ending Location': 'location', 'Ending Region Name': 'region name' }) df_regions = pd.concat([df_start, df_end]).drop_duplicates() to_be_assigned = df_regions[df_regions['location'] == -1]['region name'] for region in to_be_assigned: df_regions['location'][df_regions['region name'] == region] = df_regions['location'].max() + 1 df_minus_1 = df[(df['Starting Location'] == -1) | (df['Ending Location'] == -1)] df = df[(df['Starting Location'] != -1) & (df['Ending Location'] != -1)] df_minus_1 = df_minus_1.merge(df_regions, how='left', left_on='Starting Region Name', right_on='region name') df_minus_1['Starting Location'] = copy(df_minus_1['location']) df_minus_1.drop(columns=['location', 'region name'], inplace=True) df_minus_1 = df_minus_1.merge(df_regions, how='left', left_on='Ending Region Name', right_on='region name') df_minus_1['Ending Location'] = copy(df_minus_1['location']) df_minus_1.drop(columns=['location', 'region name'], inplace=True) df = df.append(df_minus_1)
def test_opencage(): g = geocoder.opencage(location) print g.help()
def test_opencage_no_language_param(): """ Expected result : https://api.opencagedata.com/geocode/v1/json=Ottawa,Ontario&key=YOUR-API-KEY """ g = geocoder.opencage(location) assert 'language' not in g.url
import geocoder import json API_KEY = "###########################" coor_data = {} coor_file = open("coord.json", "w+") data = json.load(open("state_district_wise.json")) try: for state in data: for district in data[state]["districtData"]: if district == "Unknown": continue query = district + "," + state ans = geocoder.opencage(query, key=API_KEY, no_annotations=1, pretty=1).json coor_data[district] = {"lat": ans["lat"], "lng": ans["lng"]} finally: coor_file.write(json.dumps(coor_data)) coor_file.close()
def test_issue_292(): g = geocoder.opencage('AirportClinic M - MediCare Flughafen München Medizinisches Zentrum', countrycode='DE', language='de', no_annotations=1) assert g.ok