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

[gdalinfo] Take .prj into account #9360

Open
pathmapper opened this issue Mar 1, 2024 · 2 comments
Open

[gdalinfo] Take .prj into account #9360

pathmapper opened this issue Mar 1, 2024 · 2 comments

Comments

@pathmapper
Copy link
Contributor

pathmapper commented Mar 1, 2024

Not critical and not sure if it's appropriate, but there is a kind of inconsistency:

With the QGIS GDAL tool "Extract projection"

grafik

it's possible to create a .prj file for a raster.

However, when opening such raster with the accompanying files .tfw and .prj, the CRS is not detected.

Expected behavior and actual behavior.

gdalinfo shows CRS information if there's an accompanying .prj , but it doesn't take .prj into account.

Steps to reproduce the problem.

Test data: 470501GF1937.zip

gdalinfo 470501GF1937.tif

Output:

Driver: GTiff/GeoTIFF
Files: 470501GF1937.tif
       470501GF1937.tfw
Size is 6295, 6280
Origin = (2534000.055432938970625,5686000.030564396642148)
Pixel Size = (0.317679361272610,-0.318498310635390)
Metadata:
  TIFFTAG_DATETIME=2020/04/01 09:16:46
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_SOFTWARE=WGEO 5.1 WGEO_PROF
  TIFFTAG_XRESOLUTION=400
  TIFFTAG_YRESOLUTION=400
Image Structure Metadata:
  COMPRESSION=CCITTFAX4
  INTERLEAVE=BAND
  MINISWHITE=YES
Corner Coordinates:
Upper Left  ( 2534000.055, 5686000.031)
Lower Left  ( 2534000.055, 5683999.861)
Upper Right ( 2535999.847, 5686000.031)
Lower Right ( 2535999.847, 5683999.861)
Center      ( 2534999.951, 5684999.946)
Band 1 Block=6295x1 Type=Byte, ColorInterp=Palette
  Image Structure Metadata:
    NBITS=1
  Color Table (RGB with 2 entries)
    0: 255,255,255,255
    1: 0,0,0,255

Operating system

Windows 10 Enterprise

GDAL version and provenance

GDAL 3.8.3, released 2024/01/04

@jratike80
Copy link
Collaborator

Maybe QGIS should rather have an option to write an .aux.xml file as an alternative for .prj

image

The .prj system is sometimes used by ESRI and it comes originally from arc/info https://gdal.org/drivers/raster/aaigrid.html. As far as I know GDAL supports .prj only with the AAIGrid and BT drivers https://gdal.org/drivers/raster/bt.html but the aux.xml (PAM) file is supported by all drivers. And I believe that ESRI supports .aux.xml too.

@pathmapper
Copy link
Contributor Author

Looking at the source of this tools, this seems indeed to be an ESRI related thing.

gdal/ogr/ogr_srs_esri.cpp

Lines 268 to 271 in a032c1a

* At this time there is no equivalent exportToESRI() method. Writing old
* style .prj files is not supported by OGRSpatialReference. However the
* morphToESRI() and exportToWkt() methods can be used to generate output
* suitable to write to new style (Arc 8) .prj files.

It's kind of weird that it's named "Extract Projection" but by default it only creates a worldfile.

I think using a file format which is capable of storing the georeferencing and projection information like GeoTIFF is here the way to go.

Please feel free to close here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants