claudiamoncada/prueba_mapa_docker
0
1import ee2import geemap3 4import solara5 6 7class Map(geemap.Map):8 def __init__(self, **kwargs):9 super().__init__(**kwargs)10 self.add_ee_data()11 12 def add_ee_data(self):13 # Select the eight NLCD epochs after 2000.14 years = ['2001', '2004', '2006', '2008', '2011', '2013', '2016', '2019']15 16 # Get an NLCD image by year.17 def getNLCD(year):18 # Import the NLCD collection.19 dataset = ee.ImageCollection('USGS/NLCD_RELEASES/2019_REL/NLCD')20 21 # Filter the collection by year.22 nlcd = dataset.filter(ee.Filter.eq('system:index', year)).first()23 24 # Select the land cover band.25 landcover = nlcd.select('landcover')26 return landcover27 28 ## Create an NLCD image collection for the selected years.29 collection = ee.ImageCollection(ee.List(years).map(lambda year: getNLCD(year)))30 31 # Create a list of labels to populate the dropdown list.32 labels = [f'NLCD {year}' for year in years]33 34 # Add a split-panel map for visualizing NLCD land cover change.35 self.ts_inspector(36 left_ts=collection,37 right_ts=collection,38 left_names=labels,39 right_names=labels,40 )41 42 # Add the NLCD legend to the map.43 self.add_legend(44 title='NLCD Land Cover Type', builtin_legend='NLCD', height="460px", add_header=False45 )46 47 48@solara.component49def Page():50 with solara.Column(style={"min-width": "500px"}):51 Map.element(52 center=[40, -100],53 zoom=4,54 height="600px",55 )56 57#jajsajkssd