We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add pixel size and center point to rio-info
Make these standard info properties as in gdalinfo.


--- 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/warp.py`
Content:
```
1 """Raster warping and reprojection"""
2 
3 from rasterio._warp import _reproject, _transform, _transform_geom, RESAMPLING
4 from rasterio.transform import guard_transform
5 
6 
7 def transform(src_crs, dst_crs, xs, ys, zs=None):
8     """
9     Transform vectors of x, y and optionally z from source
10     coordinate reference system into target.
11 
12     Parameters
13     ------------
14     src_crs: dict
15         Source coordinate reference system, in rasterio dict format.
16         Example: {'init': 'EPSG:4326'}
17     dst_crs: dict
18         Target coordinate reference system.
19     xs: array_like
20         Contains x values.  Will be cast to double floating point values.
21     ys:  array_like
22         Contains y values.
23     zs: array_like, optional
24         Contains z values.  Assumed to be all 0 if absent.
25 
26     Returns
27     ---------
28     out: tuple of array_like, (xs, ys, [zs])
29     Tuple of x, y, and optionally z vectors, transformed into the target
30     coordinate reference system.
31     """
32     return _transform(src_crs, dst_crs, xs, ys, zs)
33 
34 
35 def transform_geom(
36         src_crs,
37         dst_crs,
38         geom,
39         antimeridian_cutting=False,
40         antimeridian_offset=10.0,
41         precision=-1):
42     """
43     Transform geometry from source coordinate reference system into target.
44 
45     Parameters
46     ------------
47     src_crs: dict
48         Source coordinate reference system, in rasterio dict format.
49         Example: {'init': 'EPSG:4326'}
50     dst_crs: dict
51         Target coordinate reference system.
52     geom: GeoJSON like dict object
53     antimeridian_cutting: bool, optional
54         If True, cut geometries at the antimeridian, otherwise geometries will
55         not be cut (default).
56     antimeridian_offset: float
57         Offset from the antimeridian in degrees (default: 10) within which
58         any geometries will be split.
59     precision: float
60         If >= 0, geometry coordinates will be rounded to this number of decimal
61         places after the transform operation, otherwise original coordinate
62         values will be preserved (default).
63 
64     Returns
65     ---------
66     out: GeoJSON like dict object
67         Transformed geometry in GeoJSON dict format
68     """
69 
70     return _transform_geom(
71         src_crs,
72         dst_crs,
73         geom,
74         antimeridian_cutting,
75         antimeridian_offset,
76         precision)
77 
78 
79 def reproject(
80         source,
81         destination,
82         src_transform=None,
83         src_crs=None,
84         dst_transform=None,
85         dst_crs=None,
86         resampling=RESAMPLING.nearest,
87         **kwargs):
88     """
89     Reproject a source raster to a destination raster.
90 
91     Parameters
92     ------------
93     source: ndarray or rasterio Band
94         Source raster.
95     destination: ndarray or rasterio Band
96         Target raster.
97     src_transform: affine transform object, optional
98         Source affine transformation.  Required if source and destination
99         are ndarrays.  Will be derived from source if it is a rasterio Band.
100     src_crs: dict, optional
101         Source coordinate reference system, in rasterio dict format.
102         Required if source and destination are ndarrays.
103         Will be derived from source if it is a rasterio Band.
104         Example: {'init': 'EPSG:4326'}
105     dst_transform: affine transform object, optional
106         Target affine transformation.  Required if source and destination
107         are ndarrays.  Will be derived from target if it is a rasterio Band.
108     dst_crs: dict, optional
109         Target coordinate reference system.  Required if source and destination
110         are ndarrays.  Will be derived from target if it is a rasterio Band.
111     resampling: int
112         Resampling method to use.  One of the following:
113             RESAMPLING.nearest,
114             RESAMPLING.bilinear,
115             RESAMPLING.cubic,
116             RESAMPLING.cubic_spline,
117             RESAMPLING.lanczos,
118             RESAMPLING.average,
119             RESAMPLING.mode
120     kwargs:  dict, optional
121         Additional arguments passed to transformation function.
122 
123     Returns
124     ---------
125     out: None
126         Output is written to destination.
127     """
128 
129     if src_transform:
130         src_transform = guard_transform(src_transform).to_gdal()
131     if dst_transform:
132         dst_transform = guard_transform(dst_transform).to_gdal()
133 
134     _reproject(
135         source,
136         destination,
137         src_transform,
138         src_crs,
139         dst_transform,
140         dst_crs,
141         resampling,
142         **kwargs)
143
```

Path: `rasterio/rio/info.py`
Content:
```
1 # Info command.
2 
3 import json
4 import logging
5 import os.path
6 import pprint
7 import sys
8 
9 import click
10 
11 import rasterio
12 import rasterio.crs
13 from rasterio.rio.cli import cli
14 
15 
16 @cli.command(short_help="Print information about the rio environment.")
17 @click.option('--formats', 'key', flag_value='formats', default=True,
18               help="Enumerate the available formats.")
19 @click.pass_context
20 def env(ctx, key):
21     """Print information about the Rasterio environment: available
22     formats, etc.
23     """
24     verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1
25     logger = logging.getLogger('rio')
26     stdout = click.get_text_stream('stdout')
27     with rasterio.drivers(CPL_DEBUG=(verbosity > 2)) as env:
28         if key == 'formats':
29             for k, v in sorted(env.drivers().items()):
30                 stdout.write("%s: %s\n" % (k, v))
31             stdout.write('\n')
32 
33 
34 @cli.command(short_help="Print information about a data file.")
35 @click.argument('input', type=click.Path(exists=True))
36 @click.option('--meta', 'aspect', flag_value='meta', default=True,
37               help="Show data file structure (default).")
38 @click.option('--tags', 'aspect', flag_value='tags',
39               help="Show data file tags.")
40 @click.option('--namespace', help="Select a tag namespace.")
41 @click.option('--indent', default=None, type=int,
42               help="Indentation level for pretty printed output")
43 # Options to pick out a single metadata item and print it as
44 # a string.
45 @click.option('--count', 'meta_member', flag_value='count',
46               help="Print the count of bands.")
47 @click.option('--dtype', 'meta_member', flag_value='dtype',
48               help="Print the dtype name.")
49 @click.option('--nodata', 'meta_member', flag_value='nodata',
50               help="Print the nodata value.")
51 @click.option('-f', '--format', '--driver', 'meta_member', flag_value='driver',
52               help="Print the format driver.")
53 @click.option('--shape', 'meta_member', flag_value='shape',
54               help="Print the (height, width) shape.")
55 @click.option('--height', 'meta_member', flag_value='height',
56               help="Print the height (number of rows).")
57 @click.option('--width', 'meta_member', flag_value='width',
58               help="Print the width (number of columns).")
59 @click.option('--crs', 'meta_member', flag_value='crs',
60               help="Print the CRS as a PROJ.4 string.")
61 @click.option('--bounds', 'meta_member', flag_value='bounds',
62               help="Print the boundary coordinates "
63                    "(left, bottom, right, top).")
64 @click.pass_context
65 def info(ctx, input, aspect, indent, namespace, meta_member):
66     """Print metadata about the dataset as JSON.
67 
68     Optionally print a single metadata item as a string.
69     """
70     verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1
71     logger = logging.getLogger('rio')
72     stdout = click.get_text_stream('stdout')
73     try:
74         with rasterio.drivers(CPL_DEBUG=(verbosity > 2)):
75             with rasterio.open(input, 'r-') as src:
76                 info = src.meta
77                 del info['affine']
78                 del info['transform']
79                 info['shape'] = info['height'], info['width']
80                 info['bounds'] = src.bounds
81                 proj4 = rasterio.crs.to_string(src.crs)
82                 if proj4.startswith('+init=epsg'):
83                     proj4 = proj4.split('=')[1].upper()
84                 info['crs'] = proj4
85                 if aspect == 'meta':
86                     if meta_member:
87                         if isinstance(info[meta_member], (list, tuple)):
88                             print(" ".join(map(str, info[meta_member])))
89                         else:
90                             print(info[meta_member])
91                     else:
92                         stdout.write(json.dumps(info, indent=indent))
93                         stdout.write("\n")
94                 elif aspect == 'tags':
95                     stdout.write(json.dumps(src.tags(ns=namespace), 
96                                             indent=indent))
97                     stdout.write("\n")
98         sys.exit(0)
99     except Exception:
100         logger.exception("Failed. Exception caught")
101         sys.exit(1)
102
```
--- 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()

```

