Commit 522bd651 authored by Sylvain Dupire's avatar Sylvain Dupire
Browse files

Version 3.5

parent 935982fc
No preview for this file type
No preview for this file type
No preview for this file type
#Sylvaccess#
## Cartographie automatique de l'accessibilité des forêts / Automatic mapping of forest accessibility ##
Copyright: Sylvain DUPIRE, SylvaLab - 2020 (*sylvain.dupire@sylvalab.fr*)
![Sylvaccess](./Source_code/logo_sylvalab2.png?raw=true)
![Logo_FR](./Source_code/FR.png?raw=true)
Sylvaccess est un logiciel permettant de cartographier automatiquement l’accessibilité des forêts en fonction de différents modes d’exploitation : tracteur forestier, porteur forestier et débardage par câble.
La dernière version stable du logiciel est la version 3.4
Le modèle s’appuie sur des sources d’information spatiale [a minima : modèle numérique de terrain (MNT), couche de desserte forestière, contours des forêts] et des paramètres techniques propres à
chaque système de débardage.
Il offre aussi la possibilité d’intégrer des obstacles physiques ou environnementaux
dans l’analyse ainsi que des données sur les volumes de bois sur pied. Les résultats du modèle sont utilisables pour de nombreuses applications forestières
allant de l’aménagement et de la planification des opérations d’exploitation jusqu’à la comparaison et la
sélection de projets de desserte.
Pour plus d'information : _<https://sylvalab.fr/index.php/sylvaccess/>_
Tags = ___accessibilité___, ___forêt___, ___exploitation___, ___mnt___, ___lidar___, ___cartographie___, ___montagne___, ___mobilisation___
, ___ressource___, ___forestière___
------------------------------------
Sylvaccess is a model allowing automatic mapping of forest accessibility for the following forest operation systems : skidder, forwarder and cable yarding.
![Logo_EN](./Source_code/UK.png?raw=true) Sylvaccess is a model allowing automatic mapping of forest accessibility for the following forest operation systems : skidder, forwarder and cable yarding.
The model is based on spatial information [Compulsory: digital terrain model (DTM), shapefile of forest road network, shapefile of forest contours] and specific parameters of each logging technique.
It can also integrate physical or environmental obstacles in the analysis as well as wood volume information. The outputs of
the model can be used for many applications ranging from forest management and planning of logging operations
to the comparison and selection of new forest roads projects.
Tags = ___accessibility___, ___forest___, ___operation___, ___dtm___, ___airborne laser___
, ___mapping___, ___mountain___, ___wood___, ___resource___
__Sylvaccess license:__
Copyright (C) 2020 by Sylvain DUPIRE - SylvaLab.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The latest stable release version is 3.4
You should have received a copy of the GNU General Public License
along with this program. If not, see _(<https://www.gnu.org/licenses/>)_.
\ No newline at end of file
......@@ -2,11 +2,11 @@
"""
Software: Sylvaccess
File: Sylvaccess_0_main3.py
Copyright (C) Sylvain DUPIRE
Copyright (C) Sylvain DUPIRE -SylvaLab 2020
Authors: Sylvain DUPIRE
Contact: sylvain.dupire@gmail.com
Version: 3.4
Date: 2020/01/14
Contact: sylvain.dupire@sylvalab.fr
Version: 3.5
Date: 2020/09/04
License : GNU-GPL V3
-----------------------------------------------------------------------
......@@ -49,8 +49,9 @@ along with Sylvaccess. If not, see <https://www.gnu.org/licenses/>.
"""
import sys,os,gc,math,datetime,time,traceback
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QMainWindow, QApplication,QDialog
from sylvaccess_form_3 import Ui_Dialog
import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline
......@@ -65,7 +66,8 @@ class Interface_sylvaccess(QDialog):
def __init__(self):
QDialog.__init__(self)
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.setupUi(self)
self.ui.buttonBox.rejected.connect(self.reject)
if __name__ == "__main__":
app = QApplication(sys.argv)
......@@ -81,7 +83,8 @@ if __name__ == "__main__":
Pente_max_bucheron = Interface.ui.Pmax_buch.value()
# Get path to spatial files
global Wspace,Rspace,file_MNT,file_shp_Desserte,file_shp_Foret,file_Vol_ha
global Dir_Obs_cable,file_Htree,file_Vol_AM,language,Dir_Obs_forwarder,Dir_Full_Obs_skidder,Dir_Partial_Obs_skidder
global Dir_Obs_cable,file_Htree,file_Vol_AM,language,Dir_Obs_forwarder
global Dir_Full_Obs_skidder,Dir_Partial_Obs_skidder,file_shp_Cable_dep
language = Interface.ui.language_value
Wspace = str(Interface.ui.Wspace_path.text())
if Wspace!='':Wspace+="/"
......@@ -93,6 +96,7 @@ if __name__ == "__main__":
file_Vol_ha = str(Interface.ui.Vol_path.text())
file_Vol_AM = str(Interface.ui.vam_path.text())
file_Htree = str(Interface.ui.Hmoy_path.text())
file_shp_Cable_dep=str(Interface.ui.Cable_dep_path.text())
Dir_Obs_cable = str(Interface.ui.Obs_cable_path.text())
if Dir_Obs_cable!='':Dir_Obs_cable+="/"
Dir_Partial_Obs_skidder = str(Interface.ui.Partial_Obs_skidder_path.text())
......@@ -128,15 +132,17 @@ if __name__ == "__main__":
Forw_Debclass = Interface.ui.Forw_borneDeb.toPlainText()
# Get Cable parameters
global Lmax,Lmin,Lhor_max,slope_Wliner_up,slope_Wliner_down,slope_grav,Cable_type,Carriage_type,sup_max,prelevement
global Lmax,Lmin,Lhor_max,slope_Wliner_up,slope_Wliner_down,slope_grav,Cable_type
global Htower,Pchar,slope_min,E,q1,d,rupt_res,Hintsup,Hend,Hline_min,Hline_max
global safe_fact,angle_sup,precision,Pmax,Load_max,Max_angle,LminSpan,VariaH
global q2,q3,coeff_frot,slope_trans,angle_transv
global Cabsel_Lhor_max,new_calc
global q2,q3,coeff_frot,slope_trans,angle_transv,Carriage_type,sup_max,prelevement
global Cabsel_Lhor_max,new_calc,Lslope,PropSlope
global Dir_cable_sel,Cabsel_For,Cabsel_Vha,Cabsel_Vam,w_list,lim_list
global lim_Sfor,lim_Nsup,lim_Sens,lim_Ltot,lim_Vtot,lim_IPC,lim_VAM,lim_Dchar,lim_Cost
global w_Sfor,w_Nsup,w_Sens,w_Ltot,w_Vtot,w_IPC,w_VAM,w_Dchar,w_Cost
if test_Cable:
global w_Sfor,w_Nsup,w_Sens,w_Ltot,w_Vtot,w_IPC,w_VAM,w_Dchar,w_Cost
new_calc=0
Cabsel_For=""
if test_Cable:
Cable_type = Interface.ui.Cable_type.currentIndex()
sup_max = Interface.ui.Cab_intsupmax.value()
Lmax = Interface.ui.Cab_Lmax.value()
......@@ -157,10 +163,12 @@ if __name__ == "__main__":
Hline_min = Interface.ui.Cab_Hline_min.value()
Hline_max = Interface.ui.Cab_Hline_max.value()
safe_fact = Interface.ui.Cab_safety_fact.value()
Max_angle = Interface.ui.Cab_Max_angle.value()
#Max_angle = Interface.ui.Cab_Max_angle.value()
Max_angle = 30
precision = Interface.ui.Cab_precision.value()
Load_max = Interface.ui.Cab_Pmax.value()
LminSpan = Interface.ui.Cab_LminSpan.value()
#LminSpan = Interface.ui.Cab_LminSpan.value()
LminSpan = 50
VariaH = Interface.ui.Check_Hcable.isChecked()
### Those are not in the interface yet
q2 = 0.5
......@@ -182,7 +190,7 @@ if __name__ == "__main__":
if test_cable_optimise:
prelevement = Interface.ui.prelevement.value()*0.01
else:
prelevement = 0.25
prelevement = 0.35
#limits
lim_Sfor = Interface.ui.lim_surf.value()
......@@ -193,7 +201,7 @@ if __name__ == "__main__":
lim_IPC = Interface.ui.lim_IPC.value()
lim_VAM = Interface.ui.lim_VAM.value()
lim_Dchar = Interface.ui.lim_Dchar.value()
lim_Cost = Interface.ui.lim_Cost.value()
#lim_Cost = Interface.ui.lim_Cost.value()
#Weight
w_Sfor = Interface.ui.w_Surf.value()
......@@ -204,10 +212,10 @@ if __name__ == "__main__":
w_IPC = Interface.ui.w_IPC.value()
w_VAM = Interface.ui.w_VAM.value()
w_Dchar = Interface.ui.w_Dchar.value()
w_Cost = Interface.ui.w_Cost.value()
#w_Cost = Interface.ui.w_Cost.value()
w_list = [w_Sfor,w_Nsup,w_Sens,w_Ltot,w_Vtot,w_IPC,w_VAM,w_Dchar,w_Cost]
lim_list = [lim_Sfor,lim_Nsup,lim_Sens,lim_Ltot,lim_Vtot,lim_IPC,lim_VAM,lim_Dchar,lim_Cost]
w_list = [w_Sfor,w_Nsup,w_Sens,w_Ltot,w_Vtot,w_IPC,w_VAM,w_Dchar,0]
lim_list = [lim_Sfor,lim_Nsup,lim_Sens,lim_Ltot,lim_Vtot,lim_IPC,lim_VAM,lim_Dchar,0]
# Line optimisation only
if not test_Cable and test_cable_optimise:
......@@ -218,13 +226,9 @@ if __name__ == "__main__":
Cabsel_Vha = str(Interface.ui.cable_vha_path.text())
Cabsel_Vam = str(Interface.ui.cable_vam_path.text())
new_calc=Interface.ui.Cab_new_calc.isChecked()*1
Cabsel_Lhor_max = Interface.ui.cable_sel_Lhor_max.value()
if test_cable_optimise:
prelevement = Interface.ui.prelevement.value()*0.01
else:
prelevement = 0.25
Cabsel_Lhor_max = Interface.ui.cable_sel_Lhor_max.value()
prelevement = Interface.ui.prelevement.value()*0.01
#limits
lim_Sfor = Interface.ui.lim_surf.value()
lim_Nsup = Interface.ui.lim_intsup.value()
......@@ -234,7 +238,8 @@ if __name__ == "__main__":
lim_IPC = Interface.ui.lim_IPC.value()
lim_VAM = Interface.ui.lim_VAM.value()
lim_Dchar = Interface.ui.lim_Dchar.value()
lim_Cost = Interface.ui.lim_Cost.value()
#lim_Cost = Interface.ui.lim_Cost.value()
lim_Cost = 0
#Weight
w_Sfor = Interface.ui.w_Surf.value()
......@@ -245,44 +250,146 @@ if __name__ == "__main__":
w_IPC = Interface.ui.w_IPC.value()
w_VAM = Interface.ui.w_VAM.value()
w_Dchar = Interface.ui.w_Dchar.value()
w_Cost = Interface.ui.w_Cost.value()
#w_Cost = Interface.ui.w_Cost.value()
w_Cost = 0
w_list = [w_Sfor,w_Nsup,w_Sens,w_Ltot,w_Vtot,w_IPC,w_VAM,w_Dchar,w_Cost]
w_list = [w_Sfor ,w_Nsup ,w_Sens ,w_Ltot ,w_Vtot ,w_IPC ,w_VAM ,w_Dchar,w_Cost]
lim_list = [lim_Sfor,lim_Nsup,lim_Sens,lim_Ltot,lim_Vtot,lim_IPC,lim_VAM,lim_Dchar,lim_Cost]
try:os.mkdir(Rspace)
except:pass
Interface.close()
try:
#Check file entries before processing
test,mess = check_files(file_MNT,file_shp_Desserte,file_shp_Foret,file_Vol_ha,file_Vol_AM,file_Htree,language,test_Cable)
test,mess = check_files(file_MNT,file_shp_Desserte,file_shp_Foret,file_Vol_ha,file_Vol_AM,
file_Htree,language,test_Cable,test_Skidder,test_Forwarder,
test_cable_optimise,new_calc,Cabsel_For,file_shp_Cable_dep)
if not test:
# There is a problem with spatial inputs
print(mess)
else:
#Run Sylvaccess
if test_Skidder:
process_skidder(Wspace,Rspace,file_MNT,Dtreuil_max_up,Dtreuil_max_down,
Dmax_train_near_for,Pente_max_skidder,Pmax_amont,Pmax_aval,
Option_Skidder,Pente_max_bucheron,Dir_Full_Obs_skidder,
Dir_Partial_Obs_skidder,language,file_shp_Desserte,file_shp_Foret,
file_Vol_ha,Skid_Debclass)
gc.collect()
if test_Forwarder:
process_forwarder(Wspace,Rspace,file_MNT,Pente_max_bucheron,Forw_angle_incl,Forw_angle_up,Forw_angle_down,Forw_portee,
language,file_shp_Desserte,file_shp_Foret,Dir_Obs_forwarder,Forw_Lmax,Forw_Dmax_out_for,
file_Vol_ha,Forw_Debclass)
gc.collect()
#Run Sylvaccess
if (test_Skidder + test_Forwarder) > 0:
# Verifie si une partie de la desserte correspond a un projet
testExist = check_field(file_shp_Desserte,"EXIST")
###################################################################################################################
### Si pas de projet desserte
###################################################################################################################
if not testExist:
if test_Skidder:
process_skidder(Wspace,Rspace,file_MNT,Dtreuil_max_up,Dtreuil_max_down,
Dmax_train_near_for,Pente_max_skidder,Pmax_amont,Pmax_aval,
Option_Skidder,Pente_max_bucheron,Dir_Full_Obs_skidder,
Dir_Partial_Obs_skidder,language,file_shp_Desserte,file_shp_Foret,
file_Vol_ha,Skid_Debclass)
gc.collect()
if test_Forwarder:
process_forwarder(Wspace,Rspace,file_MNT,Pente_max_bucheron,Forw_angle_incl,Forw_angle_up,
Forw_angle_down,Forw_portee,language,file_shp_Desserte,file_shp_Foret,
Dir_Obs_forwarder,Forw_Lmax,Forw_Dmax_out_for,file_Vol_ha,Forw_Debclass)
gc.collect()
###################################################################################################################
### Si projet desserte
###################################################################################################################
else:
file_shp_Desserte_Exist = create_new_road_network(file_shp_Desserte,Wspace)
#Premiere simu sans projet
if language=="FR":
print("\nSIMULATION DEPUIS LA DESSERTE EXISTANTE")
else:
print("\nSIMULATION FROM EXISTING ROAD NETWORK")
if test_Skidder:
try:os.mkdir(Rspace+"Skidder/")
except:pass
process_skidder(Wspace,Rspace+"Skidder/",file_MNT,Dtreuil_max_up,Dtreuil_max_down,
Dmax_train_near_for,Pente_max_skidder,Pmax_amont,Pmax_aval,
Option_Skidder,Pente_max_bucheron,Dir_Full_Obs_skidder,
Dir_Partial_Obs_skidder,language,file_shp_Desserte_Exist,file_shp_Foret,
file_Vol_ha,Skid_Debclass)
gc.collect()
if language=="FR":
projdir = Rspace+"Skidder/1_Existant/"
else:
projdir = Rspace+"Skidder/1_Existing/"
os.rename(Rspace+"Skidder/Skidder/",projdir)
if test_Forwarder:
if language=='EN':
Rspace_f = Rspace+"Forwarder/"
old=Rspace+"Forwarder/Forwarder/"
new= Rspace+"Forwarder/1_Existing/"
else:
Rspace_f = Rspace+"Porteur/"
old=Rspace+"Porteur/Porteur/"
new= Rspace+"Porteur/1_Existant/"
try:os.mkdir(Rspace_f)
except:pass
process_forwarder(Wspace,Rspace_f,file_MNT,Pente_max_bucheron,Forw_angle_incl,Forw_angle_up,
Forw_angle_down,Forw_portee,language,file_shp_Desserte_Exist,file_shp_Foret,
Dir_Obs_forwarder,Forw_Lmax,Forw_Dmax_out_for,file_Vol_ha,Forw_Debclass)
gc.collect()
os.rename(old,new)
os.remove(Wspace+"Temp/Lien_piste.npy")
os.remove(Wspace+"Temp/Lien_RF.npy")
os.remove(Wspace+"Temp/Tab_res_pub.npy")
os.remove(Wspace+"Temp/Route_for.npy")
os.remove(Wspace+"Temp/Piste.npy")
#Deuxieme simu avec projet
if language=="FR":
print("\nSIMULATION INCLUANT LE PROJET DE DESSERTE")
else:
print("\nSIMULATION INCLUDING PROJECT OF ROADS")
if test_Skidder:
process_skidder(Wspace,Rspace+"Skidder/",file_MNT,Dtreuil_max_up,Dtreuil_max_down,
Dmax_train_near_for,Pente_max_skidder,Pmax_amont,Pmax_aval,
Option_Skidder,Pente_max_bucheron,Dir_Full_Obs_skidder,
Dir_Partial_Obs_skidder,language,file_shp_Desserte,file_shp_Foret,
file_Vol_ha,Skid_Debclass)
gc.collect()
if language=="FR":
projdir = Rspace+"Skidder/2_Projet/"
else:
projdir = Rspace+"Skidder/2_Project/"
os.rename(Rspace+"Skidder/Skidder/",projdir)
make_dif_files(language,Rspace,0)
if test_Forwarder:
if language=='EN':
Rspace_f = Rspace+"Forwarder/"
old=Rspace+"Forwarder/Forwarder/"
new= Rspace+"Forwarder/2_Project/"
else:
Rspace_f = Rspace+"Porteur/"
old=Rspace+"Porteur/Porteur/"
new= Rspace+"Porteur/2_Projet/"
process_forwarder(Wspace,Rspace_f,file_MNT,Pente_max_bucheron,Forw_angle_incl,Forw_angle_up,
Forw_angle_down,Forw_portee,language,file_shp_Desserte,file_shp_Foret,
Dir_Obs_forwarder,Forw_Lmax,Forw_Dmax_out_for,file_Vol_ha,Forw_Debclass)
gc.collect()
os.rename(old,new)
make_dif_files(language,Rspace,1)
if test_Cable:
process_cable(Wspace,Rspace,file_MNT,file_shp_Foret,file_shp_Desserte,Dir_Obs_cable,file_Vol_ha,file_Vol_AM,file_Htree,Pente_max_bucheron,
Lmax,Lmin,LminSpan,Htower,Hintsup,Hend,Lhor_max,Hline_min,Hline_max,sup_max,Carriage_type,Cable_type,slope_grav,
Pchar,slope_Wliner_up,slope_Wliner_down,q1,rupt_res,safe_fact,E,d,Load_max,q2,q3,Max_angle,coeff_frot,language,
precision,prelevement,slope_trans,angle_transv,test_cable_optimise,w_list,lim_list,VariaH,Lslope,PropSlope)
process_cable(Wspace,Rspace,file_MNT,file_shp_Foret,file_shp_Cable_dep,Dir_Obs_cable,file_Vol_ha,
file_Vol_AM,file_Htree,Pente_max_bucheron,Lmax,Lmin,LminSpan,Htower,Hintsup,Hend,
Lhor_max,Hline_min,Hline_max,sup_max,Carriage_type,Cable_type,slope_grav,Pchar,
slope_Wliner_up,slope_Wliner_down,q1,rupt_res,safe_fact,E,d,Load_max,q2,q3,
Max_angle,coeff_frot,language,precision,prelevement,slope_trans,angle_transv,
test_cable_optimise,w_list,lim_list,VariaH,Lslope,PropSlope)
test_cable_optimise=0
gc.collect()
if test_cable_optimise:
line_selection(Dir_cable_sel,w_list,lim_list,new_calc,Cabsel_For,Cabsel_Vha,Cabsel_Vam,
language,Cabsel_Lhor_max,prelevement,Pente_max_bucheron)
language,Cabsel_Lhor_max,prelevement,Pente_max_bucheron)
gc.collect()
try:
shutil.rmtree(Wspace+"Temp")
......@@ -292,8 +399,14 @@ if __name__ == "__main__":
log = open(Rspace + 'error_log.txt', 'w')
traceback.print_exc(file=log)
log.close()
shutil.rmtree(Wspace+"Temp")
try:
shutil.rmtree(Wspace+"Temp")
except:
pass
time.sleep(60.)
Interface.ui.buttonBox.accepted.connect(get_variable)
Interface.ui.buttonBox.accepted.connect(get_variable)
sys.exit(app.exec_())
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment