Clipping images
Very rarely is an analyst interested in an entire satellite scene, which can easily cover hundreds of square miles. Given the size of satellite data, we are highly motivated to reduce the size of an image to only our area of interest. The best way to accomplish this reduction is to clip an image to a boundary that defines our study area. We can use shapefiles (or other vector data) as our boundary definition and get rid of all the data outside that boundary.
The following figure contains our stretched.tif
image with a county boundary file layered on top, visualized in Quantum GIS (QGIS):
Figure 7.7 – Our satellite image with a county boundary shapefile overlayed
To clip the image, we need to follow these steps:
- Load the image into an array using
gdal_array
. - Create a shapefile reader using
PyShp
. - Rasterize the shapefile into a georeferenced image (convert it from a vector into a raster).
- Turn the shapefile image...