1

I am currently trying to write a python script that can do the same thing as when you right-click on a raster image and click save as. So I am still figuring out how to change the CRS for the raster image in python, choose the map view extent option and not the layer extent option, and change the layer resolution

Save As Raster Img.

I've tried:

        new_cord = iface.mapCanvas().extent()

    crsSrc =  layer_find.crs() 
    crsDest =  QgsCoordinateReferenceSystem(102671, QgsCoordinateReferenceSystem.EpsgCrsId)  # WGS84 or UTM Zone

    renderer = layer_find.renderer()
    provider = layer_find.dataProvider()

    pipe = QgsRasterPipe()
    pipe.set(provider.clone())
    pipe.set(renderer.clone())

    file_writer = QgsRasterFileWriter(filename)
    file_writer.Mode(1)

    file_writer.writeRaster(pipe, provider.xSize(), provider.ySize(), new_cord, provider.crs())

But the file that is being written is around 7gb and just causing my QGIS to freeze.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.