ConvertLidar

class lidar.ConvertLidar(lidar_shp, fishnet_shp, new_lidar)[source]

Bases: object

The ConvertLidar class is used to generate a CAPSIS tree list of lidar tree attributes from a shapefile of lidar trees.

Parameters:
  • lidar_shp (string) – name and path of input lidar shapefile.
  • fishnet_shp (string) – name and path for output fishnet shapefile.
  • new_lidar (string) – name and path for output lidar shapefile.

Methods (execution order):

  • verify_projection
  • verify_input_fields
  • calculate_extents
  • create_fishnet
  • copy_shapefile
  • cleanup_lidar_fields
  • fishnet_id
  • cleanup_lidar_features
  • add_attribute_fields
  • calculate_attribute_fields
  • number_trees
  • export_attributes_to_csv
add_attribute_fields()[source]

Adds and defines new attribute fields to the output shapefile.

Fields added:

Field Name Type Description
POINT_X Float X coordinate
POINT_Y Float Y coordinate
CR_code Integer FVS crown ratio code
DBH_in_x10 Integer Diameter at Breast Height in inches x 10
Height_ft Integer Tree height in feet
Tree_ID Integer Unique tree ID number within each plot
Returns:add attribute fields success
Return type:boolean
Returns:add attribute fields message
Return type:string
calculate_attribute_fields()[source]

Calculates values for the attribute fields added in the “add_attribute_fields” method.

Formula descriptions:

  • Height- converts from meters to feet and rounds to integer
  • DBH - converts from centimeters to inches*10 and rounds to integer
  • CR_code- calculates crown ratio while accounting for anomolous data where Height is <= CBH. Then classifies the crown ratio into FVS categories.
    • crown ratio = (height - crown base height)/height).
    • FVS crown ratio codes: 1: 0-10%; 2: 11-20%;…; 9: 81-100%
Returns:calculate attribute fields success
Return type:boolean
Returns:calculate attribute fields message
Return type:string
calculate_extents()[source]

Calculates the minimum and maximum x and y extents of the input shapefile.

Returns:x min, x max, y min, y max
Return type:list of four floats
cleanup_lidar_features()[source]

Deletes features outside the fishnet area.

Returns:cleanup success
Return type:boolean
Returns:cleanup message
Return type:string
cleanup_lidar_fields()[source]

Deletes extraneous fields from output shapefile.

Returns:cleanup success
Return type:boolean
Returns:cleanup message
Return type:string
copy_shapefile()[source]

Makes an exact copy of the input lidar shapefile for use in creating the output lidar shapefile.

Returns:shapefile copy success
Return type:boolean
Returns:shapefile copy message
Return type:string
create_fishnet(extents)[source]

Creates a fishnet polygon shapefile to be used to assign plot numbers to the lidar points. Fishnet cells are 64x64m (~1 acre). Feature ID numbers are used to number plots.

Parameters:extents (list of four floats) – x min, x max, y min, y max of the input shapefile
Returns:fishnet creation success
Return type:boolean
Returns:fishnet creation message
Return type:string
export_attributes_to_csv(lidar_csv)[source]

Exports select attributes in the new lidar shapefile to a text (.csv) file.

Exported attributes:

Name Description
FID GIS record ID number
POINT_X X coordinate
POINT_Y Y coordinate
Species Two letter FVS species code
CR_code FVS crown ratio code
DBH_in_x10 Diameter at Breast Height in inches x 10
Height_ft Tree height in feet
Plot_ID Unique plot ID number
Tree_ID Unique tree ID number within each plot
Parameters:lidar_csv (string) – name and path for output text file
Returns:export success
Return type:boolean
Returns:export message
Return type:string
fishnet_id()[source]

Assigns a fishnet-based plot ID number to each tree in the output shapefile.

Returns:plot number assignment success
Return type:boolean
Returns:plot number assignment message
Return type:string
number_trees()[source]

Numbers trees within each 64x64m (~1 acre) plot. The combination of plot ID and tree Id constitutes a unique identifier for each tree in the simulation.

Returns:numbering trees success
Return type:boolean
Returns:numbering trees message
Return type:string
verify_input_fields()[source]

Verifies that the required input fields are in the input shapefile.

Required fields:

Field Name Type Units Description
X_UTM Float Meters X coordinate
Y_UTM Float Meters Y coordinate
Height_m Float Meters Tree height
CBH_m Float Meters Crown Base Height
DBH_cm Float Centimeters Diameter at Breast Height
Species String Text Two letter FVS species code
Returns:input field fitness
Return type:boolean
Returns:fitness message
Return type:string

Note

See FVS variant users guides for definitions of species codes: https://www.fs.fed.us/fvs/documents/guides.shtml

verify_projection()[source]

Verifies that the input shapefile is projected and, if so, whether the projection is WGS 1984 UTM. Uses EPSG projection codes to verify.

Returns:projection fitness
Return type:boolean
Returns:fitness message
Return type:string
Returns:fitness code
Return type:integer

Fitness Codes:

  • 0 - projection ok
  • 1 - unable to identify projection
  • 2 - unprojected