簡體   English   中英

plot 城界,縣界,怎么能上葉 Map?

[英]How can we plot City borders, or County borders, on a Folium Map?

我有一些代碼可以為我生成一個不錯的 Heat Map。 這是我的代碼。

import folium
from folium.plugins import HeatMap

max_amount = float(df_top20['Total_Minutes'].max())

hmap = folium.Map(location=[35.5, -82.5], zoom_start=7, )

hm_wide = HeatMap(list(zip(df_top20.Latitude.values, df_top20.Longitude.values, df_top20.Total_Minutes.values)),
                   min_opacity=0.2,
                   max_val=max_amount,
                   radius=25, 
                   blur=20, 
                   max_zoom=1, 
                 )

hmap.add_child(hm_wide)

在此處輸入圖像描述

如何在這個 map 上疊加特定的北卡羅來納州城市或縣? 我在 dataframe 中有城市/縣。

如果要疊加衛星圖像:

coordinates = [35.5, -82.5]
start_and_end_dates = ee.DateRange('2015-06-30', '2023-07-01')
ee_image_col = ee.ImageCollection('LANDSAT/LC08/C02/T1').filterBounds(ee.Geometry.Point(coordinates[1], coordinates[0])).filterDate(start_and_end_dates).first()
def add_ee_layer(self, ee_image_col, params, name):
    map_dict = ee.Image(ee_image_col).getMapId(params)
    folium.raster_layers.TileLayer(
        tiles=map_dict['tile_fetcher'].url_format,
        attr='Map Data &copy; <a href="https://earthengine.google.com/">Google Earth Engine</a>',#"Map Data © Google Earth Engine"
        name=name,
        overlay=True,
        control=True
    ).add_to(self)

hmap.add_tile_layer(ee_image_col, params={'bands': ['B4', 'B3', 'B2'], 'min': 5000, 'max': 12000}, name=sat_id)
hmap.add_child(folium.LayerControl())
folium.LayerControl(collapsed=False).add_to(hmap)

您可以使用.clip()裁剪區域以指定城市或縣,或裁剪給定zoom_deg

def get_geoJSON_data(coordinates, zoom_deg):
  return {
    "type": "FeatureCollection",
    "features": [
      {
        "type": "Feature",
        "properties": {},
        "geometry": {
          "type": "Polygon",
          "coordinates": [
            [
              [
                coordinates[1] - zoom_deg,
                coordinates[0] - zoom_deg
              ],
              [
                coordinates[1] + zoom_deg,
                coordinates[0] - zoom_deg
              ],
              [
                coordinates[1] + zoom_deg,
                coordinates[0] + zoom_deg
              ],
              [
                coordinates[1] - zoom_deg,
                coordinates[0] + zoom_deg
              ],
              [
                coordinates[1] - zoom_deg,
                coordinates[0] - zoom_deg
              ]
            ]
          ]
        }
      }
    ]
  }
zoom_deg = 10.0

...first().clip(ee.Geometry.Polygon(get_geoJSON_data(coordinates, zoom_deg)['features'][0]['geometry']['coordinates']))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM