{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Uncomment the following line to install [geemap](https://geemap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# !pip install geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import geemap\n", "import ee\n", "\n", "ee.Initialize()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "band1 = np.array([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]])\n", "band2 = np.array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]])\n", "band3 = np.array([[3, 3, 3, 3], [2, 2, 2, 2], [1, 1, 1, 1]])\n", "data = np.dstack([band1, band2, band3])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Test bad input\n", "img = geemap.numpy_to_ee(1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Test with only one band:\n", "img = geemap.numpy_to_ee(\n", " band1, crs='EPSG:4326', transform=[14.5, 0, -125, 0, -8, 49], band_names='a'\n", ")\n", "# Test with multiple bands:\n", "img_multi = geemap.numpy_to_ee(\n", " data,\n", " crs='EPSG:4326',\n", " transform=[14.5, 0, -125, 0, -8, 49],\n", " band_names=['a', 'b', 'c'],\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Add images to a map\n", "Map = geemap.Map()\n", "Map.addLayer(img, {'min': 0, 'max': 11})\n", "Map.addLayer(img_multi, {'min': 0, 'max': 11, 'bands': ['a', 'b', 'c']})\n", "Map" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }