[Qgis-user] python api code explanation

Xristos Xristoou saxri89 at gmail.com
Fri Sep 28 16:23:49 PDT 2018


hello

I am trying to align rasters in pyqgis or python and i find this post

https://gis.stackexchange.com/questions/297216/qgsalignraster-extent

where is that i need ,but because i am in the first steps can someone to
help me about how t define input parameters and how to fix extend problem ?



def alignRaster(raster, raster_to_align, output, proj, cell_size):
    alignClass = QgsAlignRaster()
    item1 = QgsAlignRaster.Item(raster, "")
    item2 = QgsAlignRaster.Item(raster_to_align, output)

    alignClass.setRasters([item1, item2])
    alignClass.setParametersFromRaster(raster, proj)
    alignClass.setCellSize(cell_size,cell_size)
    alignClass.checkInputParameters()
    alignClass.createAndWarp(item2)
    rLyr = QgsRasterLayer(raster)
    clipExtent = rLyr.extent()
    alignClass.setClipExtent(clipExtent)

raster='rel_dem.tif'
raster_to_align='DEM.tif'
output='OUT.tif'
cell_size=50
proj='26986'
alignRaster(raster, raster_to_align, output, proj, cell_size)


and i take this error :


ERROR 1: Failed to import coordinate system `'.
ERROR 1: Attempt to create 0x0 dataset is illegal,sizes must be larger
than zero.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20180929/06fd03d5/attachment.html>


More information about the Qgis-user mailing list