Created
August 11, 2020 23:39
-
-
Save giswqs/56280802160f9959f4fdb6fcab0c5932 to your computer and use it in GitHub Desktop.
mcd19a2 v2.ipynb
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": [ | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "import ee\nimport geemap\nimport os", | |
"execution_count": 1, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "Map = geemap.Map()\nMap", | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "display_data", | |
"data": { | |
"text/plain": "Map(center=[40, -100], controls=(WidgetControl(options=['position'], widget=HBox(children=(ToggleButton(value=…", | |
"application/vnd.jupyter.widget-view+json": { | |
"version_major": 2, | |
"version_minor": 0, | |
"model_id": "febbac10715b436ea811a32f8e77f09f" | |
} | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "feature = Map.draw_last_feature\nroi = feature.geometry()", | |
"execution_count": 3, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "collection = ee.ImageCollection('MODIS/006/MCD19A2_GRANULES') \\\n .filterDate('2003-01-01', '2003-01-02') \\\n .filterBounds(roi) \\\n .select('Optical_Depth_047')", | |
"execution_count": 4, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "image = collection.first()", | |
"execution_count": 5, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "geemap.image_props(image).getInfo()", | |
"execution_count": 6, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 6, | |
"data": { | |
"text/plain": "{'ALGORITHMPACKAGENAME': 'MOD_PR19',\n 'ALGORITHMPACKAGEVERSION': '2.0',\n 'DESCRREVISION': '6.1',\n 'IMAGE_DATE': '2003-01-01',\n 'LOCALVERSIONID': 'SCF V6.0.32',\n 'NOMINAL_SCALE': 926.6254330554174,\n 'PGEVERSION': '6.0.35',\n 'PRODUCTIONDATETIME': 1516294681000,\n 'SATELLITE': 'A',\n 'system:asset_size': '0.024842 MB',\n 'system:band_names': ['Optical_Depth_047'],\n 'system:id': 'MODIS/006/MCD19A2_GRANULES/MCD19A2_A2003001_h27v04_006_2018018165801_01',\n 'system:index': 'MCD19A2_A2003001_h27v04_006_2018018165801_01',\n 'system:time_end': '2003-01-01 01:30:00',\n 'system:time_start': '2003-01-01 01:30:00',\n 'system:version': 1557705483290787}" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "collection.size().getInfo()", | |
"execution_count": 7, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 7, | |
"data": { | |
"text/plain": "27" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "mosaic = collection.mosaic()", | |
"execution_count": 8, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "geemap.image_stats(mosaic, region=roi).getInfo()", | |
"execution_count": 9, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 9, | |
"data": { | |
"text/plain": "{'max': {'Optical_Depth_047': 469},\n 'mean': {'Optical_Depth_047': 129.04531297096352},\n 'min': {'Optical_Depth_047': 0},\n 'std': {'Optical_Depth_047': 97.7659827175375},\n 'sum': {'Optical_Depth_047': 5036.815686274509}}" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "Map.addLayer(mosaic, {'min': 0, 'max': 500, 'palette': ['blue', 'red']}, 'mosaic')", | |
"execution_count": 10, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "Map", | |
"execution_count": 11, | |
"outputs": [ | |
{ | |
"output_type": "display_data", | |
"data": { | |
"text/plain": "Map(bottom=3401.0, center=[39.16414104768742, -225.02197265625003], controls=(WidgetControl(options=['position…", | |
"application/vnd.jupyter.widget-view+json": { | |
"version_major": 2, | |
"version_minor": 0, | |
"model_id": "febbac10715b436ea811a32f8e77f09f" | |
} | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "image.projection().getInfo()", | |
"execution_count": 12, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 12, | |
"data": { | |
"text/plain": "{'type': 'Projection',\n 'crs': 'SR-ORG:6974',\n 'transform': [926.6254330558345,\n 0,\n 10007554.677,\n 0,\n -926.6254330550003,\n 5559752.598333]}" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "reproject = mosaic.reproject('EPSG:4326', None, 1000)", | |
"execution_count": 13, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "reproject.projection().getInfo()", | |
"execution_count": 14, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 14, | |
"data": { | |
"text/plain": "{'type': 'Projection',\n 'crs': 'EPSG:4326',\n 'transform': [0.008983152841195215, 0, 0, 0, -0.008983152841195215, 0]}" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "Map.addLayer(reproject, {'min': 0, 'max': 500, 'palette': ['blue', 'red']}, 'reproject')", | |
"execution_count": 15, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "out_dir = os.path.join(os.path.expanduser('~'), 'Downloads')", | |
"execution_count": 16, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "out_file = os.path.join(out_dir, 'modis.tif')", | |
"execution_count": 17, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "geemap.ee_export_image(reproject, out_file, region=roi, scale=1000)", | |
"execution_count": 18, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "Generating URL ...\nDownloading data from https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/9dd272782e5e21d10db413e1ff68b03d-ef48bb4814f8ded9c5ea839312781622:getPixels\nPlease wait ...\nData downloaded to /home/qiusheng/Downloads/modis.tif\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3", | |
"language": "python" | |
}, | |
"language_info": { | |
"name": "python", | |
"version": "3.8.2", | |
"mimetype": "text/x-python", | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"pygments_lexer": "ipython3", | |
"nbconvert_exporter": "python", | |
"file_extension": ".py" | |
}, | |
"varInspector": { | |
"window_display": false, | |
"cols": { | |
"lenName": 16, | |
"lenType": 16, | |
"lenVar": 40 | |
}, | |
"kernels_config": { | |
"python": { | |
"library": "var_list.py", | |
"delete_cmd_prefix": "del ", | |
"delete_cmd_postfix": "", | |
"varRefreshCmd": "print(var_dic_list())" | |
}, | |
"r": { | |
"library": "var_list.r", | |
"delete_cmd_prefix": "rm(", | |
"delete_cmd_postfix": ") ", | |
"varRefreshCmd": "cat(var_dic_list()) " | |
} | |
}, | |
"types_to_exclude": [ | |
"module", | |
"function", | |
"builtin_function_or_method", | |
"instance", | |
"_Feature" | |
] | |
}, | |
"hide_input": false, | |
"toc": { | |
"nav_menu": {}, | |
"number_sections": true, | |
"sideBar": true, | |
"skip_h1_title": true, | |
"base_numbering": 1, | |
"title_cell": "Table of Contents", | |
"title_sidebar": "Table of Contents", | |
"toc_cell": false, | |
"toc_position": { | |
"height": "calc(100% - 180px)", | |
"width": "380px", | |
"left": "10px", | |
"top": "150px" | |
}, | |
"toc_section_display": true, | |
"toc_window_display": true | |
}, | |
"gist": { | |
"id": "", | |
"data": { | |
"description": "mcd19a2 v2.ipynb", | |
"public": true | |
} | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment