def OnClick(self,event): #self.logger.AppendText(" Click on object with Id %d\n" %event.GetId()) #______________________________________________________________________________________________________________ if event.GetId()==10: #10==START if Form1.Chech_single==1: import Cria_grupo Form1.out_map=Form1.import_map.split('\\');Form1.out_map=Form1.out_map[-1].replace('.','_') grass.run_command('r.in.gdal',input=Form1.import_map,out=Form1.out_map,overwrite=True) Form1.group_img=grass.list_grouped('rast', pattern='*'+Form1.out_map+'*') ['PERMANENT'] Cria_grupo.CriaGrupo(Form1.group_img) grass.run_command('g.region', rast=Form1.group_img[0],verbose=False) grass.run_command('i.segment', group='Grupo',output=Form1.group_img[0]+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize`,threshold=Form1.thrs, minsize=Form1.Misize) #grass.run_command('r.to.vect',input=Form1.group_img[0]+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize`,output=Form1.group_img[0]+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize`,type='area' ) if event.GetId()==11: if Form1.Chech_mult==1: import import_folder_imagens import_folder_imagens.import_fd(folder_files=Form1.dir_in) #______________________________________________________________________________________________________________ if event.GetId()==9: #9==CHANGE BACKGROUND if Form1.plotmovements==1: self.Refresh() Form1.background_filename=Form1.listMapsPng Form1.background_filename_start=Form1.background_filename[Form1.contBG] img =Image.open(Form1.background_filename[Form1.contBG]) # redimensionamos sem perder a qualidade img = img.resize((Form1.size,Form1.hsize),Image.ANTIALIAS) img.save(Form1.background_filename[Form1.contBG]) imageFile=Form1.background_filename[Form1.contBG] im1 = Image.open(imageFile) jpg1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap() wx.StaticBitmap(self, -1, jpg1, (380,40), (jpg1.GetWidth(), jpg1.GetHeight()), style=wx.SIMPLE_BORDER) Form1.background_filename=Form1.background_filename_start Form1.contBG=Form1.contBG+1 self.Refresh() if len(Form1.listMapsPng)==Form1.contBG: Form1.contBG=0 self.Refresh() #______________________________________________________________________________________________________________ if event.GetId()==11: if Form1.Chech_mult==1: Form1.dir_in=selecdirectori() if Form1.Chech_single==1: Form1.import_map=selecdirectori()
def OnClick(self,event): #self.logger.AppendText(" Click on object with Id %d\n" %event.GetId()) #______________________________________________________________________________________________________________ if event.GetId()==10: #10==START d= wx.MessageDialog( self, " Please select the folder where the files will be saved \n" " ","", wx.OK) # Create a message dialog box d.ShowModal() # Shows it d.Destroy() # finally destroy it when finished. Form1.dir_out=selecdirectori() self.logger.AppendText('Directory output :'+Form1.dir_out+' \n ') self.logger.AppendText('runing... :'+Form1.import_map+' \n ') if Form1.Chech_single==1: import Cria_grupo import v_what import prepara_kmeans Form1.out_map=Form1.import_map.split('\\');Form1.out_map=Form1.out_map[-1].replace('.','_') grass.run_command('r.in.gdal',input=Form1.import_map,out=Form1.out_map,overwrite=True) Form1.group_img=grass.list_grouped('rast', pattern='*'+Form1.out_map+'*') ['PERMANENT'] Cria_grupo.CriaGrupo(Form1.group_img) grass.run_command('g.region', rast=Form1.group_img[0],verbose=False) grass.run_command('i.segment', group='Grupo',output=Form1.group_img[0]+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize`,threshold=Form1.thrs, minsize=Form1.Misize,overwrite=True) Form1.out_name_vect=Form1.group_img[0]+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize` Form1.out_name_vect=Form1.out_name_vect.replace('.','_') Form1.out_name_vect=Form1.out_name_vect.replace('-','_') Form1.out_name_vect='A'+Form1.out_name_vect grass.run_command('r.to.vect',input=Form1.group_img[0]+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize`,output=Form1.out_name_vect,type='area',overwrite=True ) if Form1.classify==1: v_what.v_what(Form1.group_img,Form1.out_name_vect) os.chdir(Form1.dir_out) Form1.dir_out_vect=Form1.dir_out.replace("\\",'/').replace("\n",'/n').replace('\a','/a') print Form1.dir_out_vect grass.run_command('v.out.ogr', input=Form1.out_name_vect, output=Form1.dir_out_vect+'/'+Form1.out_name_vect+'.shp',type='area') if Form1.classify==1: prepara_kmeans.prep_kmean(Form1.out_name_vect, Form1.dir_out, Form1.nclass) p = Popen([r"C:\Program Files\R\R-2.15.3\bin\x64\Rscript.exe",Form1.dir_out_vect+'/'+"Kmeans_final.txt"]) if Form1.Chech_mult==1: import import_folder_imagens import Cria_grupo import v_what import prepara_kmeans Form1.list_pattern=import_folder_imagens.import_fd(folder_files=Form1.dir_in) for i in Form1.list_pattern: Form1.group_img=grass.list_grouped('rast', pattern='*'+i+'*') ['PERMANENT'] Cria_grupo.CriaGrupo(Form1.group_img) grass.run_command('g.region', rast=Form1.group_img[0],verbose=False) grass.run_command('i.segment', group='Grupo',output=i+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize`,threshold=Form1.thrs, minsize=Form1.Misize,overwrite=True ) Form1.out_name_vect=i+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize` Form1.out_name_vect=Form1.out_name_vect.replace('.','_') Form1.out_name_vect=Form1.out_name_vect.replace('-','_') Form1.out_name_vect='A'+Form1.out_name_vect grass.run_command('r.to.vect',input=i+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize`,output=Form1.out_name_vect,type='area',overwrite=True ) if Form1.classify==1: v_what.v_what(Form1.group_img,Form1.out_name_vect) Form1.dir_out_vect=Form1.dir_out.replace("\\",'/').replace("\n",'/n').replace('\a','/a') grass.run_command('v.out.ogr', input=Form1.out_name_vect, output=Form1.dir_out+'/'+Form1.out_name_vect+'.shp',type='area',overwrite=True) if Form1.classify==1: prepara_kmeans.prep_kmean(Form1.out_name_vect, Form1.dir_out, Form1.nclass) p = Popen([r"C:\Program Files\R\R-2.15.3\bin\x64\Rscript.exe",Form1.dir_out_vect+'/'+"Kmeans_final.txt"]) d= wx.MessageDialog( self, " Finish \n" " ","", wx.OK) # Create a message dialog box d.ShowModal() # Shows it d.Destroy() # finally destroy it when finished. #______________________________________________________________________________________________________________ if event.GetId()==11: if Form1.Chech_mult==1: Form1.dir_in=selecdirectori() self.logger.AppendText('Directory input :'+Form1.dir_in+' \n ') if Form1.Chech_single==1: Form1.import_map=selecdirectori() self.logger.AppendText('File input :'+Form1.import_map+' \n ')
def OnClick(self,event): #self.logger.AppendText(" Click on object with Id %d\n" %event.GetId()) #______________________________________________________________________________________________________________ if event.GetId()==10: #10==START if Form1.Chech_single==1: import Cria_grupo import v_what Form1.out_map=Form1.import_map.split('\\');Form1.out_map=Form1.out_map[-1].replace('.','_') grass.run_command('r.in.gdal',input=Form1.import_map,out=Form1.out_map,overwrite=True) Form1.group_img=grass.list_grouped('rast', pattern='*'+Form1.out_map+'*') ['PERMANENT'] Cria_grupo.CriaGrupo(Form1.group_img) grass.run_command('g.region', rast=Form1.group_img[0],verbose=False) #grass.run_command('i.segment', group='Grupo',output=Form1.group_img[0]+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize`,threshold=Form1.thrs, minsize=Form1.Misize) Form1.out_name_vect=Form1.group_img[0]+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize` Form1.out_name_vect=Form1.out_name_vect.replace('.','_') Form1.out_name_vect=Form1.out_name_vect.replace('-','_') Form1.out_name_vect='A'+Form1.out_name_vect #grass.run_command('r.to.vect',input=Form1.group_img[0]+'_segment_thre'+`Form1.thrs`+'_'+`Form1.Misize`,output=Form1.out_name_vect,type='area',overwrite=True ) #v_what.v_what(Form1.group_img,Form1.out_name_vect) grass.run_command('v.out.ogr', input=Form1.out_name_vect, output=Form1.out_name_vect+'.shp',type='area',) p = Popen([r"C:\Program Files\R\R-2.15.3\bin\x64\Rscript.exe", "teste_R_sem_var_amb.R"], cwd=r"E:\data_2015\___john\Desenvolvimentos\aplications\Aplicacoes_grass\automatic classification") if event.GetId()==11: if Form1.Chech_mult==1: import import_folder_imagens import_folder_imagens.import_fd(folder_files=Form1.dir_in) #______________________________________________________________________________________________________________ if event.GetId()==9: #9==CHANGE BACKGROUND if Form1.plotmovements==1: self.Refresh() Form1.background_filename=Form1.listMapsPng Form1.background_filename_start=Form1.background_filename[Form1.contBG] img =Image.open(Form1.background_filename[Form1.contBG]) # redimensionamos sem perder a qualidade img = img.resize((Form1.size,Form1.hsize),Image.ANTIALIAS) img.save(Form1.background_filename[Form1.contBG]) imageFile=Form1.background_filename[Form1.contBG] im1 = Image.open(imageFile) jpg1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap() wx.StaticBitmap(self, -1, jpg1, (380,40), (jpg1.GetWidth(), jpg1.GetHeight()), style=wx.SIMPLE_BORDER) Form1.background_filename=Form1.background_filename_start Form1.contBG=Form1.contBG+1 self.Refresh() if len(Form1.listMapsPng)==Form1.contBG: Form1.contBG=0 self.Refresh() #______________________________________________________________________________________________________________ if event.GetId()==11: if Form1.Chech_mult==1: Form1.dir_in=selecdirectori() if Form1.Chech_single==1: Form1.import_map=selecdirectori()