{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "\"Open\n", "\n", "Uncomment the following line to install [geemap](https://geemap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "# !pip install geemap" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": {}, "outputs": [], "source": [ "import geemap\n", "import json\n", "import os\n", "import requests\n", "from geemap import geojson_to_ee, ee_to_geojson\n", "from ipyleaflet import GeoJSON, Marker, MarkerCluster" ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": {}, "outputs": [], "source": [ "geemap.show_youtube(\"4HycJPrwpuo\")" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": {}, "outputs": [], "source": [ "file_path = os.path.abspath(\"../data/us_cities.json\")\n", "\n", "if not os.path.exists(file_path):\n", " url = \"https://github.com/gee-community/geemap/raw/master/examples/data/us_cities.json\"\n", " r = requests.get(url)\n", " with open(file_path, \"w\") as f:\n", " f.write(r.content.decode(\"utf-8\"))\n", "\n", "with open(file_path) as f:\n", " json_data = json.load(f)" ] }, { "cell_type": "code", "execution_count": null, "id": "6", "metadata": {}, "outputs": [], "source": [ "maker_cluster = MarkerCluster(\n", " markers=[\n", " Marker(location=feature[\"geometry\"][\"coordinates\"][::-1])\n", " for feature in json_data[\"features\"]\n", " ],\n", " name=\"Markers\",\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "7", "metadata": {}, "outputs": [], "source": [ "Map.add_layer(maker_cluster)" ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "ee_fc = geojson_to_ee(json_data)\n", "Map.addLayer(ee_fc, {}, \"US Cities EE\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }