[Qgis-user] Raster: replace a single value with another value

Carlos Cerdán sig.upagu at gmail.com
Tue Nov 18 06:36:04 PST 2014


Hi Andreas:

It is solved: you have to reproject your TEMP layer. I've tried with
UTM-32N zone and raster calculator works fine.

Why raster calculator (and SAGA) doesn't work with your original CRS? Well,
I don't know, perhaps devs group have the answer.

It was a good challenge.

Carlos

2014-11-18 4:37 GMT-05:00 Andreas Neumann <a.neumann at carto.net>:

> Hi Carlos,
>
> Thank you for your help!
>
> I tried with
>
> (TEMP at 1=249)*255 + (TEMP at 1<249)*TEMP at 1 + (TEMP at 1>249)*TEMP at 1
>
> My layer is called "temp". However, the resulting file contains all 0.
>
> I tried in both QGIS 2.4 and 2.6.
>
> Is there something wrong with the input file? It was generated from a PDF
> with ghostscript. Here is the metadata:
>
> -----
>
> GDAL provider
> GTiff
> GeoTIFF
> Datensatzbeschreibung
> //gis/gis/mapserverdata/uep/release_2014_11/temp.tif
> TIFFTAG_DATETIME=2014:11:17 09:50:08
> TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
> TIFFTAG_SOFTWARE=GPL Ghostscript 9.10
> TIFFTAG_XRESOLUTION=600
> TIFFTAG_YRESOLUTION=600
> Kanal 1
> STATISTICS_MAXIMUM=255
> STATISTICS_MEAN=247.18714741724
> STATISTICS_MINIMUM=0
> STATISTICS_STDDEV=37.198102288306
> Dimensionen
> X: 71575 Y: 70867 Kanäle: 1
> Leerwert
> *Leerwert nicht gesetzt*
> Datentyp
> Byte - Acht Bit vorzeichenlose Ganzzahl
> Pyramidenübersichten
> Räumliches Bezugssystem des Layers
> +proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1
> +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.4,15.1,405.3,0,0,0,0
> +units=m +no_defs
> Layerausdehnung (in urspünglicher Projektion des Layers)
> 0.0000000000000000,-70867.0000000000000000 : 71575.0000000000000000,0.
> 0000000000000000
> Kanal
> Kanal 1
> Kanal Nr
> 1
> Keine Statistik
> Noch keine Statistik gesammelt
>
> ------------
>
> Thanks again if you have any idea what may be wrong with my file or the
> above listed raster calc statement.
>
> Andreas
>
>
>
> Am 2014-11-17 18:38, schrieb Carlos Cerdán:
>
>> Hi Andreas:
>>
>> I think QGIS raster calculator can make this job. Conditional syntax
>> is a little bit... different.  The sentence that can do it is:
>>
>> (TIFF=249)*255 + (TIFF<249)*TIFF + (TIFF>249)*TIFF
>>
>> Where TIFF is your raster layer. The trick is: if the sentence in
>> parentheses is true, it gets value 1, else zero; so we have to
>> multiply by 255 to replace the 249 values. Next we have to add the
>> other values.
>>
>> Good luck,
>>
>> Carlos Cerdán
>>
>> PD. Please let me know if i'm wrong with this suggestion
>>
>> 2014-11-17 12:02 GMT-05:00 Andreas Neumann <a.neumann at carto.net>:
>>
>>  Hi,
>>>
>>> I have a very simple task (at least I thought it is simple), but am
>>> not able to do it properly.
>>>
>>> I have a grayscale tiff value where I would like to replace the
>>> value of 249 with 255 - all other values should stay as they are.
>>>
>>> I tried with gdal "nearblack", but nothing changed - I started a
>>> separate email-thread about that at the gdal list.
>>>
>>> Then I tried with the QGIS raster calculator - but it does not
>>> support conditional syntax.
>>>
>>> I tried with Processing and GRASS - but it would stop at 8% - the
>>> file is quite big.
>>>
>>> Finally I came across SAGA "Reclassify with grid value". The
>>> dialogue is very complicated and hard to understand. After a while
>>> it would stop with an error message telling me that Saga may not be
>>> properly configured - but it says that it is properly installed.
>>> Quite confusing ...
>>>
>>> I am trying on Win7 64bit.
>>>
>>> If the file wouldn't be so big I would try this task in The Gimp -
>>> where it is very simple to replace one pixel values with another -
>>> using "Select by color" and "fill with a specific color".
>>>
>>> Any idea how I could achieve my task with GDAL, QGIS, GRASS or
>>> Saga?
>>>
>>> Thanks,
>>> Andreas
>>>
>>> _______________________________________________
>>> Qgis-user mailing list
>>> Qgis-user at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/qgis-user [1]
>>>
>>
>>
>>
>> Links:
>> ------
>> [1] http://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20141118/cc14c1d1/attachment.html>


More information about the Qgis-user mailing list