This tutorial goes over how to process a single landsat image on a single machine, using GeoTrellis and spark. We will create a server that will serve out tiles onto a web map that represent an NDVI calculation on our image. The calculation of the NDVI and the rendering of the PNG tile will be dynamic and happen per tile request.
Download this landsat image: https://s3.amazonaws.com/geotrellis-sample-datasets/landsat/LC80140322014139LGN00.tar.bz
Un-tar this into data/landsat
The code in src/main/scala/tutorial/MaskRedAndNearInfrared.scala
will do this.
> ./sbt run
Select the tutorial.MaskRedAndNearInfrared
to run.
This will produce data/r-nir.tif
The code in src/main/scala/tutorial/CreateNDVIPng.scala
will do this.
> ./sbt run
Select the tutorial.CreateNDVIPng
to run.
This will produce data/ndvi.png
We want to use the GDAL library to do some preproccessing of our data
First, we want to reproject our data into "web mercator" (EPSG:3857)
In the data
directory:
> gdalwarp -t_srs EPSG:3857 r-nir.tif r-nir-wm.tif
We'll want to work with smaller tiles of our image when working with spark. Tile them out using gdal_retile.py
In the data
directory:
> mkdir landsat-tiles
> gdal_retile.py -ps 512 512 -targetDir landsat-tiles/ r-nir-wm.tif
This step will transform the tiles we made last step into a set of GeoTiffs representing a version of the raster in GeoTiffs according to the Slippy Map tile coordinate representation, at multiple zoom levels.
The code is in the src/main/scala/tutorial/TileGeoTiff.scala
file.
> ./sbt run
Select the tutorial.TileGeoTiff
to run.
Tiles will be generated in the data/tiles
directory.
This step will start a server that will serve out NDVI images onto a web map.
The code is located in the src/main/scala/tutorial/ServeNDVI.scala
file.
> ./sbt run
Select the tutorial.ServeNDVI
to run.
You can either go tonow open static/index.html
and see our NDVI tiles on a web map.