Adventures in Javascript

Category Archives: data

Interest in Agriculture

I have always been interested in agriculture since my humble beginnings as a home gardener in Vermont. In college, I had a group of friends who were extremely passionate about urban harvesting. They were concerned about the amount of edible food they saw go to waste around their small city and teamed up to do something about it on a volunteer basis. When I had the opportunity to dive into the NYC 2015 Tree data, I started thinking about what kind of edible tree species are within the five boroughs. Also, I often have seen Mulberry trees make a mess of the sidewalk near my house, which made me wonder where all of the Mulberry trees are located specifically.

Mulberry mess on a street in my neighborhood. Honestly, it doesn’t look like much because the rain earlier this week washed it away, but it can look like the sidewalk is full of purple jam!

NYC Parks’ TreesCount 2015!

If you read my last post, by now you know all about NYC Open Data and the Park’s Department TreesCount 2015 data. Basically, the Parks department counts all of the “NYC street trees” every ten years to keep tabs on how the urban forest is doing. Street trees are all of the trees you see in the NYC sidewalks, and they do not include trees that are in public parks.

When first given a chance to analyze this data, of course my mind started asking questions about how many NYC Street Trees are some kind of edible species. I decided to focus my visualization on that. But there’s a huge caveat! At the aforementioned event, there were many Parks Department representatives to support, and from one of them I learned that the Parks Department chooses a lot of hybrid species for their street trees. This means that although in the list of trees in NYC there are many edibles, the actual trees that are planted may not be fruit bearing because that would make a mess of the sidewalks. (The Mulberry trees I mentioned earlier ended up being on private property that borders the sidewalk.) Also, since I don’t have more specific information about the trees beyond their common and scientific names, please proceed with caution if you decide to check the trees in this visualization. The following is the process I took to create this visualization.

Consulting an Expert

My first task was to identify all of the tree species that I wanted visualize from the data. While I was able to identify some species that I knew had some kind of edible, I consulted with my good friend, Samantha Anderson, who happens to be a landscape architect and general expert in these sorts of things. With her help, we created a list of all the species that could possibly have something edible, most of them being fruit or nut bearing trees. In total I ended up with 13 species of NYC Trees to include in the visualization. (Thank you Sam! Note: final list did not include sugar maple even though the sap is edible. Can’t imagine NYC Parks is going to tap some trees anytime soon!)

Visualizing Data with CartoDB

Issue #1: Edible Species Not the Most Common

I used CartoDB for visualizing the trees of interest on a map of NYC. First, I had to import the TreesCount 2015 Street Tree Data off of the NYC Open Data Portal. Then, since I wanted my visualization to focus on the common species names for the NYC trees, I experimented with viewing the different categories of tree species by specifying that I wanted the data sorted by the “spc_common” column.

In this screen shot, you can see that ten types of specific trees that are the most common in the data set are each given their own colors and pins. My problem was that some of the species I was interested in were lumped into the gray “Other” category.

Top categories of trees mapped by category

Solution: Custom CSS

To change which species showed up on the map and to identify which colors I wanted their pins to be, all I had to do was change the CSS style for the species that were being targeted in the CartoCSS editor. At least that’s what I thought I had to do.

Issue #2: Dataset Too Broad

While some of the pins changed colors, I realized that the map was still showing ALL of the trees in NYC. I had just changed the styling, but what I really needed to change was the underlying dataset that the map was drawing from to show the plotted trees.

Solution: Custom SQL Query

There may be a more efficient way to do this, but I basically created a custom SQL query that targeted only the tree species I was looking for so that the dataset would only reflect that.

Default SQL query gets ALL the trees from the dataset.

Modified SQL query with all species I wanted to target.

Final Map

After tweaking the legend and other clean up, I finally had all of my edible tree species in NYC mapped! Check it out here. You can see what types of edible tree species live in your neighborhood, but please, sample edibles at your own risk!