Closed kylebarron closed 4 years ago
Grid size - Scale combinations:
[['7.5 X 7.5 Minute', 10000],
['7.5 X 7.5 Minute', 20000],
['7.5 X 7.5 Minute', 21120],
['7.5 X 7.5 Minute', 24000],
['7.5 X 7.5 Minute', 25000],
['7.5 X 7.5 Minute', 30000],
['7.5 X 7.5 Minute', 31680],
['7.5 X 7.5 Minute', 48000],
['7.5 X 7.5 Minute', 62500],
['3.75 X 3.75 Minute', 10000],
['3.75 X 3.75 Minute', 12000],
['15 X 15 Minute', 20000],
['15 X 15 Minute', 24000],
['15 X 15 Minute', 31680],
['15 X 15 Minute', 48000],
['15 X 15 Minute', 50000],
['15 X 15 Minute', 62500],
['15 X 15 Minute', 63360],
['15 X 15 Minute', 96000],
['7.5 X 15 Minute', 25000],
['7.5 X 15 Minute', 48000],
['None', 25000],
['30 X 30 Minute', 96000],
['30 X 30 Minute', 100000],
['30 X 30 Minute', 125000],
['30 X 30 Minute', 192000],
['30 X 30 Minute', 250000],
['30 X 60 Minute', 100000],
['30 X 60 Minute', 125000],
['1 X 2 Degree', 250000],
['1 X 3 Degree', 250000],
['1 X 1 Degree', 250000],
['1 X 4 Degree', 250000],
['2 X 1 Degree', 250000]]
Reproduction code:
df = pd.read_csv(path)
# Keep only historical maps
# Newer maps are only in GeoPDF, and not in GeoTIFF, let alone COG
df = df[df['Series'] == 'HTMC']
df['geometry'] = df.apply(construct_geometry, axis=1)
gdf = gpd.GeoDataFrame(df)
# or just use df here
grid_sizes = gdf['Grid Size'].unique()
grid_size_scales_pairs = []
for grid_size in grid_sizes:
grid_size_df = gdf[gdf['Grid Size'] == grid_size]
scales = grid_size_df['Scale'].unique()
for scale in scales:
grid_size_scales_pairs.append([grid_size, scale])
Code to visualize each combination:
cols = ['Map Name',
'Scale',
'geometry',
'W Long',
'S Lat',
'E Long',
'N Lat',
'Download Product S3']
for grid_size, scale in grid_size_scales_pairs:
if grid_size == 'None':
continue
gdf_part = gdf.loc[(gdf['Grid Size'] == grid_size) & (gdf['Scale'] == scale)]
Visualize(gdf_part[cols])
To generate automated test cases:
test_cases = []
n = 3
for grid_size, scale in grid_size_scales_pairs:
if grid_size == 'None':
continue
gdf_part = gdf.loc[(gdf['Grid Size'] == grid_size) & (gdf['Scale'] == scale)]
# Choose random 3
choose_n = min(len(gdf_part), n)
sample = gdf_part.sample(choose_n)
urls = sample['Download Product S3']
urls = urls.str.replace('PDF', 'GeoTIFF')
urls = urls.str.replace('.pdf', '.tif')
# Remove scale folder; not used with geotiff
urls = urls.str.replace(f'{scale}/', '', n=1)
# Df of bounds
bounds_df = sample.geometry.bounds.values
for url, bounds in zip(urls, bounds_df):
test_cases.append([url, list(bounds), scale, grid_size])
I don't think there will ever be a non-hacky way to discover the image's true map bounds on the fly. For example here in northern Alaska, the right border is so wide that it takes up the space of 1 degree of longitude (which in northern Alaska is relatively small).
So I think the best way forward is to "hack" the asset string to be encoded JSON, which then has "url" and "mapBounds" keys internally, so no parsing will be needed.
Crosstab of grid size vs scale: