LinuxCommandLibrary

gdalwarp

Reproject and transform raster images

TLDR

Reproject a raster dataset

$ gdalwarp -t_srs [EPSG:4326] [path/to/input.tif] [path/to/output.tif]
copy

Crop a raster dataset by using specific coordinates
$ gdalwarp -te [min_x] [min_y] [max_x] [max_y] -te_srs [EPSG:4326] [path/to/input.tif] [path/to/output.tif]
copy

Crop a raster dataset using a vector layer
$ gdalwarp -cutline [path/to/area_to_cut.geojson] -crop_to_cutline [path/to/input.tif] [path/to/output.tif]
copy

SYNOPSIS

gdalwarp [--help] [--help-general] [--formats] [--format ] [-q] [-co "NAME=VALUE"]* [-of ] [-ot ] [-pct] [-co "NAME=VALUE"]* [-s_srs ]* [-spatialite_spatial_index] [-spatialite_theme] [-t_srs ] [-ct ] [-ct_sql ] [-e ] [-rpc] [-rpc_verify] [-to RPC_AUTO_IMPROVE=NO] [-order =2] [-tps] [-et ] [-te ] [-te_srs ] [-projwin ] [-i] [-multi] [-wo "NAME=VALUE"]* [-wm ] [-et ] [-multi_scale_approx] [-nogcp] [-nostop] [-nomulti] [-nc] [-cs ] [-srcnodata ]* [-srctype ] [-dstnodata ] [-dsttype ] [-r ] [-src_reproject_to_temp_file] [-tr ] [-tap] [-ts ] [-ot ] [-rbl] [-rb] [-rmm ] [-src_overviews ] [-src_eval ] [-dst_alpha] [-to "NAME=VALUE"]* [-doo ] [-nosrcmask] [-nomask] [-dstmaskband ] [-trf ] [-abs] [-clipsrc ] [-clipsrcsql ] [-clipsrclayer ] [-clipsrcwhere ] [-clipdst ] [-clipdstsql ] [-clipdstlayer ] [-clipdstwhere ] [-cutline ] [-clipsrc ] [-cl ] [-cwhere ] [-clayer ] [-cblend ] [-crop_to_cutline] [-crop_to_cutline] [-cutline_blend ] [-cutline_blend_dist ] [-rf ] [-ro] [-overwrite] [-of ] [-a_srs ] [-co "NAME=VALUE"]* [-a_ullr ] [-ao ] [-ad ] [-mul ] [-add ] [-rm ] [-r ] [-nr ] [-tr ] [-ts ] [-ot ] [-nodata ] [-init ]* [-f ] [-quiet] [-verbose] [--debug ] [--config ] [--formats] [--format ] [--help-general] [--help-gdal]

PARAMETERS

-co "NAME=VALUE"
    Raster creation option; may be used more than once

-s_srs
    Source spatial reference set (input SRS)

-t_srs
    Target spatial reference set (output SRS)

-te
    Extent to reproject/resample to (user extent)

-tr
    Target resolution in target georeferenced units

-tap
    Target resolution in pixels aligned with the input dataset

-r
    Resampling method (near, bilinear, cubic, cubicspline, lanczos, average, mode, max, min, med, q1, q3, sum, rms)

-dstnodata
    Value to write for output image nodata pixels

-srcnodata
    Nodata values for input image(s) (space or comma separated list)

-of
    Output file format name

-ot
    Output pixel type (Byte, Int16, UInt16, UInt32, Int32, Float32, Float64, CInt16, CInt32, CFloat32, CFloat64)

-multi
    Use multi-threaded warping implementation

-wm
    Working memory limit in MB

-et
    Number of threads for TPS warping (if -tps used)

-tps
    Use Thin Plate Spline warping method

-clipsrc
    Clip to polygon in shapefile

-cutline
    Cutline polygon shapefile for masking

-crop_to_cutline
    Crop to cutline extent

-overwrite
    Overwrite output file if it exists

-q
    Quiet mode, suppress progress display

-projwin
    Source window in projected coordinates

-ts
    Target size in pixels

-a_srs
    Assign projection if no input SRS

-dstalpha
    Create alpha band in output

-wo "NAME=VALUE"
    Warp options (e.g., NUM_THREADS)

DESCRIPTION

GDALWarp, part of the GDAL (Geospatial Data Abstraction Library), reprojects and warps raster datasets from one spatial reference system to another. It handles resampling during reprojection, supports cutline-based warping, and works with various raster formats. Ideal for aligning rasters to a common projection, changing resolutions, or mosaicking images.

The tool performs geometric transformations using algorithms like nearest neighbor, bilinear, or cubic convolution. It can clip to polygons, set nodata values, and control output resolution/extent. Multi-threaded processing and virtual rasters (VRT) optimize large dataset handling.

Common uses include preparing data for GIS analysis, orthorectification, or mosaic creation. Output formats include GeoTIFF, NetCDF, and more. Memory management options prevent crashes on huge files.

CAVEATS

Memory-intensive for large rasters; use -wm and -multi for optimization. Resampling may introduce artifacts. No support for vector reprojection (use ogr2ogr). TPS method slow for large datasets.

COMMON RESAMPLING METHODS

-r near: Fastest, preserves categories.
-r bilinear/cubic: Smooth interpolation.
-r average: For continuous data.
-r mode: For categorical.

EXAMPLE USAGE

gdalwarp -t_srs EPSG:4326 -tr 0.01 0.01 input.tif output.tif
Warp to WGS84 at 0.01 degree res.

gdalwarp -cutline mask.shp -crop_to_cutline input.tif output.tif
Clip to shapefile polygon.

HISTORY

GDAL developed by Frank Warmerdam starting 1998; gdalwarp introduced in early versions (~2001) as core reprojection tool. Evolved with resampling algos, multi-threading (GDAL 1.10+), and VSI support. Now at GDAL 3.x, integral to OSGeo ecosystem.

SEE ALSO

gdal_translate(1), gdalinfo(1), gdal_merge.py(1), gdal_polygonize(1), ogr2ogr(1)

Copied to clipboard