Using the Massachusetts Census 2010 Towns data source, we generated the following maps and statistics. The software used relies on technologies such as Python and PostGIS.

Note: The data source has been generated and published by MassGIS.

Population change

Population change 2000-2010

We can see some towns in Cape Cod and Western Massachusetts not growing as fast (few even loosing population) as the rest of the state. What is driving the increase just west of 495? Is it the expensive real state closer to Boston?

Population per town

Population in 2010

No surprise that Western Massachusetts has less populated towns than the Greater Boston area.

Most populated towns:

  1. Boston – 617594
  2. Worcester – 181045
  3. Springfield – 153060
  4. Lowell – 106519
  5. Cambridge – 105162

Least populated towns:

  1. Gosnold – 75
  2. Monroe – 121
  3. Mount Washington – 167
  4. New Ashford – 228
  5. Aquinnah – 311

Residents per house unit in 2010

Residents per house unit 2010

Could the low number in Cape Code be explained by the higher number of secondary residences?

Population density in 2010

Residents per house unit 2010

We are looking at the number of habitants per acre.

Towns area

Largest towns in acres:

  1. Plymouth – 65726
  2. Middleborough – 46179
  3. Petersham – 43689
  4. Barnstable – 40001
  5. Dartmouth – 39513

Smallest towns in acres:

  1. Nahant – 671
  2. Winthrop – 1295
  3. Chelsea – 1416
  4. Hull – 1804
  5. Swampscott – 1945

Furthest towns from Boston

  1. Mount Washington – 193 kms
  2. Alford – 190 kms
  3. Egremont – 190 kms
  4. West Stockbridge – 185 kms
  5. Sheffield – 182 kms

There are many more distance and spatial computations we could make. Which one do you think would be interesting?

Software

We have been using the SnowFloat Python client and its web service running on Amazon EC2.

First step is to import the data source:

>>> import snowfloat.client
>>> client = snowfloat.client.Client()
>>> data_source = 'CENSUS2010TOWNS_POLY.zip'
>>> res = client.import_geospatial_data(data_source)
# res is a dictionary with the ID of the layer created and the number of features (districts) added.
>>> res
{u'layer_uuids': [u'b2b2660e43ef4196b999840984480338'], u'num_features': 351}
>>> layer_uuid = res['layer_uuids'][0]

Population per town

We define a map task and send it to the server.

>>> task = snowfloat.task.Task(
...     operation='map',
...     task_filter={'layer_uuid_exact': layer_uuid},
...     extras={'size': [800, 600],
...             'title': 'Population 2010',
...             'colors': {'type': 'gradient'},
...             'operation': {'type': 'nop',
...                           'value_1': 'field_pop2010',
...                           'normalize': 'log'}})

>>> res = client.execute_tasks([task,])
# res contains the URL of the map stored online.
>>> res
[[{u'url': u'http://snowfloat.results.s3.amazonaws.com/95391554fb6b4ba6bb1cffaf196f83ae?Signature=BQeDD2Ued1N2JolDwedfzjLAuoA%3D&Expires=1378834201&AWSAccessKeyId=AKIAI4JN4Z5ER2EY3A2Q'}]]

Furthest towns from Boston

First step is to calculate the centroid for the Boston town geometry:

>>> feature = client.get_features(layer_uuid=layer_uuid, field_town2_exact='Boston', spatial_operation='centroid')
>>> point = feature.spatial
>>> point
Point(coordinates=[233705.31415324158, 896147.8312876453])

Now, we can retrieve the five furthest towns from this point.

>>> features = client.get_features(layer_uuid=layer_uuid, spatial_operation='distance', spatial_geometry=point, order_by=('-spatial',), query_slice=(0,5))
>>> ['%s - %d kms' % (feature.fields['town2'], feature.spatial / 1000) for feature in features]
[u'Mount Washington - 193 kms',
 u'Alford - 190 kms',
 u'Egremont - 190 kms',
 u'West Stockbridge - 185 kms',
 u'Sheffield - 182 kms']

You can learn more about the SnowFloat service by reading its tutorial.

Last modified: May 30, 2020

Author