[Qgis-user] python api code explanation

Luigi Pirelli luipir at gmail.com
Mon Oct 1 01:46:54 PDT 2018


prem ise: I never used this class (btw it should be necessary to create a
processing alg to use it to remove some gdal calc limitations)
I can't say if there is some error in SIP definition or whatelse... but I
suggest to check the use of the class directly in it's tests
https://github.com/qgis/QGIS/blob/master/tests/src/analysis/testqgsalignraster.cpp
and if there is a lack of test, please add it in cpp or python.

I hope this can help you

Luigi Pirelli

**************************************************************************************************
* LinkedIn: https://www.linkedin.com/in/luigipirelli
* Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
* GitHub: https://github.com/luipir
* Mastering QGIS 2nd Edition:
*
https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition
* Hire me: http://goo.gl/BYRQKg
**************************************************************************************************


On Sat, 29 Sep 2018 at 01:24, Xristos Xristoou <saxri89 at gmail.com> wrote:

> 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.
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20181001/fc8b7717/attachment.html>


More information about the Qgis-user mailing list