r_colors_stddev.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. """
  2. ***************************************************************************
  3. r_colors_stddev.py
  4. ------------------
  5. Date : February 2016
  6. Copyright : (C) 2016 by Médéric Ribreux
  7. Email : medspx at medspx dot fr
  8. ***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************
  16. """
  17. __author__ = 'Médéric Ribreux'
  18. __date__ = 'February 2016'
  19. __copyright__ = '(C) 2016, Médéric Ribreux'
  20. from grassprovider.Grass7Utils import Grass7Utils
  21. def processInputs(alg, parameters, context, feedback):
  22. # We need to import all the bands and to preserve color table
  23. if 'map' in alg.exportedLayers:
  24. return
  25. # We need to import all the bands and color tables of the input raster
  26. alg.loadRasterLayerFromParameter('map', parameters, context, False, None)
  27. alg.postInputs(context)
  28. def processCommand(alg, parameters, context, feedback):
  29. # We need to remove output
  30. alg.processCommand(parameters, context, feedback, True)
  31. def processOutputs(alg, parameters, context, feedback):
  32. createOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_OPT, context)
  33. metaOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_META, context)
  34. # We need to export the raster with all its bands and its color table
  35. fileName = alg.parameterAsOutputLayer(parameters, 'output', context)
  36. outFormat = Grass7Utils.getRasterFormatFromFilename(fileName)
  37. grassName = alg.exportedLayers['map']
  38. alg.exportRasterLayer(grassName, fileName, True,
  39. outFormat, createOpt, metaOpt)