This file contains hidden or 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 lldb | |
import lldb.formatters.Logger | |
def templateParams(s): | |
depth = 0 | |
start = s.find('<') + 1 | |
result = [] | |
for i, c in enumerate(s[start:], start): | |
if c == '<': |
This file contains hidden or 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 rasterio | |
import ctypes | |
_gdal = ctypes.cdll.LoadLibrary('libgdal.so.1') | |
OSRNewSpatialReference = _gdal.OSRNewSpatialReference | |
OSRIsGeographic = _gdal.OSRIsGeographic | |
OSRIsGeographic.restype = ctypes.c_bool | |
OSRGetSemiMajor = _gdal.OSRGetSemiMajor | |
OSRGetSemiMajor.restype = ctypes.c_double |
This file contains hidden or 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
class GeoTiffBandArrayWrapper(xray.core.utils.NdimSizeLenMixin): | |
def __init__(self, raster, band): | |
self._band = raster.GetRasterBand(band) | |
self.dtype = {gdalconst.GDT_Int16: numpy.int16}[self._band.DataType] | |
self.shape = (raster.RasterYSize, raster.RasterXSize) | |
def __array__(self, dtype=None): | |
return self._band.ReadAsArray() | |
def __getitem__(self, key): |
This file contains hidden or 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
def get_descriptor(query=None): | |
# descriptor = { | |
# 'LS5TM': { # storage_type identifier | |
# 'dimensions': ['x', 'y', 't'], | |
# 'variables': { # These will be the variables which can be accessed as arrays | |
# 'B10': { | |
# 'datatype': 'int16', | |
# 'nodata_value': -999 | |
# }, |
This file contains hidden or 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 re | |
from collections import namedtuple | |
MGRS = namedtuple('MGRS', ['zone', 'band', 'col', 'row', 'east', 'north']) | |
UTM = namedtuple('UTM', ['zone', 'band', 'east', 'north']) | |
def idx(ch): | |
idx = ord(ch)-ord('A') | |
if ch > 'O': idx -= 1 # skip 'O' | |
if ch > 'I': idx -= 1 # skip 'I' |
This file contains hidden or 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 | |
def argpercentile(a, q, axis=0): | |
""" | |
Compute the index of qth percentile of the data along the specified axis. | |
Returns the index of qth percentile of the array elements. | |
Parameters |