Grasshopper

algorithmic modeling for Rhino

Hi,

I'm currently doing a project on mapping out hotspots of a particular city relative to quantitative data such as Foursquare, FLICKR, and Twitter.  However, I am interested in FLICKR because I want to be able to use the GEOTAGGED photos and use the GEO DATA to pinpoint popular tourist/local destinations of a city, thus being able to create a 3D heat/density map. 

How will I be able to go about doing this in Grasshopper, particularly GHOWL, because I came across this plugin just a few days ago and am highly interested in using GHOWL for my project.  I am reading through the FLICKR API, but how can I use the API data and read the API in Grasshopper?

Thank you very much.

-T

Views: 2163

Replies to This Discussion

Have you sen my post on datable on this subject?  It outlines how I went about it for an upcoming set of components for gHowl that take advantage of the Flickr API.

There are effectively a few ways of doing this with the current tools or a bit of scripting since the Flickr API allows you to make requests in a REST format, but utilizing the Flickr.net API library makes it much simpler.

First and foremost, you need a Flickr API key...do you have one of those?

A great way to get to know the Flickr API is with the API Explorer.  Here is a link to the page for the flickr.photos.search method explorer: http://www.flickr.com/services/api/explore/flickr.photos.search

The cool thing about this page is that it generates the REST Http call towards the bottom.  So, here is what I did:

1. Grab the coordinates of the bounding box per Flickr API request:

bbox (Optional)
A comma-delimited list of 4 values defining the Bounding Box of the area that will be searched.

The 4 values represent the bottom-left corner of the box and the top-right corner, minimum_longitude, minimum_latitude, maximum_longitude, maximum_latitude.

Longitude has a range of -180 to 180 , latitude of -90 to 90. Defaults to -180, -90, 180, 90 if not specified.

Unlike standard photo queries, geo (or bounding box) queries will only return 250 results per page.

Geo queries require some sort of limiting agent in order to prevent the database from crying. This is basically like the check against "parameterless searches" for queries without a geo component.

A tag, for instance, is considered a limiting agent as are user defined min_date_taken and min_date_upload parameters — If no limiting factor is passed we return only photos added in the last 12 hours (though we may extend the limit in the future).

So, I went to Google Earth, picked a city (London, UK) and dropped two pins:

This gave me two locations, which I can put into the Explorer Page next to the bbox option.  Here is what I put for these two points: -0.155941,51.496768,-0.116783,51.511431

2. Check has_geo

3. In extras, type in geo 

4. Make the call!

You will see a list of responses in an XML format, these responses will be from the first page.  Geolocated photos are limited to 250 / page, so you will have to grab them page by page.

If you want to add more options (minimum upload date, maximum upload date, etc) you can do this as well)

The best is at the bottom, you get the full http call for this: http://api.flickr.com/services/rest/?method=flickr.photos.search&am...

Notice this call has some other api key, you should eventually replace this with your own.

You could copy and paste this into a browser and you will get the results with the latitude and longitude:

So this is really what you need to know to do this through GH.  Since gHowl has an XML parser component that can access files on the web, you should be able to use the same http call into this component.

Eventually, we get a response, and we need to grab the lat and lon data.  With gHowl we can map these to xyz coordinates, and generate the heatmap...this is just a linear mapping:

Attached are both the Rhino file and the Grasshopper file, as well as the image underlay.

I am working on a series of components that makes this more straightforward, but for now, this should get you started.

Attachments:

Paste here the coordinates you used for the bbox...

GH can read csv files on its own.  If you can save an XML file, then you can use the definition above, otherwise you will need to parse the CSV to find the coordinates...

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service