Skip to content

Cannot choose IC=C4 with CADRG Writes #14709

@td3447

Description

@td3447

What is the bug?

Bug

Runtime error occurs when setting IC=C4 when using CADRG write.

Error:

RuntimeError: Only IC=NC (uncompressed), IC=C3/M3 (JPEG) and IC=C8 (JPEG2000) allowed with NITF CreateCopy method.

Steps to reproduce the issue

Info

Issue arises on both the CLI and the Python code

Python Code

import os
from osgeo import gdal

# OsGeo4W
os.environ["OSGEO4W_ROOT"] = str("C:/OSGeo4W")
# GDAL
os.environ["GDAL_DATA"] = str(os.path.join(os.environ["OSGEO4W_ROOT"], "apps/gdal/share/gdal"))

gdal.UseExceptions()

# https://www.faa.gov/air_traffic/flight_info/aeronav/digital_products/vfr/
fn = "maps/Albuquerque SEC.tif"
fo_vrt = "maps/Albuquerque SEC.vrt"
fo_dir = "maps/cadrg_test"

with gdal.Open(fn) as ds:

    vrt = gdal.Translate(
        destName=fo_vrt,
        srcDS=ds,
        options=gdal.TranslateOptions(rgbExpand="rgb")
    )

    gdal.Translate(
        destName=fo_dir,
        srcDS=vrt,
        format="NITF",
        creationOptions=[
            "PRODUCT_TYPE=CADRG",
            "SCALE=500000",
            "SERIES_CODE=TP",
            "IC=C4", # <- This causes the error
        ]
    )

CLI Command

gdal_translate -of NITF -co PRODUCT_TYPE=CADRG -co SCALE=500000 -co SERIES_CODE=TP -co IC=C4 -expand rgb "maps\Albuquerque SEC.tif" "maps\cli_test"

Versions and provenance

GDAL Version

GDAL 3.13.0 "Iowa City", released 2026/05/04 (OSGeo4W)

Python Version

Python 3.12.13 (OSGeo4W)

Operating System

Windows 11

Additional context

Could just be a logic bug, as was pointed out to my on my gis.stackexchange post.
Related to this line of code.

Metadata

Metadata

Assignees

Labels

not for AI loversSee https://gdal.org/en/stable/community/ai_tool_policy.html

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions