Skip to content

gdal raster info: emit short form for CRS if possible#14286

Closed
rouault wants to merge 1 commit intoOSGeo:masterfrom
rouault:gdal_raster_info_abbreviated_crs
Closed

gdal raster info: emit short form for CRS if possible#14286
rouault wants to merge 1 commit intoOSGeo:masterfrom
rouault:gdal_raster_info_abbreviated_crs

Conversation

@rouault
Copy link
Copy Markdown
Member

@rouault rouault commented Apr 2, 2026

and add a --crs-format=AUTO|WKT2|PROJJSON, only for --format=text

Triggered by remark in #14285 . @geographika @dbaston @jratike80 Good / bad idea ?

Demo:

$ gdal raster info byte.tif
Driver: GTiff/GeoTIFF
Files: byte.tif
Size is 20, 20
Coordinate Reference System name: NAD27 / UTM zone 11N
Coordinate Reference System ID: EPSG:26711
Coordinate Reference System type: Projected
Coordinate Reference System projection type: UTM zone 11N, Transverse Mercator
Coordinate Reference System units: metre
Coordinate Reference System area of use: North America..., west -120.00, south 26.93, east -114.00, north 78.13
Data axis to CRS axis mapping: 1,2
Origin = (440720.000000000000000,3751320.000000000000000)
Pixel Size = (60.000000000000000,-60.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  440720.000, 3751320.000) (117d38'28.21"W, 33d54' 8.47"N)
Lower Left  (  440720.000, 3750120.000) (117d38'27.92"W, 33d53'29.51"N)
Upper Right (  441920.000, 3751320.000) (117d37'41.48"W, 33d54' 8.71"N)
Lower Right (  441920.000, 3750120.000) (117d37'41.20"W, 33d53'29.75"N)
Center      (  441320.000, 3750720.000) (117d38' 4.70"W, 33d53'49.11"N)
Band 1 Block=20x20 Type=Byte, ColorInterp=Gray
$ gdal raster info byte.tif --crs-format=WKT2
Driver: GTiff/GeoTIFF
Files: byte.tif
Size is 20, 20
Coordinate Reference System WKT:
PROJCRS["NAD27 / UTM zone 11N",
    BASEGEOGCRS["NAD27",
        DATUM["North American Datum 1927",
            ELLIPSOID["Clarke 1866",6378206.4,294.978698213898,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4267]],
    CONVERSION["UTM zone 11N",
        METHOD["Transverse Mercator",
            ID["EPSG",9807]],
        PARAMETER["Latitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",-117,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["Scale factor at natural origin",0.9996,
            SCALEUNIT["unity",1],
            ID["EPSG",8805]],
        PARAMETER["False easting",500000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",0,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["(E)",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["(N)",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    USAGE[
        SCOPE["Engineering survey, topographic mapping."],
        AREA["North America - between 120°W and 114°W - onshore. Canada - Alberta; British Columbia; Northwest Territories; Nunavut. Mexico. United States (USA) - California; Idaho; Nevada; Oregon; Washington."],
        BBOX[26.93,-120,78.13,-114]],
    ID["EPSG",26711]]
Data axis to CRS axis mapping: 1,2
Origin = (440720.000000000000000,3751320.000000000000000)
Pixel Size = (60.000000000000000,-60.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  440720.000, 3751320.000) (117d38'28.21"W, 33d54' 8.47"N)
Lower Left  (  440720.000, 3750120.000) (117d38'27.92"W, 33d53'29.51"N)
Upper Right (  441920.000, 3751320.000) (117d37'41.48"W, 33d54' 8.71"N)
Lower Right (  441920.000, 3750120.000) (117d37'41.20"W, 33d53'29.75"N)
Center      (  441320.000, 3750720.000) (117d38' 4.70"W, 33d53'49.11"N)
Band 1 Block=20x20 Type=Byte, ColorInterp=Gray
  • [ ] AI (Copilot or something similar) supported my development of this PR. See our policy about AI tool use. Use of AI tools must be indicated.

@rouault rouault added the funded through GSP Work funded through the GDAL Sponsorship Program label Apr 2, 2026
@rouault rouault force-pushed the gdal_raster_info_abbreviated_crs branch 2 times, most recently from d9864c7 to 6d9415a Compare April 2, 2026 22:53
Comment thread doc/source/programs/gdal_raster_info.rst Outdated
@rouault rouault force-pushed the gdal_raster_info_abbreviated_crs branch from 6d9415a to cb4984c Compare April 4, 2026 14:03
@rouault
Copy link
Copy Markdown
Member Author

rouault commented Apr 4, 2026

Edited to include more details for the CRS part:

Coordinate Reference System name: NAD27 / UTM zone 11N
Coordinate Reference System ID: EPSG:26711
Coordinate Reference System type: Projected
Coordinate Reference System projection type: UTM zone 11N, Transverse Mercator
Coordinate Reference System units: metre
Coordinate Reference System area of use: North America..., west -120.00, south 26.93, east -114.00, north 78.13

and add a --crs-format=AUTO|WKT2|PROJJSON, only for --format=text

Demo:
```
$ gdal raster info byte.tif
Driver: GTiff/GeoTIFF
Files: byte.tif
Size is 20, 20
Coordinate Reference System name: NAD27 / UTM zone 11N
Coordinate Reference System ID: EPSG:26711
Coordinate Reference System type: Projected
Coordinate Reference System projection type: UTM zone 11N, Transverse Mercator
Coordinate Reference System units: metre
Coordinate Reference System area of use: North America..., west -120.00, south 26.93, east -114.00, north 78.13
Data axis to CRS axis mapping: 1,2
Origin = (440720.000000000000000,3751320.000000000000000)
Pixel Size = (60.000000000000000,-60.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  440720.000, 3751320.000) (117d38'28.21"W, 33d54' 8.47"N)
Lower Left  (  440720.000, 3750120.000) (117d38'27.92"W, 33d53'29.51"N)
Upper Right (  441920.000, 3751320.000) (117d37'41.48"W, 33d54' 8.71"N)
Lower Right (  441920.000, 3750120.000) (117d37'41.20"W, 33d53'29.75"N)
Center      (  441320.000, 3750720.000) (117d38' 4.70"W, 33d53'49.11"N)
Band 1 Block=20x20 Type=Byte, ColorInterp=Gray
```

```
$ gdal raster info byte.tif --crs-format=WKT2
Driver: GTiff/GeoTIFF
Files: byte.tif
Size is 20, 20
Coordinate Reference System WKT:
PROJCRS["NAD27 / UTM zone 11N",
    BASEGEOGCRS["NAD27",
        DATUM["North American Datum 1927",
            ELLIPSOID["Clarke 1866",6378206.4,294.978698213898,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4267]],
    CONVERSION["UTM zone 11N",
        METHOD["Transverse Mercator",
            ID["EPSG",9807]],
        PARAMETER["Latitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",-117,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["Scale factor at natural origin",0.9996,
            SCALEUNIT["unity",1],
            ID["EPSG",8805]],
        PARAMETER["False easting",500000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",0,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["(E)",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["(N)",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    USAGE[
        SCOPE["Engineering survey, topographic mapping."],
        AREA["North America - between 120°W and 114°W - onshore. Canada - Alberta; British Columbia; Northwest Territories; Nunavut. Mexico. United States (USA) - California; Idaho; Nevada; Oregon; Washington."],
        BBOX[26.93,-120,78.13,-114]],
    ID["EPSG",26711]]
Data axis to CRS axis mapping: 1,2
Origin = (440720.000000000000000,3751320.000000000000000)
Pixel Size = (60.000000000000000,-60.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  440720.000, 3751320.000) (117d38'28.21"W, 33d54' 8.47"N)
Lower Left  (  440720.000, 3750120.000) (117d38'27.92"W, 33d53'29.51"N)
Upper Right (  441920.000, 3751320.000) (117d37'41.48"W, 33d54' 8.71"N)
Lower Right (  441920.000, 3750120.000) (117d37'41.20"W, 33d53'29.75"N)
Center      (  441320.000, 3750720.000) (117d38' 4.70"W, 33d53'49.11"N)
Band 1 Block=20x20 Type=Byte, ColorInterp=Gray
```
@rouault rouault force-pushed the gdal_raster_info_abbreviated_crs branch from cb4984c to 80c7b06 Compare April 4, 2026 14:06
@geographika
Copy link
Copy Markdown
Collaborator

@rouault - I really like this summary, and I think it is more than sufficient for the majority of use cases. It also removes multiple mentions of EPSG codes which will remove a lot of confusion.
What happens if there is a projection without a "Coordinate Reference System ID"? Will this be set to unknown?

I presume this only affects the new CLI output, so anyone relying on text output for ogrinfo etc. won't be affected, and new CLI users who want to parse output are likely to be using -f json.

@rouault
Copy link
Copy Markdown
Member Author

rouault commented Apr 7, 2026

What happens if there is a projection without a "Coordinate Reference System ID"? Will this be set to unknown?

no, in that case the full WKT is given, since in that situation there's a high chance the summary might not be enough to make sense of the CRS

I presume this only affects the new CLI output, so anyone relying on text output for ogrinfo etc. won't be affected,

Yes, only for new CLI output. I intend to do the same for "gdal vector info"

Regular gdalinfo and ogrinfo unchanged.

and new CLI users who want to parse output are likely to be using -f json.

yes

@rouault
Copy link
Copy Markdown
Member Author

rouault commented Apr 7, 2026

. I intend to do the same for "gdal vector info"

done in #14303, with some adjustments for nicer output, also transposed to gdal raster info

@rouault
Copy link
Copy Markdown
Member Author

rouault commented Apr 10, 2026

merged as part of #14303

@rouault rouault closed this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

funded through GSP Work funded through the GDAL Sponsorship Program

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants