evetion / GeoArrays.jl

Simple geographical raster interaction built on top of ArchGDAL, GDAL and CoordinateTransformations
https://www.evetion.nl/GeoArrays.jl/dev/
MIT License
51 stars 13 forks source link

GeoArrays.write("output.png", ga) creates unnecessary "output.png.aux.xml" file #164

Open hawahee opened 1 week ago

hawahee commented 1 week ago

When exporting an image with an undefined coordinate reference system using GeoArrays.write("output.png", ga) an unnecessary output.png.aux.xml file is created that contains the following:

<PAMDataset>
  <GeoTransform> 0.0000000000000000e+000, 1.0000000000000000e+000, 0.0000000000000000e+000, 0.0000000000000000e+000, 0.0000000000000000e+000, 1.0000000000000000e+000</GeoTransform>
</PAMDataset>

Can the write method be changed to not write such unnecessary files when there is no defined CRS?
Using ArchGDAL instead of GeoArrays does not produce the .aux.xml file.

Steps to reproduce:

using GeoArrays

z = rand(UInt8, 10, 10)

ga = GeoArrays.GeoArray(z)

GeoArrays.write("output.png", ga)
evetion commented 1 week ago

Thanks for reporting! Interesting that ArchGDAL doesn't write the aux file.

I'd have to check if not setting some spatial information writes only the png. Then again, this whole library is for spatial information. I was thinking about always writing a crs (local engineering crs if none was provided), which wouldn't help here.

Can I ask what your use case is here? Do you just want to write png from an array, or is there an (unknown) spatial component?

evetion commented 6 days ago

Looking into a bit, it seems controlled by metadata options such as https://gdal.org/en/latest/user/configoptions.html#persistent-auxiliary-metadata-pam-options. I can't reproduce this on macos, but it seems on windows and linux it does write metadata.

Could you try to run GeoArrays.ArchGDAL.setconfigoption("GDAL_PAM_ENABLED","NO") and then see whether the .png is created or not?

hawahee commented 5 days ago

Can I ask what your use case is here? Do you just want to write png from an array, or is there an (unknown) spatial component?

Yes, I just want to write a png from an array. I sometimes have a RGB image with a spatial component and just want to remove the spatial component and save it. I could use a different library for that, but it was easier for me to also use the GeoArrays library for that.

Could you try to run GeoArrays.ArchGDAL.setconfigoption("GDAL_PAM_ENABLED","NO") and then see whether the .png is created or not?

That did stop the write from creating the .aux.xml file.