Page 21 of 171

How to visualize the density of point data in a grid

A common way to show the distribution of places (like grocery stores) is to use a heat map. The map will appear “hotter” where there are many grocery stores and “colder” where there are few grocery stores. This kind of map can be useful to show gaps in distribution or a neighborhood that has a lot of grocery stores.

One issue with that kind of heat map is that the coverage areas change their shape and color if you zoom in, since the algorithm that clusters or determines what’s “nearby” or dense has fewer locations to analyze.

I prefer to use grids in the shape of square tiles, since Chicago is grid-oriented city and the vast majority of our streets and our routes move along east-west and north-south lines. The map above shows the location of subjects and topics of news articles in the Chicago Cityscape database.

I use PostGIS to set up most of my spatial data before visualizing it in QGIS.

This tutorial shows the two steps to using PostGIS to (1) create a grid based on an existing area (polygon), (2) assigning each point location to a tile in that grid and counting the number of locations in that tile.

If you don’t have PostGIS installed, you should install it if you work with spatial data a lot. It is much, much faster at performing most of the tasks you use QGIS or ArcGIS to perform. Both QGIS and ArcGIS can read and edit data stored in PostGIS.

Additionally, there is a function within QGIS that can create grids, and another function that can do comparisons by location and count/summarize, so all of this can be done without PostGIS.

For this tutorial, you will need a single polygon with which to create the grid. I used the boundary of the City of Chicago limits.

  1. Create a grid based on an existing area

1.a. Add a new function to PostGIS

To create a grid, you need a function that draws the tiles based on the polygon. I got this from The Spatial Database Advisor.

-- Create required type
DROP   TYPE IF EXISTS T_Grid CASCADE;
CREATE TYPE T_Grid AS (
  gcol  int4,
  grow  int4,
  geom geometry
);
-- Drop function is exists
DROP FUNCTION IF EXISTS ST_RegularGrid(geometry, NUMERIC, NUMERIC, BOOLEAN);
-- Now create the function
CREATE OR REPLACE FUNCTION ST_RegularGrid(p_geometry   geometry,
                                          p_TileSizeX  NUMERIC,
                                          p_TileSizeY  NUMERIC,
                                          p_point      BOOLEAN DEFAULT TRUE)
  RETURNS SETOF T_Grid AS
$BODY$
DECLARE
   v_mbr   geometry;
   v_srid  int4;
   v_halfX NUMERIC := p_TileSizeX / 2.0;
   v_halfY NUMERIC := p_TileSizeY / 2.0;
   v_loCol int4;
   v_hiCol int4;
   v_loRow int4;
   v_hiRow int4;
   v_grid  T_Grid;
BEGIN
   IF ( p_geometry IS NULL ) THEN
      RETURN;
   END IF;
   v_srid  := ST_SRID(p_geometry);
   v_mbr   := ST_Envelope(p_geometry);
   v_loCol := trunc((ST_XMIN(v_mbr) / p_TileSizeX)::NUMERIC );
   v_hiCol := CEIL( (ST_XMAX(v_mbr) / p_TileSizeX)::NUMERIC ) - 1;
   v_loRow := trunc((ST_YMIN(v_mbr) / p_TileSizeY)::NUMERIC );
   v_hiRow := CEIL( (ST_YMAX(v_mbr) / p_TileSizeY)::NUMERIC ) - 1;
   FOR v_col IN v_loCol..v_hiCol Loop
     FOR v_row IN v_loRow..v_hiRow Loop
         v_grid.gcol := v_col;
         v_grid.grow := v_row;
         IF ( p_point ) THEN
           v_grid.geom := ST_SetSRID(
                             ST_MakePoint((v_col * p_TileSizeX) + v_halfX,
                                          (v_row * p_TileSizeY) + V_HalfY),
                             v_srid);
         ELSE
           v_grid.geom := ST_SetSRID(
                             ST_MakeEnvelope((v_col * p_TileSizeX),
                                             (v_row * p_TileSizeY),
                                             (v_col * p_TileSizeX) + p_TileSizeX,
                                             (v_row * p_TileSizeY) + p_TileSizeY),
                             v_srid);
         END IF;
         RETURN NEXT v_grid;
     END Loop;
   END Loop;
