[GRASS-user] gdal_translate too many command options

Dear community

The main aim is to produce a mask of a raster file with data > 0

Code:

r.mask raster=ch_apple_presence_total_pollinator_abundance_spring maskcats=“0.01 thru 1”

ERROR: The raster map <ch_apple_presence_total_pollinator_abundance_spring> must be integer (CELL type) in order to use the ‘maskcats’ parameter

Because of the error I followed the help here:

https://gis.stackexchange.com/questions/197145/error-in-r-thin-qgis-grass-input-raster-must-be-of-type-cell

However, wen running the code suggested with gdal_translate, I got an error

gdal_translate -co "ch_apple_presence_total_pollinator_abundance_spring " ch_apple_presence_total_pollinator_abundance_spring.tif bit_ ch_apple_presence_total_pollinator_abundance_spring.tif

r.null map=ch_apple_presence_total_pollinator_abundance_spring setnull=1

gdal_translate -co ch_apple_presence_total_pollinator_abundance_spring ch_apple_presence_total_pollinator_abundance_spring.tif bit_ ch_apple_presence_total_pollinator_abundance_spring.tif

ERROR 6: Too many command options

‘ch_apple_presence_total_pollinator_abundance_spring.tif’

Usage: gdal_translate [–help] [–help-general] [–long-

usage]

[-ot {Byte/Int8/Int16/UInt16/UInt32/Int32/UInt64/Int6

4/Float32/Float64/

CInt16/CInt32/CFloat32/CFloat64}] [-strict]

[-if ]… [-of ]

[-b ] [-mask ] [-expand {gray|rgb|rgba}]

[-outsize [%]|0 [%]|0] [-tr

]

[-ovr |AUTO|AUTO-|NONE]

[-r

{nearest,bilinear,cubic,cubicspline,lanczos,average,mode}]

[-unscale] [-scale[_bn] [<src_min> <src_max>

[<dst_min> <dst_max>]]]… [-exponent[_bn] <exp_val>]…

[-srcwin ] [-epo] [-eco]

[-projwin ] [-projwin_srs

<srs_def>]

[-a_srs <srs_def>] [-a_coord_epoch ]

[-a_ullr ] [-a_nodata ]

[-a_gt ]

[-a_scale ] [-a_offset ]

[-nogcp] [-gcp

[]]…

|-colorinterp{_bn}

{red|green|blue|alpha|gray|undefined}]

|-colorinterp

{red|green|blue|alpha|gray|undefined},…]

[-mo =]… [-q] [-sds]

[-co =]… [-stats] [-norat] [-noxmp]

[-oo =]…

<src_dataset> <dst_dataset>

Thanks a lot

Sibylle

···

On 30/05/2024 15:58, sibylle via grass-user wrote:

Dear community

The main aim is to produce a mask of a raster file with data > 0

Maybe using r.mapcalc to create the raster mask would be more appropriate:

r.mapcalc “MASK = if(ch_apple_presence_total_pollinator_abundance_spring > 0, 1, null())”

After that command completes, all further raster modules will work only on non-null cells in the MASK raster. You should see the message “[Raster MASK present]”

To remove it, you would do: r.mask -r

HTH, Micha

Code:

r.mask raster=ch_apple_presence_total_pollinator_abundance_spring maskcats=“0.01 thru 1”

ERROR: The raster map <ch_apple_presence_total_pollinator_abundance_spring> must be integer (CELL type) in order to use the ‘maskcats’ parameter

Because of the error I followed the help here:

https://gis.stackexchange.com/questions/197145/error-in-r-thin-qgis-grass-input-raster-must-be-of-type-cell

However, wen running the code suggested with gdal_translate, I got an error

gdal_translate -co "ch_apple_presence_total_pollinator_abundance_spring " ch_apple_presence_total_pollinator_abundance_spring.tif bit_ ch_apple_presence_total_pollinator_abundance_spring.tif

r.null map=ch_apple_presence_total_pollinator_abundance_spring setnull=1

gdal_translate -co ch_apple_presence_total_pollinator_abundance_spring ch_apple_presence_total_pollinator_abundance_spring.tif bit_ ch_apple_presence_total_pollinator_abundance_spring.tif

ERROR 6: Too many command options

‘ch_apple_presence_total_pollinator_abundance_spring.tif’

Usage: gdal_translate [–help] [–help-general] [–long-

usage]

[-ot {Byte/Int8/Int16/UInt16/UInt32/Int32/UInt64/Int6

4/Float32/Float64/

CInt16/CInt32/CFloat32/CFloat64}] [-strict]

[-if ]… [-of ]

[-b ] [-mask ] [-expand {gray|rgb|rgba}]

[-outsize [%]|0 [%]|0] [-tr

]

[-ovr |AUTO|AUTO-|NONE]

[-r

{nearest,bilinear,cubic,cubicspline,lanczos,average,mode}]

[-unscale] [-scale[_bn] [<src_min> <src_max>

[<dst_min> <dst_max>]]]… [-exponent[_bn] <exp_val>]…

[-srcwin ] [-epo] [-eco]

[-projwin ] [-projwin_srs

<srs_def>]

[-a_srs <srs_def>] [-a_coord_epoch ]

[-a_ullr ] [-a_nodata ]

[-a_gt ]

[-a_scale ] [-a_offset ]

[-nogcp] [-gcp

[]]…

|-colorinterp{_bn}

{red|green|blue|alpha|gray|undefined}]

|-colorinterp

{red|green|blue|alpha|gray|undefined},…]

[-mo =]… [-q] [-sds]

[-co =]… [-stats] [-norat] [-noxmp]

[-oo =]…

<src_dataset> <dst_dataset>

Thanks a lot

Sibylle

_______________________________________________
grass-user mailing list
[grass-user@lists.osgeo.org](mailto:grass-user@lists.osgeo.org)
[https://lists.osgeo.org/mailman/listinfo/grass-user](https://lists.osgeo.org/mailman/listinfo/grass-user)

-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918