06_geemap学习笔记 | 标记聚类

原文:06_marker_cluster

import geemap
import json
import os
import requests
from geemap import geojson_to_ee, ee_to_geojson
from ipyleaflet import GeoJSON, Marker, MarkerCluster
geemap.set_proxy(port=10809)
geemap.show_youtube('4HycJPrwpuo')

在这里插入图片描述

Map = geemap.Map(center = (38, 105))
Map
file_path = os.path.abspath('G:/learnpy/data//us-cities.json')

# 如果本地没有这个文件就从下面链接获取,然后写进本地路径
if not os.path.exists(file_path):
    url = 'https://github.com/giswqs/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)


json_data

# {'features': [{'properties': {'POP_2010': 40888.0,
#     'ELEV_IN_FT': 1611.0,
#     'STATE': 'ND'},
#    'id': '53',
#    'geometry': {'type': 'Point',
#     'coordinates': [-101.29627319999997, 48.232509500000106]},
#    'type': 'Feature'},
#   {'properties': {'POP_2010': 52838.0, 'ELEV_IN_FT': 830.0, 'STATE': 'ND'},
#    'id': '101',
#    'geometry': {'type': 'Point',
#     'coordinates': [-97.03285469999997, 47.92525680000006]},
#    'type': 'Feature'},
#   {'properties': {'POP_2010': 15427.0, 'ELEV_IN_FT': 1407.0, 'STATE': 'ND'},
#    'id': '153',
#    'geometry': {'type': 'Point',
#     'coordinates': [-98.70843569999994, 46.91054380000003]},
#    'type': 'Feature'},
#   {'properties': {'POP_2010': 105549.0, 'ELEV_IN_FT': 902.0, 'STATE': 'ND'},
#   ......
marker_cluster = MarkerCluster(
    markers = [Marker(location = feature['geometry']['coordinates'][::-1]) for feature in json_data['features']], 
    name = 'Markers')
Map.add_layer(marker_cluster)

大圈为markers,黑点为US Cities ee

ee_fc = geojson_to_ee(json_data)
Map.addLayer(ee_fc, {}, 'US Cities EE')

大圈为markers,黑点为US Cities ee

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值