END;
$BODY$
  LANGUAGE plpgsql IMMUTABLE
  COST 100
  ROWS 1000;

The ST_RegularGrid function works in the same projection as your source data.

1.b. Create a layer that has all of the tiles for just the Chicago boundary

--This creates grids of 1,320 feet square (a 2x2 block size in Chicago)
SELECT gcol, grow, geom
 into b_chicagoboundary_grid_1320squared
 FROM ST_RegularGrid((select geom from chicagoboundary where gid = 1), 1320, 1320,FALSE);

In that query, “1320” is a distance in feet for both the X and Y planes, as the “chicagoboundary” geometry is projected in Illinois StatePlane FIPS East (Feet) (EPSG/SRID 3435).

2. Assign each point location to a tile in that grid and count the number of locations in each tile

Now you’ll need a table that has POINT-type geometries in it. For the map in this tutorial, I used a layer of location-based news articles that are used in Chicago Cityscape to highlight local developments.

SELECT grid.id, count(*) as count, grid.geom
INTO news_grid
FROM news_articles, b_chicagoboundary_grid_1320squared AS grid
WHERE st_intersects(news_articles.geom, grid.geom)
GROUP by grid.id;

This query will result in a table with three columns:

  1. The ID of the tile, which is a primary key field.
  2. The number of news articles in that tile.
  3. The POLYGON geometry of that tile.
Look at these two maps (the one above, and the one below). The first map shows the whole city. The tiles are colored according to the number of news articles within the area of each tile. The darker the blue, the more news articles within that tile.
This map is zoomed in to the Woodlawn area. As you change scale (zoom in or zoom out), the size of the “heat” area (the size of each tile) doesn’t change – they are still 1,320 feet by 1,320 feet. The color doesn’t change either. The typical heat map doesn’t have these advantages.

A new map for finding COVID vaccination sites in Illinois

The State of Illinois map of COVID vaccination sites is pretty bad. 

Screenshot of the Illinois Department of Public Health map, taken February 14, 2021.

It’s slow (caused my browser tab to crash after a couple minutes), has misspelled county and city names, missing ZIP code digits, and cannot be searched by address. There are duplicate entries, too.

I made a new version of the state’s COVID vaccination sites map.

I didn’t make any COVID maps earlier because I didn’t want to spend the time to ensure that I understood the right and wrong ways to map disease, because people make decisions based on maps and I don’t want my maps to end up harming anyone. 

The new map of COVID vaccination sites on Chicago Cityscape.

Aside from the state website’s usability issues, I’m very disappointed that there is zero data about COVID in the state’s #opendata portal.


These cities and counties have the most COVID vaccination sites, according to the IDPH’s dataset. 

For the top 10 or so, it seems to correlate with population. Except Skokie has 7 sites, and Evanston has 4, despite Evanston having 10,000 more residents. Nearly 100% of Illinois is within 60 minutes driving of the current COVID vaccination sites. (More are coming, at least in Chicago.) 

Nearly 100% of Illinois is within 60 minutes driving of the current COVID vaccination sites. (More are coming, at least in Chicago.)

And a lot of Illinois is still within 45 minutes driving of the current COVID vaccination sites. Really big gaps in geography appear at the 30 minutes driving threshold.

A map of Illinois showing 30 minute driving areas around each of the 862 COVID vaccination sites.

I’m working with some people to show access via transit. This is super important. I predict that upwards of 75 percent of Chicagoans will be able to access a vaccination site or two within 45 minutes and 100 percent within 60 minutes.

Here’s another shortcoming of the state’s map: Each site’s unique ID is not persistent, making it difficult to compare one day’s list to the following day’s list. I got around that by making a “hash” of each vaccination site and comparing between two versions.

