better printing

This commit is contained in:
Cyberes 2023-11-06 20:24:52 -07:00
parent 359966e97e
commit 58d765b88c
2 changed files with 9 additions and 3 deletions

View File

@ -102,15 +102,19 @@ if __name__ == '__main__':
col_bar.close() col_bar.close()
print(f'Downloaded {total_downloaded} images.') print(f'Downloaded {total_downloaded} images.')
print('Preparing data...')
print('Determining tile width...', end='')
tile_size = random_file_width(tiles_output) tile_size = random_file_width(tiles_output)
print(f' {tile_size}px')
# Define the number of rows and columns based on the bounding box # 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_rows = max_row - min_row + 1
num_cols = max_col - min_col + 1 num_cols = max_col - min_col + 1
print(f' {num_cols}x{num_rows}')
# Create an empty array to store the image data # 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) 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: with ThreadPoolExecutor(max_workers=args.tiff_threads) as executor:
futures = {executor.submit(build_tiff_data, task) for task in tiles} 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 pass
# Transpose the image data array to the format (bands, rows, cols). # Transpose the image data array to the format (bands, rows, cols).
print('Transposing...')
image_data = np.transpose(image_data, (2, 0, 1)) image_data = np.transpose(image_data, (2, 0, 1))
# Define the transformation from pixel coordinates to geographic coordinates, which is an Affine transformation that # 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. # 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. 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. # 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])) * Affine.scale((bottom_right_lon - top_left_lon) / image_data.shape[2], (bottom_right_lat - top_left_lat) / image_data.shape[1]))

View File

@ -3,5 +3,5 @@ venv/bin/python3 exfiltrate.py \
--zoom 20 \ --zoom 20 \
--referer https://maps.nlsc.gov.tw/ \ --referer https://maps.nlsc.gov.tw/ \
--bbox 25.076387 121.68951 25.068282 121.700175 \ --bbox 25.076387 121.68951 25.068282 121.700175 \
--threads 30 \ --dl-threads 30 \
--output ~/Downloads/wmts-output/ --output ~/Downloads/wmts-output/