natcap.invest.wind_energy package¶

natcap.invest.wind_energy.wind_energy module¶

InVEST Wind Energy model

exception natcap.invest.wind_energy.wind_energy.FieldError

Bases: exceptions.Exception

A custom error message for fields that are missing

exception natcap.invest.wind_energy.wind_energy.TimePeriodError

Bases: exceptions.Exception

A custom error message for when the number of years does not match the number of years given in the price table

natcap.invest.wind_energy.wind_energy.add_field_to_shape_given_list(shape_ds_uri, value_list, field_name)

Adds a field and a value to a given shapefile from a list of values. The list of values must be the same size as the number of features in the shape

shape_ds_uri - a URI to an OGR datasource

value_list - a list of values that is the same length as there are
features in ‘shape_ds’

field_name - a String for the name of the new field

returns - nothing

natcap.invest.wind_energy.wind_energy.calculate_distances_grid(land_shape_uri, harvested_masked_uri, tmp_dist_final_uri)

Creates a distance transform raster from an OGR shapefile. The function first burns the features from ‘land_shape_uri’ onto a raster using ‘harvested_masked_uri’ as the base for that raster. It then does a distance transform from those locations and converts from pixel distances to distance in meters.

land_shape_uri - a URI to an OGR shapefile that has the desired
features to get the distance from (required)
harvested_masked_uri - a URI to a GDAL raster that is used to get
the proper extents and configuration for new rasters
tmp_dist_final_uri - a URI to a GDAL raster for the final
distance transform raster output

returns - Nothing

natcap.invest.wind_energy.wind_energy.calculate_distances_land_grid(land_shape_uri, harvested_masked_uri, tmp_dist_final_uri)

Creates a distance transform raster based on the shortest distances of each point feature in ‘land_shape_uri’ and each features ‘L2G’ field.

land_shape_uri - a URI to an OGR shapefile that has the desired
features to get the distance from (required)
harvested_masked_uri - a URI to a GDAL raster that is used to get
the proper extents and configuration for new rasters
tmp_dist_final_uri - a URI to a GDAL raster for the final
distance transform raster output

returns - Nothing

natcap.invest.wind_energy.wind_energy.clip_and_reproject_raster(raster_uri, aoi_uri, projected_uri)

Clip and project a Dataset to an area of interest

raster_uri - a URI to a gdal Dataset

aoi_uri - a URI to a ogr DataSource of geometry type polygon

projected_uri - a URI string for the output dataset to be written to
disk

returns - nothing

natcap.invest.wind_energy.wind_energy.clip_and_reproject_shapefile(shapefile_uri, aoi_uri, projected_uri)

Clip and project a DataSource to an area of interest

shapefile_uri - a URI to a ogr Datasource

aoi_uri - a URI to a ogr DataSource of geometry type polygon

projected_uri - a URI string for the output shapefile to be written to
disk

returns - nothing

natcap.invest.wind_energy.wind_energy.clip_datasource(aoi_uri, orig_ds_uri, output_uri)

Clip an OGR Datasource of geometry type polygon by another OGR Datasource geometry type polygon. The aoi should be a shapefile with a layer that has only one polygon feature

aoi_uri - a URI to an OGR Datasource that is the clipping bounding box

orig_ds_uri - a URI to an OGR Datasource to clip

out_uri - output uri path for the clipped datasource

returns - Nothing

natcap.invest.wind_energy.wind_energy.combine_dictionaries(dict_1, dict_2)

Add dict_2 to dict_1 and return in a new dictionary. Both dictionaries should be single level with a key that points to a value. If there is a key in ‘dict_2’ that already exists in ‘dict_1’ it will be ignored.

dict_1 - a python dictionary
ex: {‘ws_id’:1, ‘vol’:65}
dict_2 - a python dictionary
ex: {‘size’:11, ‘area’:5}

returns - a python dictionary that is the combination of ‘dict_1’ and ‘dict_2’ ex:

ex: {‘ws_id’:1, ‘vol’:65, ‘area’:5, ‘size’:11}
natcap.invest.wind_energy.wind_energy.create_wind_farm_box(spat_ref, start_point, x_len, y_len, out_uri)

Create an OGR shapefile where the geometry is a set of lines

spat_ref - a SpatialReference to use in creating the output shapefile
(required)
start_point - a tuple of floats indicating the first vertice of the
line (required)
x_len - an integer value for the length of the line segment in
the X direction (required)
y_len - an integer value for the length of the line segment in
the Y direction (required)
out_uri - a string representing the file path to disk for the new
shapefile (required)

return - nothing

natcap.invest.wind_energy.wind_energy.execute(args)

Wind Energy.

This module handles the execution of the wind energy model given the following dictionary:

Parameters: workspace_dir (string) – a python string which is the uri path to where the outputs will be saved (required) wind_data_uri (string) – path to a CSV file with the following header: [‘LONG’,’LATI’,’LAM’, ‘K’, ‘REF’]. Each following row is a location with at least the Longitude, Latitude, Scale (‘LAM’), Shape (‘K’), and reference height (‘REF’) at which the data was collected (required) aoi_uri (string) – a uri to an OGR datasource that is of type polygon and projected in linear units of meters. The polygon specifies the area of interest for the wind data points. If limiting the wind farm bins by distance, then the aoi should also cover a portion of the land polygon that is of interest (optional for biophysical and no distance masking, required for biophysical and distance masking, required for valuation) bathymetry_uri (string) – a uri to a GDAL dataset that has the depth values of the area of interest (required) land_polygon_uri (string) – a uri to an OGR datasource of type polygon that provides a coastline for determining distances from wind farm bins. Enabled by AOI and required if wanting to mask by distances or run valuation global_wind_parameters_uri (string) – a float for the average distance in kilometers from a grid connection point to a land connection point (required for valuation if grid connection points are not provided) suffix (string) – a String to append to the end of the output files (optional) turbine_parameters_uri (string) – a uri to a CSV file that holds the turbines biophysical parameters as well as valuation parameters (required) number_of_turbines (int) – an integer value for the number of machines for the wind farm (required for valuation) min_depth (float) – a float value for the minimum depth for offshore wind farm installation (meters) (required) max_depth (float) – a float value for the maximum depth for offshore wind farm installation (meters) (required) min_distance (float) – a float value for the minimum distance from shore for offshore wind farm installation (meters) The land polygon must be selected for this input to be active (optional, required for valuation) max_distance (float) – a float value for the maximum distance from shore for offshore wind farm installation (meters) The land polygon must be selected for this input to be active (optional, required for valuation) valuation_container (boolean) – Indicates whether model includes valuation foundation_cost (float) – a float representing how much the foundation will cost for the specific type of turbine (required for valuation) discount_rate (float) – a float value for the discount rate (required for valuation) grid_points_uri (string) – a uri to a CSV file that specifies the landing and grid point locations (optional) avg_grid_distance (float) – a float for the average distance in kilometers from a grid connection point to a land connection point (required for valuation if grid connection points are not provided) price_table (boolean) – a bool indicating whether to use the wind energy price table or not (required) wind_schedule (string) – a URI to a CSV file for the yearly prices of wind energy for the lifespan of the farm (required if ‘price_table’ is true) wind_price (float) – a float for the wind energy price at year 0 (required if price_table is false) rate_change (float) – a float as a percent for the annual rate of change in the price of wind energy. (required if price_table is false)

Example Args Dictionary:

{
'workspace_dir': 'path/to/workspace_dir',
'wind_data_uri': 'path/to/file',
'aoi_uri': 'path/to/shapefile',
'bathymetry_uri': 'path/to/raster',
'land_polygon_uri': 'path/to/shapefile',
'global_wind_parameters_uri': 'path/to/csv',
'suffix': '_results',
'turbine_parameters_uri': 'path/to/csv',
'number_of_turbines': 10,
'min_depth': 3,
'max_depth': 60,
'min_distance': 0,
'max_distance': 200000,
'valuation_container': True,
'foundation_cost': 3.4,
'discount_rate': 7.0,
'grid_points_uri': 'path/to/csv',
'avg_grid_distance': 4,
'price_table': True,
'wind_schedule': 'path/to/csv',
'wind_price': 0.4,
'rate_change': 0.0,

}

