Jump to content

White squares at high resolution; ZL19 Ortho4XP


User42

Recommended Posts

295909060-0fc2875c-c96a-4db1-8799-db5f4c

 

As seen in the attached image.

Used GPT4 to hopefully correct the file O4_Imagery_Utils adding the following;

###############################################################################################################################
# Additional logic for identifying and redownloading white areas missing_areas = identify_white_boxes(big_image) for area in missing_areas: new_area = attempt_redownload(area) if new_area: merge_areas(big_image, new_area, area) # Rest of your existing saving logic # ...# Additional functions like identify_white_boxes, download_specific_area, is_valid, merge_areas# would need to be implemented.
###############################################################################################################################
def build_jpeg_ortho(tile, til_x_left,til_y_top,zoomlevel,provider_code,out_file_name=''):
texture_attributes=(til_x_left,til_y_top,zoomlevel,provider_code)
if provider_code in local_combined_providers_dict:
data_found=False
for rlayer in local_combined_providers_dict[provider_code]:
(y0,x0)=GEO.gtile_to_wgs84(til_x_left,til_y_top,zoomlevel)
(y1,x1)=GEO.gtile_to_wgs84(til_x_left+16,til_y_top+16,zoomlevel)
if len(local_combined_providers_dict[provider_code])==1 or has_data((x0,y0,x1,y1),rlayer['extent_code'],is_mask_layer= (tile.lat,tile.lon, tile.mask_zl) if rlayer['priority']=='mask' else False):
data_found=True
true_til_x_left=til_x_left
true_til_y_top=til_y_top
true_zl=zoomlevel
if 'max_zl' in providers_dict[rlayer['layer_code']]:
max_zl=int(providers_dict[rlayer['layer_code']]['max_zl'])
if max_zl<zoomlevel:
(latmed,lonmed)=GEO.gtile_to_wgs84(til_x_left+8,til_y_top+8,zoomlevel)
(true_til_x_left,true_til_y_top)=GEO.wgs84_to_orthogrid(latmed,lonmed,max_zl)
true_zl=max_zl
true_texture_attributes=(true_til_x_left,true_til_y_top,true_zl,rlayer['layer_code'])
true_file_name=FNAMES.jpeg_file_name_from_attributes(true_til_x_left, true_til_y_top, true_zl,rlayer['layer_code'])
true_file_dir=FNAMES.jpeg_file_dir_from_attributes(tile.lat, tile.lon,true_zl,providers_dict[rlayer['layer_code']])
if not os.path.isfile(os.path.join(true_file_dir,true_file_name)):
UI.vprint(1," Downloading missing orthophoto "+true_file_name+" (for combining in "+provider_code+")")
if not download_jpeg_ortho(true_file_dir,true_file_name,*true_texture_attributes):
return 0
else:
UI.vprint(1," The orthophoto "+true_file_name+" (for combining in "+provider_code+") is already present.")
if not data_found:
UI.lvprint(1," -> !!! Warning : No data found for building the combined texture",
FNAMES.dds_file_name_from_attributes(*texture_attributes)," !!!")
return 0
if out_file_name:
big_img=combine_textures(tile,til_x_left,til_y_top,zoomlevel,provider_code)
big_img.convert('RGB').save(out_file_name)
elif provider_code in providers_dict: # In case one would like to save combined orthos as jpegs (this can be useful to use different masks parameters for imagery masks layers and actual masks
file_name=FNAMES.jpeg_file_name_from_attributes(til_x_left, til_y_top, zoomlevel,provider_code)
file_dir=FNAMES.jpeg_file_dir_from_attributes(tile.lat, tile.lon,zoomlevel,providers_dict[provider_code])
big_img=combine_textures(tile,til_x_left,til_y_top,zoomlevel,provider_code)
if not os.path.exists(file_dir):
os.makedirs(file_dir)
try:
big_img.convert('RGB').save(os.path.join(file_dir,file_name))
except Exception as e:
UI.lvprint(0,"OS Error : could not save orthophoto on disk, received message :",e)
return 0
elif provider_code in providers_dict:
file_name=FNAMES.jpeg_file_name_from_attributes(til_x_left, til_y_top, zoomlevel,provider_code)
file_dir=FNAMES.jpeg_file_dir_from_attributes(tile.lat, tile.lon,zoomlevel,providers_dict[provider_code])
if not os.path.isfile(os.path.join(file_dir,file_name)):
UI.vprint(1," Downloading missing orthophoto "+file_name)
if not download_jpeg_ortho(file_dir,file_name,*texture_attributes):
return 0
else:
UI.vprint(1," The orthophoto "+file_name+" is already present.")
else:
(tlat,tlon)=GEO.gtile_to_wgs84(til_x_left+8,til_y_top+8,zoomlevel)
UI.vprint(1," Unknown provider",provider_code,"or it has no data around",tlat,tlon,".")
return 0
return 1

Seems to work thus far but I'm shooting in the dark essentially, I'm not a coder, just a hobbyist. Maybe someone could review and let me know if I'm heading in the right direction?

O4_Imagery_Utils.py

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...