How to extract image geodata out of flickr xml image data with python?
Question: I'm researching the issue of electronic waste and I'm using this code in
flickrapi py module to get an xml data on Flickr images tagged with #e-waste.

    
    
    import flickrapi
    import xml
    api_key='myAPI key'
    api_secret ='myAPI secret'
    
    flickr = flickrapi.FlickrAPI(api_key,secret=api_secret)
    r = flickr.photos_search(tags='e-waste', has_geo="1", per_page='100')
    xml.etree.ElementTree.dump(r)
    

Running the code gives me results:

    
    
    <rsp stat="ok">
    <photos page="1" pages="58" perpage="100" total="5785">
        <photo farm="3" id="13982876982" isfamily="0" isfriend="0" ispublic="1" owner="100231432@N02" secret="2d33e5efb1" server="2903" title="Sean Gallagher, Pulitzer Photojournalist visits MSA" />
        <photo farm="8" id="13962977066" isfamily="0" isfriend="0" ispublic="1" owner="100231432@N02" secret="aeb6bc1454" server="7139" title="Sean Gallagher, Pulitzer Photojournalist visits MSA" />
    </photos>
    </rsp>
    

Now, I want to also **get printed the geo metadata that these images should
have**. How can I achieve that? I ultimately want to extract that geodata into
a csv that I can then map.

Cheers!


Answer: Extract the `id` attribute from the `<photo>` element, then pass that to
[flickr.photos.getInfo](https://www.flickr.com/services/api/flickr.photos.getInfo.html)
and extract data from the `<location>` element. The example on the
documentation page doesn't show this, but you can use the [API
Explorer](https://www.flickr.com/services/api/explore/flickr.photos.getInfo)
to see an example. Here's an example from one of my photos:

    
    
    <location latitude="38.829786" longitude="-77.52202" accuracy="14" context="0" place_id="ioKEzZ1TV7oQ55R_" woeid="2501239">
      <locality place_id="ioKEzZ1TV7oQ55R_" woeid="2501239">Sudley Springs</locality>
      <county place_id="hF2V0rlQUL9MlAlEkA" woeid="12590406">Prince William</county>
      <region place_id="pPrhG7VTUb6SbYO." woeid="2347605">Virginia</region>
      <country place_id="nz.gsghTUb4c2WAecA" woeid="23424977">United States</country>
    </location>
    

