# Category: Geography

## 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 →

## Computing an initial bearing

This MySQL Stored Function computes the initial bearing — the compass heading to follow — when moving from one point to another on the surface of the earth.  Here’s a web site describing this. http://www.movable-type.co.uk/scripts/latlong.html 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 Portico (the Lutheran clergy retirement and benefits organization) or 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… 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 →