Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gdaldem] Use GDALArgumentParser #9947

Merged
merged 3 commits into from
May 17, 2024
Merged

Conversation

elpaso
Copy link
Collaborator

@elpaso elpaso commented May 16, 2024

General

Usage: gdaldem [--help] [--long-usage] [--help-general] {TPI,TRI,aspect,color-relief,hillshade,roughness,slope}

Tools to analyze and visualize DEMs.

Optional arguments:
  -h, --help         Shows short help message and exits. 
  --long-usage       Shows long help message and exits. 
  --help-general     Report detailed help on general options. 

Subcommands:
  TPI               Compute the Topographic Position Index.
  TRI               Compute the Terrain Ruggedness Index.
  aspect            Compute aspect.
  color-relief      Color relief computed from the elevation and a text-based color configuration file.
  hillshade         Compute hillshade.
  roughness         Compute the roughness of the DEM.
  slope             Compute slope.

For more details, consult https://gdal.org/programs/gdaldem.html

Topographic Position Index

gdaldem tpi --long-usage
Usage: TPI [--help] [--long-usage] [--help-general]
           [-of <output_format>] [-compute_edges] [-b <value>] [-co <NAME>=<VALUE>]... [--quiet]
           input_dem output_TPI_map

Compute the Topographic Position Index.

Positional arguments:
  input_dem            The input DEM raster to be processed. 
  output_TPI_map       The output raster to be produced. 

Optional arguments:
  -h, --help           Shows short help message and exits. 
  --long-usage         Shows long help message and exits. 
  --help-general       Report detailed help on general options. 
  -of <output_format>  Output format. 
  -compute_edges       Do the computation at raster edges and near nodata values. 
  -b <value>           Select an input band. 
  -co <NAME>=<VALUE>   Creation option(s). [may be repeated]
  -q, --quiet          Quiet mode. No progress message is emitted on the standard output.

Terrain Ruggedness Index

gdaldem tri --long-usage
Export manually or use this script as a wrapper for commands!!!!
Usage: TRI [--help] [--long-usage] [--help-general]
           [-alg Wilson|Riley] [-of <output_format>] [-compute_edges] [-b <value>] [-co <NAME>=<VALUE>]... [--quiet]
           input_dem output_TRI_map

Compute the Terrain Ruggedness Index.

Positional arguments:
  input_dem            The input DEM raster to be processed. 
  output_TRI_map       The output raster to be produced. 

Optional arguments:
  -h, --help           Shows short help message and exits. 
  --long-usage         Shows long help message and exits. 
  --help-general       Report detailed help on general options. 
  -alg Wilson|Riley    Choose between Wilson or Riley algorithms. 
  -of <output_format>  Output format. 
  -compute_edges       Do the computation at raster edges and near nodata values. 
  -b <value>           Select an input band. 
  -co <NAME>=<VALUE>   Creation option(s). [may be repeated]
  -q, --quiet          Quiet mode. No progress message is emitted on the standard output. 

Hillshade

hillshade --long-usage
Usage: hillshade [--help] [--long-usage] [--help-general]
                 [-alg <Horn|ZevenbergenThorne>] [-z <factor>] [-s <scale>] [-az <azimuth>] [-alt <altitude>]
                 [[-combined]|[-multidirectional]|[-igor]]
                 [-of <output_format>] [-compute_edges] [-b <value>] [-co <NAME>=<VALUE>]... [--quiet]
                 input_dem output_hillshade

Compute hillshade.

Positional arguments:
  input_dem                      The input DEM raster to be processed. 
  output_hillshade               The output raster to be produced. 

