Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
giswqs
GitHub Repository: giswqs/geemap
Path: blob/master/docs/notebooks/113_image_area.ipynb
2313 views
Kernel: Python 3

Open in Colab

Uncomment the following line to install geemap if needed.

# !pip install geemap
import ee import geemap

Add ESA Land Cover data.

Map = geemap.Map() dataset = ee.ImageCollection("ESA/WorldCover/v100").first() Map.addLayer(dataset, {"bands": ["Map"]}, "ESA Land Cover") Map.add_legend(builtin_legend="ESA_WorldCover") Map

Calculate the area of each land cover type.

df = geemap.image_area_by_group( dataset, scale=1000, denominator=1e6, decimal_places=4, verbose=True ) df

Save the results to a CSV.

df.to_csv("esa_area.csv")

Add NLCD land cover data.

Map = geemap.Map(center=[40, -100], zoom=4) Map.add_basemap("HYBRID") nlcd = ee.Image("USGS/NLCD_RELEASES/2019_REL/NLCD/2019") landcover = nlcd.select("landcover") Map.addLayer(landcover, {}, "NLCD Land Cover 2019") Map.add_legend( title="NLCD Land Cover Classification", builtin_legend="NLCD", height="465px" ) Map

Calculate the area of each land cover type.

df = geemap.image_area_by_group( landcover, scale=1000, denominator=1e6, decimal_places=4, verbose=True ) df

Save the results to a CSV.

df.to_csv("nlcd_area.csv")