mirror of
https://github.com/rasterio/rasterio.git
synced 2025-12-08 17:36:12 +00:00
Remove cells.
This commit is contained in:
parent
03a636fa9f
commit
2fee71152d
@ -1,7 +1,7 @@
|
||||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:1f4a71e4b75cc1f61fe31b06e7896548a61c21374da560610a923999cf0800f6"
|
||||
"signature": "sha256:668cc72f84bf7467ee8cfef29fc14ef9cd1fd272e3352c5152ded54490865f5e"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
@ -212,7 +212,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"You can't read from or write to a closed dataset, but you"
|
||||
"You can't read from or write to a closed dataset, but you can access its properties."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -235,72 +235,6 @@
|
||||
],
|
||||
"prompt_number": 23
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"with rasterio.drivers(CPL_DEBUG=True):\n",
|
||||
"\n",
|
||||
" # Read raster bands directly to Numpy arrays.\n",
|
||||
" with rasterio.open('../tests/data/RGB.byte.tif') as src:\n",
|
||||
" r, g, b = src.read()\n",
|
||||
"\n",
|
||||
" # Combine arrays using the 'iadd' ufunc. Expecting that the sum will\n",
|
||||
" # exceed the 8-bit integer range, initialize it as 16-bit. Adding other\n",
|
||||
" # arrays to it in-place converts those arrays up and preserves the type\n",
|
||||
" # of the total array.\n",
|
||||
" total = np.zeros(r.shape, dtype=rasterio.uint16)\n",
|
||||
" for band in (r, g, b):\n",
|
||||
" total += band\n",
|
||||
" total /= 3\n",
|
||||
"\n",
|
||||
" # Write the product as a raster band to a new 8-bit file. For keyword\n",
|
||||
" # arguments, we start with the meta attributes of the source file, but\n",
|
||||
" # then change the band count to 1, set the dtype to uint8, and specify\n",
|
||||
" # LZW compression.\n",
|
||||
" kwds = src.meta\n",
|
||||
" kwds.update(\n",
|
||||
" dtype=rasterio.uint8,\n",
|
||||
" count=1,\n",
|
||||
" compress='lzw')\n",
|
||||
"\n",
|
||||
" with rasterio.open('output.tif', 'w', **kwds) as dst:\n",
|
||||
" dst.write_band(1, total.astype(rasterio.uint8))"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 9
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"%matplotlib inline"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 8
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"import matplotlib.pyplot as plt"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user