INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
: py: func: asyncio. coroutine | async def get_stream(self, *command_args, conn_type="I", offset=0):
"""
:py:func:`asyncio.coroutine`
Create :py:class:`aioftp.DataConnectionThrottleStreamIO` for straight
read/write io.
:param command_args: arguments for :py:meth:`aioftp.Client.command`
:param conn_typ... |
Compute jenks natural breaks on a sequence of values given nb_class the number of desired class. | def jenks_breaks(values, nb_class):
"""
Compute jenks natural breaks on a sequence of `values`, given `nb_class`,
the number of desired class.
Parameters
----------
values : array-like
The Iterable sequence of numbers (integer/float) to be used.
nb_class : int
The desired nu... |
http:// www. pygtk. org/ docs/ pygtk/ class - gdkpixbuf. html. | def grab_to_file(self, filename, bbox=None):
"""http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html.
only "jpeg" or "png"
"""
w = self.gtk.gdk.get_default_root_window()
# Capture the whole screen.
if bbox is None:
sz = w.get_size()
pb = self.gtk.g... |
Grabs an image directly to a buffer. | def grab(self, bbox=None):
"""Grabs an image directly to a buffer.
:param bbox: Optional tuple or list containing (x1, y1, x2, y2) coordinates
of sub-region to capture.
:return: PIL RGB image
:raises: ValueError, if image data does not have 3 channels (RGB), each with 8
... |
Copy the contents of the screen to PIL image memory. | def grab(bbox=None, childprocess=None, backend=None):
"""Copy the contents of the screen to PIL image memory.
:param bbox: optional bounding box (x1,y1,x2,y2)
:param childprocess: pyscreenshot can cause an error,
if it is used on more different virtual displays
and back-end is not i... |
Copy the contents of the screen to a file. Internal function! Use PIL. Image. save () for saving image to file. | def grab_to_file(filename, childprocess=None, backend=None):
"""Copy the contents of the screen to a file. Internal function! Use
PIL.Image.save() for saving image to file.
:param filename: file for saving
:param childprocess: see :py:func:`grab`
:param backend: see :py:func:`grab`
"""
if c... |
Back - end version. | def backend_version(backend, childprocess=None):
"""Back-end version.
:param backend: back-end (examples:scrot, wx,..)
:param childprocess: see :py:func:`grab`
:return: version as string
"""
if childprocess is None:
childprocess = childprocess_default_value()
if not childprocess:
... |
Write data from process tiles into PNG file ( s ). | def write(self, process_tile, data):
"""
Write data from process tiles into PNG file(s).
Parameters
----------
process_tile : ``BufferedTile``
must be member of process ``TilePyramid``
"""
data = self._prepare_array(data)
if data.mask.all():
... |
Read existing process output. | def read(self, output_tile, **kwargs):
"""
Read existing process output.
Parameters
----------
output_tile : ``BufferedTile``
must be member of output ``TilePyramid``
Returns
-------
process output : ``BufferedTile`` with appended data
... |
Create a metadata dictionary for rasterio. | def profile(self, tile=None):
"""
Create a metadata dictionary for rasterio.
Parameters
----------
tile : ``BufferedTile``
Returns
-------
metadata : dictionary
output profile dictionary used for rasterio.
"""
dst_metadata = d... |
Open a Mapchete process. | def open(
config, mode="continue", zoom=None, bounds=None, single_input_file=None,
with_cache=False, debug=False
):
"""
Open a Mapchete process.
Parameters
----------
config : MapcheteConfig object, config dict or path to mapchete file
Mapchete process configuration
mode : strin... |
Count number of tiles intersecting with geometry. | def count_tiles(geometry, pyramid, minzoom, maxzoom, init_zoom=0):
"""
Count number of tiles intersecting with geometry.
Parameters
----------
geometry : shapely geometry
pyramid : TilePyramid
minzoom : int
maxzoom : int
init_zoom : int
Returns
-------
number of tiles
... |
Determine zoom levels. | def _get_zoom_level(zoom, process):
"""Determine zoom levels."""
if zoom is None:
return reversed(process.config.zoom_levels)
if isinstance(zoom, int):
return [zoom]
elif len(zoom) == 2:
return reversed(range(min(zoom), max(zoom)+1))
elif len(zoom) == 1:
return zoom |
Worker function running the process. | def _process_worker(process, process_tile):
"""Worker function running the process."""
logger.debug((process_tile.id, "running on %s" % current_process().name))
# skip execution if overwrite is disabled and tile exists
if (
process.config.mode == "continue" and
process.config.output.til... |
Yield process tiles. | def get_process_tiles(self, zoom=None):
"""
Yield process tiles.
Tiles intersecting with the input data bounding boxes as well as
process bounds, if provided, are considered process tiles. This is to
avoid iterating through empty tiles.
Parameters
----------
... |
Process a large batch of tiles. | def batch_process(
self, zoom=None, tile=None, multi=cpu_count(), max_chunksize=1
):
"""
Process a large batch of tiles.
Parameters
----------
process : MapcheteProcess
process to be run
zoom : list or int
either single zoom level or l... |
Process a large batch of tiles and yield report messages per tile. | def batch_processor(
self, zoom=None, tile=None, multi=cpu_count(), max_chunksize=1
):
"""
Process a large batch of tiles and yield report messages per tile.
Parameters
----------
zoom : list or int
either single zoom level or list of minimum and maximum ... |
Count number of tiles intersecting with geometry. | def count_tiles(self, minzoom, maxzoom, init_zoom=0):
"""
Count number of tiles intersecting with geometry.
Parameters
----------
geometry : shapely geometry
pyramid : TilePyramid
minzoom : int
maxzoom : int
init_zoom : int
Returns
... |
Run the Mapchete process. | def execute(self, process_tile, raise_nodata=False):
"""
Run the Mapchete process.
Execute, write and return data.
Parameters
----------
process_tile : Tile or tile index tuple
Member of the process tile pyramid (not necessarily the output
pyrami... |
Read from written process output. | def read(self, output_tile):
"""
Read from written process output.
Parameters
----------
output_tile : BufferedTile or tile index tuple
Member of the output tile pyramid (not necessarily the process
pyramid, if output has a different metatiling setting)
... |
Write data into output format. | def write(self, process_tile, data):
"""
Write data into output format.
Parameters
----------
process_tile : BufferedTile or tile index tuple
process tile
data : NumPy array or features
data to be written
"""
if isinstance(process_... |
Get output raw data. | def get_raw_output(self, tile, _baselevel_readonly=False):
"""
Get output raw data.
This function won't work with multiprocessing, as it uses the
``threading.Lock()`` class.
Parameters
----------
tile : tuple, Tile or BufferedTile
If a tile index is ... |
Extract data from tile. | def _extract(self, in_tile=None, in_data=None, out_tile=None):
"""Extract data from tile."""
return self.config.output.extract_subset(
input_data_tiles=[(in_tile, in_data)],
out_tile=out_tile
) |
Read existing output data from a previous run. | def read(self, **kwargs):
"""
Read existing output data from a previous run.
Returns
-------
process output : NumPy array (raster) or feature iterator (vector)
"""
if self.tile.pixelbuffer > self.config.output.pixelbuffer:
output_tiles = list(self.con... |
Open input data. | def open(self, input_id, **kwargs):
"""
Open input data.
Parameters
----------
input_id : string
input identifier from configuration file or file path
kwargs : driver specific parameters (e.g. resampling)
Returns
-------
tiled input d... |
Calculate hillshading from elevation data. | def hillshade(
self, elevation, azimuth=315.0, altitude=45.0, z=1.0, scale=1.0
):
"""
Calculate hillshading from elevation data.
Parameters
----------
elevation : array
input elevation data
azimuth : float
horizontal angle of light sou... |
Extract contour lines from elevation data. | def contours(
self, elevation, interval=100, field='elev', base=0
):
"""
Extract contour lines from elevation data.
Parameters
----------
elevation : array
input elevation data
interval : integer
elevation value interval when drawing c... |
Clip array by geometry. | def clip(
self, array, geometries, inverted=False, clip_buffer=0
):
"""
Clip array by geometry.
Parameters
----------
array : array
raster data to be clipped
geometries : iterable
geometries used to clip source array
inverted :... |
Clip input array with a vector list. | def clip_array_with_vector(
array, array_affine, geometries, inverted=False, clip_buffer=0
):
"""
Clip input array with a vector list.
Parameters
----------
array : array
input raster data
array_affine : Affine
Affine object describing the raster's geolocation
geometries... |
Create tile pyramid out of input raster. | def pyramid(
input_raster,
output_dir,
pyramid_type=None,
output_format=None,
resampling_method=None,
scale_method=None,
zoom=None,
bounds=None,
overwrite=False,
debug=False
):
"""Create tile pyramid out of input raster."""
bounds = bounds if bounds else None
options ... |
Create a tile pyramid out of an input raster dataset. | def raster2pyramid(input_file, output_dir, options):
"""Create a tile pyramid out of an input raster dataset."""
pyramid_type = options["pyramid_type"]
scale_method = options["scale_method"]
output_format = options["output_format"]
resampling = options["resampling"]
zoom = options["zoom"]
bo... |
Determine minimum and maximum zoomlevel. | def _get_zoom(zoom, input_raster, pyramid_type):
"""Determine minimum and maximum zoomlevel."""
if not zoom:
minzoom = 1
maxzoom = get_best_zoom_level(input_raster, pyramid_type)
elif len(zoom) == 1:
minzoom = zoom[0]
maxzoom = zoom[0]
elif len(zoom) == 2:
if zoom... |
Validate whether value is found in config and has the right type. | def validate_values(config, values):
"""
Validate whether value is found in config and has the right type.
Parameters
----------
config : dict
configuration dictionary
values : list
list of (str, type) tuples of values and value types expected in config
Returns
-------
... |
Return hash of x. | def get_hash(x):
"""Return hash of x."""
if isinstance(x, str):
return hash(x)
elif isinstance(x, dict):
return hash(yaml.dump(x)) |
Validate and return zoom levels. | def get_zoom_levels(process_zoom_levels=None, init_zoom_levels=None):
"""Validate and return zoom levels."""
process_zoom_levels = _validate_zooms(process_zoom_levels)
if init_zoom_levels is None:
return process_zoom_levels
else:
init_zoom_levels = _validate_zooms(init_zoom_levels)
... |
Snaps bounds to tiles boundaries of specific zoom level. | def snap_bounds(bounds=None, pyramid=None, zoom=None):
"""
Snaps bounds to tiles boundaries of specific zoom level.
Parameters
----------
bounds : bounds to be snapped
pyramid : TilePyramid
zoom : int
Returns
-------
Bounds(left, bottom, right, top)
"""
if not isinstanc... |
Clips bounds by clip. | def clip_bounds(bounds=None, clip=None):
"""
Clips bounds by clip.
Parameters
----------
bounds : bounds to be clipped
clip : clip bounds
Returns
-------
Bounds(left, bottom, right, top)
"""
bounds = Bounds(*bounds)
clip = Bounds(*clip)
return Bounds(
max(bo... |
Loads the process pyramid of a raw configuration. | def raw_conf_process_pyramid(raw_conf):
"""
Loads the process pyramid of a raw configuration.
Parameters
----------
raw_conf : dict
Raw mapchete configuration as dictionary.
Returns
-------
BufferedTilePyramid
"""
return BufferedTilePyramid(
raw_conf["pyramid"][... |
Loads the process pyramid of a raw configuration. | def bounds_from_opts(
wkt_geometry=None, point=None, bounds=None, zoom=None, raw_conf=None
):
"""
Loads the process pyramid of a raw configuration.
Parameters
----------
raw_conf : dict
Raw mapchete configuration as dictionary.
Returns
-------
BufferedTilePyramid
"""
... |
Return a list of zoom levels. | def _validate_zooms(zooms):
"""
Return a list of zoom levels.
Following inputs are converted:
- int --> [int]
- dict{min, max} --> range(min, max + 1)
- [int] --> [int]
- [int, int] --> range(smaller int, bigger int + 1)
"""
if isinstance(zooms, dict):
if any([a not in zooms... |
Return parameter dictionary per zoom level. | def _raw_at_zoom(config, zooms):
"""Return parameter dictionary per zoom level."""
params_per_zoom = {}
for zoom in zooms:
params = {}
for name, element in config.items():
if name not in _RESERVED_PARAMETERS:
out_element = _element_at_zoom(name, element, zoom)
... |
Return the element filtered by zoom level. | def _element_at_zoom(name, element, zoom):
"""
Return the element filtered by zoom level.
- An input integer or float gets returned as is.
- An input string is checked whether it starts with "zoom". Then, the
provided zoom level gets parsed and compared with the actual zoom
... |
Return element only if zoom condition matches with config string. | def _filter_by_zoom(element=None, conf_string=None, zoom=None):
"""Return element only if zoom condition matches with config string."""
for op_str, op_func in [
# order of operators is important:
# prematurely return in cases of "<=" or ">=", otherwise
# _strip_zoom() cannot parse config... |
Return zoom level as integer or throw error. | def _strip_zoom(input_string, strip_string):
"""Return zoom level as integer or throw error."""
try:
return int(input_string.strip(strip_string))
except Exception as e:
raise MapcheteConfigError("zoom level could not be determined: %s" % e) |
Flatten dict tree into dictionary where keys are paths of old dict. | def _flatten_tree(tree, old_path=None):
"""Flatten dict tree into dictionary where keys are paths of old dict."""
flat_tree = []
for key, value in tree.items():
new_path = "/".join([old_path, key]) if old_path else key
if isinstance(value, dict) and "format" not in value:
flat_tr... |
Reverse tree flattening. | def _unflatten_tree(flat):
"""Reverse tree flattening."""
tree = {}
for key, value in flat.items():
path = key.split("/")
# we are at the end of a branch
if len(path) == 1:
tree[key] = value
# there are more branches
else:
# create new dict
... |
Process bounds as defined in the configuration. | def bounds(self):
"""Process bounds as defined in the configuration."""
if self._raw["bounds"] is None:
return self.process_pyramid.bounds
else:
return Bounds(*_validate_bounds(self._raw["bounds"])) |
Process bounds this process is currently initialized with. | def init_bounds(self):
"""
Process bounds this process is currently initialized with.
This gets triggered by using the ``init_bounds`` kwarg. If not set, it will
be equal to self.bounds.
"""
if self._raw["init_bounds"] is None:
return self.bounds
else... |
Effective process bounds required to initialize inputs. | def effective_bounds(self):
"""
Effective process bounds required to initialize inputs.
Process bounds sometimes have to be larger, because all intersecting process
tiles have to be covered as well.
"""
return snap_bounds(
bounds=clip_bounds(bounds=self.init_... |
Output object of driver. | def output(self):
"""Output object of driver."""
output_params = dict(
self._raw["output"],
grid=self.output_pyramid.grid,
pixelbuffer=self.output_pyramid.pixelbuffer,
metatiling=self.output_pyramid.metatiling
)
if "path" in output_params:
... |
Input items used for process stored in a dictionary. | def input(self):
"""
Input items used for process stored in a dictionary.
Keys are the hashes of the input parameters, values the respective
InputData classes.
"""
# the delimiters are used by some input drivers
delimiters = dict(
zoom=self.init_zoom_... |
Optional baselevels configuration. | def baselevels(self):
"""
Optional baselevels configuration.
baselevels:
min: <zoom>
max: <zoom>
lower: <resampling method>
higher: <resampling method>
"""
if "baselevels" not in self._raw:
return {}
baselevels ... |
Return configuration parameters snapshot for zoom as dictionary. | def params_at_zoom(self, zoom):
"""
Return configuration parameters snapshot for zoom as dictionary.
Parameters
----------
zoom : int
zoom level
Returns
-------
configuration snapshot : dictionary
zoom level dependent process configur... |
Return process bounding box for zoom level. | def area_at_zoom(self, zoom=None):
"""
Return process bounding box for zoom level.
Parameters
----------
zoom : int or None
if None, the union of all zoom level areas is returned
Returns
-------
process area : shapely geometry
"""
... |
Return process bounds for zoom level. | def bounds_at_zoom(self, zoom=None):
"""
Return process bounds for zoom level.
Parameters
----------
zoom : integer or list
Returns
-------
process bounds : tuple
left, bottom, right, top
"""
return () if self.area_at_zoom(zoo... |
Deprecated. | def process_file(self):
"""Deprecated."""
warnings.warn(DeprecationWarning("'self.process_file' is deprecated"))
return os.path.join(self._raw["config_dir"], self._raw["process"]) |
Generate indexes for given zoom level. | def zoom_index_gen(
mp=None,
out_dir=None,
zoom=None,
geojson=False,
gpkg=False,
shapefile=False,
txt=False,
vrt=False,
fieldname="location",
basepath=None,
for_gdal=True,
threading=False,
):
"""
Generate indexes for given zoom level.
Parameters
---------... |
Return the recommended segmentation value in input file units. | def get_segmentize_value(input_file=None, tile_pyramid=None):
"""
Return the recommended segmentation value in input file units.
It is calculated by multiplyling raster pixel size with tile shape in
pixels.
Parameters
----------
input_file : str
location of a file readable by raste... |
Return raster metadata. | def profile(self):
"""Return raster metadata."""
with rasterio.open(self.path, "r") as src:
return deepcopy(src.meta) |
Return data bounding box. | def bbox(self, out_crs=None):
"""
Return data bounding box.
Parameters
----------
out_crs : ``rasterio.crs.CRS``
rasterio CRS object (default: CRS of process pyramid)
Returns
-------
bounding box : geometry
Shapely geometry object... |
Read reprojected & resampled input data. | def read(self, indexes=None, **kwargs):
"""
Read reprojected & resampled input data.
Returns
-------
data : array
"""
return read_raster_window(
self.raster_file.path,
self.tile,
indexes=self._get_band_indexes(indexes),
... |
Check if there is data within this tile. | def is_empty(self, indexes=None):
"""
Check if there is data within this tile.
Returns
-------
is empty : bool
"""
# empty if tile does not intersect with file bounding box
return not self.tile.bbox.intersects(
self.raster_file.bbox(out_crs=se... |
Return valid band indexes. | def _get_band_indexes(self, indexes=None):
"""Return valid band indexes."""
if indexes:
if isinstance(indexes, list):
return indexes
else:
return [indexes]
else:
return range(1, self.raster_file.profile["count"] + 1) |
Example process for testing. | def execute(mp):
"""
Example process for testing.
Inputs:
-------
file1
raster file
Parameters:
-----------
Output:
-------
np.ndarray
"""
# Reading and writing data works like this:
with mp.open("file1", resampling="bilinear") as raster_file:
if ra... |
Read existing process output. | def read(self, output_tile, **kwargs):
"""
Read existing process output.
Parameters
----------
output_tile : ``BufferedTile``
must be member of output ``TilePyramid``
Returns
-------
process output : list
"""
path = self.get_p... |
Write data from process tiles into GeoJSON file ( s ). | def write(self, process_tile, data):
"""
Write data from process tiles into GeoJSON file(s).
Parameters
----------
process_tile : ``BufferedTile``
must be member of process ``TilePyramid``
"""
if data is None or len(data) == 0:
return
... |
Check if output format is valid with other process parameters. | def is_valid_with_config(self, config):
"""
Check if output format is valid with other process parameters.
Parameters
----------
config : dictionary
output configuration parameters
Returns
-------
is_valid : bool
"""
validate_... |
Read data from process output. | def read(self, validity_check=True, no_neighbors=False, **kwargs):
"""
Read data from process output.
Parameters
----------
validity_check : bool
run geometry validity check (default: True)
no_neighbors : bool
don't include neighbor tiles if there... |
Execute a Mapchete process. | def execute(
mapchete_files,
zoom=None,
bounds=None,
point=None,
wkt_geometry=None,
tile=None,
overwrite=False,
multi=None,
input_file=None,
logfile=None,
verbose=False,
no_pbar=False,
debug=False,
max_chunksize=None,
vrt=False,
idx_out_dir=None
):
"""... |
Return all available output formats. | def available_output_formats():
"""
Return all available output formats.
Returns
-------
formats : list
all available output formats
"""
output_formats = []
for v in pkg_resources.iter_entry_points(DRIVERS_ENTRY_POINT):
driver_ = v.load()
if hasattr(driver_, "MET... |
Return all available input formats. | def available_input_formats():
"""
Return all available input formats.
Returns
-------
formats : list
all available input formats
"""
input_formats = []
for v in pkg_resources.iter_entry_points(DRIVERS_ENTRY_POINT):
logger.debug("driver found: %s", v)
driver_ = v... |
Return output class of driver. | def load_output_writer(output_params, readonly=False):
"""
Return output class of driver.
Returns
-------
output : ``OutputData``
output writer object
"""
if not isinstance(output_params, dict):
raise TypeError("output_params must be a dictionary")
driver_name = output_p... |
Return input class of driver. | def load_input_reader(input_params, readonly=False):
"""
Return input class of driver.
Returns
-------
input_params : ``InputData``
input parameters
"""
logger.debug("find input reader with params %s", input_params)
if not isinstance(input_params, dict):
raise TypeError(... |
Guess driver from file extension. | def driver_from_file(input_file):
"""
Guess driver from file extension.
Returns
-------
driver : string
driver name
"""
file_ext = os.path.splitext(input_file)[1].split(".")[1]
if file_ext not in _file_ext_to_driver():
raise MapcheteDriverError(
"no driver co... |
Dump output JSON and verify parameters if output metadata exist. | def write_output_metadata(output_params):
"""Dump output JSON and verify parameters if output metadata exist."""
if "path" in output_params:
metadata_path = os.path.join(output_params["path"], "metadata.json")
logger.debug("check for output %s", metadata_path)
try:
existing_p... |
List input and/ or output formats. | def formats(input_formats, output_formats, debug=False):
"""List input and/or output formats."""
if input_formats == output_formats:
show_inputs, show_outputs = True, True
else:
show_inputs, show_outputs = input_formats, output_formats
if show_inputs:
click.echo("input formats:"... |
Return InputTile object. | def open(
self,
tile,
tile_directory_zoom=None,
matching_method="gdal",
matching_max_zoom=None,
matching_precision=8,
fallback_to_higher_zoom=False,
resampling="nearest",
**kwargs
):
"""
Return InputTile object.
Paramet... |
Return data bounding box. | def bbox(self, out_crs=None):
"""
Return data bounding box.
Parameters
----------
out_crs : ``rasterio.crs.CRS``
rasterio CRS object (default: CRS of process pyramid)
Returns
-------
bounding box : geometry
Shapely geometry object... |
Read reprojected & resampled input data. | def read(
self,
validity_check=False,
indexes=None,
resampling=None,
dst_nodata=None,
gdal_opts=None,
**kwargs
):
"""
Read reprojected & resampled input data.
Parameters
----------
validity_check : bool
vect... |
Extract contour lines from an array. | def extract_contours(array, tile, interval=100, field='elev', base=0):
"""
Extract contour lines from an array.
Parameters
----------
array : array
input elevation data
tile : Tile
tile covering the array
interval : integer
elevation value interval when drawing conto... |
Return a list of values between min and max within an interval. | def _get_contour_values(min_val, max_val, base=0, interval=100):
"""Return a list of values between min and max within an interval."""
i = base
out = []
if min_val < base:
while i >= min_val:
i -= interval
while i <= max_val:
if i >= min_val:
out.append(i)
... |
Create an empty Mapchete and process file in a given directory. | def create(
mapchete_file,
process_file,
out_format,
out_path=None,
pyramid_type=None,
force=False
):
"""Create an empty Mapchete and process file in a given directory."""
if os.path.isfile(process_file) or os.path.isfile(mapchete_file):
if not force:
raise IOError("f... |
Check whether output tiles of a tile ( either process or output ) exists. | def tiles_exist(self, process_tile=None, output_tile=None):
"""
Check whether output tiles of a tile (either process or output) exists.
Parameters
----------
process_tile : ``BufferedTile``
must be member of process ``TilePyramid``
output_tile : ``BufferedTil... |
Determine target file path. | def get_path(self, tile):
"""
Determine target file path.
Parameters
----------
tile : ``BufferedTile``
must be member of output ``TilePyramid``
Returns
-------
path : string
"""
return os.path.join(*[
self.path,
... |
Create directory and subdirectory if necessary. | def prepare_path(self, tile):
"""
Create directory and subdirectory if necessary.
Parameters
----------
tile : ``BufferedTile``
must be member of output ``TilePyramid``
"""
makedirs(os.path.dirname(self.get_path(tile))) |
Check whether process output is allowed with output driver. | def output_is_valid(self, process_data):
"""
Check whether process output is allowed with output driver.
Parameters
----------
process_data : raw process output
Returns
-------
True or False
"""
if self.METADATA["data_type"] == "raster":
... |
Return verified and cleaned output. | def output_cleaned(self, process_data):
"""
Return verified and cleaned output.
Parameters
----------
process_data : raw process output
Returns
-------
NumPy array or list of features.
"""
if self.METADATA["data_type"] == "raster":
... |
Extract subset from multiple tiles. | def extract_subset(self, input_data_tiles=None, out_tile=None):
"""
Extract subset from multiple tiles.
input_data_tiles : list of (``Tile``, process data) tuples
out_tile : ``Tile``
Returns
-------
NumPy array or list of features.
"""
if self.ME... |
Read reprojected & resampled input data. | def _read_as_tiledir(
self,
out_tile=None,
td_crs=None,
tiles_paths=None,
profile=None,
validity_check=False,
indexes=None,
resampling=None,
dst_nodata=None,
gdal_opts=None,
**kwargs
):
"""
Read reprojected & res... |
Calculate slope and aspect map. | def calculate_slope_aspect(elevation, xres, yres, z=1.0, scale=1.0):
"""
Calculate slope and aspect map.
Return a pair of arrays 2 pixels smaller than the input elevation array.
Slope is returned in radians, from 0 for sheer face to pi/2 for
flat ground. Aspect is returned in radians, counterclock... |
Return hillshaded numpy array. | def hillshade(elevation, tile, azimuth=315.0, altitude=45.0, z=1.0, scale=1.0):
"""
Return hillshaded numpy array.
Parameters
----------
elevation : array
input elevation data
tile : Tile
tile covering the array
z : float
vertical exaggeration factor
scale : floa... |
Return BufferedTile object of this BufferedTilePyramid. | def tile(self, zoom, row, col):
"""
Return ``BufferedTile`` object of this ``BufferedTilePyramid``.
Parameters
----------
zoom : integer
zoom level
row : integer
tile matrix row
col : integer
tile matrix column
Returns... |
Return all tiles intersecting with bounds. | def tiles_from_bounds(self, bounds, zoom):
"""
Return all tiles intersecting with bounds.
Bounds values will be cleaned if they cross the antimeridian or are
outside of the Northern or Southern tile pyramid bounds.
Parameters
----------
bounds : tuple
... |
All metatiles intersecting with given bounding box. | def tiles_from_bbox(self, geometry, zoom):
"""
All metatiles intersecting with given bounding box.
Parameters
----------
geometry : ``shapely.geometry``
zoom : integer
zoom level
Yields
------
intersecting tiles : generator
... |
Return all tiles intersecting with input geometry. | def tiles_from_geom(self, geometry, zoom):
"""
Return all tiles intersecting with input geometry.
Parameters
----------
geometry : ``shapely.geometry``
zoom : integer
zoom level
Yields
------
intersecting tiles : ``BufferedTile``
... |
Return all BufferedTiles intersecting with tile. | def intersecting(self, tile):
"""
Return all BufferedTiles intersecting with tile.
Parameters
----------
tile : ``BufferedTile``
another tile
"""
return [
self.tile(*intersecting_tile.id)
for intersecting_tile in self.tile_pyra... |
Return dictionary representation of pyramid parameters. | def to_dict(self):
"""
Return dictionary representation of pyramid parameters.
"""
return dict(
grid=self.grid.to_dict(),
metatiling=self.metatiling,
tile_size=self.tile_size,
pixelbuffer=self.pixelbuffer
) |
Get tile children ( intersecting tiles in next zoom level ). | def get_children(self):
"""
Get tile children (intersecting tiles in next zoom level).
Returns
-------
children : list
a list of ``BufferedTiles``
"""
return [BufferedTile(t, self.pixelbuffer) for t in self._tile.get_children()] |
Return tile neighbors. | def get_neighbors(self, connectedness=8):
"""
Return tile neighbors.
Tile neighbors are unique, i.e. in some edge cases, where both the left
and right neighbor wrapped around the antimeridian is the same. Also,
neighbors ouside the northern and southern TilePyramid boundaries ar... |
Determine whether tile touches or goes over pyramid edge. | def is_on_edge(self):
"""Determine whether tile touches or goes over pyramid edge."""
return (
self.left <= self.tile_pyramid.left or # touches_left
self.bottom <= self.tile_pyramid.bottom or # touches_bottom
self.right >= self.tile_pyramid.right or # touches... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.