The gee
library is a Python package designed for processing and analyzing Sentinel-1 and Sentinel-2 satellite imagery using Google Earth Engine (GEE). It allows for the loading, processing, and combining of Sentinel-1 and Sentinel-2 data, as well as the calculation of various vegetation indices. Additionally, it supports exporting the processed data to Google Drive.
Before using the gee
library, you need to set up the Google Earth Engine Python API. Follow the official installation guide here.
Here's a step-by-step guide on how to use the gee
library.
import ee
from gee import gee
# Initialize the Earth Engine library
ee.Initialize()
ee.Initialize(project='name of project')
This code can only be used in Google Colab
!git clone https://github.com/parvvaresh/google-earth-engine
%cd google-earth-engine
from get_data.gee import gee
You need to define your area of interest (AOI) as an ee.Geometry
. For example, to define a rectangular AOI:
aoi = ee.Geometry.Rectangle([xmin, ymin, xmax, ymax])
gee_instance = gee(aoi)
Optionally, you can provide a table_clip
parameter if you want to clip the results to a specific geometry.
Call the pipeline_data
method with the required parameters to process and export the data:
gee_instance.pipeline_data(
start_date='YYYY-MM-DD', # Start date of the data collection period
end_date='YYYY-MM-DD', # End date of the data collection period
name_file='exported_data', # Name of the exported file
name_folder='GEE_exports' # Name of the folder in Google Drive where the file will be saved
)
import ee
from gee import gee
# Initialize the Earth Engine library
ee.Initialize()
ee.Initialize(project='name of project')
!git clone https://github.com/parvvaresh/google-earth-engine
%cd google-earth-engine
from get_data.gee import gee
# Define your AOI (example coordinates)
aoi = ee.Geometry.Rectangle([-10, 35, 10, 45])
# Create an instance of the gee class
gee_instance = gee(aoi)
# Run the data pipeline
gee_instance.pipeline_data(
start_date='2023-01-01',
end_date='2023-01-31',
name_file='sentinel_data',
name_folder='GEE_exports'
)
Loads the Sentinel-1 ImageCollection within the specified date range and AOI.
Processes the loaded Sentinel-1 data, including filtering and creating mosaics based on ascending and descending orbit passes.
Loads the Sentinel-2 ImageCollection within the specified date range, AOI, and cloud cover percentage.
Processes the loaded Sentinel-2 data, creating composites at specified intervals and calculating NDVI, EVI, and SAVI indices.
Combines the processed Sentinel-1 and Sentinel-2 data into a single dataset and clips it if a table_clip
is provided.
Exports the processed and combined data to Google Drive as a CSV file.
Runs the entire data pipeline, from loading and processing Sentinel-1 and Sentinel-2 data to exporting the results.
- Ensure that you have sufficient permissions and quota in your Google Earth Engine account to run the processing tasks.
- The export task may take some time depending on the size of the AOI and the date range specified.
This code is provided under the MIT License. Feel free to use and modify it as needed.