The map has been updated once since I started. The “hash” creates a unique ID based on the attributes of each vaccination site (name, address, city, county, ZIP code). Any time one of those attributes changes, the hash will also change and thus I can more easily find new or modified vaccination sites.

Two-flat owner journal 3: Choosing the right water heater

Read all of the “Two-flat owner journal” entries

This journal entry is all about the several hours of time I spent researching which water heaters to buy for my two-flat. While my architect works on drawing the plans, I am doing a lot of research to answer questions for him, so he knows what appliances are going to be hooked up to the house’s mechanical systems.

I started researching water heaters on a cold Saturday in January so I could fill out the “appliance schedule” for the project. My first journal entry was about my new distaste for Peoples Gas. Since then, my view has evolved and we (my architect and I) are designing an all-electric house.

SCROLL DOWN FOR THE RESEARCH – Read on while I discuss my thoughts about electricity and natural gas as a power source for homes.

Discussion

Let me step back a moment. I also have a “distaste” (a weird word to use when talking about something that would literally kill you if you drank it) for fossil fuels, too. When I approached this research task I thought that an electric tankless water heater had some kind of inherent efficiency over an electric or natural gas-powered tank type.

But it doesn’t, and that’s partly dependent on how much water a household uses. Tankless water heaters are sometimes marketed as providing “unlimited” hot water, which scared me. Since I don’t go to an office anymore (because of COVID-19 and because I quit my office-attached job), I take a shower every other day. And they’re long. Just imagine that your shower never ran out of hot water. I might not get out. So that’s a personal critique of the type of water heater.

(Another con of tankless water heaters: When the electric is off, water cannot be heated; with a tank water heater, there is always residual hot water in the tank, which can still flow. Additionally, electric tankless water heaters have special electrical box requirements because they draw so much electricity.)

Let’s talk about the fuel. Natural gas is cheap right now – to purchase. But it has awful costs elsewhere, namely its contribution to pollution and carbon dioxide emissions when burnt. Burning it in the home also releases additional gases, which is why I think you should run your range hood vent/exhaust when you cook food on the stovetop.

Gas stoves emit a host of dangerous pollutants, including particulate matter, formaldehyde, carbon monoxide, and nitrogen dioxide. 

Mother Jones, “How the Fossil Fuel Industry Convinced Americans to Love Gas Stoves”, by Rebecca Leber, FEBRUARY 11, 2021

Going electric in the kitchen is pretty easy, I think. I didn’t do much research and I picked out all Energy Star-certified appliances. For cooking I chose a range with an induction cooktop and an electric convection oven (which means there’s a fan inside to blow the heat around for even cooking). Induction cooktops, while being a really efficient user of energy, have cooking benefits: Water reaches a boil faster, the surface is easy to clean, and there are fewer burns because the surface doesn’t get hot.

Creating an all-electric house is pretty easy, actually, until you get to the heating and cooling part, and knowing how to heat a house with electricity in the very cold climate of northern Illinois requires even more research.

Water heaters are actually easy to figure out (after 5 hours of research) because, in the end, all you do is plug them in to a 240 volt receptacle and connect to the already-existing water pipes.

I am still in the middle of researching electric heating and cooling and I’ve opened a conversation with two HVAC contractors (one that sells Carrier and one that sells Mitsubishi).

Water heater research

I originally tweeted all of this on January 16, 2021, because I like using Twitter as a sounding board.

I have researched five types of water heaters because I want to fully understand the purchase price and energy price of each.

  1. Natural gas, tank
  2. Natural gas, tankless
  3. Electric, tank
  4. Electric, tank (hybrid w/heat pump)
  5. Electric, tankless 

Based on my research of manufacturers’ reported “Energy Guide” stickers (the yellow stickers required by federal law) for these five types, the Electric, tank (hybrid w/heat pump) (option 4) is far and away the most efficient water heater. 

