Category: Geography

Choropleths: color-coded maps showing data by state or other geography

A Choropleth is a colored map, typically showing information gathered by some kind of census. A well-known example is the New York Times’s COVID-19 map. Let’s say you have some data that’s coded by geographic area. For example, you might have a table showing the number of COVID cases per 100,000 people county by county in Massachusetts. It might look like… Read more →

Flood Maps Miss Risk Factors

The US Federal Emergency Management Agency’s (FEMA’s) national flood insurance program has a non-governmental competitor. Here’s a Times piece about a Brooklyn-based non-governmental outfit called First Street Foundation. They’ve put together an online address lookup scheme called Flood Factor that returns a risk of flood at a property. They claim that FEMA’s rating system, based on Flood Insurance Rate Maps… Read more →

Massachusetts town-by-town COVID-19 cases

The Massachusetts Department of Public Health started publishing, on April 14, 2020, epidemiological data for each of the Commonwealth’s 351 cities and towns. The results come out once a week each Wednesday. They publish them in .pdf and .docx format. And, they don’t keep previous weeks’ data on their web site. Here is a .csv file containing  all the data… Read more →

Vaccination rates by school in Massachusetts

Here’s an interesting data set.  This table contains vaccination rates for kindergartners by town and school in Massachusetts. It shows immunization rates for DTaP (Diptheria, Tetanus, and Pertussis), Polio, MMR (Measles, Mumps, Rubella), and Hepatitis B. It also lists immunity to chickenpox. It’s published here as an Excel file.  That makes it easier to numbercrunch, slice, and dice. Vaccination Rates… Read more →

Fast nearest-location finder for SQL (MySQL, PostgreSQL, SQL Server)

I’ve spent enough time goofing around with location-finder software that it’s worth writing up how to do it.   Of course, finding distances on the surface of the earth means using Great Circle distances, worked out with the Haversine formula, also called the Spherical Cosine Law formula. The problem is this: Given a table of locations with latitudes and longitudes,… Read more →

Slowing down Wall Street

Wall Street, lately, has been using high-speed trading to allow insiders to front-run trades by ordinary investors. So, for example, when an outfit like TIAA-CREF (pension funds for teachers) tries to place an order to buy shares of a company they like, other investors’ computers can detect the trade before it happens, buy the shares, and then instantly resell them… Read more →

The Vincenty great-circle distance formula

This Vincenty formula is a more numerically stable version of the spherical cosine law formula (commonly and wrongly known as the Haversine formula) for computing great circle distances. The question of numerical stability comes up specifically when the distances between points are small. In those cases the cosine is very close to 1, so the inverse cosine function is not… Read more →

Using MySQL’s geospatial extension for a location finder

It’s possible to use the geospatial extension in MySQL for an efficient location finder.  For this to be worth the trouble, the following conditions must hold. You must use a MyISAM table for your geospatial data, or use version 5.7.5 or later of MySQL. A NOT NULL qualification on your geometry column is required A spatial index is needed:  ALTER… Read more →

Stored function for haversine distance computation

In another article I described the process of using MySQL to compute great-circle distances between various points on the earth then their latitudes and longitudes are known.  To do this requires the formula commonly called the haversine formula. It’s actually the spherical cosine law formula, and is shown here. There’s a more numerically stable formula — better when points are near… Read more →