/// <summary> /// Import an SIT formatted dataset. /// mdb, accdb, xls, or xlsx are supported /// </summary> private static void Method1() { string excelPath = @"C:\Program Files (x86)\Operational-Scale CBM-CFS3\Tutorials\Tutorial 6\Tutorial6.xls"; string projectPath = @"C:\Program Files (x86)\Operational-Scale CBM-CFS3\Projects\tutorial6\tutorial6.mdb"; var data = Sitplugin.ParseSITData( path: excelPath, AgeClassTableName: "AgeClasses$", ClassifiersTableName: "Classifiers$", DisturbanceEventsTableName: "DistEvents$", DisturbanceTypesTableName: "DistType$", InventoryTableName: "Inventory$", TransitionRulesTableName: "Transitions$", YieldTableName: "Growth$"); Sitplugin sitplugin = new Sitplugin( outputPath: projectPath, initializeMapping: false, dataset: data); sitplugin.SetSingleSpatialUnit(42); //see archive index tblSPUDefault/tblAdminBoundaryDefault/tblEcoBoundaryDefault for code definitions sitplugin.SetSpeciesClassifier("Species");//the classifier name as defined in the spreadsheet sitplugin.SetNonForestClassifier("Forest type"); // in the following mappings, the left value is something that appears in the import data, // and the right value is something that appears in the archive index database. sitplugin.MapSpecies("Hispaniolan pine", "Pine"); sitplugin.MapSpecies("Nonforest", "Not stocked"); sitplugin.MapSpecies("Improved pine stock", "Pine"); sitplugin.MapNonForest("Afforestation", "Gleysolic"); sitplugin.MapNonForest("Natural forest", Sitplugin.ForestOnly); sitplugin.MapNonForest("Control", Sitplugin.ForestOnly); sitplugin.MapDisturbanceType("Fire", "Wildfire"); sitplugin.MapDisturbanceType("Firewood collection", "Firewood Collection - post logging"); sitplugin.MapDisturbanceType("Clearcut", "Clear-cut with slash-burn"); sitplugin.MapDisturbanceType("Afforestation", "Afforestation"); sitplugin.MapDisturbanceType("Hurricane", "Generic 50% mortality"); sitplugin.Import(); }
private static void MapDisturbanceTypes(Sitplugin sitplugin, JToken mappingConfig) { if (mappingConfig != null && mappingConfig.HasValues) { if (mappingConfig["disturbance_type_mapping"] != null) { foreach (var item in mappingConfig["disturbance_type_mapping"]) { sitplugin.MapDisturbanceType( (string)item["user_dist_type"], (string)item["default_dist_type"]); } } } }