diff --git a/rasterio/rio/info.py b/rasterio/rio/info.py
--- a/rasterio/rio/info.py
+++ b/rasterio/rio/info.py
@@ -61,18 +61,29 @@
 @click.option('--bounds', 'meta_member', flag_value='bounds',
               help="Print the boundary coordinates "
                    "(left, bottom, right, top).")
+@click.option('--res', 'meta_member', flag_value='res',
+              help="Print pixel width and height.")
+@click.option('--lnglat', 'meta_member', flag_value='lnglat',
+              help="Print longitude and latitude at center.")
+@click.option('--stats', 'meta_member', flag_value='stats',
+              help="Print statistics (min, max, mean) of a single band "
+                   "(use --bidx).")
+@click.option('-v', '--tell-me-more', '--verbose', is_flag=True,
+              help="Output extra information.")
+@click.option('--bidx', type=int, default=1,
+              help="Input file band index (default: 1).")
 @click.pass_context
-def info(ctx, input, aspect, indent, namespace, meta_member):
+def info(ctx, input, aspect, indent, namespace, meta_member, verbose, bidx):
     """Print metadata about the dataset as JSON.
 
     Optionally print a single metadata item as a string.
     """
     verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1
     logger = logging.getLogger('rio')
-    stdout = click.get_text_stream('stdout')
+    mode = 'r' if (verbose or meta_member == 'stats') else 'r-'
     try:
         with rasterio.drivers(CPL_DEBUG=(verbosity > 2)):
