Geoscience Reference
In-Depth Information
the number of sample points to generate, the bounding box and the output format.
We include a check for the bounding box to ensure that the lower extents are less
than the upper extents of the area of interest.
def main():
try:
parser = argparse.ArgumentParser()
parser.add_argument('-f','--frame_type',
help='Sampling frame design', required=True)
parser.add_argument('-s','--sample',
help='Number of samples', type=int, required=True)
parser.add_argument('-b','--bbox',
help='Bounding box', type=int, nargs=4, required=True)
parser.add_argument('-o','--output_format',
help='Output Format', default='Shp')
args = parser.parse_args()
frame_type = args.frame_type
n_sample = args.sample
bbox_list = args.bbox
output_format = args.output_format
#create a dictionary to hold the four coordinates of the
bounding box
bbox_dict = {'xmin': bbox_list[0],'ymin':
bbox_list[1],'xmax':
bbox_list[2],'ymax': bbox_list[3]}
#check if xmin is greater than xmax and exit if it is
if bbox_dict['xmin'] > bbox_dict['xmax']:
print("Error xmin: "+
str(bbox_dict['xmin']) +" is greater than xmax: "+
str(bbox_dict['xmax']))
sys.exit(1)
#check if ymin is greater than ymax and exit if it is
if bbox_dict['ymin'] > bbox_dict['ymax']:
print("Error ymin: "+
str(bbox_dict['ymin']) +" is greater than ymax: "+
str(bbox_dict['ymax']))
sys.exit(1)
#call different function depending on type of sampling frame
if frame_type =="random":
print("Calling random frame...")
randomFrame(n_sample, bbox_dict,
output_format)
else:
print("Calling systematic frame...")
systematicFrame()
print'Created Sampling frame containing'
+
str(n_sample) +' plots'
return 1
except:
sys.exit(1)
return 0
 
 
Search WWH ::




Custom Search