Module Streamlines__.Geodata

Copyright (C) 2017-2018,  Colin P Stark and Gavin J Stark.  All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @file   geodata.ml
 * @brief  Module to provide loading of Geotiff data and filling out the core data
 *
module Option = Batteries.Option
module ODM = Owl.Dense.Matrix.Generic
module ODN = Owl.Dense.Ndarray.Generic

Types

These types are used by the main code and the Geotiff module. They should not really be used by code outside of this file; the global t_core_data from the Core module contains the data that should be used for later analysis. However, the DTM array is, for example, only held by the Geodata module, so to plot that the Plot module currently picks inside t_geodata.

type t_geotiff = {
gtf_filename : string;
ds : Gdal.Data_set.t;
trans : Gdal.Geo_transform.t;
num_bands : int;
width : int;
height : int;
projection : string;
orig_x : float;
orig_y : float;
pixsz_x : float;
pixsz_y : float;
rot_x : float;
rot_y : float;
}

t_geotiff

Structure used by the Geotiff module, abstracting much of the Gdal handling from the main module.

type t_geodata = {
dtm_array : Streamlines.Globals.t_ba_floats;
x_easting_bottomleft : float;
y_northing_bottomleft : float;
roi_x_origin : float;
roi_y_origin : float;
roi_width : float;
roi_height : float;
roi_dx : float;
roi_dy : float;
}

t_geodata

The data structure that is filled out by a Geodata file

type t_data = {
props : Streamlines.Properties.t_props_geodata;
mutable g : t_geodata;
}

t_data

Main data structure for the module, including the data from a Geodata file (in t_geodata) and the properties for the Geodata workflow.

val geodata_dummy : t_geodata

geodata_dummy

A t_geodata structure that is effectively empty, so that it may be used prior to the reading of an actual Geodata file.

pv_verbosity functions

val pv_noisy : t_data ‑> (unit ‑> unit) ‑> unit

pv_noisy t

Shortcut to use Geodata.t_data verbosity for Properties.pv_noisy

val pv_debug : t_data ‑> (unit ‑> unit) ‑> unit

pv_debug t

Shortcut to use Geodata.t_data verbosity for Properties.pv_debug

val pv_info : t_data ‑> (unit ‑> unit) ‑> unit

pv_info t

Shortcut to use Geodata.t_data verbosity for Properties.pv_info

val pv_verbose : t_data ‑> (unit ‑> unit) ‑> unit

pv_verbose t

Shortcut to use Geodata.t_data verbosity for Properties.pv_verbose

Geotiff submodule

module Geotiff : sig ... end

Top level Geodata module functions

exception Geodata of string

Geodata of string exception

Raised if the ROI is out of bounds

val update_properties : t_data ‑> t_geotiff ‑> unit

update_properties t geo

Update the properties based on the Geotiff file

Raise an exception if the ROI is not sensible

val fill_data : t_data ‑> Streamlines.Core.t_core_data ‑> t_geotiff ‑> unit

fill_data t data geo

Fill out the Core data and t_data structures based on the Geotiff file header.

This does not load the DTM data nor fill our the ROI data

val read_dtm_file : t_data ‑> Streamlines.Core.t_core_data ‑> t_geotiff

read_dtm_file t

Read a DTM file - fills out the data and geodata based on the header of the file, then reads the DTM data and copies the ROI array.

val read_basin : t_data ‑> Streamlines.Core.t_core_data ‑> unit

read_basin t data

Read the basin masking file, fleshing out the data basin masks

val pad_basins : clear:bool ‑> t_data ‑> Streamlines.Core.t_core_data ‑> unit

pad_basins ~clear t data

Pads and clears the basin masks as required

Also masks out any DTM data that is NaN in the ROI array

val display : t_data ‑> Streamlines.Core.t_core_data ‑> t_geotiff ‑> unit

display t

Display the t_data structure for verbose operation

val process : t_data ‑> Streamlines.Core.t_core_data ‑> Streamlines.Core.t_core_data * t_geotiff

process t

Run the Geodata workflow - loading the Geodata file and generating masks, filling out the core data, and so on.

Load the required DTM file as a Geodata.t given basic properties

Read basin mask file if required

Pad masks as necessary

val create : Streamlines.Properties.t_props ‑> t_data

create props

Create the t_data structure, and initialize the Gdal library