gdal icon indicating copy to clipboard operation
gdal copied to clipboard

Doc: Add docstrings for Python functions

Open dbaston opened this issue 9 months ago • 1 comments

Feature description

Many Python functions lack API documentation, e.g. the entire multidimensional API.

Ideally, we'd have documentation and at least one example for each function (this was requested by some respondents to the 2024 user survey.)

Some of our current docstrings are are essentially a single sentence, with a reference to the corresponding C or C++ docs:

Image

Others duplicate more content from the C/C++ documentation. This brings some future maintenance burden (we could need to make same changes in multiple places) although on the whole I don't think this content changes very often.

Image

Additional context

The edit/build/review cycle for these docstrings is unfortunately rather complicated. It is documented at https://gdal.org/en/latest/development/dev_documentation.html#python-api-documentation

dbaston avatar Mar 04 '25 17:03 dbaston

@dbaston, this is minor and I wanted to attempt an edit by PR rather than open an issue.

The edit/build/review cycle for these docstrings is unfortunately rather complicated.

In the examples under the CoordinateTransformation topic at https://gdal.org/en/latest/api/python/spatial_ref_api.html#coordinatetransformation, I believe the order of the input coordinates should be reversed for 4326, i.e., given as lat/lon instead (or add calls to SetAxisMappingStrategy()). It seems like the output coordinates are not right for 5646 in VT? And under TransformPoint() Examples:

ct = osr.CoordinateTransformation(wgs84, ps)

the ps should be changed to vt_sp.

I mention it because I was looking at those examples while troubleshooting some code and it had me confused for a bit. I started the edits for a PR but I struggled some with the edit/build/review cycle and did not complete. Will try to get there in the future.

ctoney avatar Mar 07 '25 23:03 ctoney