Cheatsheet: From GDAL/OGR

Cheatsheet: From GDAL/OGR#

This page helps users familiar with GDAL/OGR migrate their operations to the GeoUtils API.

Regarding function names, GeoUtils exposes an API almost entirely consistent with the recently overhauled GDAL CLI.

Note that GeoUtils is object-oriented (methods run on Raster, Vector, PointCloud, or on DataArray and GeoDataFrame through rst, vct and pc accessors), while GDAL/OGR utilities are typically file-oriented (read from disk, write to disk).

We also provide a conversion table for operations specific to DEMs (e.g. slope, aspect, roughness indexes) that are supported through our sister-package xDEM.

GDAL/OGR utilities#

Legend

The ⟶ symbol denotes methods interfacing from one specific object type to another.

GDAL/OGR ⟶ GeoUtils#

Operation

Old GDAL/OGR

New GDAL CLI

GeoUtils

Metadata

Footprint

gdalinfo/ogrinfo

gdal raster/vector footprint

footprint

Bounding box

gdalinfo/ogrinfo

gdal raster/vector bbox

bbox

Info summary

gdalinfo/ogrinfo

gdal raster/vector info

info()

Raster ⟶ Raster

Reproject/warp

gdalwarp

gdal raster reproject

reproject()

Crop to extent

gdal_translate -projwin

gdal raster clip --bbox

crop() / icrop()

Clip to geometry

gdalwarp -cutline

gdal raster clip --geometry

clip()

Edit referencing

gdal_edit / gdalmove.py

gdal raster edit

edit() (or individual metadata setters), translate()

Convert file format

gdal_translate

gdal raster convert

to_file()

Filter

—

gdal raster neighbors

filter()

Proximity distance

gdal_proximity

gdal raster proximity

proximity()

Raster calculator

gdal_calc.py

gdal raster calc

NumPy array interface on data

Mosaic / merge rasters

gdal_merge.py

gdalbuildvrt+gdal raster reproject

merge_rasters()

Stack rasters into multiband raster

gdal_stack.py

gdal raster stack

stack_rasters()

Fill nodata gaps

gdal_fillnodata.py

gdal raster fill-nodata

fill_nodata()

Remove small raster regions

gdal_sieve.py

gdal raster sieve

sieve()

Generate contours

gdal_contour

gdal raster contour

Not implemented

Raster ⟶ Point

Interpolate at coordinates

gdallocationinfo

gdal raster pixel-info

to_pointcloud()/interp_at_points()

Raster ⟶ Vector

Polygonize

gdal_polygonize.py

gdal raster polygonize

polygonize()

Vector ⟶ Vector

Reproject

ogr2ogr

gdal vector reproject

reproject()

Crop to extent

ogr2ogr -spat

gdal vector filter --bbox

crop()

Clip to geometry

ogr2ogr -clipsrc

gdal vector clip

clip()

Translate

ogr2ogr (SQL transform)

—

translate()

Copy

ogr2ogr

gdal vector convert

copy()

Geometric operations

ogr2ogr (specific)

gdal vector simplify/buffer/...

simplify() / buffer() / …

Vector ⟶ Raster

Rasterize

gdal_rasterize

gdal vector rasterize

rasterize()

Point ⟶ Raster

Grid points

gdal_grid

gdal vector grid

grid()

GDAL DEM utilities#

The table below maps common GDAL DEM analysis utilities (historically provided by gdaldem) to their equivalents in xDEM. Note that only attributes with equivalences are listed, as xDEM supports more terrain attributes.

Operation

Old GDAL

New GDAL CLI

xDEM

Terrain attributes

Slope

gdaldem slope

gdal raster slope

slope()

Aspect

gdaldem aspect

gdal raster aspect

aspect()

Hillshade

gdaldem hillshade

gdal raster hillshade

hillshade()

Terrain Ruggedness Index

gdaldem TRI

gdal raster TRI

terrain_ruggedness_index()

Topographic Position Index

gdaldem TPI

gdal raster TPI

topographic_position_index()

Roughness

gdaldem roughness

gdal raster roughness

roughness()