cartoee

cartoee: Publication quality maps using Earth Engine - Published in JOSS (2019)

https://github.com/kmarkert/cartoee

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

cartopy earth-engine plot visualization
Last synced: 6 months ago · JSON representation

Repository

Publication quality maps using Earth Engine and Cartopy

Basic Info
Statistics
  • Stars: 47
  • Watchers: 2
  • Forks: 7
  • Open Issues: 3
  • Releases: 2
Topics
cartopy earth-engine plot visualization
Created about 7 years ago · Last pushed about 7 years ago
Metadata Files
Readme Contributing License Authors

README.md

cartoee

PyPI version Build Status Documentation Status DOI License: GPL v3 status

Publication quality maps using Earth Engine and Cartopy! alt-text

Installation

cartoee is available to install via pip. To install the package, you can use pip install for your Python environment:

pip install cartoee

Or, you can install the package manually from source code using the following commands:

git clone https://github.com/kmarkert/cartoee.git cd cartoee python setup.py install

Please see the documentation for instructions on installing dependencies.

Working with cartoee

cartoee aims to do only one thing well: getting processing results from Earth Engine into a publication quality mapping interface. cartoee simply gets results from Earth Engine and plots it with the correct geographic projections leaving ee and cartopy to do more of the processing and visualization.

A simple case

Here is what a simple workflow looks like to visualize SRTM data on a map:

``` import cartoee as cee import ee

ee.Initialize()

get an earth engine image

srtm = ee.Image("CGIAR/SRTM90_V4")

plot the result using cartoee

ax = cee.getMap(srtm,region=[-180,-90,180,90],visParams={'min':0,'max':3000})

ax.coastlines() plt.show() ``` alt-text

Now that we have our EE image as a cartopy/matplotlib object, we can start styling our plot for the publication using the cartopy API.

``` import cartopy.crs as ccrs from cartopy.mpl.gridliner import LATITUDEFORMATTER, LONGITUDEFORMATTER

set gridlines and spacing

xticks = [-180,-120,-60,0,60,120,180] yticks = [-90,-60,-30,0,30,60,90] ax.gridlines(xlocs=xticks, ylocs=yticks,linestyle='--')

set custom formatting for the tick labels

ax.xaxis.setmajorformatter(LONGITUDEFORMATTER) ax.yaxis.setmajorformatter(LATITUDEFORMATTER)

set tick labels

ax.setxticks([-180,-120,-60, 0, 60, 120, 180], crs=ccrs.PlateCarree()) ax.setyticks([-90, -60, -30, 0, 30, 60, 90], crs=ccrs.PlateCarree()) ``` alt-text

Doing more...

Now that we have a grasp on a simple example, we can use Earth Engine to to some processing and make a pretty map.

```

function to add NDVI band to imagery

def calcndvi(img): ndvi = img.normalizedDifference(['NadirReflectanceBand2','NadirReflectance_Band1']) return img.addBands(ndvi.rename('ndvi'))

MODIS Nadir BRDF-Adjusted Reflectance with NDVI band

modis = ee.ImageCollection('MODIS/006/MCD43A4')\ .filterDate('2010-01-01','2016-01-01')\ .map(calc_ndvi)

get the cartopy map with EE results

ax = cee.getMap(modis.mean(),cmap='YlGn' visParams={'min':-0.5,'max':0.85,'bands':'ndvi',}, region=[-180,-90,180,90])

ax.coastlines()

cb = cee.addColorbar(ax,loc='right',cmap='YlGn',visParams={'min':0,'max':1,'bands':'ndvi'}) ``` alt-text

You can see from the example that we calculated NDVI on MODIS imagery from 2010-2015 and created a global map with the mean value per pixel.

What if we want to make multiple maps with some different projections? We can do that by creating our figure and supplying the axes to plot on.

```

get land mass feature collection

land = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017')

get seasonal averages and clip to land features

djf = modis.filter(ee.Filter.calendarRange(12,3,'month')).mean().clip(land) mam = modis.filter(ee.Filter.calendarRange(3,6,'month')).mean().clip(land) jja = modis.filter(ee.Filter.calendarRange(6,9,'month')).mean().clip(land) son = modis.filter(ee.Filter.calendarRange(9,12,'month')).mean().clip(land)

fig,ax = plt.subplots(ncols=2,nrows=2,subplot_kw={'projection': ccrs.Orthographic(-80,35)})

imgs = np.array([[djf,mam],[jja,son]]) titles = np.array([['DJF','MAM'],['JJA','SON']])

for i in range(len(imgs)): for j in range(len(imgs[i])): ax[i,j] = cee.addLayer(imgs[i,j],ax=ax[i,j], region=bbox,dims=500, visParams=ndviVis,cmap='YlGn' ) ax[i,j].coastlines() ax[i,j].gridlines(linestyle='--') ax[i,j].set_title(titles[i,j])

cax = fig.add_axes([0.9, 0.2, 0.02, 0.6]) cb = cee.addColorbar(ax[i,j],cax=cax,cmap='YlGn',visParams=ndviVis) ``` alt-text

To see more examples, go to the documentation at https://cartoee.readthedocs.io!

Owner

  • Name: Kel Markert
  • Login: KMarkert
  • Kind: user
  • Location: Huntsville, AL
  • Company: @google

Cloud Geographer @google. PhD candidate @BYU-Hydroinformatics

JOSS Publication

cartoee: Publication quality maps using Earth Engine
Published
January 30, 2019
Volume 4, Issue 33, Page 1207
Authors
Kel N. Markert ORCID
Earth System Science Center, The University of Alabama in Huntsville, SERVIR Science Coordination Office, NASA Marshall Space Flight Center
Editor
Lindsey Heagy ORCID
Tags
Earth Engine Cartopy Matplotlib

GitHub Events

Total
Last Year

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 91
  • Total Committers: 1
  • Avg Commits per committer: 91.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
kmarkert k****t@g****m 91

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 5
  • Total pull requests: 2
  • Average time to close issues: 3 days
  • Average time to close pull requests: 1 minute
  • Total issue authors: 5
  • Total pull request authors: 1
  • Average comments per issue: 1.6
  • Average comments per pull request: 0.5
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • manmeet3591 (1)
  • khouakhi (1)
  • thomaslauber (1)
  • Fil (1)
  • BijoyKrGayen (1)
Pull Request Authors
  • KMarkert (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 55 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
pypi.org: cartoee

Publication quality maps using Earth Engine and Cartopy!

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 55 Last month
Rankings
Stargazers count: 10.1%
Dependent packages count: 10.1%
Forks count: 12.5%
Downloads: 21.5%
Average: 24.3%
Dependent repos count: 67.3%
Maintainers (1)
Last synced: 6 months ago

Dependencies

environment.yml pypi
  • earthengine-api ==0.1.145
  • google-api-core ==1.3.0
  • google-api-python-client ==1.7.3
  • google-auth ==1.5.0
  • google-auth-httplib2 ==0.0.3
  • ipykernel *
  • nbsphinx *
  • oauth2client ==4.1.2
  • sphinxcontrib-napoleon *
requirements.txt pypi
  • ipykernel *
  • nbsphinx *
  • sphinx >=1.4
  • sphinxcontrib-napoleon *
setup.py pypi
  • Cython *
  • cartopy ==0.16.0
  • earthengine-api *
  • geos *
  • google-api-python-client *
  • matplotlib *
  • oauth2client *
  • pyproj *