Skip to main content

Google Earth Engine FeatureCollections via Dask DataFrames.

Project description

dask-ee

Google Earth Engine Feature Collections via Dask DataFrames.

ci PyPi Version Downloads

How to use

Install with pip:

pip install dask-ee

Then, authenticate Earth Engine:

earthengine authenticate

In your Python environment, you may now import the library:

import ee
import dask_ee

You'll need to initialize Earth Engine before working with data:

ee.Initialize()

From here, you can read Earth Engine FeatureCollections like they are DataFrames:

df = dask_ee.read_ee("WRI/GPPD/power_plants")
df.head()

These work like Pandas DataFrames, but they are lazily evaluated via Dask.

Feel free to do any analysis you wish. For example:

# Thanks @aazuspan, https://www.aazuspan.dev/blog/dask_featurecollection
(
    df[df.comm_year.gt(1940) & df.country.eq("USA") & df.fuel1.isin(["Coal", "Wind"])]
    .astype({"comm_year": int})
    .drop(columns=["geo"])
    .groupby(["comm_year", "fuel1"])
    .agg({"capacitymw": "sum"})
    .reset_index()
    .sort_values(by=["comm_year"])
    .compute(scheduler="threads")
    .pivot_table(index="comm_year", columns="fuel1", values="capacitymw", fill_value=0)
    .plot()
)

Coal vs Wind in the US since 1940

There are a few other useful things you can do.

For one, you may pass in a pre-processed ee.FeatureCollection. This allows full utilization of the Earth Engine API.

fc = (
  ee.FeatureCollection("WRI/GPPD/power_plants")
  .filter(ee.Filter.gt("comm_year", 1940))
  .filter(ee.Filter.eq("country", "USA"))
)
df = dask_ee.read_ee(fc)

In addition, you may change the chunksize, which controls how many rows are included in each Dask partition.

df = dask_ee.read_ee("WRI/GPPD/power_plants", chunksize=7_000)
df.head()

Contributing

Contributions are welcome. A good way to start is to check out open issues or file a new one. We're happy to review pull requests, too.

Before writing code, please install the development dependencies (after cloning the repo):

pip install -e ".[dev]"

License

Copyright 2024 Alexander S Merose

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Some sources are re-distributed from Google LLC via https://github.com/google/Xee (also Apache-2.0 License) with and without modification. These files are subject to the original copyright; they include the original license header comment as well as a note to indicate modifications (when appropriate).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dask_ee-0.0.3.tar.gz (51.7 kB view details)

Uploaded Source

Built Distribution

dask_ee-0.0.3-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file dask_ee-0.0.3.tar.gz.

File metadata

  • Download URL: dask_ee-0.0.3.tar.gz
  • Upload date:
  • Size: 51.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for dask_ee-0.0.3.tar.gz
Algorithm Hash digest
SHA256 86383caacd58cd20ce85c69357daff47a511396a00017e6b580670fa7751504a
MD5 0da0ec158cc46bd6f001b23ce5439c28
BLAKE2b-256 7d799b5d238a4158c339c98613fdd0c6843684ad0bcb314f3858832b80708a76

See more details on using hashes here.

File details

Details for the file dask_ee-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: dask_ee-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for dask_ee-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9fb8085bd3f32bbd547c9ae8e1266e3f8d69153674d88ecbe7a256950a00dacd
MD5 df1b0280b57174afbee8f742d2a2ba67
BLAKE2b-256 9d75397ae952231e00c9aaee7b2be87610829ff8dbed067a6097f6e1d013876c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page