Skip to content

mappingdc/changewithin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

changewithin is a simple script that pulls daily changes from OpenStreetMap with requests, parses them with lxml, finds the ones that are inside of a GeoJSON shape, sorts out the ones that are buildings, and emails a set of users with mailgun.

The one file that will require editing is config.ini.

At the top you will find a simple list of email addresses to which the script will send reports. The email templates for both html and text can be edited within the file lib.py. The report itself contains a summary of changes, then lists each relevant changeset, its ID, and further details. These include the user who made the change and their comment, individual element IDs for building footprint and address changes that link to their history, and a map thumbnail that is centered on the location where the edits were made.

Geography

nyc.geojson contains sample boundaries for New York City.

You can configure a remote URL containing GeoJSON data. US Census places and counties are available from Code for America, referenced by GEOID. To find the GEOID for a county or place, start with one of these Census lookup tools:

Each GEOID combines the state FIPS code (two digits) and ANSI code. For example, to find the GEOID of New York City, select New York State via the Place Lookup tool above and look for "New York City" on the page. Its ANSI code is 51000 and New York's state FIPS code is 36. Therefore, New York City's GEOID is 3651000 and its GeoJSON URL is:

Example GeoJSON URLs for L.A. County, Washington DC, and Oakland CA:

Installation

Requires wget or cURL .

cURL typically comes pre-installed.

For Mac use homebrew and one of:

brew install wget
brew install curl

For Ubuntu/Linux one of:

apt-get install wget
apt-get install curl

Requires Python with lxml, requests, pystache, PIL, and ModestMaps.

Optionally set up virtualenv:

virtualenv --no-site-packages venv-changewithin
source venv-changewithin/bin/activate

Install libraries needed for fast XML processing and Python extensions. For Ubuntu/Linux:

apt-get install python-dev libxml2-dev libxslt1-dev

Install Python packages:

pip install -r requirements.txt

Running

python changewithin.py

Automating

Assuming the above installation, edit your cron table (crontab -e) to run the script once a day at 7:00am.

0 7 * * * ~/path/to/changewithin/bin/python ~/path/to/changewithin/changewithin.py