Skip to main content

HESTIA Utils

Install

  1. Install the module:
pip install hestia_earth.utils
  1. Add this to your environment variables:
API_URL=https://api.hestia.earth
WEB_URL=https://www.hestia.earth

Usage

  1. To download a file from the HESTIA API:
from hestia_earth.schema import SchemaType
from hestia_earth.utils.api import download_hestia

cycle = download_hestia('cycleId', SchemaType.CYCLE)
sandContent = download_hestia('sandContent', SchemaType.TERM)
  1. To search for a specific Node on HESTIA:
from hestia_earth.schema import SchemaType
from hestia_earth.utils.api import find_node_exact

source = find_node_exact(SchemaType.SOURCE, {'bibliography.title': 'My Bibliography'})
  1. To get a lookup table from local file system:
from hestia_earth.schema import SchemaType
from hestia_earth.utils.lookup import load_lookup

df = load_lookup('path/to/my/lookup.csv')
  1. To get a lookup table from HESTIA:
from hestia_earth.schema import SchemaType
from hestia_earth.utils.lookup import download_lookup

df = download_lookup('crop.csv')

LSRS Format

You can use this library to convert HESTIA data into the LSRS format.

convert() accepts Impact Assessment, Cycle, Site and Source nodes and returns one simplified dict per node:

  • Impact Assessment → the 88 LSRS indicator columns plus metadata (including land transformation and deforestation read from its indicators).
  • Cycle → yield, EVS, seed, pesticide, diesel, electricity, crop residues, and (using the nutrient/unit helpers in lsrs/models_utils.py) fertiliser kg N / kg P2O5 / kg K2O, lime kg CaCO3 and irrigation m3.
  • Site → site type, country, region and current land cover.
  • Source → bibliography title and year.

These JSON outputs can be rendered to Excel or stored elsewhere. lsrs/models_utils.py holds nutrient/unit/land-cover helpers copied from hestia-earth-models so this library has no dependency on it.

For example, this will let you download all verified aggregation on HESTIA:

  1. Add the env variable API_ACCESS_TOKEN and use the API Key from your account.
  2. Create a file to store the search query:
{
  "bool": {
    "must": [
      { "match": { "@type": "ImpactAssessment" } },
      { "match": { "aggregatedDataValidated": true } }
    ]
  }
}
  1. Run python3 convert_to_lsrs.py --query-path test.json --data-state recalculated

This will create 2 files:

  • query-results-lsrs.json: contains the raw JSON data needed to generate the Excel file
  • query-results-lsrs.xlsx: cotains the LSRS data in Excel format.

Note: if you make some changes to the Excel generation, you can run this to use the json data and re-generate the Excel file quicker: python3 render_lsrs.py --filepath query-results-lsrs.json

Converting multiple files and rendering into a single Excel

You can use the convert script to create all the JSON files containing the raw data, then render everything together at once:

  1. Run all your conversion, using --skip-rendering parameter:
python3 convert_to_lsrs.py --query-path test1.json --data-state recalculated --skip-rendering
python3 convert_to_lsrs.py --query-path test1.json --data-state recalculated --skip-rendering
  1. This will write multiple JSON files in the samples folder. Once done, render all together: python3 render_lsrs.py --folder samples. This will create the final samples.xlsx file.

Download files

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

Source Distribution

hestia_earth_utils-0.17.29.tar.gz (100.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hestia_earth_utils-0.17.29-py3-none-any.whl (92.7 kB view details)

Uploaded Python 3

File details

Details for the file hestia_earth_utils-0.17.29.tar.gz.

File metadata

  • Download URL: hestia_earth_utils-0.17.29.tar.gz
  • Upload date:
  • Size: 100.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.14

File hashes

Hashes for hestia_earth_utils-0.17.29.tar.gz
Algorithm Hash digest
SHA256 585cbdc3047be3b2cb66ade4c03c8b3b070418c28c2aafc84162da4b46aaaa44
MD5 967b6fe9ef462b166a15e6e5e1ced1dd
BLAKE2b-256 11af9889c4384a61319caee7f3fc8ffa146859e42c0b21c0213fa7ea2764bbff

See more details on using hashes here.

File details

Details for the file hestia_earth_utils-0.17.29-py3-none-any.whl.

File metadata

File hashes

Hashes for hestia_earth_utils-0.17.29-py3-none-any.whl
Algorithm Hash digest
SHA256 ee7be0bd8640d2ea8689632d1dd7b83677d7ed818387d1255ed7021bb9cd61ef
MD5 ea6746de9f0fd6b9f3e80e44290f02de
BLAKE2b-256 2f23b054b4f1aa829352a03327e3f9b995b0103b2b2473b8231dac5f353f9a26

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.17.29 This release

2 files

0.17.28

2 files

0.17.27

2 files

0.17.26

2 files

0.17.25

2 files

0.17.24

2 files

0.17.23

2 files

0.17.22

2 files

0.17.21

2 files

0.17.20

2 files

0.17.19

2 files

0.17.18

2 files

0.17.17

2 files

0.17.16

2 files

0.17.15

2 files

0.17.14

2 files

0.17.13

2 files

0.17.12

2 files

0.17.11

2 files

0.17.10

2 files

0.17.9

2 files

0.17.8

2 files

0.17.7

2 files

0.17.6

2 files

0.17.5

2 files

0.17.4

2 files

0.17.3

2 files

0.17.2

2 files

0.17.1

2 files

0.17.0

2 files

0.16.31

2 files

0.16.30

2 files

0.16.29

2 files

0.16.28

2 files

0.16.27

2 files

0.16.26

2 files

0.16.25

2 files

0.16.24

2 files

0.16.23

2 files

0.16.22

2 files

0.16.21

2 files

0.16.20

2 files

0.16.19

2 files

0.16.18

2 files

0.16.17

2 files

0.16.16

2 files

0.16.15

2 files

0.16.14

2 files

0.16.13

2 files

0.16.12

2 files

0.16.11

2 files

0.16.10

2 files

0.16.9

2 files

0.16.8

2 files

0.16.7

2 files

0.16.6

2 files

0.16.5

2 files

0.16.4

2 files

0.16.3

2 files

0.16.2

2 files

0.16.1

2 files

0.15.16

2 files

0.15.15

2 files

0.15.14

2 files

0.15.13

2 files

0.15.12

2 files

0.15.11

2 files

0.15.10

2 files

0.15.9

2 files

0.15.8

2 files

0.15.7

2 files

0.15.6

2 files

0.15.5

2 files

0.15.4

2 files

0.15.3

2 files

0.15.2

2 files

0.15.1

2 files

0.15.0

2 files

0.14.11

2 files

0.14.10

2 files

0.14.9

2 files

0.14.8

2 files

0.14.7

2 files

0.14.6

2 files

0.14.5

2 files

0.14.4

2 files

0.14.3

2 files

0.14.2

2 files

0.14.1

2 files

0.14.0

2 files

0.13.30

2 files

0.13.29

2 files

0.13.28

2 files

0.13.27

2 files

0.13.26

2 files

0.13.25

2 files

0.13.24

2 files

0.13.23

2 files

0.13.22

2 files

0.13.21

2 files

0.13.20

2 files

0.13.19

2 files

0.13.18

2 files

0.13.17

2 files

0.13.16

2 files

0.13.15

2 files

0.13.14

2 files

0.13.13

2 files

0.13.12

2 files

0.13.11

2 files

0.13.10

2 files

0.13.9

2 files

0.13.8

2 files

0.13.7

2 files

0.13.6

2 files

0.13.5

2 files

0.13.4

2 files

0.13.3

2 files

0.13.2

2 files

0.13.1

2 files

0.13.0

2 files

0.12.7

2 files

0.12.6

2 files

0.12.5

2 files

0.12.4

2 files

0.12.3

2 files

0.12.2

2 files

0.12.1

2 files

0.12.0

2 files

0.11.13

2 files

0.11.12

2 files

0.11.11

2 files

0.11.10

2 files

0.11.9

2 files

0.11.8

2 files

0.11.7

2 files

0.11.6

2 files

0.11.5

2 files

0.11.4

2 files

0.11.3

2 files

0.11.2

2 files

0.11.1

2 files

0.11.0

2 files

0.10.32

2 files

0.10.31

2 files

0.10.30

2 files

0.10.29

2 files

0.10.28

2 files

0.10.27

2 files

0.10.26

2 files

0.10.25

2 files

0.10.24

2 files

0.10.23

2 files

0.10.22

2 files

0.10.21

2 files

0.10.20

2 files

0.10.19

2 files

0.10.18

2 files

0.10.17

2 files

0.10.16

2 files

0.10.15

2 files

0.10.14

2 files

0.10.13

2 files

0.10.12

2 files

0.10.11

2 files

0.10.10

2 files

0.10.9

2 files

0.10.8

2 files

0.10.7

2 files

0.10.6

2 files

0.10.5

2 files

0.10.4

2 files

0.10.3

2 files

0.10.2

2 files

0.10.1

2 files

0.10.0

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.1

2 files

0.8.0

2 files

0.7.4

2 files

0.7.3

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.10

2 files

0.4.9

2 files

0.4.8

2 files

0.4.7

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page