Created
August 20, 2019 21:20
-
-
Save scottyhq/836d1f766e48e1e0fd10d0d2c2d2a2d1 to your computer and use it in GitHub Desktop.
test merging overlapping images with gdal python pixel function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test gdal vrt pixel functions\n", | |
"\n", | |
"Use GDAL python pixel function to define how overlapping image regions are dealt with" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import matplotlib.pyplot as plt\n", | |
"import rasterio\n", | |
"from rasterio.transform import Affine\n", | |
"import rasterio.plot\n", | |
"import numpy as np" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Create two simple rasters, create vrts overlapping by 1 degree, use pixel functions to mosaiic\n", | |
"x = np.linspace(-4.0, 4.0, 240)\n", | |
"y = np.linspace(2.0, 8.0, 180)\n", | |
"X, Y = np.meshgrid(x, y)\n", | |
"Z1 = np.ones_like(X)\n", | |
"\n", | |
"Z1[:10,:] = 0 #or np.nan?\n", | |
"Z1[:,:10] = 0\n", | |
"\n", | |
"Z1c = Z1.astype('complex64') + 1j\n", | |
"\n", | |
"res = (x[-1] - x[0]) / 240.0\n", | |
"transform1 = Affine.translation(x[0] - res / 2, y[-1] - res / 2) * Affine.scale(res, -res)\n", | |
"transform1\n", | |
"\n", | |
"with rasterio.open('top-complex.tif', 'w',\n", | |
" driver='GTiff',\n", | |
" height=Z1c.shape[0],\n", | |
" width=Z1c.shape[1],\n", | |
" #nodata=np.nan, #0 #throwing KeyError: 'complex64'... likely a bug\n", | |
" count=1,\n", | |
" dtype=Z1c.dtype,\n", | |
" crs='+proj=latlong',\n", | |
" transform=transform1,\n", | |
" # creation options\n", | |
" blockxsize=128,\n", | |
" blockysize=128,\n", | |
" tiled=True,\n", | |
" ) as dst:\n", | |
" dst.write(Z1c, 1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Create two simple rasters, create vrts overlapping by 1 degree, use pixel functions to mosaiic\n", | |
"x = np.linspace(-4.0, 4.0, 240)\n", | |
"y = np.linspace(-3.0, 3.0, 180)\n", | |
"X, Y = np.meshgrid(x, y)\n", | |
"Z2 = 2*np.ones_like(X)\n", | |
"\n", | |
"Z2[-10:,:] = 0\n", | |
"Z2[:,-10:] = 0\n", | |
"\n", | |
"Z2c = Z2.astype('complex64') + 2j\n", | |
"\n", | |
"res = (x[-1] - x[0]) / 240.0\n", | |
"transform2 = Affine.translation(x[0] - res / 2, y[-1] - res / 2) * Affine.scale(res, -res)\n", | |
"transform2\n", | |
"\n", | |
"with rasterio.open('bottom-complex.tif', 'w',\n", | |
" driver='GTiff',\n", | |
" height=Z2c.shape[0],\n", | |
" width=Z2c.shape[1],\n", | |
" #nodata=np.nan,\n", | |
" count=1,\n", | |
" dtype=Z2c.dtype,\n", | |
" crs='+proj=latlong',\n", | |
" transform=transform2,\n", | |
" # creation options\n", | |
" blockxsize=128,\n", | |
" blockysize=128,\n", | |
" tiled=True,\n", | |
" ) as dst:\n", | |
" dst.write(Z2c, 1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"{'driver': 'GTiff', 'dtype': 'complex64', 'nodata': None, 'width': 240, 'height': 180, 'count': 1, 'crs': CRS.from_epsg(4326), 'transform': Affine(0.03333333333333333, 0.0, -4.016666666666667,\n", | |
" 0.0, -0.03333333333333333, 7.983333333333333), 'blockxsize': 128, 'blockysize': 128, 'tiled': True, 'interleave': 'band'}\n", | |
"{'driver': 'GTiff', 'dtype': 'complex64', 'nodata': None, 'width': 240, 'height': 180, 'count': 1, 'crs': CRS.from_epsg(4326), 'transform': Affine(0.03333333333333333, 0.0, -4.016666666666667,\n", | |
" 0.0, -0.03333333333333333, 2.9833333333333334), 'blockxsize': 128, 'blockysize': 128, 'tiled': True, 'interleave': 'band'}\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"(-3, 8)" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD8CAYAAACxd9IeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAWGklEQVR4nO3de5AdZZnH8e+Pc2ZA7kgghCQo61IWeGHFFODGWsALBgQtqywXVHBRK6ulrlpe1kutt/3HKnZdtRDdFLIsBWi5SpTaighrueVtoQwRLxiwsiELuZNECAg6c2ae/aM78TCZOaffOZ3pPtO/T9WpmdP99ttvUvXM2/322++jiMDM5r9Dqm6Amc0NB7tZQzjYzRrCwW7WEA52s4ZwsJs1RCnBLun9ku6T9GtJX5N0WBn1ms1XkpZK+oGk9XnsvHeaMpL0RUkbJP1S0lld+1ZIeiDf95Ei5xw42CUtBv4OWBYRzwdawGWD1ms2z3WAD0TE6cC5wLsknTGlzEXAaflnJfBlAEkt4Ev5/jOAy6c59gBlXca3gWdIagOHA1tLqtdsXoqIbRGxLv/9cWA9sHhKsdcCN0bmLuBYSYuAs4ENEbExIsaAr+dle2qX0Ogtkv4JeAh4CrgjIu6YWk7SSrK/Thw6cuiLFy2Y+u8yO7g2bdu4KyJOGKSOV73i9Ni95/eFyt7z84fvA/7QtWlVRKyaWk7Ss4EXAXdP2bUYeLjr++Z823Tbz+nXnoGDXdJxZH9VTgUeBf5D0psj4qbucvk/chXAqSc/J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Vaos2CW9BtgSEb+oqg0F9UxFPUdmmjZZO5KeDbwIuLvaljzN58k6lcmqG1Klg/qcvVe6Z+BjwIUH8/y9lJWKeo7ManrkXJN0JPAt4H0Rsbfq9gBIugTYGRH3SDq/6vZU6aAG+0zpniW9ADgV+EWeEHIJsE7S2RGx/WC2qV/b9qlZKuoiUysrJWmELNBvjohbq25Pl+XAayRdDBwGHC3ppoh4c8XtmnO1mFQjaROwLCJq8bZUnor6c2SpqCtfXVBSm2yg8OXAFrLpkm8sMmtqLij7i/3vwJ6IeF/V7ZlJ3rN/MCIuqbotVah6gK6urgGOIktFfa+kr1TZmHywcN/0yPXAN+oS6LnlwBXAy/L/r3vzntRqpBY9u5kdfO7ZzRrCwW7WEA52s4ZwsJs1hIPdrCEc7GYN4WA3a4j/B3OReNmnW+ulAAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 2 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"fig,ax = plt.subplots()\n", | |
"\n", | |
"with rasterio.open('top-complex.tif') as src:\n", | |
" print(src.profile)\n", | |
" data = src.read(1)\n", | |
" extent = (src.bounds.left, src.bounds.right, src.bounds.bottom, src.bounds.top) #(left, right, bottom, top)\n", | |
" plt.imshow(data.real, vmin=0, vmax=2, alpha=0.5, extent=extent)\n", | |
" \n", | |
"with rasterio.open('bottom-complex.tif') as src:\n", | |
" print(src.profile)\n", | |
" data = src.read(1)\n", | |
" extent = (src.bounds.left, src.bounds.right, src.bounds.bottom, src.bounds.top) \n", | |
" plt.imshow(data.real, vmin=0, vmax=2, alpha=0.5, extent=extent)\n", | |
"\n", | |
"plt.colorbar(ax.get_images()[0])\n", | |
"plt.xlim(-4,4)\n", | |
"plt.ylim(-3,8)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Overwriting merged-average-complex.vrt\n" | |
] | |
} | |
], | |
"source": [ | |
"%%writefile merged-average-complex.vrt\n", | |
"\n", | |
"<VRTDataset rasterXSize=\"240\" rasterYSize=\"330\">\n", | |
" <SRS>GEOGCS[\"WGS 84\",DATUM[\"unknown\",SPHEROID[\"WGS84\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]]</SRS>\n", | |
" <GeoTransform> -4.0166666666666666e+00, 3.3333333333333333e-02, 0.0000000000000000e+00, 7.9833333333333334e+00, 0.0000000000000000e+00, -3.3333333333333333e-02</GeoTransform>\n", | |
" <VRTRasterBand dataType=\"CFloat32\" band=\"1\" subClass=\"VRTDerivedRasterBand\">\n", | |
" \n", | |
" <PixelFunctionType>average</PixelFunctionType>\n", | |
" <PixelFunctionLanguage>Python</PixelFunctionLanguage>\n", | |
" <PixelFunctionCode><![CDATA[\n", | |
"\n", | |
"def average(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize, raster_ysize, buf_radius, gt, **kwargs):\n", | |
" \"\"\" Average overlapping VRTs where (data.reals != 0) \"\"\"\n", | |
" import numpy as np\n", | |
" stack = np.dstack(in_ar)\n", | |
" indValid = (stack.real != 0)\n", | |
" zero2nodata = np.where(indValid, stack, 0)\n", | |
" total = np.sum(zero2nodata, axis=-1)\n", | |
" count = np.sum(indValid.astype(int), axis=-1)\n", | |
" out_ar[:] = total / count\n", | |
" \n", | |
" ]]>\n", | |
" </PixelFunctionCode>\n", | |
" \n", | |
" <SimpleSource>\n", | |
" <SourceFilename relativeToVRT=\"1\">top-complex.tif</SourceFilename>\n", | |
" <SourceBand>1</SourceBand>\n", | |
" <SourceProperties RasterXSize=\"240\" RasterYSize=\"180\" DataType=\"CFloat32\" BlockXSize=\"128\" BlockYSize=\"128\" />\n", | |
" <SrcRect xOff=\"0\" yOff=\"0\" xSize=\"240\" ySize=\"180\" />\n", | |
" <DstRect xOff=\"0\" yOff=\"0\" xSize=\"240\" ySize=\"180\" />\n", | |
" </SimpleSource>\n", | |
" \n", | |
" <SimpleSource>\n", | |
" <SourceFilename relativeToVRT=\"1\">bottom-complex.tif</SourceFilename>\n", | |
" <SourceBand>1</SourceBand>\n", | |
" <SourceProperties RasterXSize=\"240\" RasterYSize=\"180\" DataType=\"CFloat32\" BlockXSize=\"128\" BlockYSize=\"128\" />\n", | |
" <SrcRect xOff=\"0\" yOff=\"0\" xSize=\"240\" ySize=\"180\" />\n", | |
" <DstRect xOff=\"0\" yOff=\"150\" xSize=\"240\" ySize=\"180\" />\n", | |
" </SimpleSource>\n", | |
" \n", | |
" </VRTRasterBand>\n", | |
"</VRTDataset>\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"{'driver': 'VRT', 'dtype': 'complex64', 'nodata': None, 'width': 240, 'height': 330, 'count': 1, 'crs': CRS.from_epsg(4326), 'transform': Affine(0.03333333333333333, 0.0, -4.016666666666667,\n", | |
" 0.0, -0.03333333333333333, 7.983333333333333), 'blockxsize': 128, 'blockysize': 128, 'tiled': True}\n" | |
] | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"gdal_vrt_module_0x55cf1cb6f9c0:15: RuntimeWarning: invalid value encountered in true_divide\n" | |
] | |
} | |
], | |
"source": [ | |
"with rasterio.Env(GDAL_VRT_ENABLE_PYTHON=True):\n", | |
" with rasterio.open('merged-average-complex.vrt') as src:\n", | |
" print(src.profile)\n", | |
" #print(src.read(1)[0:5])\n", | |
" data = src.read(1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAEICAYAAACK3Vc9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+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JulnTDxOfUJB0u6SpJt9U/D2u5zcdM3zZVm5LOq5+XWyWdPMA+nC/pe/VzcYOk0wbchyWSvixpu6Rtkt5crx/qc2Htc55nV56d5QGJiJEtwFzgO8BTgYOAG4EVQ2r7DmDBPuv+DDi3vn0u8N6W23wRcAKwtalNYEX9fBwMHFM/T3MH1Ifzgd+fZN9B9WERcEJ9ez7w7bqtoV/VzisAAAIrSURBVD4XXtpdnOfZl2dneTDLqN8xrwJ2RMR3I+JnwGVUU5iNympgQ317A3B6mw8eEdcA9yfbXA1cFhEPR8TtVKP6Vg2oD/szqD7sjojr69sPAtupZsMZ6nNhrXOeZ1meneXBGHVh3t90ZcMQwJckbZG0tl53ZNSfMat/HjGEfuyvzWE/N29U9e0nl/Scdhp4H1TNM/sc4BuU81zYzDjP5fwbHnqeneX2jLowj3LqwRdExAlU3/5xjqQXDandrGE+NxcBTwOOp5rD9f3D6IOkQ4DPAG+JiAem2nWQ/bDWOM/7d0Dn2Vlu16gL88imHoyIXfXPPcBnqU6n3C1pEUD9c88QurK/Nof23ETE3RExFhHjwId59NTSwPogaR5VkD8ZEZfXq0f+XFhfnOcC/g0PO8/OcvtGXZi/CSyXdIykg4A1VFOYDZSkJ0maP3EbeCmwtW77zHq3M4ErBt2XKdrcBKyRdLCkY6i+z/O6QXRgIkC1l1M9FwPrgyQBHwW2R8QHejaN/LmwvjjPBfwbHmaeneUBGfXoM6rpyr5NNTrvD4fU5lOpRgbeCGybaBd4CnA1cFv98/CW272U6tTSI1RHjmdP1Sbwh/Xzcitw6gD78HHgZuAmquAsGnAfXkh1+uom4IZ6OW3Yz4WX9hfneXbl2VkezOIpOc3MzAoy6lPZZmZm1sOF2czMrCAuzGZmZgVxYTYzMyuIC7OZmVlBXJjNzMwK4sJsZmZWkP8HseCZQhB9HJEAAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<Figure size 576x288 with 4 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"fig,(ax1,ax2) = plt.subplots(1,2, figsize=(8,4))\n", | |
"plt.sca(ax1)\n", | |
"plt.imshow(data.real, vmin=1, vmax=2)\n", | |
"plt.colorbar()\n", | |
"plt.title('real part')\n", | |
"\n", | |
"plt.sca(ax2)\n", | |
"plt.imshow(data.imag, vmin=1, vmax=2)\n", | |
"plt.colorbar()\n", | |
"plt.title('imaginary part');" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment