Skip to content

Conversation

@geographika
Copy link
Collaborator

@dbaston I tested and ran the generate_images.py script used to generate images and figures for the GDAL docs. I added a note on how to set this up in a conda environment, and tested on Windows. I ran into a few issues, fixed by this PR:

  • FAILED generate_images.py::test_gdal_raster_zonal_stats - _tkinter.TclError: invalid command name "tcl_findLibrary" - adding matplotlib.use('Agg') resolved this issue, by removing the default GUI backend - I don't think it is required for the image generation.
  • FAILED generate_images.py::test_gdal_raster_reclassify - AttributeError: 'NoneType' object has no attribute 'ReadAsMaskedArray' this was due to calling alg.Finalize() before getting the dataset. Do we have any docs about running algorithms in Python? What does alg.Finalize() do (I'm guessing it cleans up any in-memory datasets!).
  • There were references to test .SHP files, but the repo has GeoJSON files - I switched to these and got the same images without errors.
  • I think there was a problem with the raster reclassify code and image. Brackets were mismatched so the pixel with an original value of 5 is set to NoData when I think it should be 102. I have added the updated image, and fixed the brackets (there were a few places in the docs where this was the case). Maybe an error should be thrown in these cases as it was hard to spot?

There remains one issue with the check-geometry command - the line example has 2 geometry issues and so creates a MULTIPOINT output. This caused an error FAILED generate_images.py::test_gdal_vector_check_geometry - RuntimeError: Algorithm.Run() failed: Terminating translation prematurely after failed.

I tested in the command-line to get the underlying issue:

gdal vector check-geometry line.shp lineout.shp
ERROR 1: Attempt to write non-point (MULTIPOINT) geometry to point shapefile.
ERROR 1: Unable to write feature 0 from layer error_location.
ERROR 1: Terminating translation prematurely after failed
translation of layer error_location (use -skipfailures to skip errors)

I switched to gpkg which got the test running, but still gives the warning:

RuntimeWarning: A geometry of type MULTIPOINT is inserted into layer error_location of geometry type POINT, which is not normally allowed by the GeoPackage specification, 
 but the driver will however do it. To create a conformant GeoPackage, if using ogr2ogr, the -nlt option can be used to override the layer geometry type. 
 This warning will no longer be emitted for this combination of layer and feature geometry type

Maybe the output of the tool should always be set to MULTIPOINT (rather than POINT as set in #13523)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant