Skip to content

Instantly share code, notes, and snippets.

@giswqs
Created October 7, 2020 14:11
Show Gist options
  • Save giswqs/46c65e535e893ae011b430d86702f1e5 to your computer and use it in GitHub Desktop.
Save giswqs/46c65e535e893ae011b430d86702f1e5 to your computer and use it in GitHub Desktop.
get imagecollection dates
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "import ee\nimport geemap",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "Map = geemap.Map()",
"execution_count": 2,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "dataset = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR').limit(10)",
"execution_count": 3,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "dates = ee.ImageCollection(dataset).aggregate_array('system:time_start')",
"execution_count": 4,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "dates.getInfo()",
"execution_count": 5,
"outputs": [
{
"data": {
"text/plain": "[1400940473520,\n 1402322883990,\n 1403705285830,\n 1405087694720,\n 1406470097888,\n 1407852506320,\n 1431353246200,\n 1434118059050,\n 1435500465090,\n 1436882875680]"
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "dates.map(lambda d: ee.Date(d).format('YYYY-MM-dd')).getInfo()",
"execution_count": 6,
"outputs": [
{
"data": {
"text/plain": "['2014-05-24',\n '2014-06-09',\n '2014-06-25',\n '2014-07-11',\n '2014-07-27',\n '2014-08-12',\n '2015-05-11',\n '2015-06-12',\n '2015-06-28',\n '2015-07-14']"
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
]
}
],
"metadata": {
"hide_input": false,
"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"
},
"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
},
"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"
]
},
"gist": {
"id": "",
"data": {
"description": "get imagecollection dates",
"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