Returns: None
natcap.invest.wind_energy.wind_energy.get_highest_harvested_geom(wind_points_uri)

Find the point with the highest harvested value for wind energy and return its geometry

wind_points_uri - a URI to an OGR Datasource of a point geometry
shapefile for wind energy

returns - the geometry of the point with the highest harvested value

natcap.invest.wind_energy.wind_energy.mask_by_distance(dataset_uri, min_dist, max_dist, out_nodata, dist_uri, mask_uri)

Given a raster whose pixels are distances, bound them by a minimum and maximum distance

dataset_uri - a URI to a GDAL raster with distance values

min_dist - an integer of the minimum distance allowed in meters

max_dist - an integer of the maximum distance allowed in meters

mask_uri - the URI output of the raster masked by distance values

dist_uri - the URI output of the raster converted from distance
transform ranks to distance values in meters

out_nodata - the nodata value of the raster

returns - nothing

natcap.invest.wind_energy.wind_energy.pixel_size_based_on_coordinate_transform_uri(dataset_uri, coord_trans, point)

Get width and height of cell in meters.

A wrapper for pixel_size_based_on_coordinate_transform that takes a dataset uri as an input and opens it before sending it along.

Parameters: dataset_uri (string) – a URI to a gdal dataset other parameters pass along (All) – result – (pixel_width_meters, pixel_height_meters) tuple
natcap.invest.wind_energy.wind_energy.point_to_polygon_distance(poly_ds_uri, point_ds_uri)

Calculates the distances from points in a point geometry shapefile to the nearest polygon from a polygon shapefile. Both datasources must be projected in meters

poly_ds_uri - a URI to an OGR polygon geometry datasource projected in
meters
point_ds_uri - a URI to an OGR point geometry datasource projected in
meters

returns - a list of the distances from each point

natcap.invest.wind_energy.wind_energy.read_csv_wind_data(wind_data_uri, hub_height)

Unpack the csv wind data into a dictionary.

Parameters: wind_data_uri (string) – a path for the csv wind data file with header of: “LONG”,”LATI”,”LAM”,”K”,”REF” hub_height (int) – the hub height to use for calculating weibell parameters and wind energy values A dictionary where the keys are lat/long tuples which point to dictionaries that hold wind data at that location.
natcap.invest.wind_energy.wind_energy.read_csv_wind_parameters(csv_uri, parameter_list)

Construct a dictionary from a csv file given a list of keys in ‘parameter_list’. The list of keys corresponds to the parameters names in ‘csv_uri’ which are represented in the first column of the file.

csv_uri - a URI to a CSV file where every row is a parameter with the
parameter name in the first column followed by the value in the second column
parameter_list - a List of Strings that represent the parameter names to
be found in ‘csv_uri’. These Strings will be the keys in the returned dictionary
returns - a Dictionary where the the ‘parameter_list’ Strings are the
keys that have values pulled from ‘csv_uri’
natcap.invest.wind_energy.wind_energy.wind_data_to_point_shape(dict_data, layer_name, output_uri)

Given a dictionary of the wind data create a point shapefile that represents this data

dict_data - a python dictionary with the wind data, where the keys are
tuples of the lat/long coordinates: { (97, 43) : {‘LATI’:97, ‘LONG’:43, ‘LAM’:6.3, ‘K’:2.7, ‘REF’:10}, (55, 51) : {‘LATI’:55, ‘LONG’:51, ‘LAM’:6.2, ‘K’:2.4, ‘REF’:10}, (73, 47) : {‘LATI’:73, ‘LONG’:47, ‘LAM’:6.5, ‘K’:2.3, ‘REF’:10} }

layer_name - a python string for the name of the layer

output_uri - a uri for the output destination of the shapefile

return - nothing