-            with rasterio.open(input, 'r-') as src:
+            with rasterio.open(input, mode) as src:
                 info = src.meta
                 del info['affine']
                 del info['transform']
@@ -82,19 +93,28 @@
                 if proj4.startswith('+init=epsg'):
                     proj4 = proj4.split('=')[1].upper()
                 info['crs'] = proj4
+                if verbose:
+                    stats = [{'min': float(b.min()),
+                              'max': float(b.max()),
+                              'mean': float(b.mean())} for b in src.read()]
+                    info['stats'] = stats
                 if aspect == 'meta':
-                    if meta_member:
+                    if meta_member == 'stats':
+                        band = src.read(bidx)
+                        click.echo('%f %f %f' % (
+                            float(band.min()),
+                            float(band.max()),
+                            float(band.mean())))
+                    elif meta_member:
                         if isinstance(info[meta_member], (list, tuple)):
-                            print(" ".join(map(str, info[meta_member])))
+                            click.echo(" ".join(map(str, info[meta_member])))
                         else:
-                            print(info[meta_member])
+                            click.echo(info[meta_member])
                     else:
-                        stdout.write(json.dumps(info, indent=indent))
-                        stdout.write("\n")
+                        click.echo(json.dumps(info, indent=indent))
                 elif aspect == 'tags':
