Skip to content

Commit 927f1bb

Browse files
committed
Added tiled creation option, delete world file
1 parent 58caa0a commit 927f1bb

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

arho_feature_template/core/create_geotiff.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def finished():
8989

9090
# Generate the World File (.pgw)
9191
pgw_content = QgsMapSettingsUtils.worldFileContent(settings)
92-
with open(image_path.replace(".png", ".pgw"), "w") as f:
92+
pgw_path = image_path.replace(".png", ".pgw")
93+
with open(pgw_path, "w") as f:
9394
f.write(pgw_content)
9495

9596
# Convert PNG to GeoTIFF
@@ -99,6 +100,10 @@ def finished():
99100
if os.path.exists(image_path):
100101
os.remove(image_path)
101102

103+
# Delete temporary World File (.pgw)
104+
if os.path.exists(pgw_path):
105+
os.remove(pgw_path)
106+
102107
render.finished.connect(finished)
103108
render.start()
104109

@@ -129,7 +134,7 @@ def _create_geotiff_from_png(self, image_path, geotiff_path, pixels_x, pixels_y,
129134
outputBounds=output_bounds,
130135
outputSRS="EPSG:3067",
131136
format="GTiff",
132-
creationOptions=["COMPRESS=LZW"],
137+
creationOptions=["COMPRESS=LZW", "TILED=YES"],
133138
)
134139

135140
iface.messageBar().pushMessage("", f"GeoTIFF tallennettu polkuun: {geotiff_path}")

arho_feature_template/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def initGui(self) -> None: # noqa N802
243243

244244
self.create_geotiff_action = self.add_action(
245245
text="Luo kaavakartta",
246-
icon=QgsApplication.getThemeIcon(""),
246+
icon=QgsApplication.getThemeIcon("mActionAddRasterLayer.svg"),
247247
triggered_callback=self.create_geotiff,
248248
add_to_menu=True,
249249
add_to_toolbar=True,

0 commit comments

Comments
 (0)