{"id":50586249,"url":"https://github.com/crghilardi/fortyp","last_synced_at":"2026-06-05T06:31:21.997Z","repository":{"id":45168349,"uuid":"279464889","full_name":"Crghilardi/ForTyp","owner":"Crghilardi","description":"A C++ implementation of the FIA forest typing algorithm","archived":false,"fork":false,"pushed_at":"2022-01-12T01:48:10.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-06-05T06:02:59.482Z","etag":null,"topics":["biometrics","cpp","forestry"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Crghilardi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-14T02:50:34.000Z","updated_at":"2026-05-19T13:40:06.000Z","dependencies_parsed_at":"2022-09-01T07:12:04.526Z","dependency_job_id":null,"html_url":"https://github.com/Crghilardi/ForTyp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Crghilardi/ForTyp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Crghilardi%2FForTyp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Crghilardi%2FForTyp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Crghilardi%2FForTyp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Crghilardi%2FForTyp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Crghilardi","download_url":"https://codeload.github.com/Crghilardi/ForTyp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Crghilardi%2FForTyp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33932048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-05T02:00:06.157Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["biometrics","cpp","forestry"],"created_at":"2026-06-05T06:31:16.789Z","updated_at":"2026-06-05T06:31:21.984Z","avatar_url":"https://github.com/Crghilardi.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ForTyp\n\nA C++ implementation of the [Arner et al. 2001](https://www.fs.fed.us/fmsc/ftp/fvs/docs/gtr/Arner2001.pdf) forest typing algorithm.\n\nThis library is largely translated from the FVS codebase ([stkval.f](https://sourceforge.net/p/open-fvs/code/HEAD/tree/trunk/vbase/stkval.f) and [fortyp.f](https://sourceforge.net/p/open-fvs/code/HEAD/tree/trunk/vbase/fortyp.f)) but also references the Arner documents.\n\nVariable names were kept the same as the FVS FORTRAN code. There are a number of unused variables in the original code that are included but commented out.\n\n## Functions\n\nThe library provides a function `forest_type(treelist, false)` which uses DBH, species (using FIA numeric codes), and TPA expansion values and returns the forest type classification. Due to some implementation details, there is a second `bool` parameter to simulate southern variant specific logic.\n\nThere are also convenience lookup tables to convert between forest type, forest type group, and their text names.\n\n`fortyp_name()` returns the string name of a given forest type code\n`fortypgroup()` returns the forest type group int of a given forest type\n`fortypgroup_name()` returns the string name of a given forest type group code\n\nIf the forest type code is not found, it will just return a null string.\n\n## Compilation Instructions\nA library `libfortyp` can be built using `CMake` and supports out-of-source builds.\n\n```shell\ngit clone\n\ncd fortyp\n\nmkdir build #or whatever you want to call it\n\ncd build\n\ncmake .. #add -DBUILD_SHARED_LIBS=ON for shared library, otherwise will be static\n\nmake\n```\n\n## Demo\n\nThere is a small demo with some example data included in the `demo` folder. To compile the demo replace the `cmake` statement above with:\n\n```shell\ncmake -DBUILD_DEMO=ON ..\n```\n\nwhich can then be executed by running the `./demo_stocking` executable.\n\n# Calling from other languages\n## Python \n\n```\nfrom ctypes import *\nfortyplib = cdll.LoadLibrary(\"./path/to/libfortyp.so\")\n\n#convert a forest type to forest type group\nfortyplib.fortypgroup.restype = c_int\nfortyplib.fortypgroup.argtypes = [c_int]\nfortyplib.fortypgroup(101) #100\n\n#get the name of a forest type group\nfortyplib.fortypgroup_name.restype = c_char_p\nfortyplib.fortypgroup_name.argtypes = [c_int]\nfortyplib.fortypgroup_name(200).decode(\"utf-8\") #\"Douglas-fir\"\n\n#get the name of a forest type\nfortyplib.fortyp_name.restype = c_char_p\nfortyplib.fortyp_name.argtypes = [c_int]\nfortyplib.fortyp_name(201).decode(\"utf-8\") #\"Douglas-fir\"\n\n```\n\n## Julia\n\n```\nusing Libdl\nlib = Libdl.dlopen(\"./build2/lib/libfortyp.so\")\n\nccall(Libdl.dlsym(lib, :fortypgroup), Int32, (\n    Ref{Cint},\n), Ptr{Cint}(201))\n\n\nx1 = ccall(Libdl.dlsym(lib, :fortypgroup_name), Ptr{UInt8}, (\n    Ref{Cint},\n), Ptr{Cint}(200))\n\nunsafe_string(x1)\n\nx2 = ccall(Libdl.dlsym(lib, :fortyp_name), Ptr{UInt8}, (\n    Ref{Cint},\n), Ptr{Cint}(201))\n\nunsafe_string(x2)\n\n```\n\nTO DO?:\n1. generalize and clean up input structure\n2. add some error handling to map lookups\n3. cleaner way to handle variant logic?\n4. add `python` / `R` interop examples\n\nPRs/issues welcome","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrghilardi%2Ffortyp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrghilardi%2Ffortyp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrghilardi%2Ffortyp/lists"}