-                    stdout.write(json.dumps(src.tags(ns=namespace), 
+                    click.echo(json.dumps(src.tags(ns=namespace), 
                                             indent=indent))
-                    stdout.write("\n")
         sys.exit(0)
     except Exception:
         logger.exception("Failed. Exception caught")
diff --git a/rasterio/warp.py b/rasterio/warp.py
--- a/rasterio/warp.py
+++ b/rasterio/warp.py
@@ -1,6 +1,7 @@
 """Raster warping and reprojection"""
 
-from rasterio._warp import _reproject, _transform, _transform_geom, RESAMPLING
+from rasterio._base import _transform
+from rasterio._warp import _transform_geom, _reproject, RESAMPLING
 from rasterio.transform import guard_transform

{"golden_diff": "diff --git a/rasterio/rio/info.py b/rasterio/rio/info.py\n--- a/rasterio/rio/info.py\n+++ b/rasterio/rio/info.py\n@@ -61,18 +61,29 @@\n @click.option('--bounds', 'meta_member', flag_value='bounds',\n               help=\"Print the boundary coordinates \"\n                    \"(left, bottom, right, top).\")\n+@click.option('--res', 'meta_member', flag_value='res',\n+              help=\"Print pixel width and height.\")\n+@click.option('--lnglat', 'meta_member', flag_value='lnglat',\n+              help=\"Print longitude and latitude at center.\")\n+@click.option('--stats', 'meta_member', flag_value='stats',\n+              help=\"Print statistics (min, max, mean) of a single band \"\n+                   \"(use --bidx).\")\n+@click.option('-v', '--tell-me-more', '--verbose', is_flag=True,\n+              help=\"Output extra information.\")\n+@click.option('--bidx', type=int, default=1,\n+              help=\"Input file band index (default: 1).\")\n @click.pass_context\n-def info(ctx, input, aspect, indent, namespace, meta_member):\n+def info(ctx, input, aspect, indent, namespace, meta_member, verbose, bidx):\n     \"\"\"Print metadata about the dataset as JSON.\n \n     Optionally print a single metadata item as a string.\n     \"\"\"\n     verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1\n     logger = logging.getLogger('rio')\n-    stdout = click.get_text_stream('stdout')\n+    mode = 'r' if (verbose or meta_member == 'stats') else 'r-'\n     try:\n         with rasterio.drivers(CPL_DEBUG=(verbosity > 2)):\n-            with rasterio.open(input, 'r-') as src:\n+            with rasterio.open(input, mode) as src:\n                 info = src.meta\n                 del info['affine']\n                 del info['transform']\n@@ -82,19 +93,28 @@\n                 if proj4.startswith('+init=epsg'):\n                     proj4 = proj4.split('=')[1].upper()\n                 info['crs'] = proj4\n+                if verbose:\n+                    stats = [{'min': float(b.min()),\n+                              'max': float(b.max()),\n+                              'mean': float(b.mean())} for b in src.read()]\n+                    info['stats'] = stats\n                 if aspect == 'meta':\n-                    if meta_member:\n+                    if meta_member == 'stats':\n+                        band = src.read(bidx)\n+                        click.echo('%f %f %f' % (\n+                            float(band.min()),\n+                            float(band.max()),\n+                            float(band.mean())))\n+                    elif meta_member:\n                         if isinstance(info[meta_member], (list, tuple)):\n-                            print(\" \".join(map(str, info[meta_member])))\n+                            click.echo(\" \".join(map(str, info[meta_member])))\n                         else:\n-                            print(info[meta_member])\n+                            click.echo(info[meta_member])\n                     else:\n-                        stdout.write(json.dumps(info, indent=indent))\n-                        stdout.write(\"\\n\")\n+                        click.echo(json.dumps(info, indent=indent))\n                 elif aspect == 'tags':\n-                    stdout.write(json.dumps(src.tags(ns=namespace), \n+                    click.echo(json.dumps(src.tags(ns=namespace), \n                                             indent=indent))\n-                    stdout.write(\"\\n\")\n         sys.exit(0)\n     except Exception:\n         logger.exception(\"Failed. Exception caught\")\ndiff --git a/rasterio/warp.py b/rasterio/warp.py\n--- a/rasterio/warp.py\n+++ b/rasterio/warp.py\n@@ -1,6 +1,7 @@\n \"\"\"Raster warping and reprojection\"\"\"\n \n-from rasterio._warp import _reproject, _transform, _transform_geom, RESAMPLING\n+from rasterio._base import _transform\n+from rasterio._warp import _transform_geom, _reproject, RESAMPLING\n from rasterio.transform import guard_transform\n", "issue": "Add pixel size and center point to rio-info\nMake these standard info properties as in gdalinfo.\n\n", "before_files": [{"content": "\"\"\"Raster warping and reprojection\"\"\"\n\nfrom rasterio._warp import _reproject, _transform, _transform_geom, RESAMPLING\nfrom rasterio.transform import guard_transform\n\n\ndef transform(src_crs, dst_crs, xs, ys, zs=None):\n    \"\"\"\n    Transform vectors of x, y and optionally z from source\n    coordinate reference system into target.\n\n    Parameters\n    ------------\n    src_crs: dict\n        Source coordinate reference system, in rasterio dict format.\n        Example: {'init': 'EPSG:4326'}\n    dst_crs: dict\n        Target coordinate reference system.\n    xs: array_like\n        Contains x values.  Will be cast to double floating point values.\n    ys:  array_like\n        Contains y values.\n    zs: array_like, optional\n        Contains z values.  Assumed to be all 0 if absent.\n\n    Returns\n    ---------\n    out: tuple of array_like, (xs, ys, [zs])\n    Tuple of x, y, and optionally z vectors, transformed into the target\n    coordinate reference system.\n    \"\"\"\n    return _transform(src_crs, dst_crs, xs, ys, zs)\n\n\ndef transform_geom(\n        src_crs,\n        dst_crs,\n        geom,\n        antimeridian_cutting=False,\n        antimeridian_offset=10.0,\n        precision=-1):\n    \"\"\"\n    Transform geometry from source coordinate reference system into target.\n\n    Parameters\n    ------------\n    src_crs: dict\n        Source coordinate reference system, in rasterio dict format.\n        Example: {'init': 'EPSG:4326'}\n    dst_crs: dict\n        Target coordinate reference system.\n    geom: GeoJSON like dict object\n    antimeridian_cutting: bool, optional\n        If True, cut geometries at the antimeridian, otherwise geometries will\n        not be cut (default).\n    antimeridian_offset: float\n        Offset from the antimeridian in degrees (default: 10) within which\n        any geometries will be split.\n    precision: float\n        If >= 0, geometry coordinates will be rounded to this number of decimal\n        places after the transform operation, otherwise original coordinate\n        values will be preserved (default).\n\n    Returns\n    ---------\n    out: GeoJSON like dict object\n        Transformed geometry in GeoJSON dict format\n    \"\"\"\n\n    return _transform_geom(\n        src_crs,\n        dst_crs,\n        geom,\n        antimeridian_cutting,\n        antimeridian_offset,\n        precision)\n\n\ndef reproject(\n        source,\n        destination,\n        src_transform=None,\n        src_crs=None,\n        dst_transform=None,\n        dst_crs=None,\n        resampling=RESAMPLING.nearest,\n        **kwargs):\n    \"\"\"\n    Reproject a source raster to a destination raster.\n\n    Parameters\n    ------------\n    source: ndarray or rasterio Band\n        Source raster.\n    destination: ndarray or rasterio Band\n        Target raster.\n    src_transform: affine transform object, optional\n        Source affine transformation.  Required if source and destination\n        are ndarrays.  Will be derived from source if it is a rasterio Band.\n    src_crs: dict, optional\n        Source coordinate reference system, in rasterio dict format.\n        Required if source and destination are ndarrays.\n        Will be derived from source if it is a rasterio Band.\n        Example: {'init': 'EPSG:4326'}\n    dst_transform: affine transform object, optional\n        Target affine transformation.  Required if source and destination\n        are ndarrays.  Will be derived from target if it is a rasterio Band.\n    dst_crs: dict, optional\n        Target coordinate reference system.  Required if source and destination\n        are ndarrays.  Will be derived from target if it is a rasterio Band.\n    resampling: int\n        Resampling method to use.  One of the following:\n            RESAMPLING.nearest,\n            RESAMPLING.bilinear,\n            RESAMPLING.cubic,\n            RESAMPLING.cubic_spline,\n            RESAMPLING.lanczos,\n            RESAMPLING.average,\n            RESAMPLING.mode\n    kwargs:  dict, optional\n        Additional arguments passed to transformation function.\n\n    Returns\n    ---------\n    out: None\n        Output is written to destination.\n    \"\"\"\n\n    if src_transform:\n        src_transform = guard_transform(src_transform).to_gdal()\n    if dst_transform:\n        dst_transform = guard_transform(dst_transform).to_gdal()\n\n    _reproject(\n        source,\n        destination,\n        src_transform,\n        src_crs,\n        dst_transform,\n        dst_crs,\n        resampling,\n        **kwargs)\n", "path": "rasterio/warp.py"}, {"content": "# Info command.\n\nimport json\nimport logging\nimport os.path\nimport pprint\nimport sys\n\nimport click\n\nimport rasterio\nimport rasterio.crs\nfrom rasterio.rio.cli import cli\n\n\n@cli.command(short_help=\"Print information about the rio environment.\")\n@click.option('--formats', 'key', flag_value='formats', default=True,\n              help=\"Enumerate the available formats.\")\n@click.pass_context\ndef env(ctx, key):\n    \"\"\"Print information about the Rasterio environment: available\n    formats, etc.\n    \"\"\"\n    verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1\n    logger = logging.getLogger('rio')\n    stdout = click.get_text_stream('stdout')\n    with rasterio.drivers(CPL_DEBUG=(verbosity > 2)) as env:\n        if key == 'formats':\n            for k, v in sorted(env.drivers().items()):\n                stdout.write(\"%s: %s\\n\" % (k, v))\n            stdout.write('\\n')\n\n\n@cli.command(short_help=\"Print information about a data file.\")\n@click.argument('input', type=click.Path(exists=True))\n@click.option('--meta', 'aspect', flag_value='meta', default=True,\n              help=\"Show data file structure (default).\")\n@click.option('--tags', 'aspect', flag_value='tags',\n              help=\"Show data file tags.\")\n@click.option('--namespace', help=\"Select a tag namespace.\")\n@click.option('--indent', default=None, type=int,\n              help=\"Indentation level for pretty printed output\")\n# Options to pick out a single metadata item and print it as\n# a string.\n@click.option('--count', 'meta_member', flag_value='count',\n              help=\"Print the count of bands.\")\n@click.option('--dtype', 'meta_member', flag_value='dtype',\n              help=\"Print the dtype name.\")\n@click.option('--nodata', 'meta_member', flag_value='nodata',\n              help=\"Print the nodata value.\")\n@click.option('-f', '--format', '--driver', 'meta_member', flag_value='driver',\n              help=\"Print the format driver.\")\n@click.option('--shape', 'meta_member', flag_value='shape',\n              help=\"Print the (height, width) shape.\")\n@click.option('--height', 'meta_member', flag_value='height',\n              help=\"Print the height (number of rows).\")\n@click.option('--width', 'meta_member', flag_value='width',\n              help=\"Print the width (number of columns).\")\n@click.option('--crs', 'meta_member', flag_value='crs',\n              help=\"Print the CRS as a PROJ.4 string.\")\n@click.option('--bounds', 'meta_member', flag_value='bounds',\n              help=\"Print the boundary coordinates \"\n                   \"(left, bottom, right, top).\")\n@click.pass_context\ndef info(ctx, input, aspect, indent, namespace, meta_member):\n    \"\"\"Print metadata about the dataset as JSON.\n\n    Optionally print a single metadata item as a string.\n    \"\"\"\n    verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1\n    logger = logging.getLogger('rio')\n    stdout = click.get_text_stream('stdout')\n    try:\n        with rasterio.drivers(CPL_DEBUG=(verbosity > 2)):\n            with rasterio.open(input, 'r-') as src:\n                info = src.meta\n                del info['affine']\n                del info['transform']\n                info['shape'] = info['height'], info['width']\n                info['bounds'] = src.bounds\n                proj4 = rasterio.crs.to_string(src.crs)\n                if proj4.startswith('+init=epsg'):\n                    proj4 = proj4.split('=')[1].upper()\n                info['crs'] = proj4\n                if aspect == 'meta':\n                    if meta_member:\n                        if isinstance(info[meta_member], (list, tuple)):\n                            print(\" \".join(map(str, info[meta_member])))\n                        else:\n                            print(info[meta_member])\n                    else:\n                        stdout.write(json.dumps(info, indent=indent))\n                        stdout.write(\"\\n\")\n                elif aspect == 'tags':\n                    stdout.write(json.dumps(src.tags(ns=namespace), \n                                            indent=indent))\n                    stdout.write(\"\\n\")\n        sys.exit(0)\n    except Exception:\n        logger.exception(\"Failed. Exception caught\")\n        sys.exit(1)\n", "path": "rasterio/rio/info.py"}], "after_files": [{"content": "\"\"\"Raster warping and reprojection\"\"\"\n\nfrom rasterio._base import _transform\nfrom rasterio._warp import _transform_geom, _reproject, RESAMPLING\nfrom rasterio.transform import guard_transform\n\n\ndef transform(src_crs, dst_crs, xs, ys, zs=None):\n    \"\"\"\n    Transform vectors of x, y and optionally z from source\n    coordinate reference system into target.\n\n    Parameters\n    ------------\n    src_crs: dict\n        Source coordinate reference system, in rasterio dict format.\n        Example: {'init': 'EPSG:4326'}\n    dst_crs: dict\n        Target coordinate reference system.\n    xs: array_like\n        Contains x values.  Will be cast to double floating point values.\n    ys:  array_like\n        Contains y values.\n    zs: array_like, optional\n        Contains z values.  Assumed to be all 0 if absent.\n\n    Returns\n    ---------\n    out: tuple of array_like, (xs, ys, [zs])\n    Tuple of x, y, and optionally z vectors, transformed into the target\n    coordinate reference system.\n    \"\"\"\n    return _transform(src_crs, dst_crs, xs, ys, zs)\n\n\ndef transform_geom(\n        src_crs,\n        dst_crs,\n        geom,\n        antimeridian_cutting=False,\n        antimeridian_offset=10.0,\n        precision=-1):\n    \"\"\"\n    Transform geometry from source coordinate reference system into target.\n\n    Parameters\n    ------------\n    src_crs: dict\n        Source coordinate reference system, in rasterio dict format.\n        Example: {'init': 'EPSG:4326'}\n    dst_crs: dict\n        Target coordinate reference system.\n    geom: GeoJSON like dict object\n    antimeridian_cutting: bool, optional\n        If True, cut geometries at the antimeridian, otherwise geometries will\n        not be cut (default).\n    antimeridian_offset: float\n        Offset from the antimeridian in degrees (default: 10) within which\n        any geometries will be split.\n    precision: float\n        If >= 0, geometry coordinates will be rounded to this number of decimal\n        places after the transform operation, otherwise original coordinate\n        values will be preserved (default).\n\n    Returns\n    ---------\n    out: GeoJSON like dict object\n        Transformed geometry in GeoJSON dict format\n    \"\"\"\n\n    return _transform_geom(\n        src_crs,\n        dst_crs,\n        geom,\n        antimeridian_cutting,\n        antimeridian_offset,\n        precision)\n\n\ndef reproject(\n        source,\n        destination,\n        src_transform=None,\n        src_crs=None,\n        dst_transform=None,\n        dst_crs=None,\n        resampling=RESAMPLING.nearest,\n        **kwargs):\n    \"\"\"\n    Reproject a source raster to a destination raster.\n\n    Parameters\n    ------------\n    source: ndarray or rasterio Band\n        Source raster.\n    destination: ndarray or rasterio Band\n        Target raster.\n    src_transform: affine transform object, optional\n        Source affine transformation.  Required if source and destination\n        are ndarrays.  Will be derived from source if it is a rasterio Band.\n    src_crs: dict, optional\n        Source coordinate reference system, in rasterio dict format.\n        Required if source and destination are ndarrays.\n        Will be derived from source if it is a rasterio Band.\n        Example: {'init': 'EPSG:4326'}\n    dst_transform: affine transform object, optional\n        Target affine transformation.  Required if source and destination\n        are ndarrays.  Will be derived from target if it is a rasterio Band.\n    dst_crs: dict, optional\n        Target coordinate reference system.  Required if source and destination\n        are ndarrays.  Will be derived from target if it is a rasterio Band.\n    resampling: int\n        Resampling method to use.  One of the following:\n            RESAMPLING.nearest,\n            RESAMPLING.bilinear,\n            RESAMPLING.cubic,\n            RESAMPLING.cubic_spline,\n            RESAMPLING.lanczos,\n            RESAMPLING.average,\n            RESAMPLING.mode\n    kwargs:  dict, optional\n        Additional arguments passed to transformation function.\n\n    Returns\n    ---------\n    out: None\n        Output is written to destination.\n    \"\"\"\n\n    if src_transform:\n        src_transform = guard_transform(src_transform).to_gdal()\n    if dst_transform:\n        dst_transform = guard_transform(dst_transform).to_gdal()\n\n    _reproject(\n        source,\n        destination,\n        src_transform,\n        src_crs,\n        dst_transform,\n        dst_crs,\n        resampling,\n        **kwargs)\n", "path": "rasterio/warp.py"}, {"content": "# Info command.\n\nimport json\nimport logging\nimport os.path\nimport pprint\nimport sys\n\nimport click\n\nimport rasterio\nimport rasterio.crs\nfrom rasterio.rio.cli import cli\n\n\n@cli.command(short_help=\"Print information about the rio environment.\")\n@click.option('--formats', 'key', flag_value='formats', default=True,\n              help=\"Enumerate the available formats.\")\n@click.pass_context\ndef env(ctx, key):\n    \"\"\"Print information about the Rasterio environment: available\n    formats, etc.\n    \"\"\"\n    verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1\n    logger = logging.getLogger('rio')\n    stdout = click.get_text_stream('stdout')\n    with rasterio.drivers(CPL_DEBUG=(verbosity > 2)) as env:\n        if key == 'formats':\n            for k, v in sorted(env.drivers().items()):\n                stdout.write(\"%s: %s\\n\" % (k, v))\n            stdout.write('\\n')\n\n\n@cli.command(short_help=\"Print information about a data file.\")\n@click.argument('input', type=click.Path(exists=True))\n@click.option('--meta', 'aspect', flag_value='meta', default=True,\n              help=\"Show data file structure (default).\")\n@click.option('--tags', 'aspect', flag_value='tags',\n              help=\"Show data file tags.\")\n@click.option('--namespace', help=\"Select a tag namespace.\")\n@click.option('--indent', default=None, type=int,\n              help=\"Indentation level for pretty printed output\")\n# Options to pick out a single metadata item and print it as\n# a string.\n@click.option('--count', 'meta_member', flag_value='count',\n              help=\"Print the count of bands.\")\n@click.option('--dtype', 'meta_member', flag_value='dtype',\n              help=\"Print the dtype name.\")\n@click.option('--nodata', 'meta_member', flag_value='nodata',\n              help=\"Print the nodata value.\")\n@click.option('-f', '--format', '--driver', 'meta_member', flag_value='driver',\n              help=\"Print the format driver.\")\n@click.option('--shape', 'meta_member', flag_value='shape',\n              help=\"Print the (height, width) shape.\")\n@click.option('--height', 'meta_member', flag_value='height',\n              help=\"Print the height (number of rows).\")\n@click.option('--width', 'meta_member', flag_value='width',\n              help=\"Print the width (number of columns).\")\n@click.option('--crs', 'meta_member', flag_value='crs',\n              help=\"Print the CRS as a PROJ.4 string.\")\n@click.option('--bounds', 'meta_member', flag_value='bounds',\n              help=\"Print the boundary coordinates \"\n                   \"(left, bottom, right, top).\")\n@click.option('--res', 'meta_member', flag_value='res',\n              help=\"Print pixel width and height.\")\n@click.option('--lnglat', 'meta_member', flag_value='lnglat',\n              help=\"Print longitude and latitude at center.\")\n@click.option('--stats', 'meta_member', flag_value='stats',\n              help=\"Print statistics (min, max, mean) of a single band \"\n                   \"(use --bidx).\")\n@click.option('-v', '--tell-me-more', '--verbose', is_flag=True,\n              help=\"Output extra information.\")\n@click.option('--bidx', type=int, default=1,\n              help=\"Input file band index (default: 1).\")\n@click.pass_context\ndef info(ctx, input, aspect, indent, namespace, meta_member, verbose, bidx):\n    \"\"\"Print metadata about the dataset as JSON.\n\n    Optionally print a single metadata item as a string.\n    \"\"\"\n    verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1\n    logger = logging.getLogger('rio')\n    mode = 'r' if (verbose or meta_member == 'stats') else 'r-'\n    try:\n        with rasterio.drivers(CPL_DEBUG=(verbosity > 2)):\n            with rasterio.open(input, mode) as src:\n                info = src.meta\n                del info['affine']\n                del info['transform']\n                info['shape'] = info['height'], info['width']\n                info['bounds'] = src.bounds\n                proj4 = rasterio.crs.to_string(src.crs)\n                if proj4.startswith('+init=epsg'):\n                    proj4 = proj4.split('=')[1].upper()\n                info['crs'] = proj4\n                if verbose:\n                    stats = [{'min': float(b.min()),\n                              'max': float(b.max()),\n                              'mean': float(b.mean())} for b in src.read()]\n                    info['stats'] = stats\n                if aspect == 'meta':\n                    if meta_member == 'stats':\n                        band = src.read(bidx)\n                        click.echo('%f %f %f' % (\n                            float(band.min()),\n                            float(band.max()),\n                            float(band.mean())))\n                    elif meta_member:\n                        if isinstance(info[meta_member], (list, tuple)):\n                            click.echo(\" \".join(map(str, info[meta_member])))\n                        else:\n                            click.echo(info[meta_member])\n                    else:\n                        click.echo(json.dumps(info, indent=indent))\n                elif aspect == 'tags':\n                    click.echo(json.dumps(src.tags(ns=namespace), \n                                            indent=indent))\n        sys.exit(0)\n    except Exception:\n        logger.exception(\"Failed. Exception caught\")\n        sys.exit(1)\n", "path": "rasterio/rio/info.py"}]}