Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added wld file to png and tfw file to geotiff #1837

Merged
merged 3 commits into from
Mar 6, 2025

Conversation

lucadelu
Copy link
Contributor

@lucadelu lucadelu commented Mar 5, 2025

Let's discuss about this changes, I saw several requests on the forum about these files, since it is not time and space consuming I think they are good improvements for ODM outputs.

@pierotofy
Copy link
Member

TFW and WLD files are equivalent (just the extension is different), I'm leaning toward just generating TFW files?

@smathermather
Copy link
Contributor

Same tendency. Also, it's been a decade since I've encountered software that uses WLD and not TFW.

@lucadelu
Copy link
Contributor Author

lucadelu commented Mar 5, 2025

GDAL to understand something more from a PNG file would like to have .wld file
https://gdal.org/en/stable/drivers/raster/png.html

gdalinfo output with tfw file

gdalinfo odm_orthophoto.png
Driver: PNG/Portable Network Graphics
Files: odm_orthophoto.png
       odm_orthophoto.png.aux.xml
Size is 2229, 2123
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 2123.0)
Upper Right ( 2229.0,    0.0)
Lower Right ( 2229.0, 2123.0)
Center      ( 1114.5, 1061.5)
Band 1 Block=2229x1 Type=Byte, ColorInterp=Red
  Min=0.000 Max=247.000 
  Minimum=0.000, Maximum=247.000, Mean=107.130, StdDev=49.799
  Mask Flags: PER_DATASET ALPHA 
  Metadata:
    STATISTICS_APPROXIMATE=YES
    STATISTICS_MAXIMUM=247
    STATISTICS_MEAN=107.13003773252
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=49.798670180326
    STATISTICS_VALID_PERCENT=65.01
Band 2 Block=2229x1 Type=Byte, ColorInterp=Green
  Min=8.000 Max=250.000 
  Minimum=8.000, Maximum=250.000, Mean=119.696, StdDev=43.391
  Mask Flags: PER_DATASET ALPHA 
  Metadata:
    STATISTICS_APPROXIMATE=YES
    STATISTICS_MAXIMUM=250
    STATISTICS_MEAN=119.69593751376
    STATISTICS_MINIMUM=8
    STATISTICS_STDDEV=43.391056591561
    STATISTICS_VALID_PERCENT=65.01
Band 3 Block=2229x1 Type=Byte, ColorInterp=Blue
  Min=0.000 Max=255.000 
  Minimum=0.000, Maximum=255.000, Mean=91.407, StdDev=49.870
  Mask Flags: PER_DATASET ALPHA 
  Metadata:
    STATISTICS_APPROXIMATE=YES
    STATISTICS_MAXIMUM=255
    STATISTICS_MEAN=91.406659717226
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=49.870229084362
    STATISTICS_VALID_PERCENT=65.01
Band 4 Block=2229x1 Type=Byte, ColorInterp=Alpha

gdalinfo output with the wld file

Driver: PNG/Portable Network Graphics
Files: odm_orthophoto.png
       odm_orthophoto.png.aux.xml
       odm_orthophoto.wld
Size is 2229, 2123
Origin = (576646.834813122870401,5188231.064078653231263)
Pixel Size = (0.057737069400000,-0.057743744200000)
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (  576646.835, 5188231.064) 
Lower Left  (  576646.835, 5188108.474) 
Upper Right (  576775.531, 5188231.064) 
Lower Right (  576775.531, 5188108.474) 
Center      (  576711.183, 5188169.769) 
Band 1 Block=2229x1 Type=Byte, ColorInterp=Red
  Min=0.000 Max=247.000 
  Minimum=0.000, Maximum=247.000, Mean=107.130, StdDev=49.799
  Mask Flags: PER_DATASET ALPHA 
  Metadata:
    STATISTICS_APPROXIMATE=YES
    STATISTICS_MAXIMUM=247
    STATISTICS_MEAN=107.13003773252
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=49.798670180326
    STATISTICS_VALID_PERCENT=65.01
Band 2 Block=2229x1 Type=Byte, ColorInterp=Green
  Min=8.000 Max=250.000 
  Minimum=8.000, Maximum=250.000, Mean=119.696, StdDev=43.391
  Mask Flags: PER_DATASET ALPHA 
  Metadata:
    STATISTICS_APPROXIMATE=YES
    STATISTICS_MAXIMUM=250
    STATISTICS_MEAN=119.69593751376
    STATISTICS_MINIMUM=8
    STATISTICS_STDDEV=43.391056591561
    STATISTICS_VALID_PERCENT=65.01
Band 3 Block=2229x1 Type=Byte, ColorInterp=Blue
  Min=0.000 Max=255.000 
  Minimum=0.000, Maximum=255.000, Mean=91.407, StdDev=49.870
  Mask Flags: PER_DATASET ALPHA 
  Metadata:
    STATISTICS_APPROXIMATE=YES
    STATISTICS_MAXIMUM=255
    STATISTICS_MEAN=91.406659717226
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=49.870229084362
    STATISTICS_VALID_PERCENT=65.01
Band 4 Block=2229x1 Type=Byte, ColorInterp=Alpha

you can see differences in origin and pixel size.

TFW file is used by TIFF file
https://gdal.org/en/stable/drivers/raster/gtiff.html

@pierotofy
Copy link
Member

Just rename the .tfw file to .wld if you need to use gdalinfo?

@lucadelu
Copy link
Contributor Author

lucadelu commented Mar 5, 2025

Yes, it is possible; it is just a little bit less user friendly.

As I said in the first post, I understand it is duplication but it doesn't affect calculation time or output size.

You suggest to remove -co WORLDFILE=YES option?

@smathermather
Copy link
Contributor

smathermather commented Mar 5, 2025

To clarify, the are two conventions for naming the file: *.wld and naming it according to image file extension. If the product is a PNG, then the correct world file extension alternative to wld is *.pgw, similarly *.jpw for jpg, etc..

*.tfw for png does not follow the standard, and I agree that having the user rename is not a good experience.

So, either we need logic to handle the variants per output type, or we need to just write a file with a wld extension.

I have a preference for the variants according to extension as it gives the end user some hint that the files are related, but could argue for either in this case.

@pierotofy
Copy link
Member

pierotofy commented Mar 6, 2025

Thanks for everyone's feedback. We already have logic in this PR to generate the appropriate file extension depending on the file type (thanks @lucadelu).

My main concern was about redundancy; yes it's just one file, but it's one file that we will be expected to support for a long time. I just like to know the reasons for why we include stuff. User-friendliness is important, so that's a good reason enough for me, since we already support PNG outputs 👍

Side note: as a mature project we have to be a bit careful about feature-creep; it's easy to just have ODM "do more one thing", but we should always ask if an operation is better suited to be done elsewhere downstream (WebODM for example, or via scripts outside of ODM). A monolithic design is not the way to go long term.

Btw, just curious, what's the use case for using a georeferenced PNG rather than a GeoTIFF?

@pierotofy pierotofy merged commit ebe0ced into OpenDroneMap:master Mar 6, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants