示例#1
0
	def run_large(self, inTiff, outfile, r1run, r3min, r3max, r2run, r5min, r5max, r3run, r7min, r7max, r9run, r9min, r9max, r11run, r11min, r11max, smooth_strat):
		
		try:
			partdir = inTiff[:inTiff.rfind(".")] + "_parts"
			
			self.writeMessage("\nPartition Directory:\n\t" + partdir + "\n")
			                                        
			if not os.path.exists(partdir):
				os.mkdir(partdir)
			
			self.writeMessage("Partitioning:\n\t" + inTiff + " ...\n\n")
			
			TCD_module.partitionTiff(inTiff, partdir)
			
			regex   = re.compile('[0-9]+_[0-9]+\.tiff?$')
			dirList = os.listdir(partdir)
			
			for part in dirList:
				if regex.match(part):
					tiff = partdir + "/" + part
					self.writeMessage("\t" + tiff + "\n");
					TCD_module.findTreeTops(tiff, outfile, r1run, r3min, r3max, r2run, r5min, r5max, r3run, r7min, r7max, r9run, r9min, r9max, r11run, r11min, r11max, 1, smooth_strat)
						
		except:
			self.handle_exception(sys.exc_info())
示例#2
0
	def run_file(self, inTiff, outdir, r1run, r3min, r3max, r2run, r5min, r5max, r3run, r7min, r7max, r9run, r9min, r9max, r11run, r11min, r11max, smooth_strat, add_noise):
		
		try:
			#
			# Generate base name for output shape file
			#
			a = inTiff.rfind("/")
			b = inTiff.rfind(".")
			date_time_string = datetime.datetime.now().strftime("_%m_%d_%y_%H_%M_%S")
			outfile = outdir + "/TT_" + inTiff[a+1:b] + date_time_string
			
			
			self.createTreetopLogFile(outfile + ".txt", inTiff, smooth_strat,\
				r1run,  r3min,  r3max,\
				r2run,  r5min,  r5max,\
				r3run,  r7min,  r7max,\
				r9run,  r9min,  r9max,\
				r11run, r11min, r11max,
				add_noise)
			
			#
			# Remove output shape file if it already exists
			#
			postfix = [".shp", ".shx", ".dbf"]
			for pf in postfix:
				file = outfile + pf
				if os.path.exists(file):
					os.remove(file)
			
			self.writeMessage("Input:  " + inTiff + "\n")
			self.writeMessage("Output: " + outfile + "\n")
			
			TCD_module.findTreeTops(inTiff, outfile, r1run, r3min, r3max, r2run, r5min, r5max, r3run, r7min, r7max, r9run, r9min, r9max, r11run, r11min, r11max, 0, smooth_strat, add_noise)
			
			
			#########################################################
			#                 Disable Partitioning                  #
			#########################################################
			#
			#imgsize = TCD_module.getImageSize(inTiff)
			#self.writeMessage("Image Size: " + str(imgsize))
			
			#if(imgsize <= 1000000000):
				
			#	TCD_module.findTreeTops(inTiff, outfile, r1run, r3min, r3max, r2run, r5min, r5max, r3run, r7min, r7max, r9run, r9min, r9max, r11run, r11min, r11max, 0, smooth_strat)
			#else:
			#	self.run_large(inTiff, outfile, r1run, r3min, r3max, r2run, r5min, r5max, r3run, r7min, r7max, r9run, r9min, r9max, r11run, r11min, r11max, smooth_strat)
				
		except:
			self.handle_exception(sys.exc_info())