Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

GDAL and PDAL cheatsheet

Joachim Meyer edited this page May 10, 2021 · 6 revisions

Rasters

Get shapefile from raster image

gdaltindex BOUNDARIES.shp INPUT_RASTER.tif

Cut raster to shapefile

gdalwarp -cutline INPUT.shp -crop_to_cutline -co UNIFIED_SRC_NODATA=YES INPUT.tif OUTPUT.tif

Get a GeoJSON from a shapefile

ogr2ogr -f "GeoJSON" OUTPUT.json INPUT.shp

Convert kmz to shapefile

ogr2ogr -f KML OUTPUT.shp INPUT.kml

Warp

gdalwarp INPUT_RASTER.tif OUTFILE.tif -t_srs "+proj=utm +zone=13 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0"

gdalwarp INPUT_RASTER.tif OUTFILE.tif -t_srs EPSG:32613

Convert ENVI file to GeoTiff

Have the corresponding .hdr in same folder with identical name

gdal_translate -of GTiff INFILE OUTFILE.tif

Compress Tiff file

gdal_translate -co COMPRESS=LZW -co TILED=YES -co BIGTIFF=IF_SAFER input_raster.tif OUTFILE.tif

Create RGB image from tiff files

Tif images need a UInt16 data type to be recognized by PIL (Python) as valid TIF image.

gdalbuildvrt -separate source_rgb.vrt red.tif green.tif blue.tif
gdal_translate -ot UInt16 -co PHOTOMETRIC=rgb -colorinterp red,green,blue source_rgb.vrt output.tif

Point Clouds

Get boundary from lidar point cloud

pdal info --boundary POINTCLOUD.laz

Shapefiles

Get Summary for all layers of a shapefile

ogrinfo -al -ro -so SHAPEFILE.shp

Transform shapefile

ogr2ogr -t_srs EPSG:32611 OUTPUT_FILE.shp INPUT_SHAPE.shp