Invest overlap analysis filehandler for data passed in through UI
create_hubs_raster(hubs_shape_uri, decay, aoi_raster_uri, hubs_out_uri)¶
This will create a rasterized version of the hubs shapefile where each pixel on the raster will be set accourding to the decay function from the point values themselves. We will rasterize the shapefile so that all land is 0, and nodata is the distance from the closest point.
- hubs_shape_uri - Open point shapefile containing the hub locations
- as points.
- decay - Double representing the rate at which the hub importance
- depreciates relative to the distance from the location.
- aoi_raster_uri - The URI to the area interest raster on which we
- want to base our new hubs raster.
- hubs_out_uri - The URI location at which the new hubs raster should
- be placed.
- This creates a raster within hubs_out_uri whose data will be a function of the decay around points provided from hubs shape.
create_unweighted_raster(output_dir, aoi_raster_uri, raster_files_uri)¶
This will create the set of unweighted rasters- both the AOI and individual rasterizations of the activity layers. These will all be combined to output a final raster displaying unweighted activity frequency within the area of interest.
- output_dir- This is the directory in which the final frequency raster
- will be placed. That file will be named ‘hu_freq.tif’.
- aoi_raster_uri- The uri to the rasterized version of the AOI file
- raster_files_uri - The uris to the rasterized version of the files
- A raster file named [‘workspace_dir’]/output/hu_freq.tif. This depicts the unweighted frequency of activity within a gridded area or management zone.
create_weighted_raster(out_dir, intermediate_dir, aoi_raster_uri, inter_weights_dict, layers_dict, intra_name, do_inter, do_intra, do_hubs, hubs_raster_uri, raster_uris, raster_names)¶
This function will create an output raster that takes into account both inter-activity weighting and intra-activity weighting. This will produce a map that looks both at where activities are occurring, and how much people value those activities and areas.
- out_dir- This is the directory into which our completed raster file
- should be placed when completed.
- intermediate_dir- The directory in which the weighted raster files can
- be stored.
- inter_weights_dict- The dictionary that holds the mappings from layer
- layers_dict- This dictionary contains all the activity layers that are
- intra_name- A string which represents the desired field name in our
- shapefiles. This field should contain the intra-activity weight for that particular shape.
- do_inter- A boolean that indicates whether inter-activity weighting is
- do_intra- A boolean that indicates whether intra-activity weighting is
- aoi_raster_uri - The uri to the dataset for our Area Of Interest.
- This will be the base map for all following datasets.
- raster_uris - A list of uris to the open unweighted raster files
- raster_names- A list of file names that goes along with the unweighted
- weighted_raster- A raster file output that takes into account both
- inter-activity weights and intra-activity weights.
This function will take care of preparing files passed into the overlap analysis model. It will handle all files/inputs associated with calculations and manipulations. It may write log, warning, or error messages to stdout.
- args['zone_layer_uri'] (string) – A URI pointing to a shapefile with the analysis zones on it. (required)
- args['grid_size'] (int) – This is an int specifying how large the gridded squares over the shapefile should be. (required)
- args['overlap_data_dir_uri'] (string) – URI pointing to a directory where multiple shapefiles are located. Each shapefile represents an activity of interest for the model. (required)
- args['do-inter'] (bool) – Boolean that indicates whether or not inter-activity weighting is desired. This will decide if the overlap table will be created. (required)
- args['do_intra'] (bool) – Boolean which indicates whether or not intra-activity weighting is desired. This will will pull attributes from shapefiles passed in in ‘zone_layer_uri’. (required)
- args['do_hubs'] (bool) – Boolean which indicates if human use hubs are desired. (required)
- args['overlap_layer_tbl'] (string) – URI to a CSV file that holds relational data and identifier data for all layers being passed in within the overlap analysis directory. (optional)
- args['intra_name'] (string) – string which corresponds to a field within the layers being passed in within overlap analysis directory. This is the intra-activity importance for each activity. (optional)
- args['hubs_uri'] (string) – The location of the shapefile containing points for human use hub calculations. (optional)
- args['decay_amt'] (float) – A double representing the decay rate of value from the human use hubs. (optional)
This CSV file contains a string which can be used to uniquely identify a .shp file to which the values in that string’s row will correspond. This string, therefore, should be used as the key for the ovlap_analysis dictionary, so that we can get all corresponding values for a shapefile at once by knowing its name.
- over_tbl- A CSV that contains a list of each interest shapefile,
- and the inter activity weights corresponding to those layers.
- over_dict- The analysis layer dictionary that maps the unique name
make_indiv_rasters(out_dir, overlap_shape_uris, aoi_raster_uri)¶
This will pluck each of the files out of the dictionary and create a new raster file out of them. The new file will be named the same as the original shapefile, but with a .tif extension, and will be placed in the intermediate directory that is being passed in as a parameter.
- out_dir- This is the directory into which our completed raster files
- should be placed when completed.
- overlap_shape_uris- This is a dictionary containing all of the open
- aoi_raster_uri- The dataset for our AOI. This will be the base map for
- all following datasets.
- raster_files- This is a list of the datasets that we want to sum. The
- first will ALWAYS be the AOI dataset, and the rest will be the variable number of other datasets that we want to sum.
- raster_names- This is a list of layer names that corresponds to the
- files in ‘raster_files’. The first layer is guaranteed to be the AOI, but all names after that will be in the same order as the files so that it can be used for indexing later.
make_indiv_weight_rasters(input_dir, aoi_raster_uri, layers_dict, intra_name)¶
This is a helper function for create_weighted_raster, which abstracts some of the work for getting the intra-activity weights per pixel to a separate function. This function will take in a list of the activities layers, and using the aoi_raster as a base for the tranformation, will rasterize the shapefile layers into rasters where the burn value is based on a per-pixel intra-activity weight (specified in each polygon on the layer). This function will return a tuple of two lists- the first is a list of the rasterized shapefiles, starting with the aoi. The second is a list of the shapefile names (minus the extension) in the same order as they were added to the first list. This will be used to reference the dictionaries containing the rest of the weighting information for the final weighted raster calculation.
- input_dir: The directory into which the weighted rasters should be
- aoi_raster_uri: The uri to the rasterized version of the area of
- interest. This will be used as a basis for all following rasterizations.
- layers_dict: A dictionary of all shapefiles to be rasterized. The key
- intra_name: The string corresponding to the value we wish to pull out
- A list of raster versions of the original
- activity shapefiles. The first file will ALWAYS be the AOI, followed by the rasterized layers.
- weighted_names: A list of the filenames minus extensions, of the
- rasterized files in weighted_raster_files. These can be used to reference properties of the raster files that are located in other dictionaries.
Return type: weighted_raster_files
This is the preperatory class for the management zone portion of overlap analysis.
Overlap Analysis: Management Zones.
- args['zone_layer_loc'] (string) – A URI pointing to a shapefile with the analysis zones on it. (required)
- args['overlap_data_dir_loc'] (string) – URI pointing to a directory where multiple shapefiles are located. Each shapefile represents an activity of interest for the model. (required)
This is the core module for the management zone analysis portion of the Overlap Analysis model.
This is the core module for the management zone model, which was extracted from the overlap analysis model. This particular one will take in a shapefile conatining a series of AOI’s, and a folder containing activity layers, and will return a modified shapefile of AOI’s, each of which will have an attribute stating how many activities take place within that polygon.
- args[‘workspace_dir’]- The folder location into which we can write an
- Output or Intermediate folder as necessary, and where the final shapefile will be placed.
- args[‘zone_layer_file’]- An open shapefile which contains our
- args[‘over_layer_dict’] - A dictionary which maps the name of the
- A file named [workspace_dir]/Ouput/mz_frequency.shp which is a copy of args[‘zone_layer_file’] with the added attribute “ACTIV_CNT” that will total the number of activities taking place in each polygon.
Core module for both overlap analysis and management zones. This function can be used by either of the secondary modules within the OA model.
Returns a dictionary of all .shp files in the folder.
- folder- The location of all layer files. Among these, there should
- be files with the extension .shp. These will be used for all activity calculations.
- file_dict- A dictionary which maps the name (minus file extension)
- of a shapefile to the open datasource itself. The key in this dictionary is the name of the file (not including file path or extension), and the value is the open shapefile.
A replacement for the standar os.listdir which, instead of returning only the filename, will include the entire path. This will use os as a base, then just lambda transform the whole list.
- path- The location container from which we want to gather all files.
Returns: A list of full URIs contained within ‘path’.