SouthFACT / landsatfact-data

The backend geoprocessing project for nemac/landsat-fact-viewer
3 stars 1 forks source link

Create GeoPDF for Custom Request #45

Open mwhutchi opened 9 years ago

mwhutchi commented 9 years ago

The task is to create a GeoPDF that contains the change products for the custom request with the map zoomed to and showing the user's AOI and on top of the symbolized change products. The map should also be in a map template that has a map title, product dates, scale bar, north arrow, etc.

mwhutchi commented 9 years ago

William is helping me to protoype this to figure out the best method.

We first tried the GDAL/pyPDF method, which takes a geopdf that GDAL creates and merges it using pyPDF. We found the problem with this is that pyPDF does not retain its geospatial component. We tried merging it different orders and the output was non-spatial each time.

But, after digging in to GDAL some more we found there are more advanced options for creating a geoPDF with gdal_translate: http://www.gdal.org/frmt_pdf.html

We found that GDAL can take a WMS as an input, and each layer in the pdf can be specified via separate xml files that each refer to a WMS layer. So, this retains the product symbology via the WMS.

Upon further research, GDAL has the option of creating a "collar" around the map in the pdf where you can insert images (north arrow, scalebar, etc.) and text on the pdf. We tested this and have a working prototype. The next steps are to refine the map, insert the user's AOI and zoom the map to the AOI extent. Then we need to think about how this would be done programmatically.

Here is an example command we used:

` gdal_translate -of PDF -a_srs epsg:4326 layer.xml map_out_base.pdf -projwin -94.21875 37.1337890625 -89.47265625 34.4970703125 -co "LAYER_NAME=layer" -co "EXTRA_RASTERS=layer2.xml,layer3.xml,layer4.xml" -co "EXTRA_RASTERS_LAYER_NAME=layer2,layer3,layer4" -co "EXTRA_IMAGES=mapscale.PNG,0,-10,1,northarrow.png, 600,50,.5,test_title.png, 450, 550, .5" -co "EXTRA_LAYER_NAME=mapscale,northarrow,test_title" `

and here is an example WMS layer in the xml: `

1.1.1 http://landsatfact-data-dev.nemac.org/lsflayers EPSG:4326 image/png B7DIFF-raster-threshold&TIME=2015-06-29 -94.21875 37.1337890625 -89.47265625 34.4970703125 700 600 1024 1024 EPSG:4326 3 false

`