Franklin Pezzuti Dyer

Home     Posts     CV     Contact     People     RSS

A look around Albuquerque in QGIS

As a kid, I would sometimes play games on my grandparents' Wii while staying over at their house. They had one called called Wii Sports Resort, which takes place on an island resort where your avatar can participate in sporty activities like swordfighting, frisbee-throwing, biking, wakeboarding and many others.

Fig 1

For some reason, one of these games appealed to me much more than any other: the island flyover, where you could shuttle your character around the island in a cute little plane. It wasn't the flying that appealed to me so much as landmarks scattered around the island that your character could "discover" by flying directly over them. After visiting the "i point" corresponding to a certain landmark, it would appear in a list of all visited locations at the end of your flyover, as seen in this screenshot from the fan wiki:

Fig 2

Accessing some of these clandestine locations required a bit of aerial acrobatics, which only made it more tantalizing to complete my collection by visiting the last couple of tucked-away monuments that had so far eluded me. On a psychological level, I'm not sure why this game had such a strong impact on me - but I remember daydreaming about doing a "flyover" of Chattanooga, my family's home at the time, and collecting "i points" at notable locations around town like the Walnut Street Bridge and the Tennessee Aquarium.

I've gone years without thinking about this game, but recently I stumbled across something that has delighted and amused me in the same way. While looking for local tech jobs I came across a posting that asks for experience with GISs. This acronym was unfamiliar to me, but I found out that GIS stands for geographic information system, and that these systems are used to query and manipulate spatial data, which may involve either natural features or man-made administrative ones.

Naturally I wondered whether there were any open datasets about Albuquerque (where I currently live), and was astonished to find that the City of Albuquerque publishes a bunch of GIS data. Not only this, but I also learned that GIS data can often be queried using the database query language SQL. So of course I had to download several datasets and find out what sorts of whimsical pieces of information could be extracted. The rest of this post will just describe a few of the silly queries I've run on Albuquerque GIS data. I strongly encourage you to look for GIS data on your own city of residence (it probably exists!) and try some queries for yourself. I've chosen to use QGIS for my own explorations, since it's free and open source.

Before digging in, a brief technical aside. I'm still learning about how GISs work for the first time, but here's my understanding of the basic terminology:

Vector data might be used to represent discrete features, such as businesses or locations of interest (points), roads or rivers (curves) or parks or bodies of water (polygons). They might be contrasted with raster datasets, which are typically used to represent continuous data that have some distinct value at each position in space, such as elevation or temperature. There seem to be several different formats for storing vector datasets. These include shapefiles, GeoJSON and GML.

One of the most interesting Albuquerque datasets has been the one describing "land use". It took me a while to even download this dataset because I didn't realize what the deceptively bland-sounding name meant. In this dataset we can find information about all of the establishments in ABQ, sorted into pretty granular "land use codes". Let's start by picking a few different types of businesses and viewing all of the locations in the vicinity of UNM campus falling under each code.

To start with, here's UNM:

Fig 3

We can right-click on the landuse layer and choose Open Attribute Table to view the entire dataset, from which we can divide that the column entitled OldLandU_1 is probably the one containing the land use codes that we want to check against. Then, by navigating to Edit > Select > Select Features by Expression, we can open a menu that will let us select features using a SQL predicate.

Looking at the list of land use codes linked above, we can see that there are two codes corresponding to fast food restaurants (separated by the presence or absence of a drive-thru). So we can enter the following predicate to select all of the fast-food establishments:

OldLandU_1 LIKE '%FAST FOOD%'

I've also added labels to the selected features containing the first couple digits of their GlobalID field, so that I can refer to them more easily. Here are the selected results along Central, near UNM campus:

Fig 4

As a college undergraduate, of course I can identify several of the fast food restaurants directly next to campus by heart. The building CF5, for instance, is a Wendy's, and 145 is a Taco Bell. It's kind of a fun challenge to try and remember what each building is, based only on its location and its land use code - I'm pretty sure that B27 is a McDonald's and 280 is a pizza joint, but I might have them backwards. I also find it pretty funny that the Freddy's on central isn't classified as FAST FOOD nor even as a RESTAURANT, but rather as an EATING AND DRINKING ESTAB:

Fig 5

