import ee import geemap from geemap import cartoee import matplotlib.pyplot as plt geemap.ee_initialize() # Get image lon = -115.1585 lat = 36.1500 start_year = 1984 end_year = 2011 point = ee.Geometry.Point(lon, lat) years = ee.List.sequence(start_year, end_year) def get_best_image(year): start_date = ee.Date.fromYMD(year, 1, 1) end_date = ee.Date.fromYMD(year, 12, 31) image = ( ee.ImageCollection("LANDSAT/LT05/C01/T1_SR") .filterBounds(point) .filterDate(start_date, end_date) .sort("CLOUD_COVER") .first() ) return ee.Image(image) collection = ee.ImageCollection(years.map(get_best_image)) vis_params = {"bands": ['B4', 'B3', 'B2'], "min": 0, "max": 5000} image = ee.Image(collection.first()) w = 0.4 h = 0.3 region = [lon + w, lat - h, lon - w, lat + h] fig = plt.figure(figsize=(10, 8)) # use cartoee to get a map ax = cartoee.get_map(image, region=region, vis_params=vis_params) # add gridlines to the map at a specified interval cartoee.add_gridlines(ax, interval=[0.2, 0.2], linestyle=":") # add north arrow north_arrow_dict = { "text": "N", "xy": (0.10, 0.36), "arrow_length": 0.15, "text_color": "white", "arrow_color": "white", "fontsize": 20, "width": 5, "headwidth": 15, "ha": "center", "va": "center", } cartoee.add_north_arrow(ax, **north_arrow_dict) # add scale bar scale_bar_dict = { 'metric_distance': 4, 'unit': "km", 'at_x': (0.05, 0.2), 'at_y': (0.08, 0.11), 'max_stripes': 5, 'ytick_label_margins': 0.25, 'fontsize': 8, 'font_weight': "bold", 'rotation': 0, 'zorder': 999, 'paddings': {"xmin": 0.05, "xmax": 0.05, "ymin": 1.5, "ymax": 0.5}, } cartoee.add_scale_bar(ax, **scale_bar_dict) ax.set_title(label='Las Vegas, NV', fontsize=15) plt.show()