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 gdal, ogr, osr | |
import numpy as np | |
def createBuffer(inputfn, outputBufferfn, bufferDist, srs): | |
inputds = ogr.Open(inputfn) | |
inputlyr = inputds.GetLayer() | |
shpdriver = ogr.GetDriverByName('ESRI Shapefile') |
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
# Creates a mosaic for the UK for a defined bounding box: | |
# - for all Days of Year (DoY) in julian day format for a specific year | |
# - using the tiles specified | |
# - for the selected product and each associated subdataset | |
import os | |
import gdal | |
import subprocess | |
from glob import glob |
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 xarray as xr | |
import rasterio | |
from rasterio.vrt import WarpedVRT | |
fname = '/data/peatlands_test_data/MOD11A1/LST_Day_1km/h17v03/MOD11A1_LST_Day_1km_h17v03_2019-08.tif' | |
# Lazy in-memory warping from Sinusoidal to WGS84 lat/lon | |
with rasterio.open(fname) as src: | |
# print(src.profile) | |
with WarpedVRT(src, crs='epsg:4326') as vrt: |
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
# Transforms from one Spatial Reference System (SRS) to another one | |
# the SRSs must be define from their PROJ4 or WKT strings | |
import osr | |
# Sinusoidal definition | |
# from https://spatialreference.org/ref/sr-org/6842/ | |
# It fully match with the metadata in the MODIS products | |
sinusoidal_srs = (f'+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 ' | |
f'+b=6371007.181 +units=m +no_defs ') |
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
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
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 gdal | |
from osgeo import gdal_array | |
import osr | |
import numpy | |
def get_dst_dataset(dst_img, cols, rows, layers, dtype, proj, gt): | |
""" | |
Create a GDAL data set in Cloud Optimized GeoTIFF (COG) format | |
:param dst_img: Output filenane full path |
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
from osgeo import ogr | |
def ogrIntersection(tiles_layer, site_fname): | |
# Get layer for the site | |
driver = ogr.GetDriverByName("GeoJSON") | |
src_GeoJSON = driver.Open(site_fname) | |
site_layer = src_GeoJSON.GetLayer() | |
# List with tiles for every feature in site GeoJSON |