How to Generate Zoom Levels 6-12 from Existing Zoom Level 5 XYZ Tiles (.png) Without Losing Image Quality? #151998
Unanswered
nisha54321256
asked this question in
Programming Help
Replies: 1 comment 1 reply
-
Your approach correctly generates subtiles, but the blurriness is due to upscaling before cropping. Instead, crop first, then resize to maintain sharpness. Also, ensure Y tile numbering follows XYZ format by flipping it using y = (2 ** z - 1) - y. Let me know if you need refinements! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Select Topic Area
Question
Body
I already have zoom level 5 XYZ tiles in .png format, and I want to generate zoom levels 6 to 12 using these existing tiles. I don’t have any raster files—only the tiles. I'm using Python, QGIS, and OpenLayers 3 (OL3).
Problems I'm Facing:
Image quality becomes blurry when generating higher zoom levels.
Y tile numbering is incorrect (tiles are not arranged properly).
Below is my Python script that reads zoom 5 tiles, splits them into 4 subtiles, and saves them as higher zoom levels. However, I'm facing the above issues. If anyone has a solution, please help me improve it!
`import os
from PIL import Image
input_folder = "5" # Folder where zoom level 5 tiles are stored
output_base = "zoom1_12" # Base folder for output tiles (6-12)
def generate_tiles(input_folder, output_base, start_zoom=5, max_zoom=12):
for z in range(start_zoom, max_zoom): # Loop from zoom 5 to 11
input_zoom_path = os.path.join(output_base, str(z)) # Current zoom level folder
output_zoom_path = os.path.join(output_base, str(z + 1)) # Next zoom level folder
Run the function
generate_tiles(input_folder, output_base)
`
What I Need Help With:
How can I improve image quality to prevent blurriness?
How do I fix incorrect Y tile naming in the XYZ format?
If anyone has a better approach, please share your suggestions. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions