Skip to content

Instantly share code, notes, and snippets.

@mcroydon
Created December 10, 2010 20:23
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcroydon/736750 to your computer and use it in GitHub Desktop.
Save mcroydon/736750 to your computer and use it in GitHub Desktop.
# Download all current FAA sectional GeoTIFFs (zipped)
import urllib, os, csv
from lxml.html.soupparser import fromstring
FAA_CHART_URL = 'http://aeronav.faa.gov/index.asp?xml=aeronav/applications/VFR/chartlist_sect'
BASE_CONTENT_URL = 'http://aeronav.faa.gov/'
DOWNLOAD_DIR = 'download'
data = urllib.urlopen(FAA_CHART_URL).read()
root = fromstring(data)
# Make a download dir if it doesn't exist.
try:
os.makedirs(DOWNLOAD_DIR)
except OSError:
pass
# Log publish date
Writer = csv.writer(open('sectionals.csv', 'wb'))
Writer.writerow(['File', 'Date'])
# Find all <tr> elements
for tr in root.xpath('//tr'):
# Only check those that are align="left"
if tr.get('align') == 'left':
# Current charts are in the first td with headers="header2"
td = tr.xpath('td[@headers = "header2"]')[0]
for child in td.getchildren():
# Create a download URL and a local filename
path = child.get('href')
url = BASE_CONTENT_URL + path
filename = path.split('/')[-1]
date = child.text.split('-')[1].strip()
print "Downloading %s" % filename
urllib.urlretrieve(url, os.path.join(DOWNLOAD_DIR, filename))
Writer.writerow(filename, date)

Sectional Tiles

  1. Download a sectional GeoTIFF from the FAA:

    wget http://aeronav.faa.gov/content/aeronav/sectional_files/Kansas_City_85.zip
  2. Unzip:

    unzip Kansas_City_85.zip
  3. Translate the GeoTIFF to RGBA:

    gdal_translate -of vrt -expand rgba Kansas\ City\ 85\ North.tif temp.vrt
  4. Install prereqs if necessary:

    aptitude install gdal-python proj-bin
  5. Run gdal2tiles.py, substituting your bucket instead of my-bucket:

    gdal2tiles.py -t "Kansas City North" -u http://s3.amazonaws.com/my-bucket/ -g <YOUR_GOOGLE_MAPS_KEY> temp.vrt outdir

    By default, gdal2tiles.py renders zoom levels 5-10. If you'd like a little more detail, I'd suggest rendering 5-11:

    gdal2tiles.py -t "Kansas City North" -u http://s3.amazonaws.com/my-bucket/ -z '5-11' -g <YOUR_GOOGLE_MAPS_KEY> temp.vrt outdir

    If you want to add a new zoom level to an existing set of tiles, give gdal2tiles.py the -e flag, which will cause it to only fill in missing files and will also update the generated HTML/XML to use the new zoom levels.

  6. Copy the contents of outdir to S3 and make the bucket and contents public.
  7. Visit http://s3.amazonaws.com/my-bucket/openlayers.html
@NelsonMinar
Copy link

I think in step 4 you need to run gdal2tiles.py on the generated temp.vrt file, not the original .tfw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment