I rarely use the OSGEO4W shell, although I have it because I used it to download some utilities. If you have QGIS you have most of the GDAL tools in the QGIS install directory already. If you prefer you can download 32 and 64 bit GDAL/OGR from http://www.gisinternals.com/sdk/ I did because I wanted the lib and include files but find that version works well with the utilities as well.
In order to use GDAL/OGR on the command line without invoking the shell you must set some environment variables so that required files can be found; I use windows so the environments are windows flavored but I assume that Mac and Linux are similar.
// GDAL folders from http://www.gisinternals.com/sdk/
GDAL_DATA C:\Program Files\GDAL\gdal-data // csv's and stuff
GDAL_DRIVER_PATH C:\Program Files\GDAL\gdalplugins // gdal_ECW_JP2ECW.dll, gdal_HDF6.dll...
GEOTIFF_CSV C:\Program Files\GDAL\gdal-data // csv's and stuff
PROJ_LIB C:\Program Files\GDAL\projlib // nad.lst...
PATH %PATH%;C:\Program Files\GDAL // GDAL_TRANSLATE.exe ...
// QGIS folders
GDAL_DATA C:\Program Files\QGIS Dufour\share\gdal // csv's and stuff
GDAL_DRIVER_PATH C:\Program Files\QGIS Dufour\bin\gdalplugins // gdal_ECW_JP2ECW.dll, gdal_HDF6.dll...
GEOTIFF_CSV C:\Program Files\QGIS Dufour\share\epsg_csv // csv's and stuff
PROJ_LIB C:\Program Files\QGIS Dufour\share\proj // nad.lst...
PATH %PATH%;C:\Program Files\QGIS Dufour\bin // GDAL_TRANSLATE.exe ...
After you have set these environment variables GDAL should work just fine in a normal command (cmd) window.
Interrogate your PATH environment before setting, you might find the path already contains the right folder. Be aware that when windows searches for programs it looks in the current folder and then the paths (separaed by semi-colons ';') from first to last, earlier instances in the path will be executed as soon as there's a match! The order of extensions, unless implicitly supplied (like do_this.py is calling specifically for a python file), is governed by the pathext environment (usually .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS; .JSE; .WSF; .WSH; .MSC
)
For example: when you call gdal_translate the system looks in the current folder for a file called gdal_translate (not case sensitive) and then looks in the first path, the next and all the paths and then if it's not found returns 'is not recognized as an internal or external command operable program or batch file.' so it is not really needed to modify the path if you are in the folder that the program is.
I just found the SAGA tools and the better raster calculator provided. I solved the problem using the following formula:
ifelse(eq(a,190), 1, 0)
which actively sets all cells with a value other than 190 to zero.
Edit: I just found the reason why QGIS dealt differently, too: I was wrong stating that both rasters had the same format. In the first case my input raster was in ASCII format and QGIS set zeros. Doing the same operation with a tif format, it sets no data values.
Best Answer
In QGIS you have the raster calculator (Under the "Raster" menu) which will do what you want. (not a shell script command)
Note that you will have a raster with values of either 190 or 0 everywhere else. You can further use gdal_translate to set the zeros to NULL.
HTH, Micha