Skip to content

Creating New Nearest Neighbor Matches

Ryan Hodges edited this page Dec 22, 2015 · 7 revisions

This document is intended to be a roadmap for future cases of creating a new set of plots to run nearest neighbor matches against.

What you need:

  • a file containing LAT/LON point data for all conditions to be considered
    • IDB v2.0
    • PNW FIA DB 2011
    • etc...
  • buffered polygon data representing the regional variants to be considered
  • a file containing summary data for the conditions, including:
    • stand age
    • LAT, LON
    • [fill in]
  • Treelist data of the conditions, including
    • species
    • diameter (dbh)
    • [fill in]

Steps:

Create Condition-Variant Lookup CSV

  • run an intersection query between the condition point-data and the buffered variant polygon data
  • required columns:
    • Condition ID
    • Latitude
    • Longitude
    • Variant ID
  • Export as a CSV
  • Tools to choose from:
    • ArcMap (works well)
    • QGIS
      • Couldn't get field calculation to work as expected
    • Spatialite
    • geopandas (python package)

Create Forest-Type/Previous-Nearest-Neighbor-Match Table

Replace TreeliveSummary and IdbSummary Tables With Updated Candidates

  • David creates CSVs
  • Ryan truncates old tables and loads in the new data
    • script to populate treelive_summary
      • Workhorse: lot/load_new_conditions.py (does both Treelive & CVLookup)
      • Run it from: lot/scripts/load_treelive.sh
        • Process gradually sucks up all memory and slows to a crawl. This wrapper script will restart it when it slows down too much.
        • This script does not like being executable in Vagrant Shared Folders. Feel free to copy it to /tmp and run it from there.
    • script to populate condition variant lookup
      • lot/load_new_conditions.py (uncomment correct lines)

Loop Through Existing Matches

  • Current Nearest Neighbor matching code takes 1 Forest Type at a time.
  • Wrap it in a loop to run once per each user-defined Forest Type/Stand info
  • Creates a list of "Growth Candidates"
  • output should be csv: each row is a user stand, variant, forest type, one of the matching ids found, and the rank (i.e. 1-10) of that match

Collect Desired Growth Candidate Coverage By Variant

  • Be sure that you pull enough candidates to represent each variant
  • Inputs:
    • FP User Forest-Types/Previous-Nearest-Neighbor-Match Table
    • Condition-Variant Lookup CSV
    • Condition Summary Table
    • Treelist for all Conditions

Run candidates through GYB

Clone this wiki locally