Re: Writing ESRI sidecar files

James David Smith

Thanks again Sean, and Evan too. It seems I just need to get the right
combination of options.

The options that you have shown Even are they implemented?
They don't seem to go in the Env like the other options?

My code at the moment as follows. It create the .tif and .ovr file .
If anyone can improve it, and help me get the aux.xml file too I'd be
very grateful. I need the ovr and aux.xml files to be created
independently as it's what the client needs.
import rasterio

with"meri50year.tif") as file:
data =
metadata = file.profile
metadata['nodata'] = 255
data[data == 1 ] = 4
data[data == 15 ] = 255

outfile = 'meri50_processed.tif'

with rasterio.Env(GDAL_PAM_ENABLED=True, ESRI_XML_PAM=True, TIFF_USE_OVR=True):
with, 'w', **metadata) as new_temp_file:
new_temp_file.write(data, 1)
overviews = [2,4,8,16]
new_temp_file.build_overviews(overviews, Resampling.nearest)

On Fri, 28 Jun 2019 at 16:09, Even Rouault <even.rouault@...> wrote:

On vendredi 28 juin 2019 08:26:35 CEST Sean Gillies wrote:
If you are creating a GeoTIFF it is possible that no XML file will be
written. As Even Rouault explains in, the PAM
file is only created if needed.
Indeed. You can play with the GTIFF specific PROFILE creation option

PROFILE=BASELINE: .aux.xml only created if presence of georeferencing and/or
user metadata
PROFILE=GEOTIFF: .aux.xml only created if there's user metadata
PROFILE=GDALGeoTIFF: .aux.xml only created if user metadata doesn't fit in
TIFF tag


Spatialys - Geospatial professional services

Join to automatically receive all group messages.