Created
October 11, 2020 18:15
-
-
Save esenthil2018/b4057211e277ae4b5b56132e1d80f43e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Flickr API - to extract the pictures containing giraffe and geo location | |
# insert your own key and secret | |
api_key = 'bb442da9177b0f782255e227f2f2cee4' | |
secret_api_key ='4cf09aea38529025' | |
fr = flickrapi.FlickrAPI(api_key, secret_api_key) | |
pset_id = '72157673330147052' | |
for photo in fr.walk_set(photoset_id=pset_id, extras="geo"): | |
print (photo.attrib['id']) | |
print (photo.attrib['latitude']) | |
print (photo.attrib['longitude']) | |
pid = [] | |
urls = [] | |
powner = [] | |
ptitle = [] | |
plat = [] | |
plong = [] | |
#descriptions = [] | |
#names = [] | |
for i, photo in enumerate(photos): | |
#print (i) | |
url = photo.get('url_c') | |
urls.append(url) | |
oname = photo.attrib['owner'] | |
powner.append(oname) | |
title = photo.attrib['title'] | |
ptitle.append(title) | |
photoID = photo.attrib['id'] | |
pid.append(photoID) | |
#print(photo.attrib['id']) | |
for photo in fr.photos.geo.getLocation(api_key=api_key,photo_id=photoID, extras="geo"): | |
#print (photo.attrib['id']) | |
#print(photo.get('id')) | |
for location in photo: | |
#print (location.attrib['latitude']) | |
lat = location.attrib['latitude'] | |
plat.append(lat) | |
#print (location.attrib['longitude']) | |
long = location.attrib['longitude'] | |
plong.append(long) | |
# get 50 urls | |
if i > 50000: | |
break | |
dtuples = list(zip(pid,powner,ptitle,urls,plat,plong)) | |
flickr_df = pd.DataFrame(dtuples, columns=['photoID','owner','title','Url','Lat','Long']) | |
flickr_df.head() | |
flickr_df.to_csv('flickr_geo_V1.csv') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment