Raster layer spatial reference "on the fly" bug

11-18-2020 01:04 PM
New Contributor III

I'm creating .jpg.aux.xml and .jgw files "on the fly", before i create them i check if the raster already has extent and spatial reference by creating Raster object and raster layer and checking if it has spatial reference.

Raster raster = new Raster(JpgFilePath);
            RasterLayer rl = new RasterLayer(raster);
            await rl.LoadAsync();
            if (rl.SpatialReference != null)


if the file has no spatial reference i create the jpg.aux.xml and jgw files.

afterwards i check again if it has spatial reference, and its still null.

only after i restart the program and run it when the file already exists, it has the spatial reference and extent i have added.

i've stopped the program with break point before the second raster layer created and checked the folder, it has the aux.xml and jgw files but the raster layer wont see it until i restart the program.

seems like there is some kind of cache that needs to be cleared after i create the raster object.

any idea?





0 Kudos
1 Reply
New Contributor III

How are you creating aux.xml file on the fly?

0 Kudos