Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Commit

Permalink
Bug fix and README updates (#5)
Browse files Browse the repository at this point in the history
* Update readme (#2)

* Restored README

* Updated README

* Changed a character to upper case

* Problem: Path appended twice to VRT file path

Once before calling create_vrt_permanent, and a second time inside
create_vrt_permanent.

It ended up trying to create a file with a path like:

./output/fieldmosaic/./output/fieldmosaic/fullfield_mosaic.vrt

Solution: Pass the bare filename (no path) into create_vrt_permanent

P.S. I also noticed and removed a redundant conditional statement (both
branches were exactly the same)
  • Loading branch information
julianpistorius authored and Chris-Schnaufer committed Nov 26, 2019
1 parent af17319 commit 87ce072
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def create_vrt_permanent(base_dir: str, file_list: str, out_vrt: str = 'virtualT
vrt_path = os.path.join(base_dir, out_vrt)
cmd = 'gdalbuildvrt -srcnodata "-99 -99 -99" -overwrite -input_file_list ' + file_list +' ' + vrt_path
logging.debug("Running Virtual Tiff command: '%s'", cmd)
os.system(cmd)
cmd_result = os.system(cmd)
logging.debug(f'Result of Virtual Tiff command: {cmd_result}')

@staticmethod
def generate_single_mosaic(**kwargs) -> list:
Expand All @@ -60,12 +61,10 @@ def generate_single_mosaic(**kwargs) -> list:
bounds = kwargs['bounds']

# Create VRT from every GeoTIFF
out_vrt_filename = kwargs['out_vrt']
out_vrt = os.path.join(kwargs['out_dir'], kwargs['out_vrt'])
logging.info("Creating VRT %s...", out_vrt)
if out_vrt.endswith("_mask.vrt"):
__internal__.create_vrt_permanent(kwargs['out_dir'], kwargs['file_list_path'], out_vrt)
else:
__internal__.create_vrt_permanent(kwargs['out_dir'], kwargs['file_list_path'], out_vrt)
__internal__.create_vrt_permanent(kwargs['out_dir'], kwargs['file_list_path'], out_vrt_filename)
files_created.append(out_vrt)
sum_bytes += os.path.getsize(out_vrt)

Expand Down

0 comments on commit 87ce072

Please sign in to comment.