Index: src/python/bin/gnuboat-log-analyser
===================================================================
--- src/python/bin/gnuboat-log-analyser	(revision 403e4ed9d9ea958f4a7e04cd8317d86a9ab14b7e)
+++ src/python/bin/gnuboat-log-analyser	(revision 74c3571b330568daeee1f4562299f3daae280ddf)
@@ -33,6 +33,7 @@
 from gnuboat.datahandler import loghandler, logdataset
 
-
+# -999 is a workaround, as long gdal python api does not handle addAlpha
 colors = {
+	-999: "255 255 255",
 	0: "0 0 139",
 	2: "30 144 255",
@@ -41,8 +42,8 @@
 }
 input_epsg = 'EPSG:4326'
-target_nodata_value = 0.0
+target_nodata_value = -999.0
 target_zoomlevel = 19
-density_min = 20 # number of points per densitiy_base squaremetres needed to set a value different from nodata
-densitiy_base = 100 # squaremetre used as base for density_min
+density_min = 10 # number of points per density_base squaremetres needed to set a value different from nodata
+density_base = 100 # squaremetre used as base for density_min
 
 class CsvCallback:
@@ -73,9 +74,11 @@
 
 def main(argv):
-	global color, input_epsg, target_nodata_value, target_zoomlevel
+	global color, input_epsg, target_nodata_value, target_zoomlevel, density_min, density_base
 
 	input_file_path = None
 	output_directory = None
 	statistics = False
+	
+	gdal.UseExceptions()
 
 	parser = argparse.ArgumentParser(description='Generates the digital terrain model from gnuboat logfiles')
@@ -87,5 +90,5 @@
                         help='Print some statistics of the input and result datasets')
 	parser.add_argument('-p', '--points-min', dest='points_min', type=int,
-                        help='Print min points per 100 squaremetre', default=10)
+                        help='Print min points per {} squaremetre'.format(density_base), default=density_min)
 	arguments = parser.parse_args(argv)
 
@@ -111,5 +114,5 @@
 		density_min = arguments.points_min
 		
-	gdal_file_contours = os.path.join(output_directory, "contours")
+	gdal_file_contours = os.path.join(output_directory, 'contours_{}_{}'.format(density_min, density_base))
 	print("Cleaning up / Preparing output directory")
 	if os.path.exists(output_directory):
@@ -201,5 +204,5 @@
 	lat_metre_max = 111694 # metre / degree
 	
-	circle_radius = math.sqrt(densitiy_base) / math.pi
+	circle_radius = math.sqrt(density_base) / math.pi
 	radius_x = circle_radius / lon_metre_max
 	radius_y = circle_radius / lat_metre_max
@@ -214,6 +217,6 @@
 		print("  degree / pixel x and y: {}, {}".format(degree_per_pixel_lon, degree_per_pixel_lat))
 		print("  metre / pixel x and y: {}, {}".format(degree_per_pixel_lon * lon_metre_max, degree_per_pixel_lat * lat_metre_max))
-		print("  Min density per squaredegree: {}".format(density_min * densitiy_base / lon_metre_max / lat_metre_max))
-		print("  Min density per pixel: {}".format(density_min * densitiy_base / (degree_per_pixel_lon * lon_metre_max) / (degree_per_pixel_lat * lat_metre_max)))
+		print("  Min density per squaredegree: {}".format(density_min * density_base / lon_metre_max / lat_metre_max))
+		print("  Min density per pixel: {}".format(density_min * density_base / (degree_per_pixel_lon * lon_metre_max) / (degree_per_pixel_lat * lat_metre_max)))
 		print("  gridding algorithm {}".format(gridding_algorithm))
 	
@@ -230,13 +233,13 @@
 	)
 	gdal.Grid(gdal_file, source_xml_file, options = grid_options)
-	print("  Created raster DEM in memory")
+	print("  Created raster Grid in memory")
 	
 	# hillshade
-	gdal_file_hillshade  = os.path.join(output_directory, "water_depth_hillshade.tif")
+	gdal_file_hillshade  = '/vsimem/water_depth_hillshade.tif'
 	gdal.DEMProcessing(gdal_file_hillshade, gdal_file, "hillshade", options = gdal.DEMProcessingOptions(format = "GTiff", zFactor = -1))
-	print("  Created hillshade in {}".format(gdal_file_hillshade))
+	print("  Created hillshade in memory")
 	
 	# color relief