Optional arguments:
  -h, --help                     Shows short help message and exits. 
  --long-usage                   Shows long help message and exits. 
  --help-general                 Report detailed help on general options. 
  -alg <Horn|ZevenbergenThorne>  Choose between ZevenbergenThorne or Horn algorithms. 
  -z <factor>                    Vertical exaggeration. 
  -s <scale>                     Ratio of vertical units to horizontal. 
  -az <azimuth>                  Azimuth of the light, in degrees. 
  -alt <altitude>                Altitude of the light, in degrees. 
  -combined                      Use combined shading. 
  -multidirectional              Use multidirectional shading. 
  -igor                          Use multidirectional shading. 
  -of <output_format>            Output format. 
  -compute_edges                 Do the computation at raster edges and near nodata values. 
  -b <value>                     Select an input band. 
  -co <NAME>=<VALUE>             Creation option(s). [may be repeated]
  -q, --quiet                    Quiet mode. No progress message is emitted on the standard output.

Aspect

gdaldem aspect  --long-usage
Usage: aspect [--help] [--long-usage] [--help-general]
              [-alg Horn|ZevenbergenThorne] [-trigonometric] [-zero_for_flat] [-of <output_format>] [-compute_edges]
              [-b <value>] [-co <NAME>=<VALUE>]... [--quiet]
              input_dem output_aspect_map

Compute aspect.

Positional arguments:
  input_dem                    The input DEM raster to be processed. 
  output_aspect_map            The output raster to be produced. 

Optional arguments:
  -h, --help                   Shows short help message and exits. 
  --long-usage                 Shows long help message and exits. 
  --help-general               Report detailed help on general options. 
  -alg Horn|ZevenbergenThorne  Choose between ZevenbergenThorne or Horn algorithms. 
  -trigonometric               Express aspect in trigonometric format. 
  -zero_for_flat               Return 0 for flat areas with slope=0, instead of -9999. 
  -of <output_format>          Output format. 
  -compute_edges               Do the computation at raster edges and near nodata values. 
  -b <value>                   Select an input band. 
  -co <NAME>=<VALUE>           Creation option(s). [may be repeated]
  -q, --quiet                  Quiet mode. No progress message is emitted on the standard output.

Color relief

gdaldem color-relief  --long-usage
Usage: color-relief [--help] [--long-usage] [--help-general]
                    [-alpha] [-exact_color_entry] [-nearest_color_entry] [-of <output_format>] [-compute_edges]
                    [-b <value>] [-co <NAME>=<VALUE>]... [--quiet]
                    input_dem color_text_file output_color_relief_map

Color relief computed from the elevation and a text-based color configuration file.

Positional arguments:
  input_dem                The input DEM raster to be processed. 
  color_text_file          Text-based color configuration file. 
  output_color_relief_map  The output raster to be produced. 

Optional arguments:
  -h, --help               Shows short help message and exits. 
  --long-usage             Shows long help message and exits. 
  --help-general           Report detailed help on general options. 
  -alpha                   Add an alpha channel to the output raster. 
  -exact_color_entry       Use strict matching when searching in the configuration file. 
  -nearest_color_entry     Use the RGBA corresponding to the closest entry in the configuration file. 
  -of <output_format>      Output format. 
  -compute_edges           Do the computation at raster edges and near nodata values. 
  -b <value>               Select an input band. 
  -co <NAME>=<VALUE>       Creation option(s). [may be repeated]
  -q, --quiet              Quiet mode. No progress message is emitted on the standard output. 

Roughness

gdaldem roughness --long-usage
Usage: roughness [--help] [--long-usage] [--help-general]
                 [-of <output_format>] [-compute_edges] [-b <value>] [-co <NAME>=<VALUE>]... [--quiet]
                 input_dem output_roughness_map

Compute the roughness of the DEM.

Positional arguments:
  input_dem             The input DEM raster to be processed. 
  output_roughness_map  The output raster to be produced. 

Optional arguments:
  -h, --help            Shows short help message and exits. 
  --long-usage          Shows long help message and exits. 
  --help-general        Report detailed help on general options. 
  -of <output_format>   Output format. 
  -compute_edges        Do the computation at raster edges and near nodata values. 
  -b <value>            Select an input band. 
  -co <NAME>=<VALUE>    Creation option(s). [may be repeated]
  -q, --quiet           Quiet mode. No progress message is emitted on the standard output.

