prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Reprojection Example/Documentation
  I was having some trouble following the [reprojection](https://github.com/mapbox/rasterio/blob/master/examples/reproject.py) example; the Affine parameters for `dst_transform` aren't referenced anywhere before they are applied:
  
  https://github.com/mapbox/rasterio/blob/master/examples/reproject.py#L29
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `rasterio/transform.py`
  Content:
  ```
  1 import warnings
  2 
  3 from affine import Affine
  4 
  5 IDENTITY = Affine.identity()
  6 
  7 
  8 def tastes_like_gdal(seq):
  9     """Return True if `seq` matches the GDAL geotransform pattern."""
  10     return seq[2] == seq[4] == 0.0 and seq[1] > 0 and seq[5] < 0
  11 
  12 
  13 def guard_transform(transform):
  14     """Return an Affine transformation instance"""
  15     if not isinstance(transform, Affine):
  16         if tastes_like_gdal(transform):
  17             warnings.warn(
  18                 "GDAL-style transforms are deprecated and will not "
  19                 "be supported in Rasterio 1.0.",
  20                 FutureWarning,
  21                 stacklevel=2)
  22             transform = Affine.from_gdal(*transform)
  23         else:
  24             transform = Affine(*transform)
  25     return transform
  26
  ```
  
  Path: `examples/reproject.py`
  Content:
  ```
  1 import os
  2 import shutil
  3 import subprocess
  4 import tempfile
  5 
  6 import numpy
  7 import rasterio
  8 from rasterio import Affine as A
  9 from rasterio.warp import reproject, RESAMPLING
  10 
  11 tempdir = '/tmp'
  12 tiffname = os.path.join(tempdir, 'example.tif')
  13 
  14 with rasterio.drivers():
  15 
  16     # Consider a 512 x 512 raster centered on 0 degrees E and 0 degrees N
  17     # with each pixel covering 15".
  18     rows, cols = src_shape = (512, 512)
  19     dpp = 1.0/240 # decimal degrees per pixel
  20     # The following is equivalent to 
  21     # A(dpp, 0, -cols*dpp/2, 0, -dpp, rows*dpp/2).
  22     src_transform = A.translation(-cols*dpp/2, rows*dpp/2) * A.scale(dpp, -dpp)
  23     src_crs = {'init': 'EPSG:4326'}
  24     source = numpy.ones(src_shape, numpy.uint8)*255
  25 
  26     # Prepare to reproject this rasters to a 1024 x 1024 dataset in
  27     # Web Mercator (EPSG:3857) with origin at -8928592, 2999585.
  28     dst_shape = (1024, 1024)
  29     dst_transform = A.from_gdal(-237481.5, 425.0, 0.0, 237536.4, 0.0, -425.0)
  30     dst_transform = dst_transform.to_gdal()
  31     dst_crs = {'init': 'EPSG:3857'}
  32     destination = numpy.zeros(dst_shape, numpy.uint8)
  33 
  34     reproject(
  35         source, 
  36         destination, 
  37         src_transform=src_transform,
  38         src_crs=src_crs,
  39         dst_transform=dst_transform,
  40         dst_crs=dst_crs,
  41         resampling=RESAMPLING.nearest)
  42 
  43     # Assert that the destination is only partly filled.
  44     assert destination.any()
  45     assert not destination.all()
  46 
  47     # Write it out to a file.
  48     with rasterio.open(
  49             tiffname, 
  50             'w',
  51             driver='GTiff',
  52             width=dst_shape[1],
  53             height=dst_shape[0],
  54             count=1,
  55             dtype=numpy.uint8,
  56             nodata=0,
  57             transform=dst_transform,
  58             crs=dst_crs) as dst:
  59         dst.write_band(1, destination)
  60 
  61 info = subprocess.call(['open', tiffname])
  62 
  63
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/examples/reproject.py b/examples/reproject.py
  --- a/examples/reproject.py
  +++ b/examples/reproject.py
  @@ -5,7 +5,7 @@
   
   import numpy
   import rasterio
  -from rasterio import Affine as A
  +from rasterio import transform
   from rasterio.warp import reproject, RESAMPLING
   
   tempdir = '/tmp'
  @@ -17,17 +17,15 @@
       # with each pixel covering 15".
       rows, cols = src_shape = (512, 512)
       dpp = 1.0/240 # decimal degrees per pixel
  -    # The following is equivalent to 
  -    # A(dpp, 0, -cols*dpp/2, 0, -dpp, rows*dpp/2).
  -    src_transform = A.translation(-cols*dpp/2, rows*dpp/2) * A.scale(dpp, -dpp)
  +    west, south, east, north = -cols*dpp/2, -rows*dpp/2, cols*dpp/2, rows*dpp/2
  +    src_transform = transform.from_bounds(west, south, east, north, cols, rows)
       src_crs = {'init': 'EPSG:4326'}
       source = numpy.ones(src_shape, numpy.uint8)*255
   
       # Prepare to reproject this rasters to a 1024 x 1024 dataset in
  -    # Web Mercator (EPSG:3857) with origin at -8928592, 2999585.
  +    # Web Mercator (EPSG:3857) with origin at -237481.5, 237536.4.
       dst_shape = (1024, 1024)
  -    dst_transform = A.from_gdal(-237481.5, 425.0, 0.0, 237536.4, 0.0, -425.0)
  -    dst_transform = dst_transform.to_gdal()
  +    dst_transform = transform.from_origin(-237481.5, 237536.4, 425.0, 425.0)
       dst_crs = {'init': 'EPSG:3857'}
       destination = numpy.zeros(dst_shape, numpy.uint8)
   
  @@ -59,4 +57,3 @@
           dst.write_band(1, destination)
   
   info = subprocess.call(['open', tiffname])
  -
  diff --git a/rasterio/transform.py b/rasterio/transform.py
  --- a/rasterio/transform.py
  +++ b/rasterio/transform.py
  @@ -23,3 +23,18 @@
           else:
               transform = Affine(*transform)
       return transform
  +
  +
  +def from_origin(west, north, xsize, ysize):
  +    """Return an Affine transformation for a georeferenced raster given
  +    the coordinates of its upper left corner `west`, `north` and pixel
  +    sizes `xsize`, `ysize`."""
  +    return Affine.translation(west, north) * Affine.scale(xsize, -ysize)
  +
  +
  +def from_bounds(west, south, east, north, width, height):
  +    """Return an Affine transformation for a georeferenced raster given
  +    its bounds `west`, `south`, `east`, `north` and its `width` and
  +    `height` in number of pixels."""
  +    return Affine.translation(west, north) * Affine.scale(
  +            (east - west)/width, (south - north)/height)
  
verification_info: {"golden_diff": "diff --git a/examples/reproject.py b/examples/reproject.py\n--- a/examples/reproject.py\n+++ b/examples/reproject.py\n@@ -5,7 +5,7 @@\n \n import numpy\n import rasterio\n-from rasterio import Affine as A\n+from rasterio import transform\n from rasterio.warp import reproject, RESAMPLING\n \n tempdir = '/tmp'\n@@ -17,17 +17,15 @@\n     # with each pixel covering 15\".\n     rows, cols = src_shape = (512, 512)\n     dpp = 1.0/240 # decimal degrees per pixel\n-    # The following is equivalent to \n-    # A(dpp, 0, -cols*dpp/2, 0, -dpp, rows*dpp/2).\n-    src_transform = A.translation(-cols*dpp/2, rows*dpp/2) * A.scale(dpp, -dpp)\n+    west, south, east, north = -cols*dpp/2, -rows*dpp/2, cols*dpp/2, rows*dpp/2\n+    src_transform = transform.from_bounds(west, south, east, north, cols, rows)\n     src_crs = {'init': 'EPSG:4326'}\n     source = numpy.ones(src_shape, numpy.uint8)*255\n \n     # Prepare to reproject this rasters to a 1024 x 1024 dataset in\n-    # Web Mercator (EPSG:3857) with origin at -8928592, 2999585.\n+    # Web Mercator (EPSG:3857) with origin at -237481.5, 237536.4.\n     dst_shape = (1024, 1024)\n-    dst_transform = A.from_gdal(-237481.5, 425.0, 0.0, 237536.4, 0.0, -425.0)\n-    dst_transform = dst_transform.to_gdal()\n+    dst_transform = transform.from_origin(-237481.5, 237536.4, 425.0, 425.0)\n     dst_crs = {'init': 'EPSG:3857'}\n     destination = numpy.zeros(dst_shape, numpy.uint8)\n \n@@ -59,4 +57,3 @@\n         dst.write_band(1, destination)\n \n info = subprocess.call(['open', tiffname])\n-\ndiff --git a/rasterio/transform.py b/rasterio/transform.py\n--- a/rasterio/transform.py\n+++ b/rasterio/transform.py\n@@ -23,3 +23,18 @@\n         else:\n             transform = Affine(*transform)\n     return transform\n+\n+\n+def from_origin(west, north, xsize, ysize):\n+    \"\"\"Return an Affine transformation for a georeferenced raster given\n+    the coordinates of its upper left corner `west`, `north` and pixel\n+    sizes `xsize`, `ysize`.\"\"\"\n+    return Affine.translation(west, north) * Affine.scale(xsize, -ysize)\n+\n+\n+def from_bounds(west, south, east, north, width, height):\n+    \"\"\"Return an Affine transformation for a georeferenced raster given\n+    its bounds `west`, `south`, `east`, `north` and its `width` and\n+    `height` in number of pixels.\"\"\"\n+    return Affine.translation(west, north) * Affine.scale(\n+            (east - west)/width, (south - north)/height)\n", "issue": "Reprojection Example/Documentation\nI was having some trouble following the [reprojection](https://github.com/mapbox/rasterio/blob/master/examples/reproject.py) example; the Affine parameters for `dst_transform` aren't referenced anywhere before they are applied:\n\nhttps://github.com/mapbox/rasterio/blob/master/examples/reproject.py#L29\n\n", "before_files": [{"content": "import warnings\n\nfrom affine import Affine\n\nIDENTITY = Affine.identity()\n\n\ndef tastes_like_gdal(seq):\n    \"\"\"Return True if `seq` matches the GDAL geotransform pattern.\"\"\"\n    return seq[2] == seq[4] == 0.0 and seq[1] > 0 and seq[5] < 0\n\n\ndef guard_transform(transform):\n    \"\"\"Return an Affine transformation instance\"\"\"\n    if not isinstance(transform, Affine):\n        if tastes_like_gdal(transform):\n            warnings.warn(\n                \"GDAL-style transforms are deprecated and will not \"\n                \"be supported in Rasterio 1.0.\",\n                FutureWarning,\n                stacklevel=2)\n            transform = Affine.from_gdal(*transform)\n        else:\n            transform = Affine(*transform)\n    return transform\n", "path": "rasterio/transform.py"}, {"content": "import os\nimport shutil\nimport subprocess\nimport tempfile\n\nimport numpy\nimport rasterio\nfrom rasterio import Affine as A\nfrom rasterio.warp import reproject, RESAMPLING\n\ntempdir = '/tmp'\ntiffname = os.path.join(tempdir, 'example.tif')\n\nwith rasterio.drivers():\n\n    # Consider a 512 x 512 raster centered on 0 degrees E and 0 degrees N\n    # with each pixel covering 15\".\n    rows, cols = src_shape = (512, 512)\n    dpp = 1.0/240 # decimal degrees per pixel\n    # The following is equivalent to \n    # A(dpp, 0, -cols*dpp/2, 0, -dpp, rows*dpp/2).\n    src_transform = A.translation(-cols*dpp/2, rows*dpp/2) * A.scale(dpp, -dpp)\n    src_crs = {'init': 'EPSG:4326'}\n    source = numpy.ones(src_shape, numpy.uint8)*255\n\n    # Prepare to reproject this rasters to a 1024 x 1024 dataset in\n    # Web Mercator (EPSG:3857) with origin at -8928592, 2999585.\n    dst_shape = (1024, 1024)\n    dst_transform = A.from_gdal(-237481.5, 425.0, 0.0, 237536.4, 0.0, -425.0)\n    dst_transform = dst_transform.to_gdal()\n    dst_crs = {'init': 'EPSG:3857'}\n    destination = numpy.zeros(dst_shape, numpy.uint8)\n\n    reproject(\n        source, \n        destination, \n        src_transform=src_transform,\n        src_crs=src_crs,\n        dst_transform=dst_transform,\n        dst_crs=dst_crs,\n        resampling=RESAMPLING.nearest)\n\n    # Assert that the destination is only partly filled.\n    assert destination.any()\n    assert not destination.all()\n\n    # Write it out to a file.\n    with rasterio.open(\n            tiffname, \n            'w',\n            driver='GTiff',\n            width=dst_shape[1],\n            height=dst_shape[0],\n            count=1,\n            dtype=numpy.uint8,\n            nodata=0,\n            transform=dst_transform,\n            crs=dst_crs) as dst:\n        dst.write_band(1, destination)\n\ninfo = subprocess.call(['open', tiffname])\n\n", "path": "examples/reproject.py"}], "after_files": [{"content": "import warnings\n\nfrom affine import Affine\n\nIDENTITY = Affine.identity()\n\n\ndef tastes_like_gdal(seq):\n    \"\"\"Return True if `seq` matches the GDAL geotransform pattern.\"\"\"\n    return seq[2] == seq[4] == 0.0 and seq[1] > 0 and seq[5] < 0\n\n\ndef guard_transform(transform):\n    \"\"\"Return an Affine transformation instance\"\"\"\n    if not isinstance(transform, Affine):\n        if tastes_like_gdal(transform):\n            warnings.warn(\n                \"GDAL-style transforms are deprecated and will not \"\n                \"be supported in Rasterio 1.0.\",\n                FutureWarning,\n                stacklevel=2)\n            transform = Affine.from_gdal(*transform)\n        else:\n            transform = Affine(*transform)\n    return transform\n\n\ndef from_origin(west, north, xsize, ysize):\n    \"\"\"Return an Affine transformation for a georeferenced raster given\n    the coordinates of its upper left corner `west`, `north` and pixel\n    sizes `xsize`, `ysize`.\"\"\"\n    return Affine.translation(west, north) * Affine.scale(xsize, -ysize)\n\n\ndef from_bounds(west, south, east, north, width, height):\n    \"\"\"Return an Affine transformation for a georeferenced raster given\n    its bounds `west`, `south`, `east`, `north` and its `width` and\n    `height` in number of pixels.\"\"\"\n    return Affine.translation(west, north) * Affine.scale(\n            (east - west)/width, (south - north)/height)\n", "path": "rasterio/transform.py"}, {"content": "import os\nimport shutil\nimport subprocess\nimport tempfile\n\nimport numpy\nimport rasterio\nfrom rasterio import transform\nfrom rasterio.warp import reproject, RESAMPLING\n\ntempdir = '/tmp'\ntiffname = os.path.join(tempdir, 'example.tif')\n\nwith rasterio.drivers():\n\n    # Consider a 512 x 512 raster centered on 0 degrees E and 0 degrees N\n    # with each pixel covering 15\".\n    rows, cols = src_shape = (512, 512)\n    dpp = 1.0/240 # decimal degrees per pixel\n    west, south, east, north = -cols*dpp/2, -rows*dpp/2, cols*dpp/2, rows*dpp/2\n    src_transform = transform.from_bounds(west, south, east, north, cols, rows)\n    src_crs = {'init': 'EPSG:4326'}\n    source = numpy.ones(src_shape, numpy.uint8)*255\n\n    # Prepare to reproject this rasters to a 1024 x 1024 dataset in\n    # Web Mercator (EPSG:3857) with origin at -237481.5, 237536.4.\n    dst_shape = (1024, 1024)\n    dst_transform = transform.from_origin(-237481.5, 237536.4, 425.0, 425.0)\n    dst_crs = {'init': 'EPSG:3857'}\n    destination = numpy.zeros(dst_shape, numpy.uint8)\n\n    reproject(\n        source, \n        destination, \n        src_transform=src_transform,\n        src_crs=src_crs,\n        dst_transform=dst_transform,\n        dst_crs=dst_crs,\n        resampling=RESAMPLING.nearest)\n\n    # Assert that the destination is only partly filled.\n    assert destination.any()\n    assert not destination.all()\n\n    # Write it out to a file.\n    with rasterio.open(\n            tiffname, \n            'w',\n            driver='GTiff',\n            width=dst_shape[1],\n            height=dst_shape[0],\n            count=1,\n            dtype=numpy.uint8,\n            nodata=0,\n            transform=dst_transform,\n            crs=dst_crs) as dst:\n        dst.write_band(1, destination)\n\ninfo = subprocess.call(['open', tiffname])\n", "path": "examples/reproject.py"}]}