The Electric, tank (hybrid w/heat pump) has an annual operating cost of $104. What is this thing? It takes the standard tank, uses electric heating elements (think of the wires inside your bread toaster), and extracts heat from the air in your house with the heat pump. That’s pretty amazing: There is free heat to be extracted from the air.

The Electric, tank (hybrid w/heat pump) has less than half the operating cost of the next lowest type: Natural gas, tankless.

Rheem (a water heater manufacturer, which also owns the Richmond brand) says that an electric tank water heater with hybrid heat pump uses less electricity than an old-fashioned incandescent light bulb.

Note that the electrical prices in the yellow “Energy Guide” sticker is 12 cents per kWh, and ComEd just charged me ~7 cents per kWh, so the annual operating costs of electric are less than the stickers say. 

Next, as part of the “total cost of ownership” (well, minus maintenance) I added in the purchase price. The Electric, tank (hybrid w/heat pump) costs $1,400. That’s 1.5-4x more expensive than the other types of water heaters!

However, I’ve since found that Rheem/Richmond makes a couple cheaper models that don’t have high-tech features, so the purchase price is anywhere from $1,000 (if you can find that model) to $1,175.

I calculated the “5 year cost of ownership” price for water heaters of each type because it makes sense to distribute the purchase price over a period of its lifetime. I could have easily made this a 10-year amortization since water heaters come with 6 to 12-year warranties. I interpret the length of the warranty as the manufacturer’s assessment as to how durable they’ve created the machine.

How they compare

Of the five types, I compared 11 machines (view the comparison chart).

The cheapest water heaters over five years are: 

  1. Electric tankless
    $1,479 (caveats in that annual energy cost was extrapolated because a direct Energy Guide sticker wasn’t found)
  2. Electric, tank (hybrid w/heat pump)
    $1,695 (does not include federal tax credit)
  3. Natural gas, tank
    $1,999

Remember, though, that the Energy Guide stickers for the electric water heaters use a 41.7 percent higher energy cost than ComEd currently charges, and ComEd offers hourly pricing so the price can be much, much lower per kWh and the prices for the electric water heaters are EVEN LOWER. (Thank you for pointing this out, Troy.)

Guess what…the price of the Electric, tank (hybrid w/heat pump) can come down even more because of (1) a ComEd rebate, and (2) federal tax credit worth 10 percent of the purchase price + installation, up to $300.

Bonus: By getting electric you are part of the carbon-free future. 

Further discussion

Now that I’ve convinced you that an Electric, tank (hybrid w/heat pump) water heater is the cheapest option, here are a couple of other things that came up in the Twitter conversations.

  • Including utilities (i.e. electricity cost) in the rent for the rental apartment in my two-flat benefits both me and the tenant. The tenant has a fixed and predictable energy cost and fewer bills to pay, while I am able to charge a bit more than I predict the cost will be in order to pay back the higher upfront costs of the water heater and the Energy Star-certified appliances (as well as the heating and cooling system).
  • The calculations might be different if I looked into having individual tankless water heaters at the point of demand, or using them as “boosters”. Tankless water heaters come in a variety of capacities and energy outputs (measured by how much energy it takes to increase the temperature from how cold the water is when it enters the house or heater to the desired temperature). One could be added to the kitchen, the bathroom, and next to the laundry, and sized for the differing demands of each location.
  • A complex system could be built that is programmed to buy energy from ComEd when the hourly cost is the lowest and use the power from the battery when the hourly cost is highest.
  • A couple people asked about geothermal. I looked into it and I wrote it off quickly: A drilling rig needs to access the yard to drill multiple horizontal wells. The garage blocks that from happening. However, an apartment building renovation in Rogers Park designed by PMP Architects is converting its heating system to use geothermal energy.

Two-flat owner journal 2: Demolishing the interior

In order to get the two-flat ready for a gut rehab, one has to gut it.

The rehab stage is still months away, as my architect and I continue to develop plans. He does most of the work, but it’s quite collaborative because there are layout, design, and finishing choices that we need to make.