Slope

gdaldem slope --long-usage
Usage: slope [--help] [--long-usage] [--help-general]
             [-alg Horn|ZevenbergenThorne] [-p] [-s <scale>] [-of <output_format>] [-compute_edges] [-b <value>]
             [-co <NAME>=<VALUE>]... [--quiet]
             input_dem output_slope_map

Compute slope.

Positional arguments:
  input_dem                    The input DEM raster to be processed. 
  output_slope_map             The output raster to be produced. 

Optional arguments:
  -h, --help                   Shows short help message and exits. 
  --long-usage                 Shows long help message and exits. 
  --help-general               Report detailed help on general options. 
  -alg Horn|ZevenbergenThorne  Choose between ZevenbergenThorne or Horn algorithms. 
  -p                           Express slope as a percentage. 
  -s <scale>                   Ratio of vertical units to horizontal. 
  -of <output_format>          Output format. 
  -compute_edges               Do the computation at raster edges and near nodata values. 
  -b <value>                   Select an input band. 
  -co <NAME>=<VALUE>           Creation option(s). [may be repeated]
  -q, --quiet                  Quiet mode. No progress message is emitted on the standard output.

apps/gdaldem_lib.cpp Outdated Show resolved Hide resolved
apps/gdaldem_lib.cpp Outdated Show resolved Hide resolved
apps/gdaldem_lib.cpp Outdated Show resolved Hide resolved
apps/gdaldem_lib.cpp Outdated Show resolved Hide resolved
@rouault
Copy link
Member

rouault commented May 16, 2024

can you paste the output of "gdaldem --help" and "gdaldem --long-usage" ?

apps/gdal_utils_priv.h Outdated Show resolved Hide resolved
apps/gdaldem_lib.cpp Outdated Show resolved Hide resolved
@rouault
Copy link
Member

rouault commented May 16, 2024

When done, would you mind reworking commit history, to have commit "ArgParser: is_used_globally()" first, and squash together all other gdaldem specific commits?

Also add is_used_globally(const std::string &name) to
seach for used args in subparsers
@elpaso
Copy link
Collaborator Author

elpaso commented May 16, 2024

When done, would you mind reworking commit history, to have commit "ArgParser: is_used_globally()" first, and squash together all other gdaldem specific commits?

I've grouped all argparser commits in a separate one.

@rouault
Copy link
Member

rouault commented May 16, 2024

MSVC not happy:

 C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.39.33519\include\algorithm(3433,24): error C2220: the following warning is treated as an error [D:\a\gdal\gdal\build\apps\utils_common.vcxproj]
  (compiling source file '../../apps/gdalargumentparser.cpp')
  
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.39.33519\include\algorithm(3433,24): warning C4244: '=': conversion from 'int' to 'char', possible loss of data [D:\a\gdal\gdal\build\apps\utils_common.vcxproj]
  (compiling source file '../../apps/gdalargumentparser.cpp')
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.39.33519\include\algorithm(3433,24):
  the template instantiation context (the oldest one first) is
  	D:\a\gdal\gdal\apps\gdalargumentparser.cpp(420,14):
  	see reference to function template instantiation '_OutIt std::transform<std::_String_iterator<std::_String_val<std::_Simple_types<_Elem>>>,std::_String_iterator<std::_String_val<std::_Simple_types<_Elem>>>,int(__cdecl *)(int)>(const _InIt,const _InIt,_OutIt,_Fn)' being compiled
          with
          [
              _OutIt=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,
              _Elem=char,
              _InIt=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,
              _Fn=int (__cdecl *)(int)
          ]

@rouault rouault merged commit 24e799a into OSGeo:master May 17, 2024
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants