Recreation Package

Model Entry Point

invest_natcap.recreation.recreation_client.execute(args)

The main function called by IUI.

Parameters:
  • workspace_dir (string) – directory to be used as the workspace
  • aoi_file_name (string) – area of interest where the model will run the analysis.
  • grid (boolean) – selects whether the area of interest should be gridded
  • grid_type (int) – selects whether the grid should contain rectangular or hexagonal units.
  • cell_size (float) – The size of the grid units measured in the projection units of the AOI. For example, UTM projections use meters.
  • comments (string) – Any user comments to be included as part of the model run.
  • data_dir (string) – Directory containing any data to be included in model run.
  • download (boolean) – Includes the processed, unrestricted data in the results, which could be useful for scenarios.
  • global_data (boolean) – Indicates whether to use global datasets
  • landscan (boolean) – Use landscan’s global distribution of ambient population
  • protected (boolean) – Use World Database of protected areas
  • osm (boolean) – Use Open Street Maps (OSM)
  • osm_1 (boolean) – Use OSM Cultural data
  • osm_2 (boolean) – Use OSM Industrial data
  • osm_3 (boolean) – Use OSM Natural data
  • osm_4 (boolean) – Use OSM Superstructure data
  • osm_0 (boolean) – Use OSM Miscellaneous data
  • lulc (boolean) – Use Land-Use / Land-Cover
  • lulc_1 (boolean) – Use LULC Agriculture data
  • lulc_2 (boolean) – Use LULC Bare data
  • lulc_3 (boolean) – Use LULC Forest data
  • lulc_4 (boolean) – Use LULC Grassland data
  • lulc_5 (boolean) – Use LULC Shrubland data
  • lulc_6 (boolean) – Use LULC Snow and Ice data
  • lulc_7 (boolean) – Use LULC Urban data
  • lulc_8 (boolean) – Use LULC Water data
  • ouoc (boolean) – Use Ocean-Use / Ocean-Cover
  • mangroves (boolean) – Use OUOC Mangrove data
  • reefs (boolean) – Use OUOC Reef data
  • grass (boolean) – Use OUOC Grass data

Example Args Dictionary:

{
    'workspace_dir': 'path/to/workspace_dir',
    'aoi_file_name': 'path/to/shapefile',
    'grid': True,
    'grid_type': 1,  # hexagonal (rectangular: 0)
    'cell_size': 5000.0,
    'comments': 'example',
    'data_dir': 'example',
    'download': 'example',
    'global_data': 'example',
    'landscan': 'example',
    'protected': 'example',
    'osm': True,
    'osm_1': True,
    'osm_2': True,
    'osm_3': True,
    'osm_4': False,
    'osm_0': True,
    'lulc': True,
    'lulc_1': True,
    'lulc_2': False,
    'lulc_3': False,
    'lulc_4': True,
    'lulc_5': True,
    'lulc_6': False,
    'lulc_7': True,
    'lulc_8': True,
    'ouoc': True,
    'mangroves': True,
    'reefs': True,
    'grass': False,
}

Recreation Server Initial

Recreation Client

The front end to the recreation server side model.

invest_natcap.recreation.recreation_client.complete_shapefile(shapefile_name)

Checks that there is a .shp, .shx, .dbf, and .prj file by the same name.

Parameters:shapefile_name (string) – (desc)
Returns:complete – indicates whether shapefile has all required files
Return type:boolean
invest_natcap.recreation.recreation_client.execute(args)

The main function called by IUI.

