[gdal-dev] When is GDAL_DATA environment variable read by OGR?

Even Rouault even.rouault at mines-paris.org
Fri Feb 26 14:21:40 EST 2010


Le Friday 26 February 2010 19:46:40 Jason Roberts, vous avez écrit :
> I am curious to know when OGR will read the GDAL_DATA environment variable.
> After looking at the code and reviewing this
> <http://lists.osgeo.org/pipermail/gdal-dev/2009-May/020584.html>  email
> thread, it appears that the environment variable is currently only read at
> initialization time (OGRSFDriverRegistrar::OGRSFDriverRegistrar() is one
> such place), and that changes to the variable after initialization time
> will not be recognized. Is that correct?

Yes, actually it is also read in other initialization places, such as the 
registrar function of GDAL and in CPLFinderInit() and in port/cpl_csv.cpp as 
well

You can use CPLPushFinderLocation() to push a new search location, but you 
must do it before the first access to the file, as in the case of .CSV files, 
their location is cached once they are accessed the first time.

I'd recommand setting the GDAL_DATA value before using any call to GDAL/OGR 
API. If you want to set it from your code and not in the environmenent, you 
can set it with CPLSetConfigOption() for example.

> Do you anticipate that that 
> behavior will change in the future?

I don't think so.

>
>
>
> Thanks,
>
> Jason




More information about the gdal-dev mailing list