Index: src/python/bin/gnuboat-log-analyser
===================================================================
--- src/python/bin/gnuboat-log-analyser	(revision 67942749943f5900c68728feabee2c152aa756dc)
+++ src/python/bin/gnuboat-log-analyser	(revision fbc3d47ea94065ff0b950a6fc03f2c0d3b7a6c91)
@@ -32,4 +32,12 @@
 from gnuboat.datahandler import loghandler, logdataset
 
+
+colors = {
+	0: "0 0 139",
+	2: "30 144 255",
+	6: "173 216 230",
+	10: "240 248 255"
+}
+
 class CsvCallback:
 	def __init__(self, output_file):
@@ -59,4 +67,6 @@
 
 def main(argv):
+	global color
+
 	input_file_path = None
 	output_directory = None
@@ -98,6 +108,6 @@
 		logfiles = json.load(input_file)
 	
-	source_data_layer = "corrected_joined_points"
-	corrected_joined_point_cloud_file_path = "{}/{}.csv".format(output_directory, source_data_layer)
+	source_data_layer = "tmp_corrected_joined_points"
+	corrected_joined_point_cloud_file_path = os.path.join(output_directory, "{}.csv".format(source_data_layer))
 	try:
 		output_file = open(corrected_joined_point_cloud_file_path, 'w')
@@ -135,6 +145,8 @@
 	output_file.close()
 
+
+	print("Creating output files")
 	# create ogr file info
-	source_xml_file = os.path.join(output_directory, "ogr_input_file.vrt")
+	source_xml_file = os.path.join(output_directory, "tmp_ogr_input_file.vrt")
 	try:
 		output_file = open(source_xml_file, 'wb')
@@ -166,74 +178,37 @@
 		print("  extents (x_min, y_min, x_max, y_max): {}, {}, {}, {}".format(source_x_min, source_y_min, source_x_max, source_y_max))
 		
-	# Create the destination data source
+	# create the grid data
+	gdal_file = "/vsimem/water_depth.tif"
 	tile_resolution = tile_width(target_zoomlevel)
 	target_x_res = int(tile_resolution["tile_size"] / tile_resolution["longitude"] * (source_x_max - source_x_min))
 	target_y_res = int(tile_resolution["tile_size"] / tile_resolution["latitude"] * (source_y_max - source_y_min))
-	#print("target resolution x,y: {},{}".format(target_x_res, target_y_res))
-	#print("pixel size x,y: {},{}".format((source_x_max - source_x_min)/target_x_res, (source_y_max - source_y_min)/target_y_res))
-	#target_data = gdal.GetDriverByName('MEM').Create('', target_x_res, target_y_res, gdal.GDT_Byte)
-	#target_data.SetGeoTransform((source_x_min, pixel_size, 0, source_y_max, 0, -pixel_size))
-	#band = target_ds.GetRasterBand(1)
-	#band.SetNoDataValue(NoData_value)
-	
-	# create the grid data
-	gdal_file = os.path.join(output_directory, "water_depth.tif")
 	grid_options = gdal.GridOptions(outputType = gdal.GDT_Float32, format = "GTiff", width = target_x_res, height = target_y_res, outputSRS = "WGS84", noData = target_nodata_value, layers = source_data_layer)
 	gdal.Grid(gdal_file, source_xml_file, options = grid_options)
+	print("  Created raster DEM in {}".format(gdal_file))
 	
 	# hillshade
 	gdal_file_hillshade  = os.path.join(output_directory, "water_depth_hillshade.tif")
-	gdal.DEMProcessing(gdal_file_hillshade, gdal_file, "hillshade", options = gdal.DEMProcessingOptions(format = "GTiff"))
-	
-	# translate the data
-	#gdal_file_translated = '/vsimem/translated.vrt'
-	#gdal_file_translated = os.path.join(output_directory, "water_depth_translated.tif")
-	#gdal.Translate(gdal_file_translated, gdal_file, 
-		#options = gdal.TranslateOptions(width = target_x_res, height = target_y_res, outputSRS = 'EPSG:3857', noData = target_nodata_value)
-	#)
-
-	# creating pipeline
-	#output_file_path = "{}/{}".format(output_directory, "water_depth.tif") 
-	#print("Creating Digital Terrain Model in {}".format(output_file_path))
-	#pipeline = {"pipeline":[
-				#{
-					#"type": "readers.text",
-					#"filename": corrected_joined_point_cloud_file_path
-				#},
-				#{
-					#"type": "filters.pmf"
-				#},
-				#{
-					#"type": "filters.range",
-					#"limits": "Classification[2:2]"
-				#},
-				#{
-					#"type": "writers.text",
-					#"order":"X,Y,Z",
-					#"keep_unspecified":"false",
-					#"filename":"outputfile.txt"
-				#}
-				##{
-					##"type": "writers.gdal",
-					##"filename": output_file_path,
-					##"output_type": "min",
-					##"gdaldriver": "GTiff",
-					##"resolution": 0.01
-					###"grid_dist_x": 1.0,
-					###"grid_dist_y": 1.0
-				##}
-			#]}
-	#pdal_pipeline = pdal.Pipeline(json.dumps(pipeline))
-	#pdal_pipeline.validate()
-	#pdal_pipeline.set_loglevel(8)
-	#count = pdal_pipeline.execute()
-	#metadata = pdal_pipeline.get_metadata()
-	#log = pdal_pipeline.get_(log)
-	
-	#print(metadata)
-	#print(log)
-	
-	#ds_in = gdal.Open(gdal_file)
-	#band_in = ds_in.GetRasterBand(band)
+	gdal.DEMProcessing(gdal_file_hillshade, gdal_file, "hillshade", options = gdal.DEMProcessingOptions(format = "GTiff", zFactor = -1))
+	print("  Created hillshade in {}".format(gdal_file_hillshade))
+	
+	# color relief
+	gdal_file_color_relief = os.path.join(output_directory, "water_depth_color_relief.tif")
+	gdal_file_color_relief_config = os.path.join(output_directory, "tmp_water_depth_color_relief_config.txt")
+	with open(gdal_file_color_relief_config, 'w') as color_config:
+		for depth in colors:
+			color_config.write("{} {}\n".format(depth, colors[depth]))
+	gdal.DEMProcessing(gdal_file_color_relief, gdal_file, "color-relief", options = gdal.DEMProcessingOptions(format = "GTiff", colorFilename = gdal_file_color_relief_config))
+	print("  Created color relief in {}".format(gdal_file_color_relief))
+	
+	# slope shade
+	gdal_file_slope_shade_tmp = "/vsimem/tmp_water_depth_slope_shade.tif"
+	gdal_file_slope_shade = os.path.join(output_directory, "water_depth_slope_shade.tif")
+	gdal_file_slope_shade_config = os.path.join(output_directory, "tmp_water_depth_slope_shade_config.txt")
+	with open(gdal_file_slope_shade_config, 'w') as shade_config:
+		shade_config.write("0 255 255 255\n")
+		shade_config.write("90 0 0 0\n")
+	gdal.DEMProcessing(gdal_file_slope_shade_tmp, gdal_file, "slope", options = gdal.DEMProcessingOptions(format = "GTiff"))
+	gdal.DEMProcessing(gdal_file_slope_shade, gdal_file_slope_shade_tmp, "color-relief", options = gdal.DEMProcessingOptions(format = "GTiff", colorFilename = gdal_file_slope_shade_config))
+	print("  Created slope shade in {}".format(gdal_file_slope_shade))
 
 	sys.exit(0)