-	gdal_file_color_relief = os.path.join(output_directory, "water_depth_color_relief.tif")
+	gdal_file_color_relief = '/vsimem/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:
@@ -244,7 +247,8 @@
 			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), addAlpha = True)
-	print("  Created color relief in {}".format(gdal_file_color_relief))
+	print("  Created color relief in memory")
 	
 	# slopeshade
+	gdal_file_slopeshade  = os.path.join(output_directory, "water_depth_slopeshade.tif")
 	gdal_file_slopeshade_tmp = "/vsimem/tmp_water_depth_slopeshade.tif"
 	gdal_file_slopeshade_config = os.path.join(output_directory, "tmp_water_depth_slopeshade_config.txt")
@@ -252,4 +256,6 @@
 		shade_config.write("0 255 255 255\n")
 		shade_config.write("90 0 0 0\n")
+		shade_config.write("270 0 0 0\n")
+		shade_config.write("360 255 255 255\n")
 	gdal.DEMProcessing(gdal_file_slopeshade_tmp, gdal_file, "slope", options = gdal.DEMProcessingOptions(format = "GTiff"), slopeFormat = 'degree', zeroForFlat = True, addAlpha = True)
 	gdal.DEMProcessing(gdal_file_slopeshade, gdal_file_slopeshade_tmp, "color-relief", options = gdal.DEMProcessingOptions(format = "GTiff", colorFilename = gdal_file_slopeshade_config), addAlpha = True)
@@ -266,5 +272,5 @@
 	proj.SetWellKnownGeogCS(input_epsg)
 	for depth in colors:
-		contour_layer = contour_output.CreateLayer('contour-{}'.format(depth), srs = proj)
+		contour_layer = contour_output.CreateLayer('contour_{}_{}_{}'.format(density_min, density_base, depth), srs = proj)
 		field_definition = ogr.FieldDefn("ID", ogr.OFTInteger)
 		contour_layer.CreateField(field_definition)
@@ -276,19 +282,20 @@
 	del contour_output
 	
-	#overlaid = gdal.Warp(gdal_file_slopeshade, [color_relief, hillshade], format='GTiff')
-	##gdal.Translate(gdal_file_slopeshade, overlaid, creationOptions=['compress=LZW', 'alpha=yes'])
-	#gdal.Translate(gdal_file_slopeshade, overlaid, creationOptions=['alpha=yes'])
-	gdal.Warp('/tmp/gnuboat/test.tif', gdal_file_color_relief, options = gdal.WarpOptions(format = 'GTiff', dstAlpha = True, cutlineDSName = '/tmp/gnuboat/contours/contour-0.shp'))
-	#gdal.Warp('/tmp/gnuboat/test.tif', gdal_file_color_relief, options = gdal.WarpOptions(format = 'GTiff', dstAlpha = True))
+	# combining hillshade and color relief
+	
+	
+	# cropping the tifs
+	#gdal.Warp('/tmp/gnuboat/test.tif', gdal_file_color_relief, options = gdal.WarpOptions(format = 'GTiff', dstAlpha = True, srcNodata = "255 255 255", dstNodata = target_nodata_value, cutlineDSName = '/tmp/gnuboat/contours/contour-0.shp', cutlineLayer="contour-0", cropToCutline=True))
+
+	# dstNodata is a workaround for not working addAlpha in color-relief
+	gdal_final_result = '/tmp/gnuboat/water_depth_{}_{}.tif'.format(density_min, density_base)
+	gdal_color_relief_alpha_tmp = '/vsimem/tmp_color_relief.tif'
+	gdal.Warp(gdal_final_result, [gdal_file_color_relief, gdal_file_hillshade], options = gdal.WarpOptions(format = 'GTiff', dstAlpha = False, dstNodata = "255 255 255"))
 
 	# generate tiles
 	tile_zoom_option = "0-19"
 	tile_commands = [
-		#hillshade
-		{"file": gdal_file_hillshade, "title": 'Hillshade', "output": 'hillshade'},
-		#color relief
-		{"file": gdal_file_color_relief, "title": 'Color relief', "output": 'color_relief'},
-		#slopeshade
-		{"file": gdal_file_slopeshade, "title": 'Slopeshade', "output": 'slopeshade'}
+		#combined
+		{"file": gdal_final_result, "title": 'GNUBoat {} datasets per {} squaremetre'.format(density_min, density_base), "output": 'gnuboat_{}_{}'.format(density_min, density_base)},
 	]
 	print("Expanding {} tifs to tiles".format(len(tile_commands)))
