SimpleFly - Map Tiles
A flight app providing a moving map needs access to aviation maps. In the United States the FAA provides downloadable maps for free, but only in a format that facilitates printing your own large paper map. When developing SimpleFly, I needed to be able to provide these FAA maps in an online map format, and this page describes these steps.
But first, if you are interested in the SimpleFly app, the details that can be found here:
https://worktablecnc.us/projects/simplefly.html
Map Tiles for FAA VFR Sectionals
Maps shown on websites and apps are typically not a single large file. They are pieces of maps called tiles. When you need a view of a map, the system only downloads the tiles it needs to show you that view. And, tile sets are provided for different zoom levels. This way you can zoom in really close without having a fuzzy image or zoom out without having a massively large file.
The FAA provides flight maps files for free, but they are only image files of the area maps you would otherwise physically have. Sidebar: the FAA is the Federal Aviation Administration, the area maps are called Sectionals, those are provided either for Visual Flight Rules (VRF) or Instrument Flight Rules (IFR). Unfortunately, the FAA does not provide a single whole detailed map of the USA. And, they certainly do not provide map tiles (well, sometimes a third party does for them but not without prohibitive restrictions... worthless).
So you have to make your own FAA VFR Sectional map tiles. The steps:
- Download the Sectionals.
- Crop out the map, get rid of the border and legend.
- Stitch all into one big file.
- Tile the big file.
I have to credit Kira at ephemeral.cx. She detailed the steps in this blog post.
And since the size and layout of every Sectional is different, Kira also went through every Sectional and manually created the cropping information. Thank you Kira!
Using her guide I slightly modified her bash script file:
#!/bin/bash
set -e
# List all the chart zip files you have downloaded:
CHARTS=("Seattle" "Klamath Falls" "Great Falls" "Salt Lake City")
rm all_charts.vrt || true
rm -rf webviewer/tiles || true
for CHART in "${CHARTS[@]}"; do
# Unzip the folder from the FAA:
unzip -o "${CHART// /_}.zip"
# Trim the unusable edges and warp the TIF:
gdalwarp \
-t_srs EPSG:3857 \
-co TILED=YES \
-dstalpha \
-of GTiff \
-cutline "shapefiles/$CHART.shp" \
-crop_to_cutline \
-wo NUM_THREADS=`grep -c ^processor /proc/cpuinfo` \
-multi \
-overwrite \
"$CHART SEC.tif" \
"$CHART cropped.tif"
# Translate the TIF into a single VRT (vector tile):
gdal_translate -of vrt -expand rgba "$CHART cropped.tif" "$CHART.vrt"
done
# Combine the single VRT's into one large VRT:
gdalbuildvrt all_charts.vrt *.vrt
# Create VRT tile sets from the large VRT:
gdal2tiles.py \
--zoom "8-11" \
--xyz \
--processes=`grep -c ^processor /proc/cpuinfo` \
--webviewer=none \
--exclude \
--tiledriver=WEBP \
--webp-quality=50 \
all_charts.vrt \
webviewer/tiles