pro xy2loc_colrow, subset_ul_x, subset_ul_y, $ subset_lr_x, subset_lr_y, $ tile_ul_x, tile_ul_y, $ tile_lr_x, tile_lr_y, $ cols_per_tile=cols_per_tile, $ rows_per_tile=rows_per_tile, $ subset_ul_loc_col, subset_ul_loc_row, $ subset_lr_loc_col, subset_lr_loc_row, $ subset_this_tile if n_elements(cols_per_tile) eq 0 then $ cols_per_tile = 951 if n_elements(rows_per_tile) eq 0 then $ rows_per_tile = 951 meters_per_pixel_x = (tile_lr_x - tile_ul_x) / cols_per_tile meters_per_pixel_y = (tile_ul_y - tile_lr_y) / rows_per_tile subset_ul_loc_col = max([round((subset_ul_x - tile_ul_x) / $ meters_per_pixel_x), 0]) subset_ul_loc_row = max([round((tile_ul_y - subset_ul_y) / $ meters_per_pixel_y), 0]) subset_lr_loc_col = min([round((subset_lr_x - tile_ul_x) / $ meters_per_pixel_x) - 1, cols_per_tile - 1]) subset_lr_loc_row = min([round((tile_ul_y - subset_lr_y) / $ meters_per_pixel_y) - 1, rows_per_tile - 1]) if (subset_ul_loc_col lt cols_per_tile) and $ (subset_ul_loc_row lt rows_per_tile) and $ (subset_lr_loc_col ge 0) and $ (subset_lr_loc_row ge 0) then $ subset_this_tile = 1 $ else $ subset_this_tile = 0 print, 'xy2loc_colrow:' print, ' subset_ul_x: ', format='(a, f20.6)', subset_ul_x print, ' subset_ul_y: ', format='(a, f20.6)', subset_ul_y print, ' subset_lr_x: ', format='(a, f20.6)', subset_lr_x print, ' subset_lr_y: ', format='(a, f20.6)', subset_lr_y print, ' tile_ul_x: ', format='(a, f20.6)', tile_ul_x print, ' tile_ul_y: ', format='(a, f20.6)', tile_ul_y print, ' tile_lr_x: ', format='(a, f20.6)', tile_lr_x print, ' tile_lr_y: ', format='(a, f20.6)', tile_lr_y print print, ' cols_per_tile: ', cols_per_tile print, ' rows_per_tile: ', cols_per_tile print print, ' meters_per_pixel_x:', format='(a, f20.6)', meters_per_pixel_x print, ' meters_per_pixel_y:', format='(a, f20.6)', meters_per_pixel_y print print, ' subset_ul_loc_col: ', subset_ul_loc_col print, ' subset_ul_loc_row: ', subset_ul_loc_row print, ' subset_lr_loc_col: ', subset_lr_loc_col print, ' subset_lr_loc_row: ', subset_lr_loc_row print, ' subset_this_tile: ', subset_this_tile end