Changeset c5b13e1
- Timestamp:
- Jan 20, 2019, 5:21:35 PM (8 years ago)
- Branches:
- debian/bullseye, master
- Children:
- 74c3571
- Parents:
- 46f871f
- Files:
-
- 3 edited
-
setup.py (modified) (1 diff)
-
src/python/bin/gnuboat-log-analyser (modified) (12 diffs)
-
src/webapp/webserver/js/GnuBoat.Webserver.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
setup.py
r46f871f rc5b13e1 28 28 setup( 29 29 name="gnuboat", 30 version="0.4. 5",30 version="0.4.6", 31 31 maintainer="EngSaS - Langenbach", 32 32 maintainer_email="info@engsas.de", -
src/python/bin/gnuboat-log-analyser
r46f871f rc5b13e1 33 33 from gnuboat.datahandler import loghandler, logdataset 34 34 35 35 # -999 is a workaround, as long gdal python api does not handle addAlpha 36 36 colors = { 37 -999: "255 255 255", 37 38 0: "0 0 139", 38 39 2: "30 144 255", … … 41 42 } 42 43 input_epsg = 'EPSG:4326' 43 target_nodata_value = 0.044 target_nodata_value = -999.0 44 45 target_zoomlevel = 19 45 density_min = 20 # number of points per densitiy_base squaremetres needed to set a value different from nodata46 densit iy_base = 100 # squaremetre used as base for density_min46 density_min = 10 # number of points per density_base squaremetres needed to set a value different from nodata 47 density_base = 100 # squaremetre used as base for density_min 47 48 48 49 class CsvCallback: … … 73 74 74 75 def main(argv): 75 global color, input_epsg, target_nodata_value, target_zoomlevel 76 global color, input_epsg, target_nodata_value, target_zoomlevel, density_min, density_base 76 77 77 78 input_file_path = None 78 79 output_directory = None 79 80 statistics = False 81 82 gdal.UseExceptions() 80 83 81 84 parser = argparse.ArgumentParser(description='Generates the digital terrain model from gnuboat logfiles') … … 87 90 help='Print some statistics of the input and result datasets') 88 91 parser.add_argument('-p', '--points-min', dest='points_min', type=int, 89 help='Print min points per 100 squaremetre', default=10)92 help='Print min points per {} squaremetre'.format(density_base), default=density_min) 90 93 arguments = parser.parse_args(argv) 91 94 … … 111 114 density_min = arguments.points_min 112 115 113 gdal_file_contours = os.path.join(output_directory, "contours")116 gdal_file_contours = os.path.join(output_directory, 'contours_{}_{}'.format(density_min, density_base)) 114 117 print("Cleaning up / Preparing output directory") 115 118 if os.path.exists(output_directory): … … 201 204 lat_metre_max = 111694 # metre / degree 202 205 203 circle_radius = math.sqrt(densit iy_base) / math.pi206 circle_radius = math.sqrt(density_base) / math.pi 204 207 radius_x = circle_radius / lon_metre_max 205 208 radius_y = circle_radius / lat_metre_max … … 214 217 print(" degree / pixel x and y: {}, {}".format(degree_per_pixel_lon, degree_per_pixel_lat)) 215 218 print(" metre / pixel x and y: {}, {}".format(degree_per_pixel_lon * lon_metre_max, degree_per_pixel_lat * lat_metre_max)) 216 print(" Min density per squaredegree: {}".format(density_min * densit iy_base / lon_metre_max / lat_metre_max))217 print(" Min density per pixel: {}".format(density_min * densit iy_base / (degree_per_pixel_lon * lon_metre_max) / (degree_per_pixel_lat * lat_metre_max)))219 print(" Min density per squaredegree: {}".format(density_min * density_base / lon_metre_max / lat_metre_max)) 220 print(" Min density per pixel: {}".format(density_min * density_base / (degree_per_pixel_lon * lon_metre_max) / (degree_per_pixel_lat * lat_metre_max))) 218 221 print(" gridding algorithm {}".format(gridding_algorithm)) 219 222 … … 230 233 ) 231 234 gdal.Grid(gdal_file, source_xml_file, options = grid_options) 232 print(" Created raster DEMin memory")235 print(" Created raster Grid in memory") 233 236 234 237 # hillshade 235 gdal_file_hillshade = os.path.join(output_directory, "water_depth_hillshade.tif")238 gdal_file_hillshade = '/vsimem/water_depth_hillshade.tif' 236 239 gdal.DEMProcessing(gdal_file_hillshade, gdal_file, "hillshade", options = gdal.DEMProcessingOptions(format = "GTiff", zFactor = -1)) 237 print(" Created hillshade in {}".format(gdal_file_hillshade))240 print(" Created hillshade in memory") 238 241 239 242 # color relief 240 gdal_file_color_relief = os.path.join(output_directory, "water_depth_color_relief.tif")243 gdal_file_color_relief = '/vsimem/water_depth_color_relief.tif' 241 244 gdal_file_color_relief_config = os.path.join(output_directory, "tmp_water_depth_color_relief_config.txt") 242 245 with open(gdal_file_color_relief_config, 'w') as color_config: … … 244 247 color_config.write("{} {}\n".format(depth, colors[depth])) 245 248 gdal.DEMProcessing(gdal_file_color_relief, gdal_file, "color-relief", options = gdal.DEMProcessingOptions(format = "GTiff", colorFilename = gdal_file_color_relief_config), addAlpha = True) 246 print(" Created color relief in {}".format(gdal_file_color_relief))249 print(" Created color relief in memory") 247 250 248 251 # slopeshade 252 gdal_file_slopeshade = os.path.join(output_directory, "water_depth_slopeshade.tif") 249 253 gdal_file_slopeshade_tmp = "/vsimem/tmp_water_depth_slopeshade.tif" 250 254 gdal_file_slopeshade_config = os.path.join(output_directory, "tmp_water_depth_slopeshade_config.txt") … … 252 256 shade_config.write("0 255 255 255\n") 253 257 shade_config.write("90 0 0 0\n") 258 shade_config.write("270 0 0 0\n") 259 shade_config.write("360 255 255 255\n") 254 260 gdal.DEMProcessing(gdal_file_slopeshade_tmp, gdal_file, "slope", options = gdal.DEMProcessingOptions(format = "GTiff"), slopeFormat = 'degree', zeroForFlat = True, addAlpha = True) 255 261 gdal.DEMProcessing(gdal_file_slopeshade, gdal_file_slopeshade_tmp, "color-relief", options = gdal.DEMProcessingOptions(format = "GTiff", colorFilename = gdal_file_slopeshade_config), addAlpha = True) … … 266 272 proj.SetWellKnownGeogCS(input_epsg) 267 273 for depth in colors: 268 contour_layer = contour_output.CreateLayer('contour -{}'.format(depth), srs = proj)274 contour_layer = contour_output.CreateLayer('contour_{}_{}_{}'.format(density_min, density_base, depth), srs = proj) 269 275 field_definition = ogr.FieldDefn("ID", ogr.OFTInteger) 270 276 contour_layer.CreateField(field_definition) … … 276 282 del contour_output 277 283 278 #overlaid = gdal.Warp(gdal_file_slopeshade, [color_relief, hillshade], format='GTiff') 279 ##gdal.Translate(gdal_file_slopeshade, overlaid, creationOptions=['compress=LZW', 'alpha=yes']) 280 #gdal.Translate(gdal_file_slopeshade, overlaid, creationOptions=['alpha=yes']) 281 gdal.Warp('/tmp/gnuboat/test.tif', gdal_file_color_relief, options = gdal.WarpOptions(format = 'GTiff', dstAlpha = True, cutlineDSName = '/tmp/gnuboat/contours/contour-0.shp')) 282 #gdal.Warp('/tmp/gnuboat/test.tif', gdal_file_color_relief, options = gdal.WarpOptions(format = 'GTiff', dstAlpha = True)) 284 # combining hillshade and color relief 285 286 287 # cropping the tifs 288 #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)) 289 290 # dstNodata is a workaround for not working addAlpha in color-relief 291 gdal_final_result = '/tmp/gnuboat/water_depth_{}_{}.tif'.format(density_min, density_base) 292 gdal_color_relief_alpha_tmp = '/vsimem/tmp_color_relief.tif' 293 gdal.Warp(gdal_final_result, [gdal_file_color_relief, gdal_file_hillshade], options = gdal.WarpOptions(format = 'GTiff', dstAlpha = False, dstNodata = "255 255 255")) 283 294 284 295 # generate tiles 285 296 tile_zoom_option = "0-19" 286 297 tile_commands = [ 287 #hillshade 288 {"file": gdal_file_hillshade, "title": 'Hillshade', "output": 'hillshade'}, 289 #color relief 290 {"file": gdal_file_color_relief, "title": 'Color relief', "output": 'color_relief'}, 291 #slopeshade 292 {"file": gdal_file_slopeshade, "title": 'Slopeshade', "output": 'slopeshade'} 298 #combined 299 {"file": gdal_final_result, "title": 'GNUBoat {} datasets per {} squaremetre'.format(density_min, density_base), "output": 'gnuboat_{}_{}'.format(density_min, density_base)}, 293 300 ] 294 301 print("Expanding {} tifs to tiles".format(len(tile_commands))) -
src/webapp/webserver/js/GnuBoat.Webserver.js
r46f871f rc5b13e1 46 46 47 47 // add GNUBoat layers 48 var layer_gnuboat_ hillshade= L.tileLayer(49 './tiles/ hillshade/{z}/{x}/{y}.png',50 {tms: true, opacity: 0. 2, zIndex: 98, attribute: '© <a href="http://gnuboat.engsas.de">GNUBoat</a> contributors'}48 var layer_gnuboat_accuracy_low = L.tileLayer( 49 './tiles/gnuboat_10_100/{z}/{x}/{y}.png', 50 {tms: true, opacity: 0.5, zIndex: 98, attribute: '© <a href="http://gnuboat.engsas.de">GNUBoat</a> contributors'} 51 51 ); 52 var layer_gnuboat_color_relief= L.tileLayer( 53 'tiles/color_relief/{z}/{x}/{y}.png', 54 {tms: true, opacity: 0.4, zIndex: 99, attribute: '© <a href="http://gnuboat.engsas.de">GNUBoat</a> contributors'} 55 ); 56 var layer_gnuboat_slopeshade = L.tileLayer( 57 'tiles/slopeshade/{z}/{x}/{y}.png', 58 {tms: true, opacity: 0.2, zIndex: 97, attribute: '© <a href="http://gnuboat.engsas.de">GNUBoat</a> contributors'} 59 ); 60 var layer_gnuboat_group = L.layerGroup([layer_gnuboat_color_relief, layer_gnuboat_hillshade, layer_gnuboat_slopeshade]).addTo(GnuBoat.Webserver.private.map); 52 var layer_gnuboat_accuracy_high = L.tileLayer( 53 './tiles/gnuboat_100_100/{z}/{x}/{y}.png', 54 {tms: true, opacity: 0.5, zIndex: 98, attribute: '© <a href="http://gnuboat.engsas.de">GNUBoat</a> contributors'} 55 ).addTo(GnuBoat.Webserver.private.map); 61 56 62 57 // add layer control … … 66 61 // overlays 67 62 var overlays = {"Seamarks": layer_openseamap, 68 "GNUBoat": layer_gnuboat_group, 69 // "GNUBoat Hillshade": layer_gnuboat_hillshade, 70 // "GNUBoat Color Relief": layer_gnuboat_color_relief, 71 // "GNUBoat Slopeshade": layer_gnuboat_slopeshade, 63 "GNUBoat Low Accuracy": layer_gnuboat_accuracy_low, 64 "GNUBoat High Accuracy": layer_gnuboat_accuracy_high, 72 65 }; 73 66 GnuBoat.Webserver.private.mapControl = L.control.layers(
Note:
See TracChangeset
for help on using the changeset viewer.