Something I've noticed in Albuquerque during my time attending UNM is that since the legalization of marijuana here in NM, dispensaries have been popping up everywhere like weeds (pun intended). I can hardly believe that the demand is enough to support all of them! So of course I wanted to try finding GIS data for the locations of dispensaries throughout Albuquerque. This led me to the Cannabis Retail Location Approvals Map, which shows the locations of proposed dispensaries around Albuquerque as well as their respective review status. It was a huge hassle to figure out how to download the raw data, but I eventually figured it out with the help of this blog post (thanks Jonathan Chang!). So here are all of the proposed dispensaries around campus, with accepted locations in green and rejected ones in red:

Fig 6

Let's use this data to do something a bit more complex involving multiple different layers. The City of Albuquerque lists some regulations on Cannabis Retail Locations, including the following:

Using some of the tools that QGIS offers, we should be able to find out whether there are any dispensaries potentially violating these distance regulations. In particular, the buffer tool, located under Vector > Geoprocessing Tools > Buffer, allows us to create a new layer whose features consist of circles of a given radius surrounding each dispensary. Here's what these circles look like, depicted as little green clouds:

Fig 7

Next, we can perform a spatial join operation between layers, which is just like a JOIN in SQL except that it can make use of spatial information as well. This StackExchange post has some beautiful diagrams in its top-voted answer explaining how these work. In addition to the dispensary layer, I've imported a layer from the CABQ website consisting of points marking the locations of Albuquerque schools. If we join the dispensary buffer layer with the school layer using the intersect predicate, the output should be a layer indicating all of the schools falling within the 300-foot ball surrounding any dispensary.

After carrying out this join myself, I found only a single hit: the Releaf Cannabis CO at 1606 Central Ave SE, and a charter school called Tierra Adentro located just across the street from it. But a quick search led me to Tierra Adentro's website, which says that they're currently located at 1781 Bellamah Ave NW a couple of miles away. The LASTUPDATE field for this school record is equal to 11/9/16 in the dataset I downloaded, so the school must have relocated since then.

Fig 8

To find pairs of dispensaries falling within 600 feet of each other, we just need to check whether any of these 300-foot balls intersect each other - for if a ball with 300ft radius centered at one point intersects a ball with 300ft radius centered at another point, then those two points must be within 600ft of each other. This means that we should do an inner join of the buffered dispensary layer with itself, and then clean up all of the duplicate pairs of entries ("x is within 600ft of y and y is within 600ft of x") and degenerate entries pairing a dispensary with itself ("x is within 600ft of x"). Each buffered dispensary feature has a unique ID in the objectid column, and a pair of buffered dispensary features appearing in the new joined layer contains the objectid values of both features involved under the respective column names objectid and objectid_2. A neat trick for getting rid of duplicate and degenerate entries is to Filter this new layer on the predicate objectid < objectid_2. (Can you see why this works?)

I find 47 non-duplicated pairs of dispensaries falling within 600 feet of each other. It appears that the dispensaries licensed as microbusinesses have the string MICB or micb as a substring of their state_cannabis_licence_number column, so we can select only the potentially non-compliant venues using the following predicate:

NOT ( LOWER(state_cannabis_licence_number) LIKE '%micb%' OR LOWER(state_cannabis_licence_number_2) LIKE '%micb%' )

I find 14 matches when running this query. Upon inspecting them manually, I found that a couple of the entries are obvious flukes (e.g. Leaf & Flower LLC and Leaf & Flower LLC Producer have separate entries but probably correspond to the same business, and Urban Wellness has two entries with distinct ID values). Nevertheless, a few seem to be legitimate counterexamples, like the pair depicted below. Presumably one of these businesses has a "conditional use approval".

Fig 9

I'll stop there with the analysis, but I've had a lot of fun tinkering with these datasets in QGIS. This diversion has tickled several different parts of my brain, including my interest in databases, my geometic and topological reasoning, and whatever leftover bits of gray matter once made my younger self so excited at the thought of discovering hidden easter eggs from a bird's-eye view in the Wii Sports island flyover. Now that I think about it, though, I don't remember there being so many cannabis dispensaries on Wuhu island...


back to home page
The posts on this website are licensed under CC-by-NC 4.0.