Skip to content

Commit

Permalink
Add pre-commit cli (#1914)
Browse files Browse the repository at this point in the history
* Add pre-commit cli

* Remove codespell

* Add black formatting to pre-commit
  • Loading branch information
giswqs authored Feb 19, 2024
1 parent 5523f36 commit 13f9ca9
Show file tree
Hide file tree
Showing 21 changed files with 252 additions and 243 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install --user --no-cache-dir Cython
pip install codespell
pip install .[all]
- name: Discover typos with codespell
run: codespell --skip="*.csv,*.geojson,*.json,*.yml*.js,*.html,*cff,*.pdf" --ignore-words-list="aci,acount,acounts,fallow,ges,hart,hist,nd,ned,ois,wqs,watermask"
- name: LOAD EE CREDENTIALS
run: python ./.github/ee_token.py
env:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install --user --no-cache-dir Cython
pip install codespell
pip install .[all]
- name: Discover typos with codespell
run: codespell --skip="*.csv,*.geojson,*.json,*.yml*.js,*.html,*cff,*.pdf" --ignore-words-list="aci,acount,acounts,fallow,ges,hart,hist,nd,ned,ois,wqs,watermask"
- name: LOAD EE CREDENTIALS
run: python ./.github/ee_token.py
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install --no-cache-dir Cython
pip install codespell -r requirements.txt
pip install -r requirements.txt
pip install .
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
TWINE_USERNAME: ${{ secrets.PYPI_USERS }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
pip install build
pip install build
python -m build
twine upload dist/*
5 changes: 0 additions & 5 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ jobs:
gdalinfo --version
- name: Install dependencies
run: |
pip install codespell
pip install .[all]
- name: Discover typos with codespell
run: |
pip install codespell
codespell --skip="*.csv,*.geojson,*.json,*.yml*.js,*.html,*cff,*.pdf" --ignore-words-list="aci,acount,acounts,fallow,ges,hart,hist,nd,ned,ois,wqs,watermask"
- name: PKG-TEST
run: |
python -m unittest discover tests/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install --no-cache-dir Cython
pip install -r codespell requirements.txt
pip install -r requirements.txt
pip install .
35 changes: 21 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
types: [python]
- id: trailing-whitespace
- id: requirements-txt-fixer
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
types: [python]
- id: trailing-whitespace
- id: requirements-txt-fixer
- id: check-added-large-files
args: ["--maxkb=500"]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: [--toml, pyproject-codespell.precommit-toml]
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: [--toml, pyproject-codespell.precommit-toml]
29 changes: 17 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ geemap
.. image:: https://github.com/gee-community/geemap/workflows/docs/badge.svg
:target: https://geemap.org

.. image:: https://img.shields.io/badge/YouTube-Channel-red
.. image:: https://img.shields.io/badge/YouTube-Channel-red
:target: https://youtube.com/@giswqs

.. image:: https://img.shields.io/badge/License-MIT-yellow.svg
Expand All @@ -42,7 +42,12 @@ geemap
:target: https://joss.theoj.org/papers/10.21105/joss.02305

.. image:: https://badges.gitter.im/Join%20Chat.svg
:target: https://matrix.to/#/#geemap:gitter.im
:target: https://matrix.to/#/#geemap:gitter.im

.. image:: https://results.pre-commit.ci/badge/github/gee-community/geemap/master.svg
:target: https://results.pre-commit.ci/latest/github/gee-community/geemap/master
:alt: pre-commit.ci status


**A Python package for interactive geospatial analysis and visualization with Google Earth Engine.**

Expand Down Expand Up @@ -78,10 +83,10 @@ purchasing the book, please visit this URL: https://locatepress.com/book/gee.
Introduction
------------

**Geemap** is a Python package for geospatial analysis and visualization with `Google Earth Engine <https://earthengine.google.com/>`__ (GEE), which is a cloud computing platform with a `multi-petabyte catalog <https://developers.google.com/earth-engine/datasets/>`__ of satellite imagery and geospatial datasets. During the past few years,
GEE has become very popular in the geospatial community and it has empowered numerous environmental applications at local, regional, and global scales. GEE provides both JavaScript and Python APIs for
making computational requests to the Earth Engine servers. Compared with the comprehensive `documentation <https://developers.google.com/earth-engine>`__ and interactive IDE (i.e., `GEE JavaScript Code Editor <https://code.earthengine.google.com/>`__) of the GEE JavaScript API,
the GEE Python API has relatively little documentation and limited functionality for visualizing results interactively. The **geemap** Python package was created to fill this gap. It is built upon `ipyleaflet <https://github.com/jupyter-widgets/ipyleaflet>`__ and `ipywidgets <https://github.com/jupyter-widgets/ipywidgets>`__, and enables users to
**Geemap** is a Python package for geospatial analysis and visualization with `Google Earth Engine <https://earthengine.google.com/>`__ (GEE), which is a cloud computing platform with a `multi-petabyte catalog <https://developers.google.com/earth-engine/datasets/>`__ of satellite imagery and geospatial datasets. During the past few years,
GEE has become very popular in the geospatial community and it has empowered numerous environmental applications at local, regional, and global scales. GEE provides both JavaScript and Python APIs for
making computational requests to the Earth Engine servers. Compared with the comprehensive `documentation <https://developers.google.com/earth-engine>`__ and interactive IDE (i.e., `GEE JavaScript Code Editor <https://code.earthengine.google.com/>`__) of the GEE JavaScript API,
the GEE Python API has relatively little documentation and limited functionality for visualizing results interactively. The **geemap** Python package was created to fill this gap. It is built upon `ipyleaflet <https://github.com/jupyter-widgets/ipyleaflet>`__ and `ipywidgets <https://github.com/jupyter-widgets/ipywidgets>`__, and enables users to
analyze and visualize Earth Engine datasets interactively within a Jupyter-based environment.

**Geemap** is intended for students and researchers, who would like to utilize the Python ecosystem of diverse libraries and tools to explore Google Earth Engine. It is also designed for existing GEE users who would like to transition from the GEE JavaScript API to Python API. The automated JavaScript-to-Python `conversion module <https://github.com/gee-community/geemap/blob/master/geemap/conversion.py>`__ of the **geemap** package
Expand All @@ -91,10 +96,10 @@ For video tutorials and notebook examples, please visit `<https://geemap.org/tut

If you find geemap useful in your research, please consider citing the following papers to support my work. Thank you for your support.

- Wu, Q., (2020). geemap: A Python package for interactive mapping with Google Earth Engine. *The Journal of Open Source Software*, 5(51), 2305. `<https://doi.org/10.21105/joss.02305>`__
- Wu, Q., (2020). geemap: A Python package for interactive mapping with Google Earth Engine. *The Journal of Open Source Software*, 5(51), 2305. `<https://doi.org/10.21105/joss.02305>`__
- Wu, Q., Lane, C. R., Li, X., Zhao, K., Zhou, Y., Clinton, N., DeVries, B., Golden, H. E., & Lang, M. W. (2019). Integrating LiDAR data and multi-temporal aerial imagery to map wetland inundation dynamics using Google Earth Engine. *Remote Sensing of Environment*, 228, 1-13. https://doi.org/10.1016/j.rse.2019.04.015 (`pdf <https://gishub.org/2019_rse>`_ | `source code <https://doi.org/10.6084/m9.figshare.8864921>`_)

Check out the geemap workshop presented at the GeoPython Conference 2021. This workshop gives a comprehensive introduction to the key features of geemap.
Check out the geemap workshop presented at the GeoPython Conference 2021. This workshop gives a comprehensive introduction to the key features of geemap.

.. image:: https://img.youtube.com/vi/wGjpjh9IQ5I/0.jpg
:target: https://www.youtube.com/watch?v=wGjpjh9IQ5I
Expand Down Expand Up @@ -155,7 +160,7 @@ To use **geemap**, you must first `sign up <https://earthengine.google.com/signu
conda create -n gee python=3.10
conda activate gee
conda install -n base mamba -c conda-forge
mamba install geemap -c conda-forge
mamba install geemap -c conda-forge
If you have installed **geemap** before and want to upgrade to the latest version, you can run the following command in your terminal:

Expand All @@ -165,7 +170,7 @@ If you have installed **geemap** before and want to upgrade to the latest versio
If you use conda, you can update geemap to the latest version by running the following command in your terminal:

.. code:: python
conda update -c conda-forge geemap
Expand All @@ -184,11 +189,11 @@ To install the development version from GitHub directly within Jupyter notebook
import geemap
geemap.update_package()
Citations
---------

To support my work, please consider citing the following articles:

- **Wu, Q.**, (2020). geemap: A Python package for interactive mapping with Google Earth Engine. *The Journal of Open Source Software*, 5(51), 2305. https://doi.org/10.21105/joss.02305
- **Wu, Q.**, (2020). geemap: A Python package for interactive mapping with Google Earth Engine. *The Journal of Open Source Software*, 5(51), 2305. https://doi.org/10.21105/joss.02305
- **Wu, Q.**, Lane, C. R., Li, X., Zhao, K., Zhou, Y., Clinton, N., DeVries, B., Golden, H. E., & Lang, M. W. (2019). Integrating LiDAR data and multi-temporal aerial imagery to map wetland inundation dynamics using Google Earth Engine. *Remote Sensing of Environment*, 228, 1-13. https://doi.org/10.1016/j.rse.2019.04.015 (`pdf <https://gishub.org/2019_rse>`_ | `source code <https://doi.org/10.6084/m9.figshare.8864921>`_)
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[![image](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![image](https://joss.theoj.org/papers/10.21105/joss.02305/status.svg)](https://joss.theoj.org/papers/10.21105/joss.02305)
[![chat](https://badges.gitter.im/Join%20Chat.svg)](https://matrix.to/#/#geemap:gitter.im)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/gee-community/geemap/master.svg)](https://results.pre-commit.ci/latest/github/gee-community/geemap/master)

[![logo](https://i.imgur.com/9OOSpDm.png)](https://github.com/gee-community/geemap/blob/master/docs/assets/logo.png)

Expand Down
2 changes: 1 addition & 1 deletion docs/workshops/.jupytext.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Install jupytext using: conda install jupytext -c conda-forge
# Always pair ipynb notebooks to md files.
# Always pair ipynb notebooks to md files.
# formats = "ipynb,md"
formats = "ipynb,myst"

Expand Down
1 change: 0 additions & 1 deletion examples/batch_update.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""This script can do a batch update of notebook examples.
"""


import glob
import os
import shutil
Expand Down
2 changes: 1 addition & 1 deletion examples/heroku/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
voila
geemap
voila
32 changes: 16 additions & 16 deletions examples/javascripts/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,60 @@ Credits to Gennadii Donchyts.
var generateRasterGrid= function(origin, dx, dy, proj) {
var coords = origin.transform(proj).coordinates();
origin = ee.Image.constant(coords.get(0)).addBands(ee.Image.constant(coords.get(1)));

var pixelCoords = ee.Image.pixelCoordinates(proj);

var grid = pixelCoords
.subtract(origin)
.divide([dx, dy]).floor()
.toInt().reduce(ee.Reducer.sum()).bitwiseAnd(1).rename('grid');

var xy = pixelCoords.reproject(proj.translate(coords.get(0), coords.get(1)).scale(dx, dy));

var id = xy.multiply(ee.Image.constant([1, 1000000])).reduce(ee.Reducer.sum()).rename('id');

return grid
.addBands(id)
.addBands(xy);
}


/***
* Generates a regular grid using given bounds, specified as geometry.
*/
var generateGrid = function(xmin, ymin, xmax, ymax, dx, dy, marginx, marginy, opt_proj) {
var proj = opt_proj || 'EPSG:4326';

dx = ee.Number(dx);
dy = ee.Number(dy);

var xx = ee.List.sequence(xmin, ee.Number(xmax).subtract(ee.Number(dx).multiply(0.1)), dx);
var yy = ee.List.sequence(ymin, ee.Number(ymax).subtract(ee.Number(dy).multiply(0.1)), dy);

var cells = xx.map(function(x) {
return yy.map(function(y) {
var x1 = ee.Number(x).subtract(marginx);
var x2 = ee.Number(x).add(ee.Number(dx)).add(marginx);
var y1 = ee.Number(y).subtract(marginy);
var y2 = ee.Number(y).add(ee.Number(dy)).add(marginy);

var coords = ee.List([x1, y1, x2, y2]);
var rect = ee.Algorithms.GeometryConstructors.Rectangle(coords, proj, false);

var nx = x1.add(dx.multiply(0.5)).subtract(xmin).divide(dx).floor();
var ny = y1.add(dy.multiply(0.5)).subtract(ymin).divide(dy).floor();

return ee.Feature(rect)
.set({
.set({
nx: nx.format('%d'),
ny: ny.format('%d'),
});
// .set({cell_id: x1.format('%.3f').cat('_').cat(y1.format('%.3f')) })
});
}).flatten();

return ee.FeatureCollection(cells);
};
};


var grid_test = function() {
Expand Down
2 changes: 1 addition & 1 deletion examples/workshops/jupytext.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Install jupytext using: conda install jupytext -c conda-forge
# Always pair ipynb notebooks to md files.
# Always pair ipynb notebooks to md files.
# formats = "ipynb,md"
formats = "ipynb,myst"

Expand Down
1 change: 1 addition & 0 deletions geemap/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Console script for geemap."""

import sys
import click

Expand Down
Loading

0 comments on commit 13f9ca9

Please sign in to comment.