With five identical 5-meter resolution RapidEye satellites and one day revisit time, our friends at Blackbridge offer imagery that is super useful for a variety of natural resource management tasks. I decided to take advantage of our new upload workflow — you can now upload TIFFs up to 4GB directly to Mapbox.com — with some of their sample imagery.

After trimming the image to three bands, reprojecting it to web mercator, and stitching together images to make a mosaic, I uploaded the resulting TIFF directly to Mapbox.com. This is the map our imagery pipeline produced:

5,000 km2 of 5-meter imagery of Brazil's Federal District. Pan east to see beautiful textures in the agricultural fields and pan west to see the busy city of Brasilia. View full screen map.

You can use the same scripts that I did by copying and pasting the script below into a text editor and saving it as an executable bash file. Drop it into the same folder as your Blackbridge sample images then execute it from the command line with your input images as command line arguments. I saved the file as "process", navigated to the folder where the executable and my image files live, and called:

Executable bash file:

./process input-file-1.tif input-file-2.tif input-file-3.tif .... etc



# for each image: reproject, scale to 8-bit, cut to 3 bands, clean up no data values
for var in $@; do
export var=${var%.tif}

gdalwarp -s_srs EPSG:32723 -t_srs EPSG:3857 -r cubic -dstnodata 0 ${var}.tif ${var}-3857.tif

gdal_translate -scale 0 65535 0 255 -ot Byte -b 3 -b 2 -b 1 -co photometric=rgb -a_srs EPSG:3857 -a_nodata "0 0 0" -of GTiff ${var}-3857.tif ${var}-3857-rgb.tif

nearblack -o  ${var}-3857-rgb-nb.tif -of GTiff ${var}-3857-rgb.tif;

# merge together separate images
gdal_merge.py -o merged.tif -n 0 *nb.tif

# use color formula to brighten
convert -sigmoidal-contrast 30,8% -modulate 100,125 merged.tif merged-color.tif

# add geo information back to file after imagemagick command
gdal_translate -a_srs EPSG:3857 -a_nodata "0 0 0" merged-color.tif processed.tif
listgeo -tfw merged.tif
mv merged.tfw processed.tfw
gdal_edit.py -a_srs EPSG:3857 processed.tif

# clean up processing files, leaving just the original images & final processed composite image
for var in $@; do
  export var=${var%.tif}
  rm ${var}-3857.tif
  rm ${var}-3857-rgb.tif
  rm ${var}-3857-rgb.tif.aux.xml
  rm ${var}-3857-rgb-nb.tif
  rm merged.tif
  rm merged-color.tif
  rm processed.tfw;

If you'd like to modify this script for a different imagery source, you'll want to pay attention to the starting projection of the image, the "no data" values, the number of bands your source image has, and whether it needs to scaled to 8-bit.

Questions? Hit me on Twitter (@camillacaros) or reach out to us at satellite@mapbox.com.