Revisiting Farmer’s Market Map with Leaflet JS

Awhile ago, a long while ago, I wrote one of my first R tutorials. It was not pretty, it was very specific, and revisiting it I find lots of errors. Recently I decided I would rehash the visualization to match what I am currently interested in and use a few more skills I have learned along the way. This first tutorial was aimed at a very real workplace purpose, creating map plots from zip-code data. There was a great package called zipcode that aided in this and below is an example of the plot.


The problem with this map is that it is not descriptive of the data. Granted the first tutorial I wrote was not getting at trying to be descriptive of the data. Since it was just showing how to migrate zip codes to latitude and longitude values so this plot was not indicative of the data. Furthermore it is often said of creating map plots that they most often just show large population centers and not much else. Consequently it is exactly what this old map did. What you do not see from that first map is that the Farmer’s Markets are classified by location by the US Department of Agriculture. These are:

Closed-off public street, Educational institution, Faith-based institution, Farm, Government Grounds, Healthcare institution, Other, Private business parking lot, Wholesale market facility

So clearly we need to see the spread of the Farmer’s Markets colored by these location types, right?


What ends up happening is an example of data overload, and it occurs a lot in visualizations, graphs, dashboards, etc. The data is important to have, but it should be curated to show what the creator wants to indicate first. This allows the user to remove and replace selections to enhance the exploration of the data. This requires us to be interactive, and those first two are clearly not. We already have our Locations as the color, which is already a step ahead of the first map. What else can be done? Well if you want to view the CSV you can do so and you will see a few columns with some 1’s and 0’s. These columns indicate what I like to call the “amenities”. Some are documented as having corn offered, whereas others accept the SNAP program vouchers. All really interesting and important pieces of this data. I want to help guide the user to the “best” markets which could be as simple as those with the most amenities. To do this we will sum the count of 1’s in those columns and get the “best” markets, and after a little log function, here we are:

FYI If you did download the CSV you will see that I have massaged the data a little for you. First off the data did not come with 1’s and 0’s, it was Y’s and N’s so I replaced those, and then summed the counts as seen in the aptly named column.