Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bash one-liners | |
get list of GLAD geostores in the last 30 days | |
gcloud logging read "(resource.type="container" AND resource.labels.cluster_name="wri-prod" AND resource.labels.namespace_id="default" AND resource.labels.container_name="forest-change" AND textPayload:(geostore))" --freshness 30d | grep glad | grep -v .py | grep -o 'geostore=.*' | cut -f2- -d= | cut -d'&' -f1 | sort | uniq | |
now need to do the same except for download from that dataset - download/3bec70f3-136b-4046-80c6-2a05afd741c6 | |
gcloud logging read "(resource.type="container" AND resource.labels.cluster_name="wri-prod" AND resource.labels.namespace_id="default" AND logName="projects/resource-watch/logs/document" AND jsonPayload.src.func = "toSQLMiddleware" AND ("geostore" AND "lat"))" --freshness 30d | grep geostore | |
# gdal_translate |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def main(): | |
tile_list = ['000E_00N_010E_10N', '000E_10N_010E_20N', '000E_10S_010E_00N', '000E_20N_010E_30N', '010E_00N_020E_10N', '010E_10N_020E_20N', '010E_10S_020E_00N', '010E_20N_020E_30N', '010E_20S_020E_10S', '010E_30S_020E_20S', '010W_00N_000E_10N', '010W_10N_000E_20N', '010W_20N_000E_30N', '020E_00N_030E_10N', '020E_10N_030E_20N', '020E_10S_030E_00N', '020E_20N_030E_30N', '020E_20S_030E_10S', '020E_30S_030E_20S', '020W_00N_010W_10N', '020W_10N_010W_20N', '020W_20N_010W_30N', '030E_00N_040E_10N', '030E_10N_040E_20N', '030E_10S_040E_00N', '030E_20N_040E_30N', '030E_20S_040E_10S', '030E_30S_040E_20S', '030W_10N_020W_20N', '040E_00N_050E_10N', '040E_10N_050E_20N', '040E_10S_050E_00N', '040E_20N_050E_30N', '040E_20S_050E_10S', '040E_30S_050E_20S', '050E_00N_060E_10N', '050E_10N_060E_20N', '050E_10S_060E_00N', '050E_20N_060E_30N', '050E_20S_060E_10S', '050E_30S_060E_20S'] | |
out_gj = {"type":"FeatureCollection","features":[]} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import xarray as xr | |
# convert input tifs to netcdf | |
subprocess.check_call(['gdal_translate', '-of', 'NetCDF', 'biomass.tif', 'biomass.nc']) | |
subprocess.check_call(['gdal_translate', '-of', 'NetCDF', 'extent.tif', 'extent.nc']) | |
# rename bands to match data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import rasterio | |
# open loss and grab metadata about the tif, | |
# like it's location / projection / cellsize | |
with rasterio.open('loss.tif') as loss_src: | |
kwargs = loss_src.meta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import errno | |
import sys | |
import pandas as pd | |
input_csv = sys.argv[1] | |
adm_level = sys.argv[2] | |
csv_name = os.path.splitext(os.path.basename(input_csv))[0] |