The Greater London Authority publishes a dataset of over 815,000 of London's Local Authority Maintained Trees. Kevin shows you how Directus can be used to further explore, understand, and remix this dataset both in the Data Studio and via API.
Speaker 0: There is so much fantastic open data out there, but often after publishing, very little happens with it. In this show, we give new life to open datasets with the help of directors. So join me as we explore, analyze, and generate APIs to improve access to and democratize data. Now before we get started, if you have or know of an interesting open dataset and want us to include it as part of this series, Just reach out to our team and it may well feature in a future episode. Today's dataset was published by the Greater London Authority as part of the London urban forest plan.
It contains 815,000 trees managed by 26 of London's boroughs, the city of London, and transport for London. Now this dataset includes things like where trees are planted, what species they are, how old they are, and more. Now this data didn't need much preprocessing before we imported it into Directus. The only thing I had to do was take the coordinate set and format wise convert that into GeoJSON. Some datasets already have that as a property, you know, when you download them, but this one didn't.
So I did that, and in a moment, you'll get to see the benefit of having done that. Other than that, I just created a collection called trees, inside of my director's project, added fields that aligned with each of the column headings and went ahead and imported it. So let's see what the outcome is. So if you've not seen it before, this is the Director's Data Studio. It's a web application that lets you explore, analyze, and interact with data inside of a database.
And I have already imported 815,000 trees with that were included as part of this dataset. Now immediately, I can jump in and start searching through it. I can filter it. So maybe I'll say something like only show me maple trees, for example, and you see that this has now been filtered down to a 100000 maple trees in this data set, and you can create more complex filters as well. Once you've created a set of filters that you may want to return to, you can also save them as a preset bookmark, and they will appear over here in the sidebar.
And as this data set is added to or changed inside of Directus, of course, those views will automatically update the data that they display. We can step into a single item, of course, as well. So let's look at this tree here. We see its object ID. We see its borrow.
We see its tree name as it's called in the database, its age group, and then this location here. Now because I went ahead and formatted the, coordinates as a GeoJSON point, now I can render this map. There are several mapping views inside of Directus. If you have a map box key and set that up, you'll get an enriched map, but this is what ships out of the box. So we see that this is exactly where this maple tree in Hillingdon is located.
Now going back out to the explore view for a moment, there's something really cool, about this explore view. And right now, we are looking at this data in a table, very standard view, obviously, for looking at, data. But we can also go ahead and use one of the other built in layouts. These are not the only layouts that are available. You can instal more layouts from the marketplace, but one that's really good and built in is the map.
So if I zoom out here, this is the maple trees, inside of the dataset all mapped. So instead of a table view, now we get this view, and I can click straight in and go to the individual tree. So let's give that just a moment, and there are the maple trees again. So that's really cool inside of Directus Explore and the editor. And, of course, if you update data inside of the editor and hit save, it will change the data that is displayed in this view.
Once data is in Directus, we can also use the Directus insights module to start to visualize and understand it. So here I've built a little insights dashboard, and the way this works is that we have this variable here that I populated with all of the boroughs. And when one of those boroughs is selected, we get to see how many trees are in that burrow, the breakdown by age. Now the breakdown by age is interesting, because I have applied a filter that will remove any undefined options. Because, obviously, that column's quite large, but it doesn't tell us anything.
So we've filtered those out. So these are all of the trees that have an age assigned to them. We have a breakdown by tree type. So we see there's a lot of cherry trees, for example, in Bexley comparative to others, and the top five tree types like so. And this all of these fields here, all of these panels here use the value of this drop down.
So in Camden, there's 24,000 trees. This is the breakdown of them. We see a majority of trees are between 31 80 years old. There's quite a lot of plain trees followed by maple trees and cherry trees. On tree types, you know, you could also filter out other, which I suppose would make sense, and we get this breakdown by tree type.
Now the each of these panels have their own configuration. You can change the way they look, the color, the filters, whether or not, in this case, there is a legend that's being shown or just labels on hover, and a whole bunch more. This is not all of the panels that are available either. We have things like meters, metrics, line charts, and so on. And once again, using the directors extension system and the directors marketplace, you can go and install more panels and visualize data in other novel and interesting ways.
Now as well as the data studio, directors also automatically generates APIs for your data that allow developers and applications to consume that data and perhaps remix it into new applications. There is a very, very granular set of permissions that you can set So you can perhaps allow certain data to be available publicly. Some might require a user to first register and you can enable or disable data that can be seen or interacted with on a per field basis. So I have prepared some API requests here for this specific data set that I think will demonstrate some of the powers of this API. So right here, remembering that our collection was called trees, we automatically have an API end point that will return all trees in the dataset.
So we make this request and what is returned is an object, is an array of objects, Each object representing 1 tree and the specific fields which we have allowed to be returned publicly. By default, a 100 items are returned at once. You can edit that, and you can also paginate. So perhaps you only get a 100 or 200 at a time, and then you can build out a pagination system. Now you can also just very much the same way as inside of the data studio, filter the data that is returned.
And the example we gave earlier was to filter to just show maple trees, and this is exactly how you would do it using the API. We add a filter and we say the tree name must equal maple. And now we only have those 100000 trees returned, or the first 100, of course. But, you know, you this only returns maple trees across all boroughs. You can do that with any field.
So here we say we only want to return items where the borough is equal to Brent, and you can stack these. So you can say, I only wanna return trees that are in Lewisham and there are oak trees. And that hopefully you're starting to see that you can build quite powerful queries and the applications you can build on top of that. There are also API endpoints for creating, for editing, and for deleting data points. So that's also kind of introduces some really interesting potential uses for this dataset where perhaps it could even be maintained or moderated through citizen engagement.
Now these last two examples I'm about to show you use different query parameters. So we're not filtering here, but instead, we are aggregating and grouping data to start to analyze it. So here we are saying we want to return every tree, but we wanna group it by the borough that that tree exists in. And this query here returns this result. So we see for every borough, we get to see how many trees are planted.
Here's another example where we're grouping by a couple of different, heuristics and you'll get to see how this works. So here we're saying, again, return every tree, just count them. But I wanna group them by borough and by tree name. So now you get to see embarking in Dagenham, there are 219 elder trees. Embarking in Dagenham, there are 695 apple trees and so on.
So, of course, there are gonna be way more objects here. It's gonna effectively be a matrix of every tree and every bar that exists in the dataset. But once again, we are effectively analyzing this data now via API. And it's these kind of queries that actually power the panels inside of directors insights. Now there are a whole bunch of query parameters that you can use over in the API here.
You can filter, you can search, sort, limit, the number of items that are shown as seen. The default limit is 100. We mentioned that earlier. We also get to see all of the aggregation and grouping functions that are available, to, again, do more analysis on that data, and more. So refer to the documentation, but the APIs are super powerful, and allow developers to effectively remix and use data in their applications and projects.
I hope you found this episode of democratizing data interesting. And once again, if you have a dataset or know of a dataset that might be interesting to include in this series, please do reach out to us. We'd love to see it. Until next time. Bye for now.