Library to parse SQL-like queries to Google's Earth Engine syntax
Python Makefile
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

license Build Status codecov

sql2gee

Read the docs

A Python 3 library to make SQL-like queries to Google's Earth Engine Main asset data types (Feature Collections, and Fusion Tables, Image Collections and Images). It is able to perform Postgis-like operations, including returning summary statistics, and histogram data and subsetting by geojson vector data.

Example usage

  1. Import the SQL2GEE class from the sql2gee library in python.
>>>import ee
>>>from sql2gee import SQL2GEE
>>>from utils.jsonSql import JsonSql
>>>ee.Initialize()
>>>
>>>sql = "SELECT ST_HISTOGRAM(raster, lossyear, 15, true) FROM 'UMD/hansen/global_forest_change_2015'"
>>>myQuery = SQL2GEE(JsonSql(sql).to_json())
>>>print("Result of my query: ", q.response())
Result of my query: [{'st_histogram': {'lossyear': [[0.0, 6929647.301960737], [1.0, 0.0], [2.0, 3.0], [3.0, 1.0], [4.0, 13.0], [5.0, 5.0], [6.0, 5.250980392156863], [7.0, 1.0], [8.0, 5.0], [9.0, 9.0], [10.0, 12.0], [11.0, 3.0], [12.0, 6.0], [13.0, 1.0], [14.0, 16.0]]}}]

Execute tests

$make test

or using py.test

$cd <path/sql2gee>
$py.test -v

Development

Notes

Want to Contribute?

Submit a pull request and We will review it.