A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/earth-engine/guides/quickstart_python below:

Get started with Earth Engine for Python | Google Earth Engine

Skip to main content Get started with Earth Engine for Python

Stay organized with collections Save and categorize content based on your preferences.

This quickstart will give you an interactive introduction to visualizing and analyzing geospatial data with the Earth Engine Python interface.

Before you begin

Register or create a Google Cloud Project; you'll be prompted to complete the following steps. If you already have a project registered for Earth Engine access, skip to the next section.

Notebook setup

Jupyter notebooks allow you to use Earth Engine and explore results interactively. The quickest way to get started is with a notebook in Google Colab notebook. You can either

open a new notebook

and copy the following code chunks into individual cells or use the prefilled

Earth Engine Python Quickstart notebook

.

  1. Import the Earth Engine and geemap libraries.
    import ee
    import geemap.core as geemap
  1. Authenticate and initialize the Earth Engine service. Follow the resulting prompts to complete authentication. Be sure to replace PROJECT_ID with the name of the project you set up for this quickstart.
    ee.Authenticate()
    ee.Initialize(project='PROJECT_ID')
Add raster data to a map
  1. Load climate data for a given period and display its metadata.
    jan_2023_climate = (
        ee.ImageCollection('ECMWF/ERA5_LAND/MONTHLY_AGGR')
        .filterDate('2023-01', '2023-02')
        .first()
    )
    jan_2023_climate
  1. Instantiate a map object and add the temperature band as a layer with specific visualization properties. Display the map.
    m = geemap.Map(center=[30, 0], zoom=2)
    
    vis_params = {
        'bands': ['temperature_2m'],
        'min': 229,
        'max': 304,
        'palette': 'inferno',
    }
    m.add_layer(jan_2023_climate, vis_params, 'Temperature (K)')
    m
Add vector data to a map
  1. Create a vector data object with points for three cities.
    cities = ee.FeatureCollection([
        ee.Feature(ee.Geometry.Point(10.75, 59.91), {'city': 'Oslo'}),
        ee.Feature(ee.Geometry.Point(-118.24, 34.05), {'city': 'Los Angeles'}),
        ee.Feature(ee.Geometry.Point(103.83, 1.33), {'city': 'Singapore'}),
    ])
    cities
  1. Add the city locations to the map and redisplay it.
    m.add_layer(cities, name='Cities')
    m
Extract and chart data
  1. Import the Altair charting library.
    %pip install -q --upgrade altair
    import altair as alt
  1. Extract the climate data for the three cities as a pandas DataFrame.
    city_climates = jan_2023_climate.reduceRegions(cities, ee.Reducer.first())
    
    city_climates_dataframe = ee.data.computeFeatures(
        {'expression': city_climates, 'fileFormat': 'PANDAS_DATAFRAME'}
    )
    city_climates_dataframe
  1. Plot the temperature for the cities as a bar chart.
    alt.Chart(city_climates_dataframe).mark_bar(size=100).encode(
        alt.X('city:N', sort='y', axis=alt.Axis(labelAngle=0), title='City'),
        alt.Y('temperature_2m:Q', title='Temperature (K)'),
        tooltip=[
            alt.Tooltip('city:N', title='City'),
            alt.Tooltip('temperature_2m:Q', title='Temperature (K)'),
        ],
    ).properties(title='January 2023 temperature for selected cities', width=500)
What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-11-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-07 UTC."],[[["This quickstart provides an interactive introduction to visualizing and analyzing geospatial data using the Earth Engine Python interface within a Jupyter notebook environment like Google Colab."],["Users will learn to add both raster and vector data to an interactive map, visualizing climate data and city locations as examples."],["The guide demonstrates data extraction and charting by retrieving climate data for specific cities and creating a bar chart using the Altair library."],["Before starting, users need a Google Cloud Project registered for Earth Engine access, and the quickstart provides instructions for setting one up."],["Further learning resources on Earth Engine objects, processing environments, machine learning capabilities, and data export to BigQuery are linked at the end."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4