1

Following installation of QGIS v 3.10.1 on a W10 machine, I am automatically hooked up with OSGeo4W Shell. From there, I can directly invoke gdal utilities such as gdalinfo and gdal_translate. However, other utilities fail me, such as gdal_edit and pct2rgb, even though they are listed alongside each other at the gdal raster programs website.

It appears that gdal_edit and the likes are implemented in Python, quoting from OSGeo4W site:

To get the commandline utilities implemented in Python (like gdal_merge, and rgb2pct), install gdal-python.

Reading up on gdal-python says:

The standard scripts, like rgb2pct.py, are placed in osgeo4w\bin and include .bat wrapper scripts

This is as far as I get. I can't find the mentioned location, nor any .bat wrapper scripts. The nearest I can get is: c:\Program Files\QGIS 3.10\apps\Python37\Scripts\gdal_edit.py but I am lost how to employ this script to my needs.

How can I use gdal_edit?

4
  • There should be nothing special to do. Do you get a list of commands from the OSGeo4W shell with command o-help? – user30184 Sep 23 '20 at 13:39
  • Yes, I get a list of about 142 commands. However, gdal_edit is not among them – Hans Roelofsen Sep 23 '20 at 15:32
  • Ok, I think I got it now. I've used an Anaconda Python environment created earlier, which as among others, geopandas installed. Then I can run: >python "C:\Program Files\QGIS 3.10\apps\Python37\Scripts\gdal_edit.py" -unsetnodata c:\apps\images\dummy_image.tif – Hans Roelofsen Sep 23 '20 at 16:02
  • 1
    It is not quite as it is supposed to be used but if it works just go ahead. Still have a look at some environment variables that OSGeo4W sets like PYTHONHOME and path. Also notice that for example command gdal_edit is supposed to run script gdal_edit.bat in the \bin directory. The gdal_edit.bat looks like this @echo off call "%OSGEO4W_ROOT%\bin\o4w_env.bat" python "%OSGEO4W_ROOT%\bin\gdal_edit.py" %* – user30184 Sep 23 '20 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.