Parameters:
  • workspace_dir (string) – directory to be used as the workspace
  • aoi_file_name (string) – area of interest where the model will run the analysis.
  • grid (boolean) – selects whether the area of interest should be gridded
  • grid_type (int) – selects whether the grid should contain rectangular or hexagonal units.
  • cell_size (float) – The size of the grid units measured in the projection units of the AOI. For example, UTM projections use meters.
  • comments (string) – Any user comments to be included as part of the model run.
  • data_dir (string) – Directory containing any data to be included in model run.
  • download (boolean) – Includes the processed, unrestricted data in the results, which could be useful for scenarios.
  • global_data (boolean) – Indicates whether to use global datasets
  • landscan (boolean) – Use landscan’s global distribution of ambient population
  • protected (boolean) – Use World Database of protected areas
  • osm (boolean) – Use Open Street Maps (OSM)
  • osm_1 (boolean) – Use OSM Cultural data
  • osm_2 (boolean) – Use OSM Industrial data
  • osm_3 (boolean) – Use OSM Natural data
  • osm_4 (boolean) – Use OSM Superstructure data
  • osm_0 (boolean) – Use OSM Miscellaneous data
  • lulc (boolean) – Use Land-Use / Land-Cover
  • lulc_1 (boolean) – Use LULC Agriculture data
  • lulc_2 (boolean) – Use LULC Bare data
  • lulc_3 (boolean) – Use LULC Forest data
  • lulc_4 (boolean) – Use LULC Grassland data
  • lulc_5 (boolean) – Use LULC Shrubland data
  • lulc_6 (boolean) – Use LULC Snow and Ice data
  • lulc_7 (boolean) – Use LULC Urban data
  • lulc_8 (boolean) – Use LULC Water data
  • ouoc (boolean) – Use Ocean-Use / Ocean-Cover
  • mangroves (boolean) – Use OUOC Mangrove data
  • reefs (boolean) – Use OUOC Reef data
  • grass (boolean) – Use OUOC Grass data

Example Args Dictionary:

{
    'workspace_dir': 'path/to/workspace_dir',
    'aoi_file_name': 'path/to/shapefile',
    'grid': True,
    'grid_type': 1,  # hexagonal (rectangular: 0)
    'cell_size': 5000.0,
    'comments': 'example',
    'data_dir': 'example',
    'download': 'example',
    'global_data': 'example',
    'landscan': 'example',
    'protected': 'example',
    'osm': True,
    'osm_1': True,
    'osm_2': True,
    'osm_3': True,
    'osm_4': False,
    'osm_0': True,
    'lulc': True,
    'lulc_1': True,
    'lulc_2': False,
    'lulc_3': False,
    'lulc_4': True,
    'lulc_5': True,
    'lulc_6': False,
    'lulc_7': True,
    'lulc_8': True,
    'ouoc': True,
    'mangroves': True,
    'reefs': True,
    'grass': False,
}
invest_natcap.recreation.recreation_client.log_check(url, flag='Dropped intermediate tables.', delay=15, log=<logging.Logger object at 0x655a790>, line=0)

Echoes a remote log until the flag message is found.

Parameters:

url (string) – url to server session log

Keyword Arguments:
 
  • flag (string) – the line that this function waits for in the remote server’s log file that triggers the function to complete.
  • delay (float) – number of seconds to wait before reading next line in log file
  • log (logger object) – client-side logger
  • line (int) – the first line to read in the log file
Returns:

line – the first line in the remote server’s log that has not

yet been read

Return type:

int

invest_natcap.recreation.recreation_client.relogger(log, msg_type, msg)

Logs a message to a logger using the method named by a string.

Parameters:
  • log (logger object) – client-side logger
  • msg_type (string) – the type of logger message
  • msg (string) – the message to be logged
Returns:

None

Raises:

IOError – triggered when msg_type == “Error”, indicating that an error has occurred on the remote server

invest_natcap.recreation.recreation_client.urlopen(url, request, tries=3, delay=15, log=<logging.Logger object at 0x655a790>)

An error tolerant URL opener with retries and delays.

Parameters:
  • url (string) – url to remote server file
  • request (urllib2.Request or string) – urllib2 request object or string
Keyword Arguments:
 
  • tries (int) – the number of request attempts to be made before quitting
  • delay (float) – number of seconds before each attempt
  • log (logging.Logger) – logger object
Returns:

msg – response message from remote server

Return type:

string

Recreation Server Scenario

Recreation Server Core

Module contents