Created
April 21, 2021 22:08
-
-
Save jdbcode/e7105fcbb376673b1c48ef0e6383fc13 to your computer and use it in GitHub Desktop.
naip_in_earth_engine.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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "naip_in_earth_engine.ipynb", | |
"provenance": [], | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/jdbcode/e7105fcbb376673b1c48ef0e6383fc13/naip_in_earth_engine.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "RM1yFZ79b_JW" | |
}, | |
"source": [ | |
"import ee\n", | |
"ee.Authenticate()\n", | |
"ee.Initialize()" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "I81fLOL2cpbf" | |
}, | |
"source": [ | |
"import folium\n", | |
"\n", | |
"\n", | |
"def add_ee_layer(self, ee_image_object, vis_params, name):\n", | |
" map_id_dict = ee.Image(ee_image_object).getMapId(vis_params)\n", | |
" folium.raster_layers.TileLayer(\n", | |
" tiles=map_id_dict['tile_fetcher'].url_format,\n", | |
" attr='Map Data © <a href=\"https://earthengine.google.com/\">Google Earth Engine</a>',\n", | |
" name=name,\n", | |
" overlay=True,\n", | |
" control=True\n", | |
" ).add_to(self)\n", | |
"\n", | |
"folium.Map.add_ee_layer = add_ee_layer" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "SeLUNTkPcJsv" | |
}, | |
"source": [ | |
"naip_col = (ee.ImageCollection('USDA/NAIP/DOQQ')\n", | |
" .filter(ee.Filter.date('2017-01-01', '2018-12-31')));\n", | |
"\n", | |
"rgb_bands = naip_col.select(['R', 'G', 'B']);\n", | |
"\n", | |
"vis_params = {\n", | |
" min: 0.0,\n", | |
" max: 255.0,\n", | |
"};\n", | |
"\n", | |
"lon, lat, zoom = -73.9958, 40.7278, 15\n", | |
"naip_map = folium.Map(location=[lat, lon], zoom_start=zoom)\n", | |
"\n", | |
"naip_map.add_ee_layer(rgb_bands.mosaic(), vis_params, 'NAIP composite, 2017-2018')\n", | |
"display(naip_map.add_child(folium.LayerControl()))" | |
], | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment