classes package

Submodules

classes.config module

System-wide configuration

Assumes the existence of the file ‘api_credentials.ini’ for accessing the NISMODDB++ API. This should reside in
the same directory (‘classes’) as this file, and contain the following lines:

[API_CREDENTIALS]
username = <api_username>
password = <api_password>

Note that no extra quotation marks are required around the credentials.

Created on Wed Jun 5 16:22:55 2019

@author: ndh114
class classes.config.Config

Bases: object

static get(name)
static set(name, value)

classes.fishnet module

Fishnet creation class

Created on Wed Jun 5 14:41:41 2019

@author: ndh114

class classes.fishnet.FishNet(outfile=None, outformat='GeoJSON', lad=None, bbox=[90000.0, 10000.0, 400000.0, 660000.0], netsize=100.0)

Bases: object

Constructor

Keyword arguments:
outfile – filename to write the fishnet output to (default None, indicating return the data as GeoJSON string)
outformat – ESRI Shapefile|GeoJSON, (default ‘GeoJSON’)
lad – Local Authority District code(s) to deduce bounds from (‘all’ to use all)
(default None, will be used preferentially to bbox if supplied)
bbox – Bounding box of interest (default to bounding box of England and Wales)
netsize – Resolution of the grid in metres (default 100.0)

Returns:
full file path (outfile supplied), or GeoJSON string (outfile not supplied)
create()
read_file(filename)

Read an in-memory file https://gis.stackexchange.com/questions/255153/gdal-vectortranslate-returns-an-empty-file also see: https://gis.stackexchange.com/questions/318916/getting-png-binary-data-from-gdaldataset

classes.rasteriser module

Rasteriser class

Created on Mon Jun 17 14:30:23 2019

@author: ndh114

class classes.rasteriser.Rasteriser(geojson_data, area_codes=[], bounding_box=None, fishnet=None, scale='lad', output_filename='output_raster.tif', output_format='GeoTIFF', resolution=100.0, area_threshold=50.0, invert=True)

Bases: object

Constructor

Keyword arguments:
geojson_data – extracted GeoJSON data
area_codes – boundary specified by area code list OR
bounding_box – as a bounding box as a list [xmin, ymin, xmax, ymax] OR
fishnet – as existing fishnet GeoJSON output from the FishNet class
scale – scale to look at (oa|lad|gor)
output_filename – output filename
output_format – raster output file format (GeoTIFF|ASCII)
resolution – fishnet sampling resolution in metres
area_threshold – minimum data area within a cell to trigger raster inclusion
invert – True if output raster gets a ‘0’ for areas > threshold

Returns:
full file path (output_filename supplied)
create()
Generate the output raster dataset
debug_dump_geojson_to_file(filename, json_data)

Dump the given JSON data to a file for examination

Module contents

__init__.py

Created on Thu Jun 6 15:17:03 2019

@author: ndh114