How to crop a raster image by coordinates in python?
<p>I have a GeoTiff in UTM32 and coordinates of a rectangle also in UTM32.
(This projection may not always be the case, but the projections will always be the same)</p>

<p>I simply need to <strong>crop the image using the rectangle</strong>.</p>

<p>The rectangle is given by: (xmin, xmax, ymin, ymax)</p>

<pre><code>699934.584491, 700160.946739, 6168703.00544, 6169364.0093
</code></pre>

<p>I know how to make a polygon from the points, how to make a shapefile from the polygon, and I know how to create a masked numpy array using the points. However, I don't know how to use the polygon, the shapefile or the mask to actually crop the image.</p>

<p>I already looked at the description at:
<a href="https://pcjericks.github.io/py-gdalogr-cookbook/raster_layers.html#clip-a-geotiff-with-shapefile" rel="nofollow">https://pcjericks.github.io/py-gdalogr-cookbook/raster_layers.html#clip-a-geotiff-with-shapefile</a></p>

<p>However, I don't really understand it and it seems overly complicated. (like I don't know what histogram stretching is supposed to be doing there except confusing)</p>