py4sci

Table Of Contents

Previous topic

Using the tools

Next topic

osm2shp

This Page

osm2hydro

OSM2hydro

Execute the osm2hydro script.

Usage:

osm2hydro.py  -c inifilename [-E extent][-W working dir][-C caseFolder]
              [-N caseName][-O osm_extract_file][-F osmfile]

-c inifilename
Optional (overrides the ini settings):
    -E  extent according to: [xmin, ymin, xmax, ymax]
    -W working_directory
    -C caseFolder
    -N caseName
    -O osm_extract_file
    -F osmfile

Description

osm2hydro generates hydrological and hydraulic model schematisations from OpenStreetMap data

Status

Still under construction by Jaap Schellekens, Hessel Winsemius, Jan Talsma, Ferdinand Diermanse, Ruben Dahm, Reinder Brolsma and Daniel Tollenaar TODO: cleanup script, move stuff to functions

Dependencies

For osm2hydro, it is mandatory that GDAL version 1.10 or higher is installed.
osm2hydro.burn_lines(shapeFile, mapFile, value, x, y)

Make a map with zeros and burned in values at locations where a line shape is present shapeFile: string - Shapefile with line elements that need to be burned mapFile: string - Target GeoTIFF map file that will be written in this step value: string - The value that should be burned into the map x: 1-D array - x-axis of target map y: 1-D array - y-axis of target map

osm2hydro.closeLogger(logger, ch)

Closes the logger

osm2hydro.configget(log, config, section, var, default)

Gets a string from a config file (.ini) and returns a default value if the key is not found. If the key is not found it also sets the value with the default in the config-file

Input:
  • config - python ConfigParser object
  • section - section in the file
  • var - variable (key) to get
  • default - default string
Returns:
  • string - either the value from the config file or the default value
osm2hydro.configset(config, section, var, value, overwrite=False)

Sets a string in the in memory representation of the config object Deos NOT overwrite existing values if overwrite is set to False (default)

Input:
  • config - python ConfigParser object
  • section - section in the file
  • var - variable (key) to set
  • value - the value to set
  • overwrite (optional, default is False)
Returns:
  • nothing
osm2hydro.cutMap(xmin, ymin, xmax, ymax, origMap, transMap)

translateMap translates the tif formatted files from the srtm to PCRaster .map files origMap = your_map.tif transMap= your_map.map

osm2hydro.filter_shape(attribute, value, origShape, transShape)

Filters a shapefile based on a selection of and attribute/value attribute: string - indicating the attribute value: string - the value or comma-separated list of values of the attribute, filtered out origShape: strong - location of original shapefile transShape: string - location of target shapefile

osm2hydro.iniFileSetUp(configfile)

Reads .ini file and sets default values if not present

osm2hydro.projectMap(src_proj, trg_proj, origMap, transMap)

projectMap projects a source map to a targetmap with defined srs src_proj = projection of source data trg_proj = projection of target data origMap = your_map.tif transMap= your_map.map

osm2hydro.readMap(fileName, fileFormat)

Read geographical file into memory

Input:
filename - string holding file name fileFormat - a file format string according to the GDAL list of formats
Returns:
x,y,data,FillVal
osm2hydro.recursive_glob(rootdir='.', suffix='')

Prepares a list of files in location rootdir, with a suffix

input:

rootdir: string, path-name suffix: suffix of required files

output:

fileList: list-strings, file paths and names
osm2hydro.reduce_resolution(x, y, data, target_resolution)

Reduces resolution of a map (contained by x-axis, y-axis and an array) to a user-defined target resolution. This is done by a convolution and then picking one value per the amount of required resolution values.

osm2hydro.removeFinishedProcesses(processes)

given a list of (commandString, process), remove those that have completed and return the result

osm2hydro.runCommands(commands, maxCpu)

Runs a list of processes deviding over maxCpu

osm2hydro.setlogger(logfilename, logReference)

Set-up the logging system. Exit if this fails

input:

logfilename: string, referring to the logfile logReference: string, referring to reference used in log lines
output:
ch: handle, refer to logging object logger: logger object
osm2hydro.usage(*args)

Print usage information

@param args: command line arguments given

osm2hydro.writeMap(fileName, fileFormat, x, y, data, FillVal)

Write geographical data into file