Last active
December 10, 2023 14:30
-
-
Save jdbcode/794875b4fb7f28bf5ec6eee5e917e0c9 to your computer and use it in GitHub Desktop.
ee_landsat_8_mean_composite
This file contains hidden or 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": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/jdbcode/794875b4fb7f28bf5ec6eee5e917e0c9/ee_landsat_8_mean_composite.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"id": "lIYdn1woOS1n" | |
}, | |
"outputs": [], | |
"source": [ | |
"import ee\n", | |
"import geemap\n", | |
"geemap.ee_initialize()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"def prepare_sr(image):\n", | |
" qa_mask = image.select('QA_PIXEL').bitwiseAnd(int('11111', 2)).eq(0)\n", | |
" optical_bands = image.select('SR_B.').multiply(0.0000275).add(-0.2)\n", | |
" return image.select().addBands(optical_bands).updateMask(qa_mask)\n", | |
"\n", | |
"composite = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2').filterDate(\n", | |
" '2020-06-01', '2021-10-01').map(prepare_sr).mean()\n", | |
"\n", | |
"m = geemap.Map()\n", | |
"m.set_center(-122.3645, 37.7978, 12)\n", | |
"m.add_layer(composite, {'bands': ['SR_B4', 'SR_B3', 'SR_B2'], 'min': 0, 'max': 0.3})\n", | |
"m" | |
], | |
"metadata": { | |
"id": "PSThvVd7VYKU" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"colab": { | |
"name": "ee_landsat_8_mean_composite.ipynb", | |
"provenance": [], | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"display_name": "Python 3", | |
"name": "python3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment