GDAL – How to Work with ECW in GDAL

ecwgdal

I have GDAL 2.4.2 plus ECW plugin.

gdalinfo --formats
>>ECW -raster- (rw): ERDAS Compressed Wavelets (SDK 3.x)

And gdalinfo shows ecw file info.
But when i tried to use gdal2tiles i got error:

"C:\Program Files\GDAL\gdal2tiles.py" -r near -a 0,0,0 -z 15 D:\OFP\input.ecw D:\dev\nginx-1.12.1\www\OFP

ERROR 4: `D:\OFP\input.ecw' not recognized as a supported file f
ormat.
Usage: gdal2tiles.py [options] input_file [output]

gdal2tiles.py: error: It is not possible to open the input file 'D:\OFP\input.ecw'.

What can be wrong here?

UPDATE

I found that gdal module do not know about this format:

from osgeo import gdal

driver_list = []
for i in range(gdal.GetDriverCount()):
    driver = gdal.GetDriver(i)
    driver_list.append(driver.GetDescription())

print(str(driver_list))

['VRT', 'DERIVED', 'GTiff', 'NITF', 'RPFTOC', 'ECRGTOC', 'HFA', 'SAR_CEOS', 'CEO
S', 'JAXAPALSAR', 'GFF', 'ELAS', 'AIG', 'AAIGrid', 'GRASSASCIIGrid', 'SDTS', 'DT
ED', 'PNG', 'JPEG', 'MEM', 'JDEM', 'GIF', 'BIGGIF', 'ESAT', 'BSB', 'XPM', 'BMP',
 'DIMAP', 'AirSAR', 'RS2', 'SAFE', 'PCIDSK', 'PCRaster', 'ILWIS', 'SGI', 'SRTMHG
T', 'Leveller', 'Terragen', 'ISIS3', 'ISIS2', 'PDS', 'PDS4', 'VICAR', 'TIL', 'ER
S', 'JP2OpenJPEG', 'L1B', 'FIT', 'GRIB', 'RMF', 'WCS', 'WMS', 'MSGN', 'RST', 'IN
GR', 'GSAG', 'GSBG', 'GS7BG', 'COSAR', 'TSX', 'COASP', 'R', 'MAP', 'KMLSUPEROVER
LAY', 'PDF', 'Rasterlite', 'MBTiles', 'PLMOSAIC', 'CALS', 'WMTS', 'SENTINEL2', '
MRF', 'PNM', 'DOQ1', 'DOQ2', 'PAux', 'MFF', 'MFF2', 'FujiBAS', 'GSC', 'FAST', 'B
T', 'LAN', 'CPG', 'IDA', 'NDF', 'EIR', 'DIPEx', 'LCP', 'GTX', 'LOSLAS', 'NTv1',
'NTv2', 'CTable2', 'ACE2', 'SNODAS', 'KRO', 'ROI_PAC', 'RRASTER', 'BYN', 'ARG',
'RIK', 'USGSDEM', 'GXF', 'NWT_GRD', 'NWT_GRC', 'ADRG', 'SRP', 'BLX', 'PostGISRas
ter', 'SAGA', 'IGNFHeightASCIIGrid', 'XYZ', 'HF2', 'OZI', 'CTG', 'E00GRID', 'ZMa
p', 'NGSGEOID', 'IRIS', 'PRF', 'RDA', 'EEDAI', 'EEDA', 'SIGDEM', 'GNMFile', 'GNM
Database', 'DB2ODBC', 'ESRI Shapefile', 'MapInfo File', 'UK .NTF', 'OGR_SDTS', '
S57', 'DGN', 'OGR_VRT', 'REC', 'Memory', 'BNA', 'CSV', 'NAS', 'GML', 'GPX', 'LIB
KML', 'KML', 'GeoJSON', 'GeoJSONSeq', 'ESRIJSON', 'TopoJSON', 'Interlis 1', 'Int
erlis 2', 'OGR_GMT', 'GPKG', 'SQLite', 'ODBC', 'WAsP', 'PGeo', 'MSSQLSpatial', '
PostgreSQL', 'MySQL', 'OpenFileGDB', 'XPlane', 'DXF', 'CAD', 'Geoconcept', 'GeoR
SS', 'GPSTrackMaker', 'VFK', 'PGDUMP', 'OSM', 'GPSBabel', 'SUA', 'OpenAir', 'OGR
_PDS', 'WFS', 'WFS3', 'HTF', 'AeronavFAA', 'Geomedia', 'EDIGEO', 'GFT', 'SVG', '
CouchDB', 'Cloudant', 'Idrisi', 'ARCGEN', 'SEGUKOOA', 'SEGY', 'ODS', 'XLSX', 'El
asticSearch', 'Walk', 'Carto', 'SXF', 'Selafin', 'JML', 'PLSCENES', 'CSW', 'VDV'
, 'GMLAS', 'MVT', 'TIGER', 'AVCBin', 'AVCE00', 'NGW', 'GenBin', 'ENVI', 'EHdr',
'ISCE', 'HTTP']

Best Answer

Judging by :https://gdal.org/drivers/raster/ecw.html

You'll need the ECW SDK which will probably mean that you'll have to compile GDAL yourself.

Specifically: "GDAL supports reading and writing ECW files using the ERDAS ECW/JP2 SDK developed by Hexagon Geospatial (formerly Intergraph, ERDAS, ERMapper). Support is optional and requires linking in the libraries available from the ECW/JP2 SDK Download page."