I have GDAL installed in Linux (i.e. the easiest way to install/implement it) so the following examples represent command line usage. I have used a smattering of different GDAL utilities, and the links in the descriptions go to the manual page for the utility in each example. I have incorporated these example commands into various bash scripts if I need to implement them in an iteration over multiple files.
This is an example of re-sampling a raster to larger pixel sizes (in this case to a lower resolution of 0.09 degree from the original 0.0002 degree [30m LANDSAT pixels]) by taking the mean of the pixels encompassed in the coarser output.
gdalwarp -tr 0.09 0.09 -r average -ot Float32 file.tif fileout.tif
I have used GDAL to set no data values (in this case, I reclassified 0 as the no data value).
gdal_translate -of GTiff -a_nodata 0 PPR/2000/Playas_2000.tif region_img/Playas.tif
Here’s an example of stitching 2 tiff’s together into a larger area, and setting the output no data value to be where the 0’s were in the original input files.
gdal_merge.py -o region_img/Canada.tif -a_nodata 0 PPR/2000/Alberta_PPR_2000.tif PPR/2000/SAK_MAN_PPR_2000.tif
If you want to stitch shape files together into a new file, you have to initialize the new shape file first with one of your input files and then add to it.
ogr2ogr regions/Canada.shp shapefiles/Alberta_PPR_2001.shp ogr2ogr -update -append regions/Canada.shp shapefiles/SAK_MAN_PPR_2001.shp -nln Canada
If you’re going to, say, turn your raster into polygons, you can get rid of clumps below a certain threshold before doing so (in this case, I’m getting rid of single pixels in my unary raster when using an 8-neighbor clumping rule).
gdal_sieve.py -st 2 -8 file.tif
Then, I can make my polygon layer, simplified. In the 2nd line, I project the shapefile to Albers Equal Area.
gdal_polygonize.py -8 file.tif -f "ESRI Shapefile" shapefile/file.shp ogr2ogr -f "ESRI Shapefile" -progress outfile.shp shapefile/file.shp -t_srs "EPSG:5070"