Mapping Restaurant Grades

Today I took up a quick challenge to see if I could map NYC's restaurant grades by zip code, and whether it would be interesting.

I gave myself 50 minutes, and it took about 60. Answers: 1) Yes and 2) doesn't seem to be.

Great analysis and other maps I really like on this front are already out there from Dan Nguyen and Steven Romalewski.

For me, it was more a data-map-time challenge to myself.

Below are my quick proof-of-concept (or no proof!) maps. There aren't any legends on them yet, but the color gradients indicate the number of restaurants getting that grade as a percentage of all the restaurants in the zip code (0-2-4-6-8-10%+).

Grade A map

Grade B map

Grade C map

See any patterns? I don't ... yet.

But I did learn how to take a whole bunch of records and run a couple of aggregations and merges in Fusion Tables to actually visualize them. In about an hour.

UPDATE: Because some folks have asked: The sum includes all restaruants in the zip code, including those with "Pending" grades and those that haven't been inspected, which is the vast majority in many zip codes.

UPDATE2: Pulled together key parts of the twexchange using Storify, below.

UPDATE3: Steven Romalewski's look at a Wall Street Journal story let me to realize that even though only a small fraction of the restaurants in the data set have letter grades, almost all of them have a "score" -- which means I ought to re-analyze based on that column instead (which I'll do tomorrow).

 

View "The Restaurant Grade Challenge & Chat" on Storify

Playing with SeeClickFix

I found out yesterday that every report collected by SeeClickFix -- from pothole to trash pile -- is openly available via their widgets and an API.

That is pretty cool. It means that anyone who contributes online, whith their phone or via a SeeClickFix interface, such as the embedded one below, adds to a communal set of civic issues.

And if the 311 folks are watching and responding -- like they are in San Francisco -- then it actually can result in civic, or at least municipal, action.

So when will New York City move to a more open 311 reporting system?

Allowing Cross-Domain Access in Sinatra

I've been trying to make a little Sinatra app that accepts a "GET" request and sends back some JSON. But I kept getting a version of this error in my JavaScript console:

Origin http://domain.com is not allowed by Access-Control-Allow-Origin

Eventually I learned this was because I was making AJAX requests from one domain to another, which is generally not allowed for very good security reasons. That is, unless you explicitly allow it on the server side.

Naturally, Sinatra provides a ridiculously easy way to do this, which is explained extremely well by Functional Objects. Just add this line in the route somewhere before the result is sent to the requester:

response['Access-Control-Allow-Origin'] = 'http://domain.com'

To grant access to everyone, it's

response['Access-Control-Allow-Origin'] = '*'

I am so glad to see those errors disappear.

Turning PDF Charts Into Usable Data

Someone once opined that nothing set back information exchange more than the fax machine.

For data, I'd rank PDFs as a close contender.

Tonight I became convinced that I needed to begin pulling City of New York numbers out of a PDF chart by hand (I'll share the chart once the story comes out), or plunk down $100 for some conversion software.

Then, through this blog post, I discovered this online conversion service from Nitro. For free. 

It took a few minutes for it to convert ... in fact I thought it didn't work. But then, it appeared in my email box: A perfect Excel file, correctly formatted, funky columns and all. Whew.

Now if NYC.gov would post this info in a more data-friendly format, that'd be really fantastic.

Custom Maps a la Mapping L.A.

I'm pretty thrilled about this. I've managed to quickly whip together a Google map of NYC public schools using style changes, custom icons and data from the NYC DataMine. I'll share how I did it in a longer post soonest.

Full admiration of and inspriation from the Mapping L.A. folks, and their great neighborhood maps.

This table uses iFrame, which isn't supported on your browser. </iframe

Drawing Data with Processing

Dipping my toes into making drawings from data.

I've started into Jer Thorp's great introduction, in which he walks you through pulling a column of numbers from a Google spreadsheet into some neat drawings. In this case, the data are a set of numbers he asked of his Twitter followers. Below, I've plotted the frequency of numbers from 0 to 100 as a bar chart.

Numbers, from 0-100, picked out of the air by @blprnt's Twitter followers. 17, 37 and 42 were most common.

Jer even provides a Processing sketch you can download to grab numbers from simple Google spreadsheets. Nice.

Painting With Grass

"I'm painting with grass!" said my 5-year-old when she tried the app below.

Exactly!

"Can I make it red?"

I'll get right on that!

Click and drag in the box to draw. Then type r for red, b for blue, g for green. c clears it.

Update: p is for purple, as requested.

[The content that should be here uses "iframe," which isn't supported either by your browser or this server.]

The Processing code for this is here.

Originally written during Jer Thorp's Processing workshop.

Drawing Using Processing

Yesterday I took a Processing workshop from the brilliant and talented Jer Thorp. I learned a ton about programming in general, programming in Processing, coding visuals and the concept of Perlin landscapes.

Today, I figured out how to put my Processing experiments online using Processing.js. A sample is below (requires a newish, HTML5-capable browser). 

More to come!

This table uses iFrame, which isn't supported on your browser.

Gem Info Right Under My Nose

This is probably the most useful thing I learned today. 

As a ruby newbie, I'm always looking for documentation for stuff, including information on the "gems" -- or little extra programs others have built -- I've installed on my computer. I didn't realize there was a trove of that info actually sitting locally on my computer.

Thanks to a post by Corey Ehmke, I now know how to see it:

You can see what gems are installed on your local system using gem list in Terminal, but did you know that there's an even better way?

Try this instead: gem server

This starts a WEBrick instance running. Fire up the browser of your choice and navigate to localhost:8808. You'll see a page that not only shows a list of the gems that are installed, but also provides quick and easy access to each gem's RDoc [documentation] and home page.

Very cool. Extremely useful.

Floating Point Results in Ruby

Sometimes it's the little things.

Today I couldn't figure out the syntax that would tell Ruby to give me a fraction result -- that is, a floating-point answer instead of an integer. 

> 5/3

 => 1 

The rule is that one of the numbers has to be floating point to get a floating point result. And if none is, you make one so! Adding .to_f (to float) makes the 3 into 3.0000000 ... and we're set.

 > 5/3.to_f

 => 1.66666666666667 

Thanks to Melvin Ram for being on the other end of my Google search.