Gutting the house is also necessary for the plans because my architect needs to know what’s behind the walls.

I hired Amplify Property Solutions for the job. APS has a social mission of training and employing young Black men. You can ask me personally how much it cost, but it was between $5,000 and $10,000 (that range includes the cost of six Dumpsters).

I am very happy with the crew’s work and Ron and Ted’s dedication to communication, clarity, and customer service. The work took a week longer than they predicted because of some aspects that I think were next to impossible to know:

  • There were 1-2 “extra” layers of flooring in some places. From top to bottom in the upstairs living room there were carpet, wood, linoleum, wood, and subfloor layers.
  • Because the center beam in the basement has been failing (sagging) for years, the centers of each floor were sinking making the floors unlevel. Platforms were built in each kitchen to raise and level the floor.
  • The house is one of two row houses, so one exterior wall is shared. On this wall, behind the drywall was a 1″ layer of plaster that took awhile to chip away.

The subfloor boards are very wide and old growth and original (so they’re at least 130 years old). I’ve been told that some people find these valuable; if you’re interested in purchasing them, please get in touch!

See more photos below and in the house photo album.

Permitting

With this level of demolition, a permit is required! I pulled an easy permit for this project (which I think cost $375). The Dumpster company obtained their own permits to occupy the street right of way.

Also, as a way for the Chicago Department of Buildings to discourage gut rehabs being permitted with a series of easy permits, when a Standard Plan Review is most likely required, the DOB required that I apply for a renovation/alteration permit and show them in-progress drawings.

Consultants and contractors used so far


First floor kitchen
The demolition exposed the shape of the chimney. The right side was filled in and the wall was flat so we didn’t know how wide the chimney was.
The kitchen platform
The kitchen platform had a level top, but the floor beneath was uneven. The framing underneath the platform had angles cut to ensure the platform was level.

2020 year in review

Rear view of the two prefab single-unit detached houses and their backyard ADUs
I was biking around in Denver and I came across these identical modular houses with backyard houses under construction. The City of Denver posts building permit plans online, which is fantastic because it makes design more transparent. Architects from around the world can be inspired by this project.
  • Due to the (ongoing) COVID-19 pandemic, I started working from home on March 12, 2020. I visited the office once in the fall for an hour to perform a minor task.
  • My small business, Chicago Cityscape, hired Casey Smagala to run business development for the real estate information website.
  • I bought a two-flat in East Garfield Park in the summer after touring dozens of houses. I had first toured this house, and met the owner, Carl, who lived there, in February. I toured it a second time that month, with my friend, Kevin. After several more months of touring houses and realizing that I couldn’t afford an already-renovated house, I made an offer to Carl in May. The house closed in July.
  • Friends in Denver asked me and my friend, R, to come visit and camp, hike, and bike in and around Aspen in August. Denver also has allowed accessory dwelling units (ADUs) for years, so I talked to a local housing organizer and biked around the city looking at backyard houses.
  • I didn’t move into my two-flat because it turned out to need more renovation than I had believed. I also started a journal, which has one post so far.
  • I left my job as of December 31, 2020, so that I could focus on developing and growing Chicago Cityscape.
  • By the end of the year, I published eight blog posts. I didn’t have a goal; two of them were based on books I was reading: (1) Before the Lake Street elevated (now the Green Line) was built, a monorail was proposed (via a book about the history of the CTA’s predecessors)! (2) I read Beryl Satter’s book about her father, a landlord in Chicago, “Family Properties”, and I biked by one of the extant buildings.
  • My “hot air balloon” was used for some cool projects that needed aerial photography (both co-produced by Paola Aguirre and her consulting firm, Borderless Studio). I filmed some the massive mapmaking happening at the former Overton school in Bronzeville – which can only be seen from the sky – for an AIA film challenge; I also snagged some clips of the Pink Line ‘L’ going in and out of the California Ave station to visualize an area being studied for a corridor revitalization.