@@ -44,6 +44,7 @@ class warp(GdalAlgorithm):
4444 METHOD = 'METHOD'
4545 METHOD_OPTIONS = ['near' , 'bilinear' , 'cubic' , 'cubicspline' , 'lanczos' ]
4646 TR = 'TR'
47+ NO_DATA = 'NO_DATA'
4748 EXTRA = 'EXTRA'
4849 RTYPE = 'RTYPE'
4950
@@ -54,9 +55,12 @@ def defineCharacteristics(self):
5455 self .group = '[GDAL] Projections'
5556 self .addParameter (ParameterRaster (self .INPUT , self .tr ('Input layer' ), False ))
5657 self .addParameter (ParameterCrs (self .SOURCE_SRS ,
57- self .tr ('Source SRS' ), 'EPSG:4326 ' ))
58+ self .tr ('Source SRS' ), '' ))
5859 self .addParameter (ParameterCrs (self .DEST_SRS ,
59- self .tr ('Destination SRS' ), 'EPSG:4326' ))
60+ self .tr ('Destination SRS' ), '' ))
61+ self .addParameter (ParameterString (self .NO_DATA ,
62+ self .tr ("Nodata value, leave blank to take the nodata value from input" ),
63+ '-9999' ))
6064 self .addParameter (ParameterNumber (self .TR ,
6165 self .tr ('Output file resolution in target georeferenced units (leave 0 for no change)' ),
6266 0.0 , None , 0.0 ))
@@ -70,14 +74,21 @@ def defineCharacteristics(self):
7074 self .addOutput (OutputRaster (self .OUTPUT , self .tr ('Output layer' )))
7175
7276 def processAlgorithm (self , progress ):
77+ noData = str (self .getParameterValue (self .NO_DATA ))
78+ srccrs = self .getParameterValue (self .SOURCE_SRS )
79+ dstcrs = self .getParameterValue (self .DEST_SRS )
7380 arguments = []
7481 arguments .append ('-ot' )
7582 arguments .append (self .TYPE [self .getParameterValue (self .RTYPE )])
76- arguments .append ('-s_srs' )
77- arguments .append (str (self .getParameterValue (self .SOURCE_SRS )))
78- arguments .append ('-t_srs' )
79- crsId = self .getParameterValue (self .DEST_SRS )
80- arguments .append (str (crsId ))
83+ if len (srccrs ) > 0 :
84+ arguments .append ('-s_srs' )
85+ arguments .append (srccrs )
86+ if len (dstcrs ) > 0 :
87+ arguments .append ('-t_srs' )
88+ arguments .append (dstcrs )
89+ if len (noData ) > 0 :
90+ arguments .append ('-dstnodata' )
91+ arguments .append (noData )
8192 arguments .append ('-r' )
8293 arguments .append (
8394 self .METHOD_OPTIONS [self .getParameterValue (self .METHOD )])
0 commit comments