diff --git a/exfiltrate.py b/exfiltrate.py index 265b079..de682fa 100644 --- a/exfiltrate.py +++ b/exfiltrate.py @@ -102,15 +102,19 @@ if __name__ == '__main__': col_bar.close() print(f'Downloaded {total_downloaded} images.') - print('Preparing data...') + print('Determining tile width...', end='') tile_size = random_file_width(tiles_output) + print(f' {tile_size}px') # Define the number of rows and columns based on the bounding box + print('Calculating maximum columns and rows...', end='') num_rows = max_row - min_row + 1 num_cols = max_col - min_col + 1 + print(f' {num_cols}x{num_rows}') # Create an empty array to store the image data + print(f'Allocating an array with the shape {num_rows * tile_size, num_cols * tile_size} and dimension 3...') image_data = np.empty((num_rows * tile_size, num_cols * tile_size, 3), dtype=np.uint8) @@ -145,14 +149,16 @@ if __name__ == '__main__': with ThreadPoolExecutor(max_workers=args.tiff_threads) as executor: futures = {executor.submit(build_tiff_data, task) for task in tiles} - for future in tqdm(as_completed(futures), total=len(futures), desc='Preparing Data'): + for future in tqdm(as_completed(futures), total=len(futures), desc='Building TIFF'): pass # Transpose the image data array to the format (bands, rows, cols). + print('Transposing...') image_data = np.transpose(image_data, (2, 0, 1)) # Define the transformation from pixel coordinates to geographic coordinates, which is an Affine transformation that # maps pixel coordinates in the image to geographic coordinates on the Earth's surface. + print('Calculating transform...') transform = (Affine.translation(top_left_lon, top_left_lat) # Create a translation transformation that shifts the image and set the origin of the image to the top-left corner of the bounding box. # Create a scaling transformation that scales the image in the x and y directions to convert the pixel coordinates of the image to the geographic coordinates of the bounding box. * Affine.scale((bottom_right_lon - top_left_lon) / image_data.shape[2], (bottom_right_lat - top_left_lat) / image_data.shape[1])) diff --git a/test.sh b/test.sh index 38c42cc..8e97dae 100644 --- a/test.sh +++ b/test.sh @@ -3,5 +3,5 @@ venv/bin/python3 exfiltrate.py \ --zoom 20 \ --referer https://maps.nlsc.gov.tw/ \ --bbox 25.076387 121.68951 25.068282 121.700175 \ - --threads 30 \ + --dl-threads 30 \ --output ~/Downloads/wmts-output/