hazimp.raster
¶
Manipulate raster data.
Module Contents¶
Classes¶
A simple class to describe a raster. |
Functions¶
|
Get data at lat lon points, based on a set of files |
|
Given an extent and a maximum extent modify maximum extent so |
- class hazimp.raster.Raster(filename, upper_left_x, upper_left_y, x_pixel, y_pixel, no_data_value, x_size, y_size)¶
Bases:
object
A simple class to describe a raster.
- classmethod from_file(cls, filename)¶
Load a file in a raster file format known to GDAL. Note, image must be ‘North up’.
- Parameters:
filename – The raster file path string.
- Returns:
A Raster instance.
- raster_data_at_points(self, lon, lat, scaling_factor=None)¶
Get data at lat lon points of the raster.
- Parameters:
lon – A 1D array of the longitude of the points.
lat – A 1D array of the latitude of the points.
scaling_factor – An optional scaling factor to apply to the values.
- Returns:
A numpy array, First dimension being the points/sites.
- extent(self)¶
Return the extent, in lats and longs of the raster.
- Returns:
min_long, min_lat, max_long, max_lat
- hazimp.raster.files_raster_data_at_points(lon, lat, files, scaling_factor=None)¶
Get data at lat lon points, based on a set of files
- Parameters:
files – A list of files.
lon – A 1D array of the longitude of the points.
lat – A 1d array of the latitude of the points.
scaling_factor – An optional scaling factor to apply to the values.
- Returns:
reshaped_data, max_extent reshaped_data: A numpy array, shape (sites, hazards) or shape (sites), for one hazard. max_extent: [min_long, min_lat, max_long, max_lat] A rectange covering the extents of all of the loaded rasters.
- hazimp.raster.recalc_max(max_extent, extent)¶
Given an extent and a maximum extent modify maximum extent so it covers the extent area.
- Both parameters describe a rectangle;
[min_long, min_lat, max_long, max_lat]
- Parameters:
max_extent – A list describing a rectangular area.
extent – A tuple/list describing the area that must be covered by max_extent.