06 marker cluster
Uncomment the following line to install geemap if needed.
In [ ]:
Copied!
# !pip install geemap
# !pip install geemap
In [ ]:
Copied!
import geemap
import json
import os
import requests
from geemap import geojson_to_ee, ee_to_geojson
from ipyleaflet import GeoJSON, Marker, MarkerCluster
import geemap
import json
import os
import requests
from geemap import geojson_to_ee, ee_to_geojson
from ipyleaflet import GeoJSON, Marker, MarkerCluster
In [ ]:
Copied!
geemap.show_youtube("4HycJPrwpuo")
geemap.show_youtube("4HycJPrwpuo")
In [ ]:
Copied!
Map = geemap.Map()
Map
Map = geemap.Map()
Map
In [ ]:
Copied!
file_path = os.path.abspath("../data/us_cities.json")
if not os.path.exists(file_path):
url = "https://github.com/gee-community/geemap/raw/master/examples/data/us_cities.json"
r = requests.get(url)
with open(file_path, "w") as f:
f.write(r.content.decode("utf-8"))
with open(file_path) as f:
json_data = json.load(f)
file_path = os.path.abspath("../data/us_cities.json")
if not os.path.exists(file_path):
url = "https://github.com/gee-community/geemap/raw/master/examples/data/us_cities.json"
r = requests.get(url)
with open(file_path, "w") as f:
f.write(r.content.decode("utf-8"))
with open(file_path) as f:
json_data = json.load(f)
In [ ]:
Copied!
maker_cluster = MarkerCluster(
markers=[
Marker(location=feature["geometry"]["coordinates"][::-1])
for feature in json_data["features"]
],
name="Markers",
)
maker_cluster = MarkerCluster(
markers=[
Marker(location=feature["geometry"]["coordinates"][::-1])
for feature in json_data["features"]
],
name="Markers",
)
In [ ]:
Copied!
Map.add_layer(maker_cluster)
Map.add_layer(maker_cluster)
In [ ]:
Copied!
ee_fc = geojson_to_ee(json_data)
Map.addLayer(ee_fc, {}, "US Cities EE")
ee_fc = geojson_to_ee(json_data)
Map.addLayer(ee_fc, {}, "US Cities EE")