ubarsc / kealib

KEALib provides an implementation of the GDAL data model. The format supports raster attribute tables, image pyramids, meta-data and in-built statistics while also handling very large files and compression throughout.
http://kealib.org/
MIT License
12 stars 7 forks source link

add functionality to remove a layer #22

Closed gillins closed 2 years ago

gillins commented 2 years ago

And add implementation of Dataset.DeleteLayer() in the GDAL driver.

@petebunting am I on the right track here? I followed your pattern of addImageBand() where there is a virtual method that can be overridden for extra functionality and a static function that just does the base functionality.

As there is an extra virtual method the ABI is broken so I have to bumped the minor version.

petebunting commented 2 years ago

thanks @gillins.

Looks correct to me. I cannot think of anything else but it was a long time since I looked at this code base.

However, if I remember correctly hdf5 gets a bit more complicated when removing datasets and groups as the disk space isn't necessarily released (i.e., the file size is reduced). If someone were to add and remove datasets from a hdf5 file a number of times you might get a fragmented file which reduces performance.

Typically we haven't worried about this as we just create the file and the structure has stayed constant with just pixel and metadata values being updated. However, if someone were wanting to start doing more adding and removing to the structure (i.e., number of bands) they might want to do some reading as there are some options in HDF5 as to what the library will do under different circumstances.

I did a quick search and found this doc which looks like a useful reference: https://docs.hdfgroup.org/hdf5/rfc/FileSpaceManagement.pdf

gillins commented 2 years ago

Hi @petebunting, I'm not too worried about fragmentation - most formats seem to have this problem. They can always gdal_translate or h5repack (just saw this in the doc you linked to) to a new file if they want to make it smaller. I was more thinking that gdal allows this and since we claim to implement the gdal data model it was a missing feature. Could be handy if the user has made a mistake with the number of bands, or some bands are temporary and not needed in the final product....

The other thing that I keep getting asked about is deleting columns in the RAT (not currently supported by gdal). I think this would be even more useful but looking at the code and the way the columns are stored this doesn't seem easy. I'd have to re-write the data in the dataspace (eg for int columns) so the last column is the one to remove then resize the dataspace. This seems a bit too hard for kealib unless you know a better way?