Skip to content

Instantly share code, notes, and snippets.

@giswqs
Created August 7, 2020 14:17
Show Gist options
  • Save giswqs/90221083a85a640df7e929679a6dbf87 to your computer and use it in GitHub Desktop.
Save giswqs/90221083a85a640df7e929679a6dbf87 to your computer and use it in GitHub Desktop.
modis download
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "import ee\nimport geemap\nimport os",
"execution_count": 11,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "Map = geemap.Map()\nMap",
"execution_count": 12,
"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": "d2eee84f26934692bc451a2f6197c987"
}
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "# feature = Map.draw_last_feature\n# roi = feature.geometry()",
"execution_count": 13,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "roi = ee.Geometry.Point(-221.427096, 36.579695)",
"execution_count": 14,
"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": 16,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "image = collection.first()",
"execution_count": 17,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "geemap.image_props(image).getInfo()",
"execution_count": 18,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 18,
"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.6254330558331,\n 'PGEVERSION': '6.0.35',\n 'PRODUCTIONDATETIME': 1516291561000,\n 'SATELLITE': 'T',\n 'system:asset_size': '3.459874 MB',\n 'system:band_names': ['Optical_Depth_047'],\n 'system:id': 'MODIS/006/MCD19A2_GRANULES/MCD19A2_A2003001_h29v05_006_2018018160601_01',\n 'system:index': 'MCD19A2_A2003001_h29v05_006_2018018160601_01',\n 'system:time_end': '2003-01-01 01:35:00',\n 'system:time_start': '2003-01-01 01:35:00',\n 'system:version': 1557713431394822}"
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "collection.size().getInfo()",
"execution_count": 19,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 19,
"data": {
"text/plain": "3"
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "image = collection.toBands()",
"execution_count": 20,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "out_dir = os.path.join(os.path.expanduser('~'), 'Downloads')",
"execution_count": 21,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "out_file = os.path.join(out_dir, 'modis.tif')",
"execution_count": 22,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "# geemap.ee_export_image_collection(collection, out_dir=out_dir, region=roi)",
"execution_count": null,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "geemap.ee_export_image(image, out_file)",
"execution_count": 23,
"outputs": [
{
"output_type": "stream",
"text": "Generating URL ...\nDownloading data from https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/thumbnails/9d4490731049cffd4183169e7036d2b0-abeb738918f87db0835d8572cb3a1211: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": {},
"toc_section_display": true,
"toc_window_display": true
},
"gist": {
"id": "",
"data": {
"description": "modis download",
"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