Skip to content

Commit d721108

Browse files
committed
Corrected a couple of items for debugging
1 parent 5dae0c8 commit d721108

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

main.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,16 @@ def get_crs_of_data(file, vector=False):
193193
exit(2)
194194

195195
logger.info('Verified input files: %s' %input_files)
196-
196+
print('Verified input files: %s' %input_files)
197197

198198
# get extents for clip - file or defined extents
199199
# clip area file
200200

201201
# checks the dataslot
202202
clip_file = fetch_clip_file()
203-
print('clip files is:', clip_file)
203+
if type(clip_file) is list:
204+
clip_file = clip_file[0]
205+
print('Clip files is:', clip_file)
204206
logger.info('Clip file: %s' % clip_file)
205207

206208
# check if file passed from previous step
@@ -210,7 +212,7 @@ def get_crs_of_data(file, vector=False):
210212
if outcome[0] is not None:
211213
clip_file = outcome
212214

213-
logger.info('Clip file set to:', clip_file)
215+
logger.info('Clip file set to: %s' %clip_file)
214216

215217
# defined extents
216218
extent = None
@@ -228,10 +230,10 @@ def get_crs_of_data(file, vector=False):
228230
# if a text bounds file passed, convert to extent text so can use that existing method
229231
# xmin,ymin,xmax,ymax
230232
print('reading extents file')
231-
cf_ext = clip_file[0].split('.')[1]
233+
cf_ext = clip_file.split('.')[1]
232234
print(cf_ext)
233235
if cf_ext == 'txt':
234-
with open(join(data_path, input_dir, clip_file[0])) as ef:
236+
with open(join(data_path, input_dir, clip_file)) as ef:
235237
extent = ef.readline()
236238
clip_file = None
237239

@@ -362,7 +364,7 @@ def get_crs_of_data(file, vector=False):
362364
logger.info("Using clip file method")
363365

364366
# get crs of clip file
365-
clip_crs = get_crs_of_data(clip_file[0], vector=True)
367+
clip_crs = get_crs_of_data(clip_file, vector=True)
366368

367369
# if crs could not be found, return error
368370
if clip_crs is None:
@@ -379,7 +381,7 @@ def get_crs_of_data(file, vector=False):
379381
if cut_to_bounding_box is False:
380382
# crop to the shapefile, not just the bounding box of the shapefile
381383
print('Clipping with cutline flag')
382-
command_output = subprocess.run(["gdalwarp", "-cutline", clip_file[0], "-crop_to_cutline", join(data_path, input_dir, data_to_clip_dir, input_file),
384+
command_output = subprocess.run(["gdalwarp", "-cutline", clip_file, "-crop_to_cutline", join(data_path, input_dir, data_to_clip_dir, input_file),
383385
join(data_path, output_dir, output_file_name_set)])
384386

385387
else:
@@ -389,11 +391,11 @@ def get_crs_of_data(file, vector=False):
389391
print(join(data_path, output_dir, output_file_name_set)
390392
)
391393
# this should work but does not for some reason....
392-
#command_output = subprocess.run(["gdalwarp", "-cutline", clip_file[0], join(data_path, input_dir, data_to_clip_dir, input_file), join(data_path, output_dir, output_file_name_set)])
394+
#command_output = subprocess.run(["gdalwarp", "-cutline", clip_file, join(data_path, input_dir, data_to_clip_dir, input_file), join(data_path, output_dir, output_file_name_set)])
393395
# so instead using this....
394396

395397
# read in shapefile
396-
t = gpd.read_file(clip_file[0])
398+
t = gpd.read_file(clip_file)
397399
# get bounding box for shapefile
398400
bounds = t.geometry.total_bounds
399401
# run clip

0 commit comments

Comments
 (0)