eemont


Nameeemont JSON
Version 0.3.6 PyPI version JSON
download
home_pagehttps://github.com/davemlz/eemont
SummaryA Python package that extends Google Earth Engine
upload_time2023-01-23 09:27:13
maintainer
docs_urlNone
authorDavid Montero Loaiza
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <a href="https://github.com/davemlz/eemont"><img src="https://raw.githubusercontent.com/davemlz/eemont/master/docs/_static/header2.png" alt="header"></a>
</p>
<p align="center">
    <em>A python package that extends Google Earth Engine</em>
</p>
<p align="center">
<a href='https://pypi.python.org/pypi/eemont'>
    <img src='https://img.shields.io/pypi/v/eemont.svg' alt='PyPI' />
</a>
<a href='https://anaconda.org/conda-forge/eemont'>
    <img src='https://img.shields.io/conda/vn/conda-forge/eemont.svg' alt='conda-forge' />
</a>
<a href="https://opensource.org/licenses/MIT" target="_blank">
    <img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License">
</a>
<a href='https://eemont.readthedocs.io/en/latest/?badge=latest'>
    <img src='https://readthedocs.org/projects/eemont/badge/?version=latest' alt='Documentation Status' />
</a>
<a href="https://github.com/davemlz/eemont/actions/workflows/tests.yml" target="_blank">
    <img src="https://github.com/davemlz/eemont/actions/workflows/tests.yml/badge.svg" alt="Tests">
</a>
<a href="https://github.com/sponsors/davemlz" target="_blank">
    <img src="https://img.shields.io/badge/GitHub%20Sponsors-Donate-ff69b4.svg" alt="GitHub Sponsors">
</a>
<a href="https://www.buymeacoffee.com/davemlz" target="_blank">
    <img src="https://img.shields.io/badge/Buy%20me%20a%20coffee-Donate-ff69b4.svg" alt="Buy me a coffee">
</a>
<a href="https://ko-fi.com/davemlz" target="_blank">
    <img src="https://img.shields.io/badge/kofi-Donate-ff69b4.svg" alt="Ko-fi">
</a>
<a href="https://developers.google.com/earth-engine/tutorials/community/developer-resources" target="_blank">
    <img src="https://img.shields.io/badge/GEE%20Community-Developer%20Resources-00b6ff.svg" alt="GEE Community">
</a>
<a href="https://twitter.com/dmlmont" target="_blank">
    <img src="https://img.shields.io/twitter/follow/dmlmont?style=social" alt="Twitter">
</a>
<a href='https://joss.theoj.org/papers/34696c5b62c50898b4129cbbe8befb0a'>
    <img src='https://joss.theoj.org/papers/34696c5b62c50898b4129cbbe8befb0a/status.svg' alt='JOSS' />
</a>
<a href="https://github.com/psf/black" target="_blank">
    <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Black">
</a>
<a href="https://pycqa.github.io/isort/" target="_blank">
    <img src="https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336" alt="isort">
</a>
</p>

---

**GitHub**: [https://github.com/davemlz/eemont](https://github.com/davemlz/eemont)

**Documentation**: [https://eemont.readthedocs.io/](https://eemont.readthedocs.io/)

**PyPI**: [https://pypi.org/project/eemont/](https://pypi.org/project/eemont/)

**Conda-forge**: [https://anaconda.org/conda-forge/eemont](https://anaconda.org/conda-forge/eemont)

**Tutorials**: [https://github.com/davemlz/eemont/tree/master/docs/tutorials](https://github.com/davemlz/eemont/tree/master/docs/tutorials)

**Paper**: [https://joss.theoj.org/papers/10.21105/joss.03168](https://joss.theoj.org/papers/10.21105/joss.03168)

---

## Overview

[Google Earth Engine](https://earthengine.google.com/) is a cloud-based service for 
geospatial processing of vector and raster data. The Earth Engine platform has a 
[JavaScript and a Python API](https://developers.google.com/earth-engine/guides) with 
different methods to process geospatial objects. Google Earth Engine also provides a 
[HUGE PETABYTE-SCALE CATALOG](https://developers.google.com/earth-engine/datasets/) of 
raster and vector data that users can process online (e.g. Landsat Missions Image 
Collections, Sentinel Missions Image Collections, MODIS Products Image Collections, World 
Database of Protected Areas, etc.). The eemont package extends the 
[Google Earth Engine Python API](https://developers.google.com/earth-engine/guides/python_install) 
with pre-processing and processing tools for the most used satellite platforms by adding 
utility methods for different 
[Earth Engine Objects](https://developers.google.com/earth-engine/guides/objects_methods_overview) 
that are friendly with the Python method chaining.


## Google Earth Engine Community: Developer Resources

The eemont Python package can be found in the 
[Earth Engine Community: Developer Resources](https://developers.google.com/earth-engine/tutorials/community/developer-resources) 
together with other awesome resources such as [geemap](https://geemap.org/) and 
[rgee](https://github.com/r-spatial/rgee).


## How does it work?

The eemont python package extends the following Earth Engine classes:

- [ee.Feature](https://developers.google.com/earth-engine/guides/features)
- [ee.FeatureCollection](http://developers.google.com/earth-engine/guides/feature_collections)
- [ee.Geometry](https://developers.google.com/earth-engine/guides/geometries)
- [ee.Image](https://developers.google.com/earth-engine/guides/image_overview)
- [ee.ImageCollection](https://developers.google.com/earth-engine/guides/ic_creating)
- [ee.List](https://developers.google.com/earth-engine/guides/objects_methods_overview)
- [ee.Number](https://developers.google.com/earth-engine/guides/objects_methods_overview)

New utility methods and constructors are added to above-mentioned classes in order
to create a more fluid code by being friendly with the Python method chaining. These
methods are mandatory for some pre-processing and processing tasks (e.g. clouds masking,
shadows masking, image scaling, spectral indices computation, etc.), and they are
presented as simple functions that give researchers, students and analysts the chance to
analyze data with far fewer lines of code.

Look at this simple example where a
[Sentinel-2 Surface Reflectance Image Collection](https://developers.google.com/earth-engine/datasets/catalog/COPERNICUS_S2_SR)
is pre-processed and processed in just one step:

```python
import ee, eemont
   
ee.Authenticate()
ee.Initialize()

point = ee.Geometry.PointFromQuery(
    'Cali, Colombia',
    user_agent = 'eemont-example'
) # Extended constructor

S2 = (ee.ImageCollection('COPERNICUS/S2_SR')
    .filterBounds(point)
    .closest('2020-10-15') # Extended (pre-processing)
    .maskClouds(prob = 70) # Extended (pre-processing)
    .scaleAndOffset() # Extended (pre-processing)
    .spectralIndices(['NDVI','NDWI','BAIS2'])) # Extended (processing)
```

And just like that, the collection was pre-processed, processed and ready to be analyzed!

## Installation

Install the latest version from PyPI:

```
pip install eemont
```

Upgrade `eemont` by running:

```
pip install -U eemont
```

Install the latest version from conda-forge:

```
conda install -c conda-forge eemont
```

Install the latest dev version from GitHub by running:

```
pip install git+https://github.com/davemlz/eemont
```

## Features

Let's see some of the main features of eemont and how simple they are compared to the GEE
Python API original methods:

### Overloaded Operators

The following operators are overloaded: +, -, \*\, /, //, %, \**\ , <<, >>, &, \|\, <, <=,
==, !=, >, >=, -, ~. (and you can avoid the `ee.Image.expression()` method!)

<table>

<tr>
<th> GEE Python API </th>
<th> eemont-style </th>
</tr>

<tr>
<td>
  
``` python
ds = 'COPERNICUS/S2_SR'
          
S2 = (ee.ImageCollection(ds)
.first())

def scaleImage(img):
    scaling = img.select('B.*')
    x = scaling.multiply(0.0001)
    scaling = img.select(['AOT','WVP'])
    scaling = scaling.multiply(0.001)
    x = x.addBands(scaling)
    notScaling = img.select([
        'SCL',
        'TCI.*',
        'MSK.*',
        'QA.*'
    ]))
    return x.addBands(notScaling)
    
S2 = scaleImage(S2)

exp = '2.5*(N-R)/(N+(6*R)-(7.5*B)+1)'

imgDict = {
'N': S2.select('B8'),
'R': S2.select('B4'),
'B': S2.select('B2')
}

EVI = S2.expression(exp,imgDict)
```

</td>
<td>

``` python
ds = 'COPERNICUS/S2_SR'
          
S2 = (ee.ImageCollection(ds)
.first()
.scale())

N = S2.select('B8')
R = S2.select('B4')
B = S2.select('B2')

EVI = 2.5*(N-R)/(N+(6*R)-(7.5*B)+1)
```
</td>
</tr>

</table>

### Clouds and Shadows Masking

Masking clouds and shadows can be done using eemont with just one method: `maskClouds()`!

<table>

<tr>
<th> GEE Python API </th>
<th> eemont-style </th>
</tr>

<tr>
<td>
  
``` python
ds = 'LANDSAT/LC08/C01/T1_SR'
          
def maskCloudsShadows(img):
    c = (1 << 3)
    s = (1 << 5)
    qa = 'pixel_qa'
    qa = img.select(qa)
    cm = qa.bitwiseAnd(c).eq(0)
    sm = qa.bitwiseAnd(s).eq(0)
    mask = cm.And(sm)
    return img.updateMask(mask)
    
(ee.ImageCollection(ds)
    .map(maskCloudsShadows))
```

</td>
<td>

``` python
ds = 'LANDSAT/LC08/C01/T1_SR'
          
(ee.ImageCollection(ds)
    .maskClouds())
```
</td>
</tr>

</table>

### Image Scaling and Offsetting

Scaling and offsetting can also be done using eemont with just one method: `scale()`!

<table>

<tr>
<th> GEE Python API </th>
<th> eemont-style </th>
</tr>

<tr>
<td>
  
``` python
def scaleBands(img):
    scaling = img.select([
    'NDVI',
    'EVI',
    'sur.*'
    ])
    x = scaling.multiply(0.0001)
    scaling = img.select('.*th')
    scaling = scaling.multiply(0.01)
    x = x.addBands(scaling)
    notScaling = img.select([
    'DetailedQA',
    'DayOfYear',
    'SummaryQA'
    ])
    return x.addBands(notScaling)              

ds = 'MODIS/006/MOD13Q1'

(ee.ImageCollection(ds)
    .map(scaleBands))
```

</td>
<td>

``` python
ds = 'MODIS/006/MOD13Q1'
          
(ee.ImageCollection(ds)
    .scaleAndOffset())
```
</td>
</tr>

</table>


### Complete Preprocessing

The complete preprocessing workflow (Masking clouds and shadows, and image scaling and
offsetting) can be done using eemont with just one method: `preprocess()`!


<table>

<tr>
<th> GEE Python API </th>
<th> eemont-style </th>
</tr>

<tr>
<td>
  
``` python
ds = 'LANDSAT/LC08/C01/T1_SR'
          
def maskCloudsShadows(img):
    c = (1 << 3)
    s = (1 << 5)
    qa = 'pixel_qa'
    qa = img.select(qa)
    cm = qa.bitwiseAnd(c).eq(0)
    sm = qa.bitwiseAnd(s).eq(0)
    mask = cm.And(sm)
    return img.updateMask(mask)
    
def scaleBands(img):
    scaling = img.select('B[1-7]')
    x = scaling.multiply(0.0001)
    scaling = img.select([
    'B10','B11'
    ])
    scaling = scaling.multiply(0.1)
    x = x.addBands(scaling)
    notScaling = img.select([
    'sr_aerosol',
    'pixel_qa',
    'radsat_qa'
    ])
    return x.addBands(notScaling)
    
(ee.ImageCollection(ds)
    .map(maskCloudsShadows)
    .map(scaleBands))
```

</td>
<td>

``` python
ds = 'LANDSAT/LC08/C01/T1_SR'
          
(ee.ImageCollection(ds)
    .preprocess())
```
</td>
</tr>

</table>


### Spectral Indices

Do you need to compute several spectral indices? Use the `spectralIndices()` method! The
indices are taken from [Awesome Spectral Indices](https://github.com/davemlz/awesome-spectral-indices).

<table>

<tr>
<th> GEE Python API </th>
<th> eemont-style </th>
</tr>

<tr>
<td>
  
``` python
ds = 'LANDSAT/LC08/C01/T1_SR'
          
def scaleImage(img):
    scaling = img.select('B[1-7]')
    x = scaling.multiply(0.0001)
    scaling = img.select(['B10','B11'])
    scaling = scaling.multiply(0.1)
    x = x.addBands(scaling)
    notScaling = img.select([
        'sr_aerosol',
        'pixel_qa',
        'radsat_qa'
    ]))
    return x.addBands(notScaling)

def addIndices(img):
    x = ['B5','B4']
    a = img.normalizedDifference(x)
    a = a.rename('NDVI')
    x = ['B5','B3']
    b = img.normalizedDifference(x)
    b = b.rename('GNDVI')
    x = ['B3','B6']
    c = img.normalizedDifference(x)
    c = b.rename('NDSI')
    return img.addBands([a,b,c])                    

(ee.ImageCollection(ds)
    .map(scaleImage)
    .map(addIndices))
```

</td>
<td>

``` python
ds = 'LANDSAT/LC08/C01/T1_SR'
          
(ee.ImageCollection(ds)
    .scaleAndOffset()
    .spectralIndices([
        'NDVI',
        'GNDVI',
        'NDSI'])
)
```
</td>
</tr>

</table>

The list of available indices can be retrieved by running:

``` python 
eemont.listIndices()
```

Information about the indices can also be checked:

``` python 
indices = eemont.indices() 
indices.BAIS2.formula
indices.BAIS2.reference
```

### Closest Image to a Specific Date

Struggling to get the closest image to a specific date? Here is the solution: the
`closest()` method!

<table>

<tr>
<th> GEE Python API </th>
<th> eemont-style </th>
</tr>

<tr>
<td>
  
``` python
ds = 'COPERNICUS/S5P/OFFL/L3_NO2'
          
xy = [-76.21, 3.45]
poi = ee.Geometry.Point(xy)

date = ee.Date('2020-10-15')
date = date.millis()

def setTimeDelta(img):              
    prop = 'system:time_start'
    prop = img.get(prop)
    prop = ee.Number(prop)              
    delta = prop.subtract(date)
    delta = delta.abs()              
    return img.set(
    'dateDist',
    delta)                     

(ee.ImageCollection(ds)
    .filterBounds(poi)
    .map(setTimeDelta)
    .sort('dateDist')
    .first())
```

</td>
<td>

``` python
ds = 'COPERNICUS/S5P/OFFL/L3_NO2'
          
xy = [-76.21, 3.45]
poi = ee.Geometry.Point(xy)

(ee.ImageCollection(ds)
    .filterBounds(poi)
    .closest('2020-10-15'))
```
</td>
</tr>

</table>


### Time Series By Regions

The JavaScript API has a method for time series extraction (included in the `ui.Chart`
module), but this method is missing in the Python API... so, here it is!

PD: Actually, there are two methods that you can use: `getTimeSeriesByRegion()` and
`getTimeSeriesByRegions()`!

``` python
f1 = ee.Feature(ee.Geometry.Point([3.984770,48.767221]).buffer(50),{'ID':'A'})
f2 = ee.Feature(ee.Geometry.Point([4.101367,48.748076]).buffer(50),{'ID':'B'})
fc = ee.FeatureCollection([f1,f2])

S2 = (ee.ImageCollection('COPERNICUS/S2_SR')
    .filterBounds(fc)
    .filterDate('2020-01-01','2021-01-01')
    .maskClouds()
    .scaleAndOffset()
    .spectralIndices(['EVI','NDVI']))

# By Region
ts = S2.getTimeSeriesByRegion(reducer = [ee.Reducer.mean(),ee.Reducer.median()],
                                geometry = fc,
                                bands = ['EVI','NDVI'],
                                scale = 10)

# By Regions
ts = S2.getTimeSeriesByRegions(reducer = [ee.Reducer.mean(),ee.Reducer.median()],
                                collection = fc,
                                bands = ['EVI','NDVI'],
                                scale = 10)
```

### Constructors by Queries

Don't you have the coordinates of a place? You can construct them by using queries!

``` python
usr = 'my-eemont-query-example'
   
seattle_bbox = ee.Geometry.BBoxFromQuery('Seattle',user_agent = usr)
cali_coords = ee.Feature.PointFromQuery('Cali, Colombia',user_agent = usr)
amazonas_river = ee.FeatureCollection.MultiPointFromQuery('Río Amazonas',user_agent = usr)
```

### JavaScript Modules

This is perhaps the most important feature in `eeExtra`! What if you could use a
JavaScript module (originally just useful for the Code Editor) in python or R? Well,
wait no more for it!

<table>

<tr>
<th> JS (Code Editor) </th>
<th> Python (eemont) </th>
<th> R (rgee+) </th>
</tr>

<tr>
<td>
  
``` javascript
var usr = 'users/sofiaermida/'
var rep = 'landsat_smw_lst:'
var fld = 'modules/'
var fle = 'Landsat_LST.js'
var pth = usr+rep+fld+fle
var mod = require(pth)
var LST = mod.collection(
    ee.Geometry.Rectangle([
        -8.91,
        40.0,
        -8.3,
        40.4
    ]),
    'L8',
    '2018-05-15',
    '2018-05-31',
    true
)
```

</td>
<td>
  
``` python
import ee, eemont
ee.Initialize()
usr = 'users/sofiaermida/'
rep = 'landsat_smw_lst:'
fld = 'modules/'
fle = 'Landsat_LST.js'
pth = usr+rep+fld+fle
ee.install(pth)
mod = ee.require(pth)
LST = mod.collection(
    ee.Geometry.Rectangle([
        -8.91,
        40.0,
        -8.3,
        40.4
    ]),
    'L8',
    '2018-05-15',
    '2018-05-31',
    True
)
```

</td>
<td>

``` r
library(rgee)
library(rgeeExtra)
ee_Initialize()
usr <- 'users/sofiaermida/'
rep <- 'landsat_smw_lst:'
fld <- 'modules/'
fle <- 'Landsat_LST.js'
pth <- paste0(usr,rep,fld,fle)
mod <- ee$require(pth)
LST = mod$collection(
    ee$Geometry$Rectangle(c(
        -8.91,
        40.0,
        -8.3,
        40.4
    )),
    'L8',
    '2018-05-15',
    '2018-05-31',
    TRUE
)
```
</td>
</tr>

</table>

## License

The project is licensed under the MIT license.

## How to cite

Do you like using eemont and think it is useful? Share the love by citing it!:

```
Montero, D., (2021). eemont: A Python package that extends Google Earth Engine. 
Journal of Open Source Software, 6(62), 3168, https://doi.org/10.21105/joss.03168
```
   
If required, here is the BibTex!:

```
@article{Montero2021,
    doi = {10.21105/joss.03168},
    url = {https://doi.org/10.21105/joss.03168},
    year = {2021},
    publisher = {The Open Journal},
    volume = {6},
    number = {62},
    pages = {3168},
    author = {David Montero},
    title = {eemont: A Python package that extends Google Earth Engine},
    journal = {Journal of Open Source Software}
}
```

## Artists

- [David Montero Loaiza](https://github.com/davemlz): Lead Developer of eemont and eeExtra.
- [César Aybar](https://github.com/csaybar): Lead Developer of rgee and eeExtra.
- [Aaron Zuspan](https://github.com/aazuspan): Plus Codes Constructors and Methods, Panchromatic Sharpening and Histogram Matching Developer.

## Credits

Special thanks to [Justin Braaten](https://github.com/jdbcode) for featuring eemont in
tutorials and the GEE Community: Developer Resources Page, to
[César Aybar](https://github.com/csaybar) for the formidable help with Awesome Spectral
Indices and to the JOSS Review Team ([Katy Barnhart](https://github.com/kbarnhart),
[Jayaram Hariharan](https://github.com/elbeejay), [Qiusheng Wu](https://github.com/giswqs)
and [Patrick Gray](https://github.com/patrickcgray)) for the comments, suggestions and contributions!
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/davemlz/eemont",
    "name": "eemont",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "David Montero Loaiza",
    "author_email": "dml.mont@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f3/ee/60d5114874ebdbe4f2efd0cdfc8f6ae90c023eceb76cec2255791d7679bb/eemont-0.3.6.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <a href=\"https://github.com/davemlz/eemont\"><img src=\"https://raw.githubusercontent.com/davemlz/eemont/master/docs/_static/header2.png\" alt=\"header\"></a>\n</p>\n<p align=\"center\">\n    <em>A python package that extends Google Earth Engine</em>\n</p>\n<p align=\"center\">\n<a href='https://pypi.python.org/pypi/eemont'>\n    <img src='https://img.shields.io/pypi/v/eemont.svg' alt='PyPI' />\n</a>\n<a href='https://anaconda.org/conda-forge/eemont'>\n    <img src='https://img.shields.io/conda/vn/conda-forge/eemont.svg' alt='conda-forge' />\n</a>\n<a href=\"https://opensource.org/licenses/MIT\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/License-MIT-blue.svg\" alt=\"License\">\n</a>\n<a href='https://eemont.readthedocs.io/en/latest/?badge=latest'>\n    <img src='https://readthedocs.org/projects/eemont/badge/?version=latest' alt='Documentation Status' />\n</a>\n<a href=\"https://github.com/davemlz/eemont/actions/workflows/tests.yml\" target=\"_blank\">\n    <img src=\"https://github.com/davemlz/eemont/actions/workflows/tests.yml/badge.svg\" alt=\"Tests\">\n</a>\n<a href=\"https://github.com/sponsors/davemlz\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/GitHub%20Sponsors-Donate-ff69b4.svg\" alt=\"GitHub Sponsors\">\n</a>\n<a href=\"https://www.buymeacoffee.com/davemlz\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/Buy%20me%20a%20coffee-Donate-ff69b4.svg\" alt=\"Buy me a coffee\">\n</a>\n<a href=\"https://ko-fi.com/davemlz\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/kofi-Donate-ff69b4.svg\" alt=\"Ko-fi\">\n</a>\n<a href=\"https://developers.google.com/earth-engine/tutorials/community/developer-resources\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/GEE%20Community-Developer%20Resources-00b6ff.svg\" alt=\"GEE Community\">\n</a>\n<a href=\"https://twitter.com/dmlmont\" target=\"_blank\">\n    <img src=\"https://img.shields.io/twitter/follow/dmlmont?style=social\" alt=\"Twitter\">\n</a>\n<a href='https://joss.theoj.org/papers/34696c5b62c50898b4129cbbe8befb0a'>\n    <img src='https://joss.theoj.org/papers/34696c5b62c50898b4129cbbe8befb0a/status.svg' alt='JOSS' />\n</a>\n<a href=\"https://github.com/psf/black\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/code%20style-black-000000.svg\" alt=\"Black\">\n</a>\n<a href=\"https://pycqa.github.io/isort/\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336\" alt=\"isort\">\n</a>\n</p>\n\n---\n\n**GitHub**: [https://github.com/davemlz/eemont](https://github.com/davemlz/eemont)\n\n**Documentation**: [https://eemont.readthedocs.io/](https://eemont.readthedocs.io/)\n\n**PyPI**: [https://pypi.org/project/eemont/](https://pypi.org/project/eemont/)\n\n**Conda-forge**: [https://anaconda.org/conda-forge/eemont](https://anaconda.org/conda-forge/eemont)\n\n**Tutorials**: [https://github.com/davemlz/eemont/tree/master/docs/tutorials](https://github.com/davemlz/eemont/tree/master/docs/tutorials)\n\n**Paper**: [https://joss.theoj.org/papers/10.21105/joss.03168](https://joss.theoj.org/papers/10.21105/joss.03168)\n\n---\n\n## Overview\n\n[Google Earth Engine](https://earthengine.google.com/) is a cloud-based service for \ngeospatial processing of vector and raster data. The Earth Engine platform has a \n[JavaScript and a Python API](https://developers.google.com/earth-engine/guides) with \ndifferent methods to process geospatial objects. Google Earth Engine also provides a \n[HUGE PETABYTE-SCALE CATALOG](https://developers.google.com/earth-engine/datasets/) of \nraster and vector data that users can process online (e.g. Landsat Missions Image \nCollections, Sentinel Missions Image Collections, MODIS Products Image Collections, World \nDatabase of Protected Areas, etc.). The eemont package extends the \n[Google Earth Engine Python API](https://developers.google.com/earth-engine/guides/python_install) \nwith pre-processing and processing tools for the most used satellite platforms by adding \nutility methods for different \n[Earth Engine Objects](https://developers.google.com/earth-engine/guides/objects_methods_overview) \nthat are friendly with the Python method chaining.\n\n\n## Google Earth Engine Community: Developer Resources\n\nThe eemont Python package can be found in the \n[Earth Engine Community: Developer Resources](https://developers.google.com/earth-engine/tutorials/community/developer-resources) \ntogether with other awesome resources such as [geemap](https://geemap.org/) and \n[rgee](https://github.com/r-spatial/rgee).\n\n\n## How does it work?\n\nThe eemont python package extends the following Earth Engine classes:\n\n- [ee.Feature](https://developers.google.com/earth-engine/guides/features)\n- [ee.FeatureCollection](http://developers.google.com/earth-engine/guides/feature_collections)\n- [ee.Geometry](https://developers.google.com/earth-engine/guides/geometries)\n- [ee.Image](https://developers.google.com/earth-engine/guides/image_overview)\n- [ee.ImageCollection](https://developers.google.com/earth-engine/guides/ic_creating)\n- [ee.List](https://developers.google.com/earth-engine/guides/objects_methods_overview)\n- [ee.Number](https://developers.google.com/earth-engine/guides/objects_methods_overview)\n\nNew utility methods and constructors are added to above-mentioned classes in order\nto create a more fluid code by being friendly with the Python method chaining. These\nmethods are mandatory for some pre-processing and processing tasks (e.g. clouds masking,\nshadows masking, image scaling, spectral indices computation, etc.), and they are\npresented as simple functions that give researchers, students and analysts the chance to\nanalyze data with far fewer lines of code.\n\nLook at this simple example where a\n[Sentinel-2 Surface Reflectance Image Collection](https://developers.google.com/earth-engine/datasets/catalog/COPERNICUS_S2_SR)\nis pre-processed and processed in just one step:\n\n```python\nimport ee, eemont\n   \nee.Authenticate()\nee.Initialize()\n\npoint = ee.Geometry.PointFromQuery(\n    'Cali, Colombia',\n    user_agent = 'eemont-example'\n) # Extended constructor\n\nS2 = (ee.ImageCollection('COPERNICUS/S2_SR')\n    .filterBounds(point)\n    .closest('2020-10-15') # Extended (pre-processing)\n    .maskClouds(prob = 70) # Extended (pre-processing)\n    .scaleAndOffset() # Extended (pre-processing)\n    .spectralIndices(['NDVI','NDWI','BAIS2'])) # Extended (processing)\n```\n\nAnd just like that, the collection was pre-processed, processed and ready to be analyzed!\n\n## Installation\n\nInstall the latest version from PyPI:\n\n```\npip install eemont\n```\n\nUpgrade `eemont` by running:\n\n```\npip install -U eemont\n```\n\nInstall the latest version from conda-forge:\n\n```\nconda install -c conda-forge eemont\n```\n\nInstall the latest dev version from GitHub by running:\n\n```\npip install git+https://github.com/davemlz/eemont\n```\n\n## Features\n\nLet's see some of the main features of eemont and how simple they are compared to the GEE\nPython API original methods:\n\n### Overloaded Operators\n\nThe following operators are overloaded: +, -, \\*\\, /, //, %, \\**\\ , <<, >>, &, \\|\\, <, <=,\n==, !=, >, >=, -, ~. (and you can avoid the `ee.Image.expression()` method!)\n\n<table>\n\n<tr>\n<th> GEE Python API </th>\n<th> eemont-style </th>\n</tr>\n\n<tr>\n<td>\n  \n``` python\nds = 'COPERNICUS/S2_SR'\n          \nS2 = (ee.ImageCollection(ds)\n.first())\n\ndef scaleImage(img):\n    scaling = img.select('B.*')\n    x = scaling.multiply(0.0001)\n    scaling = img.select(['AOT','WVP'])\n    scaling = scaling.multiply(0.001)\n    x = x.addBands(scaling)\n    notScaling = img.select([\n        'SCL',\n        'TCI.*',\n        'MSK.*',\n        'QA.*'\n    ]))\n    return x.addBands(notScaling)\n    \nS2 = scaleImage(S2)\n\nexp = '2.5*(N-R)/(N+(6*R)-(7.5*B)+1)'\n\nimgDict = {\n'N': S2.select('B8'),\n'R': S2.select('B4'),\n'B': S2.select('B2')\n}\n\nEVI = S2.expression(exp,imgDict)\n```\n\n</td>\n<td>\n\n``` python\nds = 'COPERNICUS/S2_SR'\n          \nS2 = (ee.ImageCollection(ds)\n.first()\n.scale())\n\nN = S2.select('B8')\nR = S2.select('B4')\nB = S2.select('B2')\n\nEVI = 2.5*(N-R)/(N+(6*R)-(7.5*B)+1)\n```\n</td>\n</tr>\n\n</table>\n\n### Clouds and Shadows Masking\n\nMasking clouds and shadows can be done using eemont with just one method: `maskClouds()`!\n\n<table>\n\n<tr>\n<th> GEE Python API </th>\n<th> eemont-style </th>\n</tr>\n\n<tr>\n<td>\n  \n``` python\nds = 'LANDSAT/LC08/C01/T1_SR'\n          \ndef maskCloudsShadows(img):\n    c = (1 << 3)\n    s = (1 << 5)\n    qa = 'pixel_qa'\n    qa = img.select(qa)\n    cm = qa.bitwiseAnd(c).eq(0)\n    sm = qa.bitwiseAnd(s).eq(0)\n    mask = cm.And(sm)\n    return img.updateMask(mask)\n    \n(ee.ImageCollection(ds)\n    .map(maskCloudsShadows))\n```\n\n</td>\n<td>\n\n``` python\nds = 'LANDSAT/LC08/C01/T1_SR'\n          \n(ee.ImageCollection(ds)\n    .maskClouds())\n```\n</td>\n</tr>\n\n</table>\n\n### Image Scaling and Offsetting\n\nScaling and offsetting can also be done using eemont with just one method: `scale()`!\n\n<table>\n\n<tr>\n<th> GEE Python API </th>\n<th> eemont-style </th>\n</tr>\n\n<tr>\n<td>\n  \n``` python\ndef scaleBands(img):\n    scaling = img.select([\n    'NDVI',\n    'EVI',\n    'sur.*'\n    ])\n    x = scaling.multiply(0.0001)\n    scaling = img.select('.*th')\n    scaling = scaling.multiply(0.01)\n    x = x.addBands(scaling)\n    notScaling = img.select([\n    'DetailedQA',\n    'DayOfYear',\n    'SummaryQA'\n    ])\n    return x.addBands(notScaling)              \n\nds = 'MODIS/006/MOD13Q1'\n\n(ee.ImageCollection(ds)\n    .map(scaleBands))\n```\n\n</td>\n<td>\n\n``` python\nds = 'MODIS/006/MOD13Q1'\n          \n(ee.ImageCollection(ds)\n    .scaleAndOffset())\n```\n</td>\n</tr>\n\n</table>\n\n\n### Complete Preprocessing\n\nThe complete preprocessing workflow (Masking clouds and shadows, and image scaling and\noffsetting) can be done using eemont with just one method: `preprocess()`!\n\n\n<table>\n\n<tr>\n<th> GEE Python API </th>\n<th> eemont-style </th>\n</tr>\n\n<tr>\n<td>\n  \n``` python\nds = 'LANDSAT/LC08/C01/T1_SR'\n          \ndef maskCloudsShadows(img):\n    c = (1 << 3)\n    s = (1 << 5)\n    qa = 'pixel_qa'\n    qa = img.select(qa)\n    cm = qa.bitwiseAnd(c).eq(0)\n    sm = qa.bitwiseAnd(s).eq(0)\n    mask = cm.And(sm)\n    return img.updateMask(mask)\n    \ndef scaleBands(img):\n    scaling = img.select('B[1-7]')\n    x = scaling.multiply(0.0001)\n    scaling = img.select([\n    'B10','B11'\n    ])\n    scaling = scaling.multiply(0.1)\n    x = x.addBands(scaling)\n    notScaling = img.select([\n    'sr_aerosol',\n    'pixel_qa',\n    'radsat_qa'\n    ])\n    return x.addBands(notScaling)\n    \n(ee.ImageCollection(ds)\n    .map(maskCloudsShadows)\n    .map(scaleBands))\n```\n\n</td>\n<td>\n\n``` python\nds = 'LANDSAT/LC08/C01/T1_SR'\n          \n(ee.ImageCollection(ds)\n    .preprocess())\n```\n</td>\n</tr>\n\n</table>\n\n\n### Spectral Indices\n\nDo you need to compute several spectral indices? Use the `spectralIndices()` method! The\nindices are taken from [Awesome Spectral Indices](https://github.com/davemlz/awesome-spectral-indices).\n\n<table>\n\n<tr>\n<th> GEE Python API </th>\n<th> eemont-style </th>\n</tr>\n\n<tr>\n<td>\n  \n``` python\nds = 'LANDSAT/LC08/C01/T1_SR'\n          \ndef scaleImage(img):\n    scaling = img.select('B[1-7]')\n    x = scaling.multiply(0.0001)\n    scaling = img.select(['B10','B11'])\n    scaling = scaling.multiply(0.1)\n    x = x.addBands(scaling)\n    notScaling = img.select([\n        'sr_aerosol',\n        'pixel_qa',\n        'radsat_qa'\n    ]))\n    return x.addBands(notScaling)\n\ndef addIndices(img):\n    x = ['B5','B4']\n    a = img.normalizedDifference(x)\n    a = a.rename('NDVI')\n    x = ['B5','B3']\n    b = img.normalizedDifference(x)\n    b = b.rename('GNDVI')\n    x = ['B3','B6']\n    c = img.normalizedDifference(x)\n    c = b.rename('NDSI')\n    return img.addBands([a,b,c])                    \n\n(ee.ImageCollection(ds)\n    .map(scaleImage)\n    .map(addIndices))\n```\n\n</td>\n<td>\n\n``` python\nds = 'LANDSAT/LC08/C01/T1_SR'\n          \n(ee.ImageCollection(ds)\n    .scaleAndOffset()\n    .spectralIndices([\n        'NDVI',\n        'GNDVI',\n        'NDSI'])\n)\n```\n</td>\n</tr>\n\n</table>\n\nThe list of available indices can be retrieved by running:\n\n``` python \neemont.listIndices()\n```\n\nInformation about the indices can also be checked:\n\n``` python \nindices = eemont.indices() \nindices.BAIS2.formula\nindices.BAIS2.reference\n```\n\n### Closest Image to a Specific Date\n\nStruggling to get the closest image to a specific date? Here is the solution: the\n`closest()` method!\n\n<table>\n\n<tr>\n<th> GEE Python API </th>\n<th> eemont-style </th>\n</tr>\n\n<tr>\n<td>\n  \n``` python\nds = 'COPERNICUS/S5P/OFFL/L3_NO2'\n          \nxy = [-76.21, 3.45]\npoi = ee.Geometry.Point(xy)\n\ndate = ee.Date('2020-10-15')\ndate = date.millis()\n\ndef setTimeDelta(img):              \n    prop = 'system:time_start'\n    prop = img.get(prop)\n    prop = ee.Number(prop)              \n    delta = prop.subtract(date)\n    delta = delta.abs()              \n    return img.set(\n    'dateDist',\n    delta)                     \n\n(ee.ImageCollection(ds)\n    .filterBounds(poi)\n    .map(setTimeDelta)\n    .sort('dateDist')\n    .first())\n```\n\n</td>\n<td>\n\n``` python\nds = 'COPERNICUS/S5P/OFFL/L3_NO2'\n          \nxy = [-76.21, 3.45]\npoi = ee.Geometry.Point(xy)\n\n(ee.ImageCollection(ds)\n    .filterBounds(poi)\n    .closest('2020-10-15'))\n```\n</td>\n</tr>\n\n</table>\n\n\n### Time Series By Regions\n\nThe JavaScript API has a method for time series extraction (included in the `ui.Chart`\nmodule), but this method is missing in the Python API... so, here it is!\n\nPD: Actually, there are two methods that you can use: `getTimeSeriesByRegion()` and\n`getTimeSeriesByRegions()`!\n\n``` python\nf1 = ee.Feature(ee.Geometry.Point([3.984770,48.767221]).buffer(50),{'ID':'A'})\nf2 = ee.Feature(ee.Geometry.Point([4.101367,48.748076]).buffer(50),{'ID':'B'})\nfc = ee.FeatureCollection([f1,f2])\n\nS2 = (ee.ImageCollection('COPERNICUS/S2_SR')\n    .filterBounds(fc)\n    .filterDate('2020-01-01','2021-01-01')\n    .maskClouds()\n    .scaleAndOffset()\n    .spectralIndices(['EVI','NDVI']))\n\n# By Region\nts = S2.getTimeSeriesByRegion(reducer = [ee.Reducer.mean(),ee.Reducer.median()],\n                                geometry = fc,\n                                bands = ['EVI','NDVI'],\n                                scale = 10)\n\n# By Regions\nts = S2.getTimeSeriesByRegions(reducer = [ee.Reducer.mean(),ee.Reducer.median()],\n                                collection = fc,\n                                bands = ['EVI','NDVI'],\n                                scale = 10)\n```\n\n### Constructors by Queries\n\nDon't you have the coordinates of a place? You can construct them by using queries!\n\n``` python\nusr = 'my-eemont-query-example'\n   \nseattle_bbox = ee.Geometry.BBoxFromQuery('Seattle',user_agent = usr)\ncali_coords = ee.Feature.PointFromQuery('Cali, Colombia',user_agent = usr)\namazonas_river = ee.FeatureCollection.MultiPointFromQuery('R\u00edo Amazonas',user_agent = usr)\n```\n\n### JavaScript Modules\n\nThis is perhaps the most important feature in `eeExtra`! What if you could use a\nJavaScript module (originally just useful for the Code Editor) in python or R? Well,\nwait no more for it!\n\n<table>\n\n<tr>\n<th> JS (Code Editor) </th>\n<th> Python (eemont) </th>\n<th> R (rgee+) </th>\n</tr>\n\n<tr>\n<td>\n  \n``` javascript\nvar usr = 'users/sofiaermida/'\nvar rep = 'landsat_smw_lst:'\nvar fld = 'modules/'\nvar fle = 'Landsat_LST.js'\nvar pth = usr+rep+fld+fle\nvar mod = require(pth)\nvar LST = mod.collection(\n    ee.Geometry.Rectangle([\n        -8.91,\n        40.0,\n        -8.3,\n        40.4\n    ]),\n    'L8',\n    '2018-05-15',\n    '2018-05-31',\n    true\n)\n```\n\n</td>\n<td>\n  \n``` python\nimport ee, eemont\nee.Initialize()\nusr = 'users/sofiaermida/'\nrep = 'landsat_smw_lst:'\nfld = 'modules/'\nfle = 'Landsat_LST.js'\npth = usr+rep+fld+fle\nee.install(pth)\nmod = ee.require(pth)\nLST = mod.collection(\n    ee.Geometry.Rectangle([\n        -8.91,\n        40.0,\n        -8.3,\n        40.4\n    ]),\n    'L8',\n    '2018-05-15',\n    '2018-05-31',\n    True\n)\n```\n\n</td>\n<td>\n\n``` r\nlibrary(rgee)\nlibrary(rgeeExtra)\nee_Initialize()\nusr <- 'users/sofiaermida/'\nrep <- 'landsat_smw_lst:'\nfld <- 'modules/'\nfle <- 'Landsat_LST.js'\npth <- paste0(usr,rep,fld,fle)\nmod <- ee$require(pth)\nLST = mod$collection(\n    ee$Geometry$Rectangle(c(\n        -8.91,\n        40.0,\n        -8.3,\n        40.4\n    )),\n    'L8',\n    '2018-05-15',\n    '2018-05-31',\n    TRUE\n)\n```\n</td>\n</tr>\n\n</table>\n\n## License\n\nThe project is licensed under the MIT license.\n\n## How to cite\n\nDo you like using eemont and think it is useful? Share the love by citing it!:\n\n```\nMontero, D., (2021). eemont: A Python package that extends Google Earth Engine. \nJournal of Open Source Software, 6(62), 3168, https://doi.org/10.21105/joss.03168\n```\n   \nIf required, here is the BibTex!:\n\n```\n@article{Montero2021,\n    doi = {10.21105/joss.03168},\n    url = {https://doi.org/10.21105/joss.03168},\n    year = {2021},\n    publisher = {The Open Journal},\n    volume = {6},\n    number = {62},\n    pages = {3168},\n    author = {David Montero},\n    title = {eemont: A Python package that extends Google Earth Engine},\n    journal = {Journal of Open Source Software}\n}\n```\n\n## Artists\n\n- [David Montero Loaiza](https://github.com/davemlz): Lead Developer of eemont and eeExtra.\n- [C\u00e9sar Aybar](https://github.com/csaybar): Lead Developer of rgee and eeExtra.\n- [Aaron Zuspan](https://github.com/aazuspan): Plus Codes Constructors and Methods, Panchromatic Sharpening and Histogram Matching Developer.\n\n## Credits\n\nSpecial thanks to [Justin Braaten](https://github.com/jdbcode) for featuring eemont in\ntutorials and the GEE Community: Developer Resources Page, to\n[C\u00e9sar Aybar](https://github.com/csaybar) for the formidable help with Awesome Spectral\nIndices and to the JOSS Review Team ([Katy Barnhart](https://github.com/kbarnhart),\n[Jayaram Hariharan](https://github.com/elbeejay), [Qiusheng Wu](https://github.com/giswqs)\nand [Patrick Gray](https://github.com/patrickcgray)) for the comments, suggestions and contributions!",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python package that extends Google Earth Engine",
    "version": "0.3.6",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3ee60d5114874ebdbe4f2efd0cdfc8f6ae90c023eceb76cec2255791d7679bb",
                "md5": "ba77e8572a5e53c1691059057161dcf8",
                "sha256": "49f4c1f7e2ae432ec678875177619b1fed2e99017a810aa49a4c760fc0994ef0"
            },
            "downloads": -1,
            "filename": "eemont-0.3.6.tar.gz",
            "has_sig": false,
            "md5_digest": "ba77e8572a5e53c1691059057161dcf8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 134698,
            "upload_time": "2023-01-23T09:27:13",
            "upload_time_iso_8601": "2023-01-23T09:27:13.610851Z",
            "url": "https://files.pythonhosted.org/packages/f3/ee/60d5114874ebdbe4f2efd0cdfc8f6ae90c023eceb76cec2255791d7679bb/eemont-0.3.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-23 09:27:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "davemlz",
    "github_project": "eemont",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "eemont"
}
        
Elapsed time: 0.05047s