Geo-Rails part 8: ZCTA Lookup, A Worked Example

This week we’ll put together what we’ve covered so far in this series by implementing a simple but usable service: looking up the Zip Code Tabulation Area (ZCTA) for a location. This is an actual task I had to do for my job at Pirq, and while I will pare it down for this article, we’ll go through some of the actual trade-offs and optimization decisions I made in our implementation.

In this article, we will cover:

  • The goals for the service, and what is a ZCTA anyway
  • Obtaining ZCTA data from the U.S. Census
  • Developing our own ZCTA database
  • Querying the database
  • Improving performance using polygon segmentation

This is part 8 of my continuing series of articles on geospatial programming in Ruby and Rails. For a list of the other installments, please visit http://www.daniel-azuma.com/blog/archives/category/tech/georails.

Continue reading

Geo-Rails part 5: Spatial Data Formats

The location revolution is a revolution of data. Ubiquitous data, from mobile GPS and user input as well as from census and other datasets, is what makes location-aware applications possible. And so the first task of many geospatial projects is to determine how to find and utilize (and, in some cases, produce) external data.

In this article, we will survey some of the important spatial data formats, including serialization, file formats, and api-oriented formats. Specifically, we will look at:

  • Basic serialization using WKT and WKB
  • Variants on WKT and WKB
  • Reading public datasets from shapefiles
  • Web service oriented formats such as GeoJSON
  • XML-based formats commonly used in web services

We will also go over a few quick examples using Ruby and RGeo. This will be a fairly high-level overview and we won’t go into a lot of detail. We’ll take deeper looks at some of these formats in future articles.

This is part 5 of my continuing series of articles on geospatial programming in Ruby and Rails. For a list of the other installments, please visit http://www.daniel-azuma.com/blog/archives/category/tech/georails.

Continue reading