[gdal-dev] Add to PythonGotchas: saving and closing raster datasets

Mike Toews mwtoews at gmail.com
Tue May 27 15:06:04 PDT 2014


Thanks Even and Sean for the input. I'll proceed to add this to the
wiki when I have an extended moment.

I think I'll rephrase this gotcha to also apply to OGR datasources,
where the API reads "you should always close any opened datasource
with OGR_DS_Destroy() that will ensure all data is correctly
flushed"[1]

I think it is worth to mention that raster datasets can use
FlushCache() and vector datasources can use SyncToDisk() to "save" the
data intermittently without closing, but is driver-specific and not
required before closing.

As for "save and close", I think I'll use `del ds` as the recommended
method, with mention that any copies of the references to the
dataset/source also need to be dereferenced.

-Mike

[1] http://www.gdal.org/ogr__api_8h.html#a9d845a6cf6652756925530418905471a


More information about the gdal-dev mailing list