id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
14,500 | opendatateam/udata | udata/search/fields.py | TermsFacet.add_filter | def add_filter(self, filter_values):
"""Improve the original one to deal with OR cases."""
field = self._params['field']
# Build a `AND` query on values wihtout the OR operator.
# and a `OR` query for each value containing the OR operator.
filters = [
Q('bool', should... | python | def add_filter(self, filter_values):
"""Improve the original one to deal with OR cases."""
field = self._params['field']
# Build a `AND` query on values wihtout the OR operator.
# and a `OR` query for each value containing the OR operator.
filters = [
Q('bool', should... | [
"def",
"add_filter",
"(",
"self",
",",
"filter_values",
")",
":",
"field",
"=",
"self",
".",
"_params",
"[",
"'field'",
"]",
"# Build a `AND` query on values wihtout the OR operator.",
"# and a `OR` query for each value containing the OR operator.",
"filters",
"=",
"[",
"Q"... | Improve the original one to deal with OR cases. | [
"Improve",
"the",
"original",
"one",
"to",
"deal",
"with",
"OR",
"cases",
"."
] | f016585af94b0ff6bd73738c700324adc8ba7f8f | https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/search/fields.py#L87-L100 |
14,501 | opendatateam/udata | udata/search/fields.py | ModelTermsFacet.get_values | def get_values(self, data, filter_values):
"""
Turn the raw bucket data into a list of tuples containing the object,
number of documents and a flag indicating whether this value has been
selected or not.
"""
values = super(ModelTermsFacet, self).get_values(data, filter_va... | python | def get_values(self, data, filter_values):
"""
Turn the raw bucket data into a list of tuples containing the object,
number of documents and a flag indicating whether this value has been
selected or not.
"""
values = super(ModelTermsFacet, self).get_values(data, filter_va... | [
"def",
"get_values",
"(",
"self",
",",
"data",
",",
"filter_values",
")",
":",
"values",
"=",
"super",
"(",
"ModelTermsFacet",
",",
"self",
")",
".",
"get_values",
"(",
"data",
",",
"filter_values",
")",
"ids",
"=",
"[",
"key",
"for",
"(",
"key",
",",
... | Turn the raw bucket data into a list of tuples containing the object,
number of documents and a flag indicating whether this value has been
selected or not. | [
"Turn",
"the",
"raw",
"bucket",
"data",
"into",
"a",
"list",
"of",
"tuples",
"containing",
"the",
"object",
"number",
"of",
"documents",
"and",
"a",
"flag",
"indicating",
"whether",
"this",
"value",
"has",
"been",
"selected",
"or",
"not",
"."
] | f016585af94b0ff6bd73738c700324adc8ba7f8f | https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/search/fields.py#L135-L151 |
14,502 | opendatateam/udata | udata/core/organization/forms.py | OrganizationForm.save | def save(self, commit=True, **kwargs):
'''Register the current user as admin on creation'''
org = super(OrganizationForm, self).save(commit=False, **kwargs)
if not org.id:
user = current_user._get_current_object()
member = Member(user=user, role='admin')
org.... | python | def save(self, commit=True, **kwargs):
'''Register the current user as admin on creation'''
org = super(OrganizationForm, self).save(commit=False, **kwargs)
if not org.id:
user = current_user._get_current_object()
member = Member(user=user, role='admin')
org.... | [
"def",
"save",
"(",
"self",
",",
"commit",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"org",
"=",
"super",
"(",
"OrganizationForm",
",",
"self",
")",
".",
"save",
"(",
"commit",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"org",... | Register the current user as admin on creation | [
"Register",
"the",
"current",
"user",
"as",
"admin",
"on",
"creation"
] | f016585af94b0ff6bd73738c700324adc8ba7f8f | https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/core/organization/forms.py#L36-L48 |
14,503 | antonagestam/collectfast | collectfast/etag.py | get_cache_key | def get_cache_key(path):
"""
Create a cache key by concatenating the prefix with a hash of the path.
"""
# Python 2/3 support for path hashing
try:
path_hash = hashlib.md5(path).hexdigest()
except TypeError:
path_hash = hashlib.md5(path.encode('utf-8')).hexdigest()
return set... | python | def get_cache_key(path):
"""
Create a cache key by concatenating the prefix with a hash of the path.
"""
# Python 2/3 support for path hashing
try:
path_hash = hashlib.md5(path).hexdigest()
except TypeError:
path_hash = hashlib.md5(path.encode('utf-8')).hexdigest()
return set... | [
"def",
"get_cache_key",
"(",
"path",
")",
":",
"# Python 2/3 support for path hashing",
"try",
":",
"path_hash",
"=",
"hashlib",
".",
"md5",
"(",
"path",
")",
".",
"hexdigest",
"(",
")",
"except",
"TypeError",
":",
"path_hash",
"=",
"hashlib",
".",
"md5",
"(... | Create a cache key by concatenating the prefix with a hash of the path. | [
"Create",
"a",
"cache",
"key",
"by",
"concatenating",
"the",
"prefix",
"with",
"a",
"hash",
"of",
"the",
"path",
"."
] | fb9d7976da2a2578528fa6f3bbd053ee87475ecb | https://github.com/antonagestam/collectfast/blob/fb9d7976da2a2578528fa6f3bbd053ee87475ecb/collectfast/etag.py#L28-L37 |
14,504 | antonagestam/collectfast | collectfast/etag.py | get_remote_etag | def get_remote_etag(storage, prefixed_path):
"""
Get etag of path from S3 using boto or boto3.
"""
normalized_path = safe_join(storage.location, prefixed_path).replace(
'\\', '/')
try:
return storage.bucket.get_key(normalized_path).etag
except AttributeError:
pass
try... | python | def get_remote_etag(storage, prefixed_path):
"""
Get etag of path from S3 using boto or boto3.
"""
normalized_path = safe_join(storage.location, prefixed_path).replace(
'\\', '/')
try:
return storage.bucket.get_key(normalized_path).etag
except AttributeError:
pass
try... | [
"def",
"get_remote_etag",
"(",
"storage",
",",
"prefixed_path",
")",
":",
"normalized_path",
"=",
"safe_join",
"(",
"storage",
".",
"location",
",",
"prefixed_path",
")",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
"try",
":",
"return",
"storage",
".",
... | Get etag of path from S3 using boto or boto3. | [
"Get",
"etag",
"of",
"path",
"from",
"S3",
"using",
"boto",
"or",
"boto3",
"."
] | fb9d7976da2a2578528fa6f3bbd053ee87475ecb | https://github.com/antonagestam/collectfast/blob/fb9d7976da2a2578528fa6f3bbd053ee87475ecb/collectfast/etag.py#L40-L54 |
14,505 | antonagestam/collectfast | collectfast/etag.py | get_etag | def get_etag(storage, path, prefixed_path):
"""
Get etag of path from cache or S3 - in that order.
"""
cache_key = get_cache_key(path)
etag = cache.get(cache_key, False)
if etag is False:
etag = get_remote_etag(storage, prefixed_path)
cache.set(cache_key, etag)
return etag | python | def get_etag(storage, path, prefixed_path):
"""
Get etag of path from cache or S3 - in that order.
"""
cache_key = get_cache_key(path)
etag = cache.get(cache_key, False)
if etag is False:
etag = get_remote_etag(storage, prefixed_path)
cache.set(cache_key, etag)
return etag | [
"def",
"get_etag",
"(",
"storage",
",",
"path",
",",
"prefixed_path",
")",
":",
"cache_key",
"=",
"get_cache_key",
"(",
"path",
")",
"etag",
"=",
"cache",
".",
"get",
"(",
"cache_key",
",",
"False",
")",
"if",
"etag",
"is",
"False",
":",
"etag",
"=",
... | Get etag of path from cache or S3 - in that order. | [
"Get",
"etag",
"of",
"path",
"from",
"cache",
"or",
"S3",
"-",
"in",
"that",
"order",
"."
] | fb9d7976da2a2578528fa6f3bbd053ee87475ecb | https://github.com/antonagestam/collectfast/blob/fb9d7976da2a2578528fa6f3bbd053ee87475ecb/collectfast/etag.py#L57-L66 |
14,506 | antonagestam/collectfast | collectfast/etag.py | get_file_hash | def get_file_hash(storage, path):
"""
Create md5 hash from file contents.
"""
contents = storage.open(path).read()
file_hash = hashlib.md5(contents).hexdigest()
# Check if content should be gzipped and hash gzipped content
content_type = mimetypes.guess_type(path)[0] or 'application/octet-s... | python | def get_file_hash(storage, path):
"""
Create md5 hash from file contents.
"""
contents = storage.open(path).read()
file_hash = hashlib.md5(contents).hexdigest()
# Check if content should be gzipped and hash gzipped content
content_type = mimetypes.guess_type(path)[0] or 'application/octet-s... | [
"def",
"get_file_hash",
"(",
"storage",
",",
"path",
")",
":",
"contents",
"=",
"storage",
".",
"open",
"(",
"path",
")",
".",
"read",
"(",
")",
"file_hash",
"=",
"hashlib",
".",
"md5",
"(",
"contents",
")",
".",
"hexdigest",
"(",
")",
"# Check if cont... | Create md5 hash from file contents. | [
"Create",
"md5",
"hash",
"from",
"file",
"contents",
"."
] | fb9d7976da2a2578528fa6f3bbd053ee87475ecb | https://github.com/antonagestam/collectfast/blob/fb9d7976da2a2578528fa6f3bbd053ee87475ecb/collectfast/etag.py#L76-L97 |
14,507 | antonagestam/collectfast | collectfast/etag.py | has_matching_etag | def has_matching_etag(remote_storage, source_storage, path, prefixed_path):
"""
Compare etag of path in source storage with remote.
"""
storage_etag = get_etag(remote_storage, path, prefixed_path)
local_etag = get_file_hash(source_storage, path)
return storage_etag == local_etag | python | def has_matching_etag(remote_storage, source_storage, path, prefixed_path):
"""
Compare etag of path in source storage with remote.
"""
storage_etag = get_etag(remote_storage, path, prefixed_path)
local_etag = get_file_hash(source_storage, path)
return storage_etag == local_etag | [
"def",
"has_matching_etag",
"(",
"remote_storage",
",",
"source_storage",
",",
"path",
",",
"prefixed_path",
")",
":",
"storage_etag",
"=",
"get_etag",
"(",
"remote_storage",
",",
"path",
",",
"prefixed_path",
")",
"local_etag",
"=",
"get_file_hash",
"(",
"source_... | Compare etag of path in source storage with remote. | [
"Compare",
"etag",
"of",
"path",
"in",
"source",
"storage",
"with",
"remote",
"."
] | fb9d7976da2a2578528fa6f3bbd053ee87475ecb | https://github.com/antonagestam/collectfast/blob/fb9d7976da2a2578528fa6f3bbd053ee87475ecb/collectfast/etag.py#L100-L106 |
14,508 | antonagestam/collectfast | collectfast/etag.py | should_copy_file | def should_copy_file(remote_storage, path, prefixed_path, source_storage):
"""
Returns True if the file should be copied, otherwise False.
"""
if has_matching_etag(
remote_storage, source_storage, path, prefixed_path):
logger.info("%s: Skipping based on matching file hashes" % path)
... | python | def should_copy_file(remote_storage, path, prefixed_path, source_storage):
"""
Returns True if the file should be copied, otherwise False.
"""
if has_matching_etag(
remote_storage, source_storage, path, prefixed_path):
logger.info("%s: Skipping based on matching file hashes" % path)
... | [
"def",
"should_copy_file",
"(",
"remote_storage",
",",
"path",
",",
"prefixed_path",
",",
"source_storage",
")",
":",
"if",
"has_matching_etag",
"(",
"remote_storage",
",",
"source_storage",
",",
"path",
",",
"prefixed_path",
")",
":",
"logger",
".",
"info",
"("... | Returns True if the file should be copied, otherwise False. | [
"Returns",
"True",
"if",
"the",
"file",
"should",
"be",
"copied",
"otherwise",
"False",
"."
] | fb9d7976da2a2578528fa6f3bbd053ee87475ecb | https://github.com/antonagestam/collectfast/blob/fb9d7976da2a2578528fa6f3bbd053ee87475ecb/collectfast/etag.py#L109-L121 |
14,509 | antonagestam/collectfast | collectfast/management/commands/collectstatic.py | Command.set_options | def set_options(self, **options):
"""
Set options and handle deprecation.
"""
ignore_etag = options.pop('ignore_etag', False)
disable = options.pop('disable_collectfast', False)
if ignore_etag:
warnings.warn(
"--ignore-etag is deprecated since ... | python | def set_options(self, **options):
"""
Set options and handle deprecation.
"""
ignore_etag = options.pop('ignore_etag', False)
disable = options.pop('disable_collectfast', False)
if ignore_etag:
warnings.warn(
"--ignore-etag is deprecated since ... | [
"def",
"set_options",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"ignore_etag",
"=",
"options",
".",
"pop",
"(",
"'ignore_etag'",
",",
"False",
")",
"disable",
"=",
"options",
".",
"pop",
"(",
"'disable_collectfast'",
",",
"False",
")",
"if",
"igno... | Set options and handle deprecation. | [
"Set",
"options",
"and",
"handle",
"deprecation",
"."
] | fb9d7976da2a2578528fa6f3bbd053ee87475ecb | https://github.com/antonagestam/collectfast/blob/fb9d7976da2a2578528fa6f3bbd053ee87475ecb/collectfast/management/commands/collectstatic.py#L44-L56 |
14,510 | antonagestam/collectfast | collectfast/management/commands/collectstatic.py | Command.handle | def handle(self, **options):
"""
Override handle to supress summary output
"""
super(Command, self).handle(**options)
return "{} static file{} copied.".format(
self.num_copied_files,
'' if self.num_copied_files == 1 else 's') | python | def handle(self, **options):
"""
Override handle to supress summary output
"""
super(Command, self).handle(**options)
return "{} static file{} copied.".format(
self.num_copied_files,
'' if self.num_copied_files == 1 else 's') | [
"def",
"handle",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"super",
"(",
"Command",
",",
"self",
")",
".",
"handle",
"(",
"*",
"*",
"options",
")",
"return",
"\"{} static file{} copied.\"",
".",
"format",
"(",
"self",
".",
"num_copied_files",
",",... | Override handle to supress summary output | [
"Override",
"handle",
"to",
"supress",
"summary",
"output"
] | fb9d7976da2a2578528fa6f3bbd053ee87475ecb | https://github.com/antonagestam/collectfast/blob/fb9d7976da2a2578528fa6f3bbd053ee87475ecb/collectfast/management/commands/collectstatic.py#L68-L75 |
14,511 | antonagestam/collectfast | collectfast/management/commands/collectstatic.py | Command.do_copy_file | def do_copy_file(self, args):
"""
Determine if file should be copied or not and handle exceptions.
"""
path, prefixed_path, source_storage = args
reset_connection(self.storage)
if self.collectfast_enabled and not self.dry_run:
try:
if not sho... | python | def do_copy_file(self, args):
"""
Determine if file should be copied or not and handle exceptions.
"""
path, prefixed_path, source_storage = args
reset_connection(self.storage)
if self.collectfast_enabled and not self.dry_run:
try:
if not sho... | [
"def",
"do_copy_file",
"(",
"self",
",",
"args",
")",
":",
"path",
",",
"prefixed_path",
",",
"source_storage",
"=",
"args",
"reset_connection",
"(",
"self",
".",
"storage",
")",
"if",
"self",
".",
"collectfast_enabled",
"and",
"not",
"self",
".",
"dry_run",... | Determine if file should be copied or not and handle exceptions. | [
"Determine",
"if",
"file",
"should",
"be",
"copied",
"or",
"not",
"and",
"handle",
"exceptions",
"."
] | fb9d7976da2a2578528fa6f3bbd053ee87475ecb | https://github.com/antonagestam/collectfast/blob/fb9d7976da2a2578528fa6f3bbd053ee87475ecb/collectfast/management/commands/collectstatic.py#L77-L100 |
14,512 | antonagestam/collectfast | collectfast/management/commands/collectstatic.py | Command.copy_file | def copy_file(self, path, prefixed_path, source_storage):
"""
Appends path to task queue if threads are enabled, otherwise copies
the file with a blocking call.
"""
args = (path, prefixed_path, source_storage)
if settings.threads:
self.tasks.append(args)
... | python | def copy_file(self, path, prefixed_path, source_storage):
"""
Appends path to task queue if threads are enabled, otherwise copies
the file with a blocking call.
"""
args = (path, prefixed_path, source_storage)
if settings.threads:
self.tasks.append(args)
... | [
"def",
"copy_file",
"(",
"self",
",",
"path",
",",
"prefixed_path",
",",
"source_storage",
")",
":",
"args",
"=",
"(",
"path",
",",
"prefixed_path",
",",
"source_storage",
")",
"if",
"settings",
".",
"threads",
":",
"self",
".",
"tasks",
".",
"append",
"... | Appends path to task queue if threads are enabled, otherwise copies
the file with a blocking call. | [
"Appends",
"path",
"to",
"task",
"queue",
"if",
"threads",
"are",
"enabled",
"otherwise",
"copies",
"the",
"file",
"with",
"a",
"blocking",
"call",
"."
] | fb9d7976da2a2578528fa6f3bbd053ee87475ecb | https://github.com/antonagestam/collectfast/blob/fb9d7976da2a2578528fa6f3bbd053ee87475ecb/collectfast/management/commands/collectstatic.py#L102-L111 |
14,513 | antonagestam/collectfast | collectfast/management/commands/collectstatic.py | Command.delete_file | def delete_file(self, path, prefixed_path, source_storage):
"""
Override delete_file to skip modified time and exists lookups.
"""
if not self.collectfast_enabled:
return super(Command, self).delete_file(
path, prefixed_path, source_storage)
if not sel... | python | def delete_file(self, path, prefixed_path, source_storage):
"""
Override delete_file to skip modified time and exists lookups.
"""
if not self.collectfast_enabled:
return super(Command, self).delete_file(
path, prefixed_path, source_storage)
if not sel... | [
"def",
"delete_file",
"(",
"self",
",",
"path",
",",
"prefixed_path",
",",
"source_storage",
")",
":",
"if",
"not",
"self",
".",
"collectfast_enabled",
":",
"return",
"super",
"(",
"Command",
",",
"self",
")",
".",
"delete_file",
"(",
"path",
",",
"prefixe... | Override delete_file to skip modified time and exists lookups. | [
"Override",
"delete_file",
"to",
"skip",
"modified",
"time",
"and",
"exists",
"lookups",
"."
] | fb9d7976da2a2578528fa6f3bbd053ee87475ecb | https://github.com/antonagestam/collectfast/blob/fb9d7976da2a2578528fa6f3bbd053ee87475ecb/collectfast/management/commands/collectstatic.py#L113-L125 |
14,514 | satellogic/telluric | telluric/georaster.py | join | def join(rasters):
"""
This method takes a list of rasters and returns a raster that is constructed of all of them
"""
raster = rasters[0] # using the first raster to understand what is the type of data we have
mask_band = None
nodata = None
with raster._raster_opener(raster.source_file) a... | python | def join(rasters):
"""
This method takes a list of rasters and returns a raster that is constructed of all of them
"""
raster = rasters[0] # using the first raster to understand what is the type of data we have
mask_band = None
nodata = None
with raster._raster_opener(raster.source_file) a... | [
"def",
"join",
"(",
"rasters",
")",
":",
"raster",
"=",
"rasters",
"[",
"0",
"]",
"# using the first raster to understand what is the type of data we have",
"mask_band",
"=",
"None",
"nodata",
"=",
"None",
"with",
"raster",
".",
"_raster_opener",
"(",
"raster",
".",... | This method takes a list of rasters and returns a raster that is constructed of all of them | [
"This",
"method",
"takes",
"a",
"list",
"of",
"rasters",
"and",
"returns",
"a",
"raster",
"that",
"is",
"constructed",
"of",
"all",
"of",
"them"
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L95-L109 |
14,515 | satellogic/telluric | telluric/georaster.py | merge_all | def merge_all(rasters, roi=None, dest_resolution=None, merge_strategy=MergeStrategy.UNION,
shape=None, ul_corner=None, crs=None, pixel_strategy=PixelStrategy.FIRST,
resampling=Resampling.nearest):
"""Merge a list of rasters, cropping by a region of interest.
There are cases that t... | python | def merge_all(rasters, roi=None, dest_resolution=None, merge_strategy=MergeStrategy.UNION,
shape=None, ul_corner=None, crs=None, pixel_strategy=PixelStrategy.FIRST,
resampling=Resampling.nearest):
"""Merge a list of rasters, cropping by a region of interest.
There are cases that t... | [
"def",
"merge_all",
"(",
"rasters",
",",
"roi",
"=",
"None",
",",
"dest_resolution",
"=",
"None",
",",
"merge_strategy",
"=",
"MergeStrategy",
".",
"UNION",
",",
"shape",
"=",
"None",
",",
"ul_corner",
"=",
"None",
",",
"crs",
"=",
"None",
",",
"pixel_st... | Merge a list of rasters, cropping by a region of interest.
There are cases that the roi is not precise enough for this cases one can use,
the upper left corner the shape and crs to precisely define the roi.
When roi is provided the ul_corner, shape and crs are ignored | [
"Merge",
"a",
"list",
"of",
"rasters",
"cropping",
"by",
"a",
"region",
"of",
"interest",
".",
"There",
"are",
"cases",
"that",
"the",
"roi",
"is",
"not",
"precise",
"enough",
"for",
"this",
"cases",
"one",
"can",
"use",
"the",
"upper",
"left",
"corner",... | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L120-L161 |
14,516 | satellogic/telluric | telluric/georaster.py | _merge_common_bands | def _merge_common_bands(rasters):
# type: (List[_Raster]) -> List[_Raster]
"""Combine the common bands.
"""
# Compute band order
all_bands = IndexedSet([rs.band_names[0] for rs in rasters])
def key(rs):
return all_bands.index(rs.band_names[0])
rasters_final = [] # type: List[_Ras... | python | def _merge_common_bands(rasters):
# type: (List[_Raster]) -> List[_Raster]
"""Combine the common bands.
"""
# Compute band order
all_bands = IndexedSet([rs.band_names[0] for rs in rasters])
def key(rs):
return all_bands.index(rs.band_names[0])
rasters_final = [] # type: List[_Ras... | [
"def",
"_merge_common_bands",
"(",
"rasters",
")",
":",
"# type: (List[_Raster]) -> List[_Raster]",
"# Compute band order",
"all_bands",
"=",
"IndexedSet",
"(",
"[",
"rs",
".",
"band_names",
"[",
"0",
"]",
"for",
"rs",
"in",
"rasters",
"]",
")",
"def",
"key",
"(... | Combine the common bands. | [
"Combine",
"the",
"common",
"bands",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L197-L212 |
14,517 | satellogic/telluric | telluric/georaster.py | _explode_raster | def _explode_raster(raster, band_names=[]):
# type: (_Raster, Iterable[str]) -> List[_Raster]
"""Splits a raster into multiband rasters.
"""
# Using band_names=[] does no harm because we are not mutating it in place
# and it makes MyPy happy
if not band_names:
band_names = raster.band_n... | python | def _explode_raster(raster, band_names=[]):
# type: (_Raster, Iterable[str]) -> List[_Raster]
"""Splits a raster into multiband rasters.
"""
# Using band_names=[] does no harm because we are not mutating it in place
# and it makes MyPy happy
if not band_names:
band_names = raster.band_n... | [
"def",
"_explode_raster",
"(",
"raster",
",",
"band_names",
"=",
"[",
"]",
")",
":",
"# type: (_Raster, Iterable[str]) -> List[_Raster]",
"# Using band_names=[] does no harm because we are not mutating it in place",
"# and it makes MyPy happy",
"if",
"not",
"band_names",
":",
"ba... | Splits a raster into multiband rasters. | [
"Splits",
"a",
"raster",
"into",
"multiband",
"rasters",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L244-L256 |
14,518 | satellogic/telluric | telluric/georaster.py | _fill_pixels | def _fill_pixels(one, other):
# type: (_Raster, _Raster) -> _Raster
"""Merges two single band rasters with the same band by filling the pixels according to depth.
"""
assert len(one.band_names) == len(other.band_names) == 1, "Rasters are not single band"
# We raise an error in the intersection is ... | python | def _fill_pixels(one, other):
# type: (_Raster, _Raster) -> _Raster
"""Merges two single band rasters with the same band by filling the pixels according to depth.
"""
assert len(one.band_names) == len(other.band_names) == 1, "Rasters are not single band"
# We raise an error in the intersection is ... | [
"def",
"_fill_pixels",
"(",
"one",
",",
"other",
")",
":",
"# type: (_Raster, _Raster) -> _Raster",
"assert",
"len",
"(",
"one",
".",
"band_names",
")",
"==",
"len",
"(",
"other",
".",
"band_names",
")",
"==",
"1",
",",
"\"Rasters are not single band\"",
"# We r... | Merges two single band rasters with the same band by filling the pixels according to depth. | [
"Merges",
"two",
"single",
"band",
"rasters",
"with",
"the",
"same",
"band",
"by",
"filling",
"the",
"pixels",
"according",
"to",
"depth",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L286-L329 |
14,519 | satellogic/telluric | telluric/georaster.py | _stack_bands | def _stack_bands(one, other):
# type: (_Raster, _Raster) -> _Raster
"""Merges two rasters with non overlapping bands by stacking the bands.
"""
assert set(one.band_names).intersection(set(other.band_names)) == set()
# We raise an error in the bands are the same. See above.
if one.band_names ==... | python | def _stack_bands(one, other):
# type: (_Raster, _Raster) -> _Raster
"""Merges two rasters with non overlapping bands by stacking the bands.
"""
assert set(one.band_names).intersection(set(other.band_names)) == set()
# We raise an error in the bands are the same. See above.
if one.band_names ==... | [
"def",
"_stack_bands",
"(",
"one",
",",
"other",
")",
":",
"# type: (_Raster, _Raster) -> _Raster",
"assert",
"set",
"(",
"one",
".",
"band_names",
")",
".",
"intersection",
"(",
"set",
"(",
"other",
".",
"band_names",
")",
")",
"==",
"set",
"(",
")",
"# W... | Merges two rasters with non overlapping bands by stacking the bands. | [
"Merges",
"two",
"rasters",
"with",
"non",
"overlapping",
"bands",
"by",
"stacking",
"the",
"bands",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L332-L362 |
14,520 | satellogic/telluric | telluric/georaster.py | merge_two | def merge_two(one, other, merge_strategy=MergeStrategy.UNION, silent=False, pixel_strategy=PixelStrategy.FIRST):
# type: (GeoRaster2, GeoRaster2, MergeStrategy, bool, PixelStrategy) -> GeoRaster2
"""Merge two rasters into one.
Parameters
----------
one : GeoRaster2
Left raster to merge.
... | python | def merge_two(one, other, merge_strategy=MergeStrategy.UNION, silent=False, pixel_strategy=PixelStrategy.FIRST):
# type: (GeoRaster2, GeoRaster2, MergeStrategy, bool, PixelStrategy) -> GeoRaster2
"""Merge two rasters into one.
Parameters
----------
one : GeoRaster2
Left raster to merge.
... | [
"def",
"merge_two",
"(",
"one",
",",
"other",
",",
"merge_strategy",
"=",
"MergeStrategy",
".",
"UNION",
",",
"silent",
"=",
"False",
",",
"pixel_strategy",
"=",
"PixelStrategy",
".",
"FIRST",
")",
":",
"# type: (GeoRaster2, GeoRaster2, MergeStrategy, bool, PixelStrat... | Merge two rasters into one.
Parameters
----------
one : GeoRaster2
Left raster to merge.
other : GeoRaster2
Right raster to merge.
merge_strategy : MergeStrategy, optional
Merge strategy, from :py:data:`telluric.georaster.MergeStrategy` (default to "union").
silent : boo... | [
"Merge",
"two",
"rasters",
"into",
"one",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L365-L414 |
14,521 | satellogic/telluric | telluric/georaster.py | _Raster._set_image | def _set_image(self, image, nodata=None):
"""
Set self._image.
:param image: supported: np.ma.array, np.array, TODO: PIL image
:param nodata: if provided image is array (not masked array), treat pixels with value=nodata as nodata
:return:
"""
# convert to masked ... | python | def _set_image(self, image, nodata=None):
"""
Set self._image.
:param image: supported: np.ma.array, np.array, TODO: PIL image
:param nodata: if provided image is array (not masked array), treat pixels with value=nodata as nodata
:return:
"""
# convert to masked ... | [
"def",
"_set_image",
"(",
"self",
",",
"image",
",",
"nodata",
"=",
"None",
")",
":",
"# convert to masked array:",
"if",
"isinstance",
"(",
"image",
",",
"np",
".",
"ma",
".",
"core",
".",
"MaskedArray",
")",
":",
"masked",
"=",
"image",
"elif",
"isinst... | Set self._image.
:param image: supported: np.ma.array, np.array, TODO: PIL image
:param nodata: if provided image is array (not masked array), treat pixels with value=nodata as nodata
:return: | [
"Set",
"self",
".",
"_image",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L467-L497 |
14,522 | satellogic/telluric | telluric/georaster.py | GeoRaster2.from_wms | def from_wms(cls, filename, vector, resolution, destination_file=None):
"""Create georaster from the web service definition file."""
doc = wms_vrt(filename,
bounds=vector,
resolution=resolution).tostring()
filename = cls._save_to_destination_file(doc, ... | python | def from_wms(cls, filename, vector, resolution, destination_file=None):
"""Create georaster from the web service definition file."""
doc = wms_vrt(filename,
bounds=vector,
resolution=resolution).tostring()
filename = cls._save_to_destination_file(doc, ... | [
"def",
"from_wms",
"(",
"cls",
",",
"filename",
",",
"vector",
",",
"resolution",
",",
"destination_file",
"=",
"None",
")",
":",
"doc",
"=",
"wms_vrt",
"(",
"filename",
",",
"bounds",
"=",
"vector",
",",
"resolution",
"=",
"resolution",
")",
".",
"tostr... | Create georaster from the web service definition file. | [
"Create",
"georaster",
"from",
"the",
"web",
"service",
"definition",
"file",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L626-L632 |
14,523 | satellogic/telluric | telluric/georaster.py | GeoRaster2.from_rasters | def from_rasters(cls, rasters, relative_to_vrt=True, destination_file=None, nodata=None, mask_band=None):
"""Create georaster out of a list of rasters."""
if isinstance(rasters, list):
doc = raster_list_vrt(rasters, relative_to_vrt, nodata, mask_band).tostring()
else:
doc... | python | def from_rasters(cls, rasters, relative_to_vrt=True, destination_file=None, nodata=None, mask_band=None):
"""Create georaster out of a list of rasters."""
if isinstance(rasters, list):
doc = raster_list_vrt(rasters, relative_to_vrt, nodata, mask_band).tostring()
else:
doc... | [
"def",
"from_rasters",
"(",
"cls",
",",
"rasters",
",",
"relative_to_vrt",
"=",
"True",
",",
"destination_file",
"=",
"None",
",",
"nodata",
"=",
"None",
",",
"mask_band",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"rasters",
",",
"list",
")",
":",
... | Create georaster out of a list of rasters. | [
"Create",
"georaster",
"out",
"of",
"a",
"list",
"of",
"rasters",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L635-L642 |
14,524 | satellogic/telluric | telluric/georaster.py | GeoRaster2.open | def open(cls, filename, band_names=None, lazy_load=True, mutable=False, **kwargs):
"""
Read a georaster from a file.
:param filename: url
:param band_names: list of strings, or string.
if None - will try to read from image, otherwise - these will be ['0', ..]... | python | def open(cls, filename, band_names=None, lazy_load=True, mutable=False, **kwargs):
"""
Read a georaster from a file.
:param filename: url
:param band_names: list of strings, or string.
if None - will try to read from image, otherwise - these will be ['0', ..]... | [
"def",
"open",
"(",
"cls",
",",
"filename",
",",
"band_names",
"=",
"None",
",",
"lazy_load",
"=",
"True",
",",
"mutable",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"mutable",
":",
"geo_raster",
"=",
"MutableGeoRaster",
"(",
"filename",
"=... | Read a georaster from a file.
:param filename: url
:param band_names: list of strings, or string.
if None - will try to read from image, otherwise - these will be ['0', ..]
:param lazy_load: if True - do not load anything
:return: GeoRaster2 | [
"Read",
"a",
"georaster",
"from",
"a",
"file",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L645-L661 |
14,525 | satellogic/telluric | telluric/georaster.py | GeoRaster2.tags | def tags(cls, filename, namespace=None):
"""Extract tags from file."""
return cls._raster_opener(filename).tags(ns=namespace) | python | def tags(cls, filename, namespace=None):
"""Extract tags from file."""
return cls._raster_opener(filename).tags(ns=namespace) | [
"def",
"tags",
"(",
"cls",
",",
"filename",
",",
"namespace",
"=",
"None",
")",
":",
"return",
"cls",
".",
"_raster_opener",
"(",
"filename",
")",
".",
"tags",
"(",
"ns",
"=",
"namespace",
")"
] | Extract tags from file. | [
"Extract",
"tags",
"from",
"file",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L724-L726 |
14,526 | satellogic/telluric | telluric/georaster.py | GeoRaster2.image | def image(self):
"""Raster bitmap in numpy array."""
if self._image is None:
self._populate_from_rasterio_object(read_image=True)
return self._image | python | def image(self):
"""Raster bitmap in numpy array."""
if self._image is None:
self._populate_from_rasterio_object(read_image=True)
return self._image | [
"def",
"image",
"(",
"self",
")",
":",
"if",
"self",
".",
"_image",
"is",
"None",
":",
"self",
".",
"_populate_from_rasterio_object",
"(",
"read_image",
"=",
"True",
")",
"return",
"self",
".",
"_image"
] | Raster bitmap in numpy array. | [
"Raster",
"bitmap",
"in",
"numpy",
"array",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L729-L733 |
14,527 | satellogic/telluric | telluric/georaster.py | GeoRaster2.crs | def crs(self): # type: () -> CRS
"""Raster crs."""
if self._crs is None:
self._populate_from_rasterio_object(read_image=False)
return self._crs | python | def crs(self): # type: () -> CRS
"""Raster crs."""
if self._crs is None:
self._populate_from_rasterio_object(read_image=False)
return self._crs | [
"def",
"crs",
"(",
"self",
")",
":",
"# type: () -> CRS",
"if",
"self",
".",
"_crs",
"is",
"None",
":",
"self",
".",
"_populate_from_rasterio_object",
"(",
"read_image",
"=",
"False",
")",
"return",
"self",
".",
"_crs"
] | Raster crs. | [
"Raster",
"crs",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L758-L762 |
14,528 | satellogic/telluric | telluric/georaster.py | GeoRaster2.shape | def shape(self):
"""Raster shape."""
if self._shape is None:
self._populate_from_rasterio_object(read_image=False)
return self._shape | python | def shape(self):
"""Raster shape."""
if self._shape is None:
self._populate_from_rasterio_object(read_image=False)
return self._shape | [
"def",
"shape",
"(",
"self",
")",
":",
"if",
"self",
".",
"_shape",
"is",
"None",
":",
"self",
".",
"_populate_from_rasterio_object",
"(",
"read_image",
"=",
"False",
")",
"return",
"self",
".",
"_shape"
] | Raster shape. | [
"Raster",
"shape",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L765-L769 |
14,529 | satellogic/telluric | telluric/georaster.py | GeoRaster2.source_file | def source_file(self):
""" When using open, returns the filename used
"""
if self._filename is None:
self._filename = self._as_in_memory_geotiff()._filename
return self._filename | python | def source_file(self):
""" When using open, returns the filename used
"""
if self._filename is None:
self._filename = self._as_in_memory_geotiff()._filename
return self._filename | [
"def",
"source_file",
"(",
"self",
")",
":",
"if",
"self",
".",
"_filename",
"is",
"None",
":",
"self",
".",
"_filename",
"=",
"self",
".",
"_as_in_memory_geotiff",
"(",
")",
".",
"_filename",
"return",
"self",
".",
"_filename"
] | When using open, returns the filename used | [
"When",
"using",
"open",
"returns",
"the",
"filename",
"used"
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L788-L793 |
14,530 | satellogic/telluric | telluric/georaster.py | GeoRaster2.blockshapes | def blockshapes(self):
"""Raster all bands block shape."""
if self._blockshapes is None:
if self._filename:
self._populate_from_rasterio_object(read_image=False)
else:
# if no file is attached to the raster set the shape of each band to be the data... | python | def blockshapes(self):
"""Raster all bands block shape."""
if self._blockshapes is None:
if self._filename:
self._populate_from_rasterio_object(read_image=False)
else:
# if no file is attached to the raster set the shape of each band to be the data... | [
"def",
"blockshapes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_blockshapes",
"is",
"None",
":",
"if",
"self",
".",
"_filename",
":",
"self",
".",
"_populate_from_rasterio_object",
"(",
"read_image",
"=",
"False",
")",
"else",
":",
"# if no file is attached ... | Raster all bands block shape. | [
"Raster",
"all",
"bands",
"block",
"shape",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L822-L830 |
14,531 | satellogic/telluric | telluric/georaster.py | GeoRaster2.get | def get(self, point):
"""
Get the pixel values at the requested point.
:param point: A GeoVector(POINT) with the coordinates of the values to get
:return: numpy array of values
"""
if not (isinstance(point, GeoVector) and point.type == 'Point'):
raise TypeErr... | python | def get(self, point):
"""
Get the pixel values at the requested point.
:param point: A GeoVector(POINT) with the coordinates of the values to get
:return: numpy array of values
"""
if not (isinstance(point, GeoVector) and point.type == 'Point'):
raise TypeErr... | [
"def",
"get",
"(",
"self",
",",
"point",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"point",
",",
"GeoVector",
")",
"and",
"point",
".",
"type",
"==",
"'Point'",
")",
":",
"raise",
"TypeError",
"(",
"'expect GeoVector(Point), got %s'",
"%",
"(",
"poi... | Get the pixel values at the requested point.
:param point: A GeoVector(POINT) with the coordinates of the values to get
:return: numpy array of values | [
"Get",
"the",
"pixel",
"values",
"at",
"the",
"requested",
"point",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L978-L989 |
14,532 | satellogic/telluric | telluric/georaster.py | GeoRaster2.copy | def copy(self, mutable=False):
"""Return a copy of this GeoRaster with no modifications.
Can be use to create a Mutable copy of the GeoRaster"""
if self.not_loaded():
_cls = self.__class__
if mutable:
_cls = MutableGeoRaster
return _cls.open(... | python | def copy(self, mutable=False):
"""Return a copy of this GeoRaster with no modifications.
Can be use to create a Mutable copy of the GeoRaster"""
if self.not_loaded():
_cls = self.__class__
if mutable:
_cls = MutableGeoRaster
return _cls.open(... | [
"def",
"copy",
"(",
"self",
",",
"mutable",
"=",
"False",
")",
":",
"if",
"self",
".",
"not_loaded",
"(",
")",
":",
"_cls",
"=",
"self",
".",
"__class__",
"if",
"mutable",
":",
"_cls",
"=",
"MutableGeoRaster",
"return",
"_cls",
".",
"open",
"(",
"sel... | Return a copy of this GeoRaster with no modifications.
Can be use to create a Mutable copy of the GeoRaster | [
"Return",
"a",
"copy",
"of",
"this",
"GeoRaster",
"with",
"no",
"modifications",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1198-L1209 |
14,533 | satellogic/telluric | telluric/georaster.py | GeoRaster2._resize | def _resize(self, ratio_x, ratio_y, resampling):
"""Return raster resized by ratio."""
new_width = int(np.ceil(self.width * ratio_x))
new_height = int(np.ceil(self.height * ratio_y))
dest_affine = self.affine * Affine.scale(1 / ratio_x, 1 / ratio_y)
if self.not_loaded():
... | python | def _resize(self, ratio_x, ratio_y, resampling):
"""Return raster resized by ratio."""
new_width = int(np.ceil(self.width * ratio_x))
new_height = int(np.ceil(self.height * ratio_y))
dest_affine = self.affine * Affine.scale(1 / ratio_x, 1 / ratio_y)
if self.not_loaded():
... | [
"def",
"_resize",
"(",
"self",
",",
"ratio_x",
",",
"ratio_y",
",",
"resampling",
")",
":",
"new_width",
"=",
"int",
"(",
"np",
".",
"ceil",
"(",
"self",
".",
"width",
"*",
"ratio_x",
")",
")",
"new_height",
"=",
"int",
"(",
"np",
".",
"ceil",
"(",... | Return raster resized by ratio. | [
"Return",
"raster",
"resized",
"by",
"ratio",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1277-L1288 |
14,534 | satellogic/telluric | telluric/georaster.py | GeoRaster2.to_pillow_image | def to_pillow_image(self, return_mask=False):
"""Return Pillow. Image, and optionally also mask."""
img = np.rollaxis(np.rollaxis(self.image.data, 2), 2)
img = Image.fromarray(img[:, :, 0]) if img.shape[2] == 1 else Image.fromarray(img)
if return_mask:
mask = np.ma.getmaskarr... | python | def to_pillow_image(self, return_mask=False):
"""Return Pillow. Image, and optionally also mask."""
img = np.rollaxis(np.rollaxis(self.image.data, 2), 2)
img = Image.fromarray(img[:, :, 0]) if img.shape[2] == 1 else Image.fromarray(img)
if return_mask:
mask = np.ma.getmaskarr... | [
"def",
"to_pillow_image",
"(",
"self",
",",
"return_mask",
"=",
"False",
")",
":",
"img",
"=",
"np",
".",
"rollaxis",
"(",
"np",
".",
"rollaxis",
"(",
"self",
".",
"image",
".",
"data",
",",
"2",
")",
",",
"2",
")",
"img",
"=",
"Image",
".",
"fro... | Return Pillow. Image, and optionally also mask. | [
"Return",
"Pillow",
".",
"Image",
"and",
"optionally",
"also",
"mask",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1290-L1299 |
14,535 | satellogic/telluric | telluric/georaster.py | GeoRaster2.from_bytes | def from_bytes(cls, image_bytes, affine, crs, band_names=None):
"""Create GeoRaster from image BytesIo object.
:param image_bytes: io.BytesIO object
:param affine: rasters affine
:param crs: rasters crs
:param band_names: e.g. ['red', 'blue'] or 'red'
"""
b = io.... | python | def from_bytes(cls, image_bytes, affine, crs, band_names=None):
"""Create GeoRaster from image BytesIo object.
:param image_bytes: io.BytesIO object
:param affine: rasters affine
:param crs: rasters crs
:param band_names: e.g. ['red', 'blue'] or 'red'
"""
b = io.... | [
"def",
"from_bytes",
"(",
"cls",
",",
"image_bytes",
",",
"affine",
",",
"crs",
",",
"band_names",
"=",
"None",
")",
":",
"b",
"=",
"io",
".",
"BytesIO",
"(",
"image_bytes",
")",
"image",
"=",
"imageio",
".",
"imread",
"(",
"b",
")",
"roll",
"=",
"... | Create GeoRaster from image BytesIo object.
:param image_bytes: io.BytesIO object
:param affine: rasters affine
:param crs: rasters crs
:param band_names: e.g. ['red', 'blue'] or 'red' | [
"Create",
"GeoRaster",
"from",
"image",
"BytesIo",
"object",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1506-L1522 |
14,536 | satellogic/telluric | telluric/georaster.py | GeoRaster2._repr_html_ | def _repr_html_(self):
"""Required for jupyter notebook to show raster as an interactive map."""
TileServer.run_tileserver(self, self.footprint())
capture = "raster: %s" % self._filename
mp = TileServer.folium_client(self, self.footprint(), capture=capture)
return mp._repr_html_(... | python | def _repr_html_(self):
"""Required for jupyter notebook to show raster as an interactive map."""
TileServer.run_tileserver(self, self.footprint())
capture = "raster: %s" % self._filename
mp = TileServer.folium_client(self, self.footprint(), capture=capture)
return mp._repr_html_(... | [
"def",
"_repr_html_",
"(",
"self",
")",
":",
"TileServer",
".",
"run_tileserver",
"(",
"self",
",",
"self",
".",
"footprint",
"(",
")",
")",
"capture",
"=",
"\"raster: %s\"",
"%",
"self",
".",
"_filename",
"mp",
"=",
"TileServer",
".",
"folium_client",
"("... | Required for jupyter notebook to show raster as an interactive map. | [
"Required",
"for",
"jupyter",
"notebook",
"to",
"show",
"raster",
"as",
"an",
"interactive",
"map",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1524-L1529 |
14,537 | satellogic/telluric | telluric/georaster.py | GeoRaster2.image_corner | def image_corner(self, corner):
"""Return image corner in pixels, as shapely.Point."""
if corner not in self.corner_types():
raise GeoRaster2Error('corner %s invalid, expected: %s' % (corner, self.corner_types()))
x = 0 if corner[1] == 'l' else self.width
y = 0 if corner[0] ... | python | def image_corner(self, corner):
"""Return image corner in pixels, as shapely.Point."""
if corner not in self.corner_types():
raise GeoRaster2Error('corner %s invalid, expected: %s' % (corner, self.corner_types()))
x = 0 if corner[1] == 'l' else self.width
y = 0 if corner[0] ... | [
"def",
"image_corner",
"(",
"self",
",",
"corner",
")",
":",
"if",
"corner",
"not",
"in",
"self",
".",
"corner_types",
"(",
")",
":",
"raise",
"GeoRaster2Error",
"(",
"'corner %s invalid, expected: %s'",
"%",
"(",
"corner",
",",
"self",
".",
"corner_types",
... | Return image corner in pixels, as shapely.Point. | [
"Return",
"image",
"corner",
"in",
"pixels",
"as",
"shapely",
".",
"Point",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1555-L1562 |
14,538 | satellogic/telluric | telluric/georaster.py | GeoRaster2.center | def center(self):
"""Return footprint center in world coordinates, as GeoVector."""
image_center = Point(self.width / 2, self.height / 2)
return self.to_world(image_center) | python | def center(self):
"""Return footprint center in world coordinates, as GeoVector."""
image_center = Point(self.width / 2, self.height / 2)
return self.to_world(image_center) | [
"def",
"center",
"(",
"self",
")",
":",
"image_center",
"=",
"Point",
"(",
"self",
".",
"width",
"/",
"2",
",",
"self",
".",
"height",
"/",
"2",
")",
"return",
"self",
".",
"to_world",
"(",
"image_center",
")"
] | Return footprint center in world coordinates, as GeoVector. | [
"Return",
"footprint",
"center",
"in",
"world",
"coordinates",
"as",
"GeoVector",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1576-L1579 |
14,539 | satellogic/telluric | telluric/georaster.py | GeoRaster2.bounds | def bounds(self):
"""Return image rectangle in pixels, as shapely.Polygon."""
corners = [self.image_corner(corner) for corner in self.corner_types()]
return Polygon([[corner.x, corner.y] for corner in corners]) | python | def bounds(self):
"""Return image rectangle in pixels, as shapely.Polygon."""
corners = [self.image_corner(corner) for corner in self.corner_types()]
return Polygon([[corner.x, corner.y] for corner in corners]) | [
"def",
"bounds",
"(",
"self",
")",
":",
"corners",
"=",
"[",
"self",
".",
"image_corner",
"(",
"corner",
")",
"for",
"corner",
"in",
"self",
".",
"corner_types",
"(",
")",
"]",
"return",
"Polygon",
"(",
"[",
"[",
"corner",
".",
"x",
",",
"corner",
... | Return image rectangle in pixels, as shapely.Polygon. | [
"Return",
"image",
"rectangle",
"in",
"pixels",
"as",
"shapely",
".",
"Polygon",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1581-L1584 |
14,540 | satellogic/telluric | telluric/georaster.py | GeoRaster2._calc_footprint | def _calc_footprint(self):
"""Return rectangle in world coordinates, as GeoVector."""
corners = [self.corner(corner) for corner in self.corner_types()]
coords = []
for corner in corners:
shape = corner.get_shape(corner.crs)
coords.append([shape.x, shape.y])
... | python | def _calc_footprint(self):
"""Return rectangle in world coordinates, as GeoVector."""
corners = [self.corner(corner) for corner in self.corner_types()]
coords = []
for corner in corners:
shape = corner.get_shape(corner.crs)
coords.append([shape.x, shape.y])
... | [
"def",
"_calc_footprint",
"(",
"self",
")",
":",
"corners",
"=",
"[",
"self",
".",
"corner",
"(",
"corner",
")",
"for",
"corner",
"in",
"self",
".",
"corner_types",
"(",
")",
"]",
"coords",
"=",
"[",
"]",
"for",
"corner",
"in",
"corners",
":",
"shape... | Return rectangle in world coordinates, as GeoVector. | [
"Return",
"rectangle",
"in",
"world",
"coordinates",
"as",
"GeoVector",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1586-L1597 |
14,541 | satellogic/telluric | telluric/georaster.py | GeoRaster2.to_raster | def to_raster(self, vector):
"""Return the vector in pixel coordinates, as shapely.Geometry."""
return transform(vector.get_shape(vector.crs), vector.crs, self.crs, dst_affine=~self.affine) | python | def to_raster(self, vector):
"""Return the vector in pixel coordinates, as shapely.Geometry."""
return transform(vector.get_shape(vector.crs), vector.crs, self.crs, dst_affine=~self.affine) | [
"def",
"to_raster",
"(",
"self",
",",
"vector",
")",
":",
"return",
"transform",
"(",
"vector",
".",
"get_shape",
"(",
"vector",
".",
"crs",
")",
",",
"vector",
".",
"crs",
",",
"self",
".",
"crs",
",",
"dst_affine",
"=",
"~",
"self",
".",
"affine",
... | Return the vector in pixel coordinates, as shapely.Geometry. | [
"Return",
"the",
"vector",
"in",
"pixel",
"coordinates",
"as",
"shapely",
".",
"Geometry",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1611-L1613 |
14,542 | satellogic/telluric | telluric/georaster.py | GeoRaster2.reduce | def reduce(self, op):
"""Reduce the raster to a score, using 'op' operation.
nodata pixels are ignored.
op is currently limited to numpy.ma, e.g. 'mean', 'std' etc
:returns list of per-band values
"""
per_band = [getattr(np.ma, op)(self.image.data[band, np.ma.getmaskarra... | python | def reduce(self, op):
"""Reduce the raster to a score, using 'op' operation.
nodata pixels are ignored.
op is currently limited to numpy.ma, e.g. 'mean', 'std' etc
:returns list of per-band values
"""
per_band = [getattr(np.ma, op)(self.image.data[band, np.ma.getmaskarra... | [
"def",
"reduce",
"(",
"self",
",",
"op",
")",
":",
"per_band",
"=",
"[",
"getattr",
"(",
"np",
".",
"ma",
",",
"op",
")",
"(",
"self",
".",
"image",
".",
"data",
"[",
"band",
",",
"np",
".",
"ma",
".",
"getmaskarray",
"(",
"self",
".",
"image",... | Reduce the raster to a score, using 'op' operation.
nodata pixels are ignored.
op is currently limited to numpy.ma, e.g. 'mean', 'std' etc
:returns list of per-band values | [
"Reduce",
"the",
"raster",
"to",
"a",
"score",
"using",
"op",
"operation",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1642-L1651 |
14,543 | satellogic/telluric | telluric/georaster.py | GeoRaster2.mask | def mask(self, vector, mask_shape_nodata=False):
"""
Set pixels outside vector as nodata.
:param vector: GeoVector, GeoFeature, FeatureCollection
:param mask_shape_nodata: if True - pixels inside shape are set nodata, if False - outside shape is nodata
:return: GeoRaster2
... | python | def mask(self, vector, mask_shape_nodata=False):
"""
Set pixels outside vector as nodata.
:param vector: GeoVector, GeoFeature, FeatureCollection
:param mask_shape_nodata: if True - pixels inside shape are set nodata, if False - outside shape is nodata
:return: GeoRaster2
... | [
"def",
"mask",
"(",
"self",
",",
"vector",
",",
"mask_shape_nodata",
"=",
"False",
")",
":",
"from",
"telluric",
".",
"collections",
"import",
"BaseCollection",
"# crop raster to reduce memory footprint",
"cropped",
"=",
"self",
".",
"crop",
"(",
"vector",
")",
... | Set pixels outside vector as nodata.
:param vector: GeoVector, GeoFeature, FeatureCollection
:param mask_shape_nodata: if True - pixels inside shape are set nodata, if False - outside shape is nodata
:return: GeoRaster2 | [
"Set",
"pixels",
"outside",
"vector",
"as",
"nodata",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1700-L1721 |
14,544 | satellogic/telluric | telluric/georaster.py | GeoRaster2.mask_by_value | def mask_by_value(self, nodata):
"""
Return raster with a mask calculated based on provided value.
Only pixels with value=nodata will be masked.
:param nodata: value of the pixels that should be masked
:return: GeoRaster2
"""
return self.copy_with(image=np.ma.mas... | python | def mask_by_value(self, nodata):
"""
Return raster with a mask calculated based on provided value.
Only pixels with value=nodata will be masked.
:param nodata: value of the pixels that should be masked
:return: GeoRaster2
"""
return self.copy_with(image=np.ma.mas... | [
"def",
"mask_by_value",
"(",
"self",
",",
"nodata",
")",
":",
"return",
"self",
".",
"copy_with",
"(",
"image",
"=",
"np",
".",
"ma",
".",
"masked_array",
"(",
"self",
".",
"image",
".",
"data",
",",
"mask",
"=",
"self",
".",
"image",
".",
"data",
... | Return raster with a mask calculated based on provided value.
Only pixels with value=nodata will be masked.
:param nodata: value of the pixels that should be masked
:return: GeoRaster2 | [
"Return",
"raster",
"with",
"a",
"mask",
"calculated",
"based",
"on",
"provided",
"value",
".",
"Only",
"pixels",
"with",
"value",
"=",
"nodata",
"will",
"be",
"masked",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1723-L1731 |
14,545 | satellogic/telluric | telluric/georaster.py | GeoRaster2.save_cloud_optimized | def save_cloud_optimized(self, dest_url, resampling=Resampling.gauss, blocksize=256,
overview_blocksize=256, creation_options=None):
"""Save as Cloud Optimized GeoTiff object to a new file.
:param dest_url: path to the new raster
:param resampling: which Resampling ... | python | def save_cloud_optimized(self, dest_url, resampling=Resampling.gauss, blocksize=256,
overview_blocksize=256, creation_options=None):
"""Save as Cloud Optimized GeoTiff object to a new file.
:param dest_url: path to the new raster
:param resampling: which Resampling ... | [
"def",
"save_cloud_optimized",
"(",
"self",
",",
"dest_url",
",",
"resampling",
"=",
"Resampling",
".",
"gauss",
",",
"blocksize",
"=",
"256",
",",
"overview_blocksize",
"=",
"256",
",",
"creation_options",
"=",
"None",
")",
":",
"src",
"=",
"self",
"# GeoRa... | Save as Cloud Optimized GeoTiff object to a new file.
:param dest_url: path to the new raster
:param resampling: which Resampling to use on reading, default Resampling.gauss
:param blocksize: the size of the blocks default 256
:param overview_blocksize: the block size of the overviews, ... | [
"Save",
"as",
"Cloud",
"Optimized",
"GeoTiff",
"object",
"to",
"a",
"new",
"file",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1773-L1794 |
14,546 | satellogic/telluric | telluric/georaster.py | GeoRaster2._get_window_out_shape | def _get_window_out_shape(self, bands, window, xsize, ysize):
"""Get the outshape of a window.
this method is only used inside get_window to calculate the out_shape
"""
if xsize and ysize is None:
ratio = window.width / xsize
ysize = math.ceil(window.height / ra... | python | def _get_window_out_shape(self, bands, window, xsize, ysize):
"""Get the outshape of a window.
this method is only used inside get_window to calculate the out_shape
"""
if xsize and ysize is None:
ratio = window.width / xsize
ysize = math.ceil(window.height / ra... | [
"def",
"_get_window_out_shape",
"(",
"self",
",",
"bands",
",",
"window",
",",
"xsize",
",",
"ysize",
")",
":",
"if",
"xsize",
"and",
"ysize",
"is",
"None",
":",
"ratio",
"=",
"window",
".",
"width",
"/",
"xsize",
"ysize",
"=",
"math",
".",
"ceil",
"... | Get the outshape of a window.
this method is only used inside get_window to calculate the out_shape | [
"Get",
"the",
"outshape",
"of",
"a",
"window",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1796-L1811 |
14,547 | satellogic/telluric | telluric/georaster.py | GeoRaster2._read_with_mask | def _read_with_mask(raster, masked):
""" returns if we should read from rasterio using the masked
"""
if masked is None:
mask_flags = raster.mask_flag_enums
per_dataset_mask = all([rasterio.enums.MaskFlags.per_dataset in flags for flags in mask_flags])
masked ... | python | def _read_with_mask(raster, masked):
""" returns if we should read from rasterio using the masked
"""
if masked is None:
mask_flags = raster.mask_flag_enums
per_dataset_mask = all([rasterio.enums.MaskFlags.per_dataset in flags for flags in mask_flags])
masked ... | [
"def",
"_read_with_mask",
"(",
"raster",
",",
"masked",
")",
":",
"if",
"masked",
"is",
"None",
":",
"mask_flags",
"=",
"raster",
".",
"mask_flag_enums",
"per_dataset_mask",
"=",
"all",
"(",
"[",
"rasterio",
".",
"enums",
".",
"MaskFlags",
".",
"per_dataset"... | returns if we should read from rasterio using the masked | [
"returns",
"if",
"we",
"should",
"read",
"from",
"rasterio",
"using",
"the",
"masked"
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1814-L1821 |
14,548 | satellogic/telluric | telluric/georaster.py | GeoRaster2.get_window | def get_window(self, window, bands=None,
xsize=None, ysize=None,
resampling=Resampling.cubic, masked=None, affine=None
):
"""Get window from raster.
:param window: requested window
:param bands: list of indices of requested bads, default ... | python | def get_window(self, window, bands=None,
xsize=None, ysize=None,
resampling=Resampling.cubic, masked=None, affine=None
):
"""Get window from raster.
:param window: requested window
:param bands: list of indices of requested bads, default ... | [
"def",
"get_window",
"(",
"self",
",",
"window",
",",
"bands",
"=",
"None",
",",
"xsize",
"=",
"None",
",",
"ysize",
"=",
"None",
",",
"resampling",
"=",
"Resampling",
".",
"cubic",
",",
"masked",
"=",
"None",
",",
"affine",
"=",
"None",
")",
":",
... | Get window from raster.
:param window: requested window
:param bands: list of indices of requested bads, default None which returns all bands
:param xsize: tile x size default None, for full resolution pass None
:param ysize: tile y size default None, for full resolution pass None
... | [
"Get",
"window",
"from",
"raster",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1823-L1862 |
14,549 | satellogic/telluric | telluric/georaster.py | GeoRaster2._get_tile_when_web_mercator_crs | def _get_tile_when_web_mercator_crs(self, x_tile, y_tile, zoom,
bands=None, masked=None,
resampling=Resampling.cubic):
""" The reason we want to treat this case in a special way
is that there are cases where the rater is... | python | def _get_tile_when_web_mercator_crs(self, x_tile, y_tile, zoom,
bands=None, masked=None,
resampling=Resampling.cubic):
""" The reason we want to treat this case in a special way
is that there are cases where the rater is... | [
"def",
"_get_tile_when_web_mercator_crs",
"(",
"self",
",",
"x_tile",
",",
"y_tile",
",",
"zoom",
",",
"bands",
"=",
"None",
",",
"masked",
"=",
"None",
",",
"resampling",
"=",
"Resampling",
".",
"cubic",
")",
":",
"roi",
"=",
"GeoVector",
".",
"from_xyz",... | The reason we want to treat this case in a special way
is that there are cases where the rater is aligned so you need to be precise
on which raster you want | [
"The",
"reason",
"we",
"want",
"to",
"treat",
"this",
"case",
"in",
"a",
"special",
"way",
"is",
"that",
"there",
"are",
"cases",
"where",
"the",
"rater",
"is",
"aligned",
"so",
"you",
"need",
"to",
"be",
"precise",
"on",
"which",
"raster",
"you",
"wan... | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1864-L1887 |
14,550 | satellogic/telluric | telluric/georaster.py | GeoRaster2.get_tile | def get_tile(self, x_tile, y_tile, zoom,
bands=None, masked=None, resampling=Resampling.cubic):
"""Convert mercator tile to raster window.
:param x_tile: x coordinate of tile
:param y_tile: y coordinate of tile
:param zoom: zoom level
:param bands: list of indic... | python | def get_tile(self, x_tile, y_tile, zoom,
bands=None, masked=None, resampling=Resampling.cubic):
"""Convert mercator tile to raster window.
:param x_tile: x coordinate of tile
:param y_tile: y coordinate of tile
:param zoom: zoom level
:param bands: list of indic... | [
"def",
"get_tile",
"(",
"self",
",",
"x_tile",
",",
"y_tile",
",",
"zoom",
",",
"bands",
"=",
"None",
",",
"masked",
"=",
"None",
",",
"resampling",
"=",
"Resampling",
".",
"cubic",
")",
":",
"if",
"self",
".",
"crs",
"==",
"WEB_MERCATOR_CRS",
":",
"... | Convert mercator tile to raster window.
:param x_tile: x coordinate of tile
:param y_tile: y coordinate of tile
:param zoom: zoom level
:param bands: list of indices of requested bands, default None which returns all bands
:param resampling: reprojection resampling method, defau... | [
"Convert",
"mercator",
"tile",
"to",
"raster",
"window",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1889-L1922 |
14,551 | satellogic/telluric | telluric/georaster.py | GeoRaster2.colorize | def colorize(self, colormap, band_name=None, vmin=None, vmax=None):
"""Apply a colormap on a selected band.
colormap list: https://matplotlib.org/examples/color/colormaps_reference.html
Parameters
----------
colormap : str
Colormap name from this list https://matplotlib... | python | def colorize(self, colormap, band_name=None, vmin=None, vmax=None):
"""Apply a colormap on a selected band.
colormap list: https://matplotlib.org/examples/color/colormaps_reference.html
Parameters
----------
colormap : str
Colormap name from this list https://matplotlib... | [
"def",
"colorize",
"(",
"self",
",",
"colormap",
",",
"band_name",
"=",
"None",
",",
"vmin",
"=",
"None",
",",
"vmax",
"=",
"None",
")",
":",
"vmin",
"=",
"vmin",
"if",
"vmin",
"is",
"not",
"None",
"else",
"min",
"(",
"self",
".",
"min",
"(",
")"... | Apply a colormap on a selected band.
colormap list: https://matplotlib.org/examples/color/colormaps_reference.html
Parameters
----------
colormap : str
Colormap name from this list https://matplotlib.org/examples/color/colormaps_reference.html
band_name : str, optional... | [
"Apply",
"a",
"colormap",
"on",
"a",
"selected",
"band",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1933-L1986 |
14,552 | satellogic/telluric | telluric/georaster.py | GeoRaster2.chunks | def chunks(self, shape=256, pad=False):
"""This method returns GeoRaster chunks out of the original raster.
The chunck is evaluated only when fetched from the iterator.
Useful when you want to iterate over a big rasters.
Parameters
----------
shape : int or tuple, optio... | python | def chunks(self, shape=256, pad=False):
"""This method returns GeoRaster chunks out of the original raster.
The chunck is evaluated only when fetched from the iterator.
Useful when you want to iterate over a big rasters.
Parameters
----------
shape : int or tuple, optio... | [
"def",
"chunks",
"(",
"self",
",",
"shape",
"=",
"256",
",",
"pad",
"=",
"False",
")",
":",
"_self",
"=",
"self",
".",
"_raster_backed_by_a_file",
"(",
")",
"if",
"isinstance",
"(",
"shape",
",",
"int",
")",
":",
"shape",
"=",
"(",
"shape",
",",
"s... | This method returns GeoRaster chunks out of the original raster.
The chunck is evaluated only when fetched from the iterator.
Useful when you want to iterate over a big rasters.
Parameters
----------
shape : int or tuple, optional
The shape of the chunk. Default: 25... | [
"This",
"method",
"returns",
"GeoRaster",
"chunks",
"out",
"of",
"the",
"original",
"raster",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1998-L2048 |
14,553 | satellogic/telluric | telluric/collections.py | dissolve | def dissolve(collection, aggfunc=None):
# type: (BaseCollection, Optional[Callable[[list], Any]]) -> GeoFeature
"""Dissolves features contained in a FeatureCollection and applies an aggregation
function to its properties.
"""
new_properties = {}
if aggfunc:
temp_properties = defaultdict... | python | def dissolve(collection, aggfunc=None):
# type: (BaseCollection, Optional[Callable[[list], Any]]) -> GeoFeature
"""Dissolves features contained in a FeatureCollection and applies an aggregation
function to its properties.
"""
new_properties = {}
if aggfunc:
temp_properties = defaultdict... | [
"def",
"dissolve",
"(",
"collection",
",",
"aggfunc",
"=",
"None",
")",
":",
"# type: (BaseCollection, Optional[Callable[[list], Any]]) -> GeoFeature",
"new_properties",
"=",
"{",
"}",
"if",
"aggfunc",
":",
"temp_properties",
"=",
"defaultdict",
"(",
"list",
")",
"# t... | Dissolves features contained in a FeatureCollection and applies an aggregation
function to its properties. | [
"Dissolves",
"features",
"contained",
"in",
"a",
"FeatureCollection",
"and",
"applies",
"an",
"aggregation",
"function",
"to",
"its",
"properties",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L34-L55 |
14,554 | satellogic/telluric | telluric/collections.py | BaseCollection.filter | def filter(self, intersects):
"""Filter results that intersect a given GeoFeature or Vector.
"""
try:
crs = self.crs
vector = intersects.geometry if isinstance(intersects, GeoFeature) else intersects
prepared_shape = prep(vector.get_shape(crs))
hi... | python | def filter(self, intersects):
"""Filter results that intersect a given GeoFeature or Vector.
"""
try:
crs = self.crs
vector = intersects.geometry if isinstance(intersects, GeoFeature) else intersects
prepared_shape = prep(vector.get_shape(crs))
hi... | [
"def",
"filter",
"(",
"self",
",",
"intersects",
")",
":",
"try",
":",
"crs",
"=",
"self",
".",
"crs",
"vector",
"=",
"intersects",
".",
"geometry",
"if",
"isinstance",
"(",
"intersects",
",",
"GeoFeature",
")",
"else",
"intersects",
"prepared_shape",
"=",... | Filter results that intersect a given GeoFeature or Vector. | [
"Filter",
"results",
"that",
"intersect",
"a",
"given",
"GeoFeature",
"or",
"Vector",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L137-L155 |
14,555 | satellogic/telluric | telluric/collections.py | BaseCollection.sort | def sort(self, by, desc=False):
"""Sorts by given property or function, ascending or descending order.
Parameters
----------
by : str or callable
If string, property by which to sort.
If callable, it should receive a GeoFeature a return a value by which to sort.
... | python | def sort(self, by, desc=False):
"""Sorts by given property or function, ascending or descending order.
Parameters
----------
by : str or callable
If string, property by which to sort.
If callable, it should receive a GeoFeature a return a value by which to sort.
... | [
"def",
"sort",
"(",
"self",
",",
"by",
",",
"desc",
"=",
"False",
")",
":",
"if",
"callable",
"(",
"by",
")",
":",
"key",
"=",
"by",
"else",
":",
"def",
"key",
"(",
"feature",
")",
":",
"return",
"feature",
"[",
"by",
"]",
"sorted_features",
"=",... | Sorts by given property or function, ascending or descending order.
Parameters
----------
by : str or callable
If string, property by which to sort.
If callable, it should receive a GeoFeature a return a value by which to sort.
desc : bool, optional
D... | [
"Sorts",
"by",
"given",
"property",
"or",
"function",
"ascending",
"or",
"descending",
"order",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L157-L176 |
14,556 | satellogic/telluric | telluric/collections.py | BaseCollection.groupby | def groupby(self, by):
# type: (Union[str, Callable[[GeoFeature], str]]) -> _CollectionGroupBy
"""Groups collection using a value of a property.
Parameters
----------
by : str or callable
If string, name of the property by which to group.
If callable, sho... | python | def groupby(self, by):
# type: (Union[str, Callable[[GeoFeature], str]]) -> _CollectionGroupBy
"""Groups collection using a value of a property.
Parameters
----------
by : str or callable
If string, name of the property by which to group.
If callable, sho... | [
"def",
"groupby",
"(",
"self",
",",
"by",
")",
":",
"# type: (Union[str, Callable[[GeoFeature], str]]) -> _CollectionGroupBy",
"results",
"=",
"OrderedDict",
"(",
")",
"# type: OrderedDict[str, list]",
"for",
"feature",
"in",
"self",
":",
"if",
"callable",
"(",
"by",
... | Groups collection using a value of a property.
Parameters
----------
by : str or callable
If string, name of the property by which to group.
If callable, should receive a GeoFeature and return the category.
Returns
-------
_CollectionGroupBy | [
"Groups",
"collection",
"using",
"a",
"value",
"of",
"a",
"property",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L178-L207 |
14,557 | satellogic/telluric | telluric/collections.py | BaseCollection.dissolve | def dissolve(self, by=None, aggfunc=None):
# type: (Optional[str], Optional[Callable]) -> FeatureCollection
"""Dissolve geometries and rasters within `groupby`.
"""
if by:
agg = partial(dissolve, aggfunc=aggfunc) # type: Callable[[BaseCollection], GeoFeature]
re... | python | def dissolve(self, by=None, aggfunc=None):
# type: (Optional[str], Optional[Callable]) -> FeatureCollection
"""Dissolve geometries and rasters within `groupby`.
"""
if by:
agg = partial(dissolve, aggfunc=aggfunc) # type: Callable[[BaseCollection], GeoFeature]
re... | [
"def",
"dissolve",
"(",
"self",
",",
"by",
"=",
"None",
",",
"aggfunc",
"=",
"None",
")",
":",
"# type: (Optional[str], Optional[Callable]) -> FeatureCollection",
"if",
"by",
":",
"agg",
"=",
"partial",
"(",
"dissolve",
",",
"aggfunc",
"=",
"aggfunc",
")",
"# ... | Dissolve geometries and rasters within `groupby`. | [
"Dissolve",
"geometries",
"and",
"rasters",
"within",
"groupby",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L209-L219 |
14,558 | satellogic/telluric | telluric/collections.py | BaseCollection.rasterize | def rasterize(self, dest_resolution, *, polygonize_width=0, crs=WEB_MERCATOR_CRS, fill_value=None,
bounds=None, dtype=None, **polygonize_kwargs):
"""Binarize a FeatureCollection and produce a raster with the target resolution.
Parameters
----------
dest_resolution: flo... | python | def rasterize(self, dest_resolution, *, polygonize_width=0, crs=WEB_MERCATOR_CRS, fill_value=None,
bounds=None, dtype=None, **polygonize_kwargs):
"""Binarize a FeatureCollection and produce a raster with the target resolution.
Parameters
----------
dest_resolution: flo... | [
"def",
"rasterize",
"(",
"self",
",",
"dest_resolution",
",",
"*",
",",
"polygonize_width",
"=",
"0",
",",
"crs",
"=",
"WEB_MERCATOR_CRS",
",",
"fill_value",
"=",
"None",
",",
"bounds",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"*",
"*",
"polygonize_k... | Binarize a FeatureCollection and produce a raster with the target resolution.
Parameters
----------
dest_resolution: float
Resolution in units of the CRS.
polygonize_width : int, optional
Width for the polygonized features (lines and points) in pixels, default to... | [
"Binarize",
"a",
"FeatureCollection",
"and",
"produce",
"a",
"raster",
"with",
"the",
"target",
"resolution",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L227-L306 |
14,559 | satellogic/telluric | telluric/collections.py | BaseCollection.save | def save(self, filename, driver=None, schema=None):
"""Saves collection to file.
"""
if driver is None:
driver = DRIVERS.get(os.path.splitext(filename)[-1])
if schema is None:
schema = self.schema
if driver == "GeoJSON":
# Workaround for htt... | python | def save(self, filename, driver=None, schema=None):
"""Saves collection to file.
"""
if driver is None:
driver = DRIVERS.get(os.path.splitext(filename)[-1])
if schema is None:
schema = self.schema
if driver == "GeoJSON":
# Workaround for htt... | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"driver",
"=",
"None",
",",
"schema",
"=",
"None",
")",
":",
"if",
"driver",
"is",
"None",
":",
"driver",
"=",
"DRIVERS",
".",
"get",
"(",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
... | Saves collection to file. | [
"Saves",
"collection",
"to",
"file",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L311-L334 |
14,560 | satellogic/telluric | telluric/collections.py | BaseCollection.apply | def apply(self, **kwargs):
"""Return a new FeatureCollection with the results of applying the statements in the arguments to each element.
"""
def _apply(f):
properties = copy.deepcopy(f.properties)
for prop, value in kwargs.items():
if callable(value):
... | python | def apply(self, **kwargs):
"""Return a new FeatureCollection with the results of applying the statements in the arguments to each element.
"""
def _apply(f):
properties = copy.deepcopy(f.properties)
for prop, value in kwargs.items():
if callable(value):
... | [
"def",
"apply",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"_apply",
"(",
"f",
")",
":",
"properties",
"=",
"copy",
".",
"deepcopy",
"(",
"f",
".",
"properties",
")",
"for",
"prop",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")"... | Return a new FeatureCollection with the results of applying the statements in the arguments to each element. | [
"Return",
"a",
"new",
"FeatureCollection",
"with",
"the",
"results",
"of",
"applying",
"the",
"statements",
"in",
"the",
"arguments",
"to",
"each",
"element",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L341-L363 |
14,561 | satellogic/telluric | telluric/collections.py | FeatureCollection.validate | def validate(self):
"""
if schema exists we run shape file validation code of fiona by trying to save to in MemoryFile
"""
if self._schema is not None:
with MemoryFile() as memfile:
with memfile.open(driver="ESRI Shapefile", schema=self.schema) as target:
... | python | def validate(self):
"""
if schema exists we run shape file validation code of fiona by trying to save to in MemoryFile
"""
if self._schema is not None:
with MemoryFile() as memfile:
with memfile.open(driver="ESRI Shapefile", schema=self.schema) as target:
... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"self",
".",
"_schema",
"is",
"not",
"None",
":",
"with",
"MemoryFile",
"(",
")",
"as",
"memfile",
":",
"with",
"memfile",
".",
"open",
"(",
"driver",
"=",
"\"ESRI Shapefile\"",
",",
"schema",
"=",
"self"... | if schema exists we run shape file validation code of fiona by trying to save to in MemoryFile | [
"if",
"schema",
"exists",
"we",
"run",
"shape",
"file",
"validation",
"code",
"of",
"fiona",
"by",
"trying",
"to",
"save",
"to",
"in",
"MemoryFile"
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L386-L396 |
14,562 | satellogic/telluric | telluric/collections.py | FileCollection.open | def open(cls, filename, crs=None):
"""Creates a FileCollection from a file in disk.
Parameters
----------
filename : str
Path of the file to read.
crs : CRS
overrides the crs of the collection, this funtion will not reprojects
"""
with fi... | python | def open(cls, filename, crs=None):
"""Creates a FileCollection from a file in disk.
Parameters
----------
filename : str
Path of the file to read.
crs : CRS
overrides the crs of the collection, this funtion will not reprojects
"""
with fi... | [
"def",
"open",
"(",
"cls",
",",
"filename",
",",
"crs",
"=",
"None",
")",
":",
"with",
"fiona",
".",
"Env",
"(",
")",
":",
"with",
"fiona",
".",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"source",
":",
"original_crs",
"=",
"CRS",
"(",
"sour... | Creates a FileCollection from a file in disk.
Parameters
----------
filename : str
Path of the file to read.
crs : CRS
overrides the crs of the collection, this funtion will not reprojects | [
"Creates",
"a",
"FileCollection",
"from",
"a",
"file",
"in",
"disk",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L524-L542 |
14,563 | satellogic/telluric | telluric/collections.py | _CollectionGroupBy.filter | def filter(self, func):
# type: (Callable[[BaseCollection], bool]) -> _CollectionGroupBy
"""Filter out Groups based on filtering function.
The function should get a FeatureCollection and return True to leave in the Group and False to take it out.
"""
results = OrderedDict() # t... | python | def filter(self, func):
# type: (Callable[[BaseCollection], bool]) -> _CollectionGroupBy
"""Filter out Groups based on filtering function.
The function should get a FeatureCollection and return True to leave in the Group and False to take it out.
"""
results = OrderedDict() # t... | [
"def",
"filter",
"(",
"self",
",",
"func",
")",
":",
"# type: (Callable[[BaseCollection], bool]) -> _CollectionGroupBy",
"results",
"=",
"OrderedDict",
"(",
")",
"# type: OrderedDict",
"for",
"name",
",",
"group",
"in",
"self",
":",
"if",
"func",
"(",
"group",
")"... | Filter out Groups based on filtering function.
The function should get a FeatureCollection and return True to leave in the Group and False to take it out. | [
"Filter",
"out",
"Groups",
"based",
"on",
"filtering",
"function",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L636-L647 |
14,564 | satellogic/telluric | telluric/context.py | reset_context | def reset_context(**options):
"""Reset context to default."""
local_context._options = {}
local_context._options.update(options)
log.debug("New TelluricContext context %r created", local_context._options) | python | def reset_context(**options):
"""Reset context to default."""
local_context._options = {}
local_context._options.update(options)
log.debug("New TelluricContext context %r created", local_context._options) | [
"def",
"reset_context",
"(",
"*",
"*",
"options",
")",
":",
"local_context",
".",
"_options",
"=",
"{",
"}",
"local_context",
".",
"_options",
".",
"update",
"(",
"options",
")",
"log",
".",
"debug",
"(",
"\"New TelluricContext context %r created\"",
",",
"loc... | Reset context to default. | [
"Reset",
"context",
"to",
"default",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/context.py#L131-L135 |
14,565 | satellogic/telluric | telluric/context.py | get_context | def get_context():
"""Get a mapping of current options."""
if not local_context._options:
raise TelluricContextError("TelluricContext context not exists")
else:
log.debug("Got a copy of context %r options", local_context._options)
return local_context._options.copy() | python | def get_context():
"""Get a mapping of current options."""
if not local_context._options:
raise TelluricContextError("TelluricContext context not exists")
else:
log.debug("Got a copy of context %r options", local_context._options)
return local_context._options.copy() | [
"def",
"get_context",
"(",
")",
":",
"if",
"not",
"local_context",
".",
"_options",
":",
"raise",
"TelluricContextError",
"(",
"\"TelluricContext context not exists\"",
")",
"else",
":",
"log",
".",
"debug",
"(",
"\"Got a copy of context %r options\"",
",",
"local_con... | Get a mapping of current options. | [
"Get",
"a",
"mapping",
"of",
"current",
"options",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/context.py#L138-L144 |
14,566 | satellogic/telluric | telluric/context.py | set_context | def set_context(**options):
"""Set options in the existing context."""
if not local_context._options:
raise TelluricContextError("TelluricContext context not exists")
else:
local_context._options.update(options)
log.debug("Updated existing %r with options %r", local_context._options,... | python | def set_context(**options):
"""Set options in the existing context."""
if not local_context._options:
raise TelluricContextError("TelluricContext context not exists")
else:
local_context._options.update(options)
log.debug("Updated existing %r with options %r", local_context._options,... | [
"def",
"set_context",
"(",
"*",
"*",
"options",
")",
":",
"if",
"not",
"local_context",
".",
"_options",
":",
"raise",
"TelluricContextError",
"(",
"\"TelluricContext context not exists\"",
")",
"else",
":",
"local_context",
".",
"_options",
".",
"update",
"(",
... | Set options in the existing context. | [
"Set",
"options",
"in",
"the",
"existing",
"context",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/context.py#L147-L153 |
14,567 | satellogic/telluric | telluric/features.py | transform_properties | def transform_properties(properties, schema):
"""Transform properties types according to a schema.
Parameters
----------
properties : dict
Properties to transform.
schema : dict
Fiona schema containing the types.
"""
new_properties = properties.copy()
for prop_value, (p... | python | def transform_properties(properties, schema):
"""Transform properties types according to a schema.
Parameters
----------
properties : dict
Properties to transform.
schema : dict
Fiona schema containing the types.
"""
new_properties = properties.copy()
for prop_value, (p... | [
"def",
"transform_properties",
"(",
"properties",
",",
"schema",
")",
":",
"new_properties",
"=",
"properties",
".",
"copy",
"(",
")",
"for",
"prop_value",
",",
"(",
"prop_name",
",",
"prop_type",
")",
"in",
"zip",
"(",
"new_properties",
".",
"values",
"(",
... | Transform properties types according to a schema.
Parameters
----------
properties : dict
Properties to transform.
schema : dict
Fiona schema containing the types. | [
"Transform",
"properties",
"types",
"according",
"to",
"a",
"schema",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/features.py#L22-L44 |
14,568 | satellogic/telluric | telluric/features.py | serialize_properties | def serialize_properties(properties):
"""Serialize properties.
Parameters
----------
properties : dict
Properties to serialize.
"""
new_properties = properties.copy()
for attr_name, attr_value in new_properties.items():
if isinstance(attr_value, datetime):
new_p... | python | def serialize_properties(properties):
"""Serialize properties.
Parameters
----------
properties : dict
Properties to serialize.
"""
new_properties = properties.copy()
for attr_name, attr_value in new_properties.items():
if isinstance(attr_value, datetime):
new_p... | [
"def",
"serialize_properties",
"(",
"properties",
")",
":",
"new_properties",
"=",
"properties",
".",
"copy",
"(",
")",
"for",
"attr_name",
",",
"attr_value",
"in",
"new_properties",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"attr_value",
",",
"d... | Serialize properties.
Parameters
----------
properties : dict
Properties to serialize. | [
"Serialize",
"properties",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/features.py#L47-L65 |
14,569 | satellogic/telluric | telluric/features.py | GeoFeature.from_record | def from_record(cls, record, crs, schema=None):
"""Create GeoFeature from a record."""
properties = cls._to_properties(record, schema)
vector = GeoVector(shape(record['geometry']), crs)
if record.get('raster'):
assets = {k: dict(type=RASTER_TYPE, product='visual', **v) for k,... | python | def from_record(cls, record, crs, schema=None):
"""Create GeoFeature from a record."""
properties = cls._to_properties(record, schema)
vector = GeoVector(shape(record['geometry']), crs)
if record.get('raster'):
assets = {k: dict(type=RASTER_TYPE, product='visual', **v) for k,... | [
"def",
"from_record",
"(",
"cls",
",",
"record",
",",
"crs",
",",
"schema",
"=",
"None",
")",
":",
"properties",
"=",
"cls",
".",
"_to_properties",
"(",
"record",
",",
"schema",
")",
"vector",
"=",
"GeoVector",
"(",
"shape",
"(",
"record",
"[",
"'geome... | Create GeoFeature from a record. | [
"Create",
"GeoFeature",
"from",
"a",
"record",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/features.py#L126-L134 |
14,570 | satellogic/telluric | telluric/features.py | GeoFeature.copy_with | def copy_with(self, geometry=None, properties=None, assets=None):
"""Generate a new GeoFeature with different geometry or preperties."""
def copy_assets_object(asset):
obj = asset.get("__object")
if hasattr("copy", obj):
new_obj = obj.copy()
if obj:
... | python | def copy_with(self, geometry=None, properties=None, assets=None):
"""Generate a new GeoFeature with different geometry or preperties."""
def copy_assets_object(asset):
obj = asset.get("__object")
if hasattr("copy", obj):
new_obj = obj.copy()
if obj:
... | [
"def",
"copy_with",
"(",
"self",
",",
"geometry",
"=",
"None",
",",
"properties",
"=",
"None",
",",
"assets",
"=",
"None",
")",
":",
"def",
"copy_assets_object",
"(",
"asset",
")",
":",
"obj",
"=",
"asset",
".",
"get",
"(",
"\"__object\"",
")",
"if",
... | Generate a new GeoFeature with different geometry or preperties. | [
"Generate",
"a",
"new",
"GeoFeature",
"with",
"different",
"geometry",
"or",
"preperties",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/features.py#L262-L280 |
14,571 | satellogic/telluric | telluric/features.py | GeoFeature.from_raster | def from_raster(cls, raster, properties, product='visual'):
"""Initialize a GeoFeature object with a GeoRaster
Parameters
----------
raster : GeoRaster
the raster in the feature
properties : dict
Properties.
product : str
product assoc... | python | def from_raster(cls, raster, properties, product='visual'):
"""Initialize a GeoFeature object with a GeoRaster
Parameters
----------
raster : GeoRaster
the raster in the feature
properties : dict
Properties.
product : str
product assoc... | [
"def",
"from_raster",
"(",
"cls",
",",
"raster",
",",
"properties",
",",
"product",
"=",
"'visual'",
")",
":",
"footprint",
"=",
"raster",
".",
"footprint",
"(",
")",
"assets",
"=",
"raster",
".",
"to_assets",
"(",
"product",
"=",
"product",
")",
"return... | Initialize a GeoFeature object with a GeoRaster
Parameters
----------
raster : GeoRaster
the raster in the feature
properties : dict
Properties.
product : str
product associated to the raster | [
"Initialize",
"a",
"GeoFeature",
"object",
"with",
"a",
"GeoRaster"
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/features.py#L287-L301 |
14,572 | satellogic/telluric | telluric/features.py | GeoFeature.has_raster | def has_raster(self):
"""True if any of the assets is type 'raster'."""
return any(asset.get('type') == RASTER_TYPE for asset in self.assets.values()) | python | def has_raster(self):
"""True if any of the assets is type 'raster'."""
return any(asset.get('type') == RASTER_TYPE for asset in self.assets.values()) | [
"def",
"has_raster",
"(",
"self",
")",
":",
"return",
"any",
"(",
"asset",
".",
"get",
"(",
"'type'",
")",
"==",
"RASTER_TYPE",
"for",
"asset",
"in",
"self",
".",
"assets",
".",
"values",
"(",
")",
")"
] | True if any of the assets is type 'raster'. | [
"True",
"if",
"any",
"of",
"the",
"assets",
"is",
"type",
"raster",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/features.py#L304-L306 |
14,573 | satellogic/telluric | telluric/util/projections.py | transform | def transform(shape, source_crs, destination_crs=None, src_affine=None, dst_affine=None):
"""Transforms shape from one CRS to another.
Parameters
----------
shape : shapely.geometry.base.BaseGeometry
Shape to transform.
source_crs : dict or str
Source CRS in the form of key/value pa... | python | def transform(shape, source_crs, destination_crs=None, src_affine=None, dst_affine=None):
"""Transforms shape from one CRS to another.
Parameters
----------
shape : shapely.geometry.base.BaseGeometry
Shape to transform.
source_crs : dict or str
Source CRS in the form of key/value pa... | [
"def",
"transform",
"(",
"shape",
",",
"source_crs",
",",
"destination_crs",
"=",
"None",
",",
"src_affine",
"=",
"None",
",",
"dst_affine",
"=",
"None",
")",
":",
"if",
"destination_crs",
"is",
"None",
":",
"destination_crs",
"=",
"WGS84_CRS",
"if",
"src_af... | Transforms shape from one CRS to another.
Parameters
----------
shape : shapely.geometry.base.BaseGeometry
Shape to transform.
source_crs : dict or str
Source CRS in the form of key/value pairs or proj4 string.
destination_crs : dict or str, optional
Destination CRS, EPSG:43... | [
"Transforms",
"shape",
"from",
"one",
"CRS",
"to",
"another",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/util/projections.py#L24-L57 |
14,574 | satellogic/telluric | telluric/plotting.py | simple_plot | def simple_plot(feature, *, mp=None, **map_kwargs):
"""Plots a GeoVector in a simple Folium map.
For more complex and customizable plots using Jupyter widgets,
use the plot function instead.
Parameters
----------
feature : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.coll... | python | def simple_plot(feature, *, mp=None, **map_kwargs):
"""Plots a GeoVector in a simple Folium map.
For more complex and customizable plots using Jupyter widgets,
use the plot function instead.
Parameters
----------
feature : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.coll... | [
"def",
"simple_plot",
"(",
"feature",
",",
"*",
",",
"mp",
"=",
"None",
",",
"*",
"*",
"map_kwargs",
")",
":",
"# This import is here to avoid cyclic references",
"from",
"telluric",
".",
"collections",
"import",
"BaseCollection",
"if",
"mp",
"is",
"None",
":",
... | Plots a GeoVector in a simple Folium map.
For more complex and customizable plots using Jupyter widgets,
use the plot function instead.
Parameters
----------
feature : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.collections.BaseCollection
Data to plot. | [
"Plots",
"a",
"GeoVector",
"in",
"a",
"simple",
"Folium",
"map",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/plotting.py#L24-L53 |
14,575 | satellogic/telluric | telluric/plotting.py | zoom_level_from_geometry | def zoom_level_from_geometry(geometry, splits=4):
"""Generate optimum zoom level for geometry.
Notes
-----
The obvious solution would be
>>> mercantile.bounding_tile(*geometry.get_shape(WGS84_CRS).bounds).z
However, if the geometry is split between two or four tiles,
the resulting zoom le... | python | def zoom_level_from_geometry(geometry, splits=4):
"""Generate optimum zoom level for geometry.
Notes
-----
The obvious solution would be
>>> mercantile.bounding_tile(*geometry.get_shape(WGS84_CRS).bounds).z
However, if the geometry is split between two or four tiles,
the resulting zoom le... | [
"def",
"zoom_level_from_geometry",
"(",
"geometry",
",",
"splits",
"=",
"4",
")",
":",
"# This import is here to avoid cyclic references",
"from",
"telluric",
".",
"vectors",
"import",
"generate_tile_coordinates",
"# We split the geometry and compute the zoom level for each chunk",... | Generate optimum zoom level for geometry.
Notes
-----
The obvious solution would be
>>> mercantile.bounding_tile(*geometry.get_shape(WGS84_CRS).bounds).z
However, if the geometry is split between two or four tiles,
the resulting zoom level might be too big. | [
"Generate",
"optimum",
"zoom",
"level",
"for",
"geometry",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/plotting.py#L56-L79 |
14,576 | satellogic/telluric | telluric/plotting.py | layer_from_element | def layer_from_element(element, style_function=None):
"""Return Leaflet layer from shape.
Parameters
----------
element : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.collections.BaseCollection
Data to plot.
"""
# This import is here to avoid cyclic references
... | python | def layer_from_element(element, style_function=None):
"""Return Leaflet layer from shape.
Parameters
----------
element : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.collections.BaseCollection
Data to plot.
"""
# This import is here to avoid cyclic references
... | [
"def",
"layer_from_element",
"(",
"element",
",",
"style_function",
"=",
"None",
")",
":",
"# This import is here to avoid cyclic references",
"from",
"telluric",
".",
"collections",
"import",
"BaseCollection",
"if",
"isinstance",
"(",
"element",
",",
"BaseCollection",
... | Return Leaflet layer from shape.
Parameters
----------
element : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.collections.BaseCollection
Data to plot. | [
"Return",
"Leaflet",
"layer",
"from",
"shape",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/plotting.py#L96-L114 |
14,577 | satellogic/telluric | telluric/plotting.py | plot | def plot(feature, mp=None, style_function=None, **map_kwargs):
"""Plots a GeoVector in an ipyleaflet map.
Parameters
----------
feature : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.collections.BaseCollection
Data to plot.
mp : ipyleaflet.Map, optional
Map in ... | python | def plot(feature, mp=None, style_function=None, **map_kwargs):
"""Plots a GeoVector in an ipyleaflet map.
Parameters
----------
feature : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.collections.BaseCollection
Data to plot.
mp : ipyleaflet.Map, optional
Map in ... | [
"def",
"plot",
"(",
"feature",
",",
"mp",
"=",
"None",
",",
"style_function",
"=",
"None",
",",
"*",
"*",
"map_kwargs",
")",
":",
"map_kwargs",
".",
"setdefault",
"(",
"'basemap'",
",",
"basemaps",
".",
"Stamen",
".",
"Terrain",
")",
"if",
"feature",
"... | Plots a GeoVector in an ipyleaflet map.
Parameters
----------
feature : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.collections.BaseCollection
Data to plot.
mp : ipyleaflet.Map, optional
Map in which to plot, default to None (creates a new one).
style_function... | [
"Plots",
"a",
"GeoVector",
"in",
"an",
"ipyleaflet",
"map",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/plotting.py#L117-L146 |
14,578 | satellogic/telluric | telluric/util/tileserver_utils.py | tileserver_optimized_raster | def tileserver_optimized_raster(src, dest):
""" This method converts a raster to a tileserver optimized raster.
The method will reproject the raster to align to the xyz system, in resolution and projection
It will also create overviews
And finally it will arragne the raster in a cog way.
... | python | def tileserver_optimized_raster(src, dest):
""" This method converts a raster to a tileserver optimized raster.
The method will reproject the raster to align to the xyz system, in resolution and projection
It will also create overviews
And finally it will arragne the raster in a cog way.
... | [
"def",
"tileserver_optimized_raster",
"(",
"src",
",",
"dest",
")",
":",
"src_raster",
"=",
"tl",
".",
"GeoRaster2",
".",
"open",
"(",
"src",
")",
"bounding_box",
"=",
"src_raster",
".",
"footprint",
"(",
")",
".",
"get_shape",
"(",
"tl",
".",
"constants",... | This method converts a raster to a tileserver optimized raster.
The method will reproject the raster to align to the xyz system, in resolution and projection
It will also create overviews
And finally it will arragne the raster in a cog way.
You could take the dest file upload it to a web... | [
"This",
"method",
"converts",
"a",
"raster",
"to",
"a",
"tileserver",
"optimized",
"raster",
".",
"The",
"method",
"will",
"reproject",
"the",
"raster",
"to",
"align",
"to",
"the",
"xyz",
"system",
"in",
"resolution",
"and",
"projection",
"It",
"will",
"also... | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/util/tileserver_utils.py#L20-L58 |
14,579 | satellogic/telluric | telluric/vectors.py | get_dimension | def get_dimension(geometry):
"""Gets the dimension of a Fiona-like geometry element."""
coordinates = geometry["coordinates"]
type_ = geometry["type"]
if type_ in ('Point',):
return len(coordinates)
elif type_ in ('LineString', 'MultiPoint'):
return len(coordinates[0])
elif type_... | python | def get_dimension(geometry):
"""Gets the dimension of a Fiona-like geometry element."""
coordinates = geometry["coordinates"]
type_ = geometry["type"]
if type_ in ('Point',):
return len(coordinates)
elif type_ in ('LineString', 'MultiPoint'):
return len(coordinates[0])
elif type_... | [
"def",
"get_dimension",
"(",
"geometry",
")",
":",
"coordinates",
"=",
"geometry",
"[",
"\"coordinates\"",
"]",
"type_",
"=",
"geometry",
"[",
"\"type\"",
"]",
"if",
"type_",
"in",
"(",
"'Point'",
",",
")",
":",
"return",
"len",
"(",
"coordinates",
")",
... | Gets the dimension of a Fiona-like geometry element. | [
"Gets",
"the",
"dimension",
"of",
"a",
"Fiona",
"-",
"like",
"geometry",
"element",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/vectors.py#L82-L95 |
14,580 | satellogic/telluric | telluric/vectors.py | GeoVector.from_geojson | def from_geojson(cls, filename):
"""Load vector from geojson."""
with open(filename) as fd:
geometry = json.load(fd)
if 'type' not in geometry:
raise TypeError("%s is not a valid geojson." % (filename,))
return cls(to_shape(geometry), WGS84_CRS) | python | def from_geojson(cls, filename):
"""Load vector from geojson."""
with open(filename) as fd:
geometry = json.load(fd)
if 'type' not in geometry:
raise TypeError("%s is not a valid geojson." % (filename,))
return cls(to_shape(geometry), WGS84_CRS) | [
"def",
"from_geojson",
"(",
"cls",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"fd",
":",
"geometry",
"=",
"json",
".",
"load",
"(",
"fd",
")",
"if",
"'type'",
"not",
"in",
"geometry",
":",
"raise",
"TypeError",
"(",
"\"%s ... | Load vector from geojson. | [
"Load",
"vector",
"from",
"geojson",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/vectors.py#L296-L304 |
14,581 | satellogic/telluric | telluric/vectors.py | GeoVector.to_geojson | def to_geojson(self, filename):
"""Save vector as geojson."""
with open(filename, 'w') as fd:
json.dump(self.to_record(WGS84_CRS), fd) | python | def to_geojson(self, filename):
"""Save vector as geojson."""
with open(filename, 'w') as fd:
json.dump(self.to_record(WGS84_CRS), fd) | [
"def",
"to_geojson",
"(",
"self",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"fd",
":",
"json",
".",
"dump",
"(",
"self",
".",
"to_record",
"(",
"WGS84_CRS",
")",
",",
"fd",
")"
] | Save vector as geojson. | [
"Save",
"vector",
"as",
"geojson",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/vectors.py#L306-L309 |
14,582 | satellogic/telluric | telluric/vectors.py | GeoVector.from_bounds | def from_bounds(cls, xmin, ymin, xmax, ymax, crs=DEFAULT_CRS):
"""Creates GeoVector object from bounds.
Parameters
----------
xmin, ymin, xmax, ymax : float
Bounds of the GeoVector. Also (east, south, north, west).
crs : ~rasterio.crs.CRS, dict
Projection... | python | def from_bounds(cls, xmin, ymin, xmax, ymax, crs=DEFAULT_CRS):
"""Creates GeoVector object from bounds.
Parameters
----------
xmin, ymin, xmax, ymax : float
Bounds of the GeoVector. Also (east, south, north, west).
crs : ~rasterio.crs.CRS, dict
Projection... | [
"def",
"from_bounds",
"(",
"cls",
",",
"xmin",
",",
"ymin",
",",
"xmax",
",",
"ymax",
",",
"crs",
"=",
"DEFAULT_CRS",
")",
":",
"return",
"cls",
"(",
"Polygon",
".",
"from_bounds",
"(",
"xmin",
",",
"ymin",
",",
"xmax",
",",
"ymax",
")",
",",
"crs"... | Creates GeoVector object from bounds.
Parameters
----------
xmin, ymin, xmax, ymax : float
Bounds of the GeoVector. Also (east, south, north, west).
crs : ~rasterio.crs.CRS, dict
Projection, default to :py:data:`telluric.constants.DEFAULT_CRS`.
Examples
... | [
"Creates",
"GeoVector",
"object",
"from",
"bounds",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/vectors.py#L328-L347 |
14,583 | satellogic/telluric | telluric/vectors.py | GeoVector.from_xyz | def from_xyz(cls, x, y, z):
"""Creates GeoVector from Mercator slippy map values.
"""
bb = xy_bounds(x, y, z)
return cls.from_bounds(xmin=bb.left, ymin=bb.bottom,
xmax=bb.right, ymax=bb.top,
crs=WEB_MERCATOR_CRS) | python | def from_xyz(cls, x, y, z):
"""Creates GeoVector from Mercator slippy map values.
"""
bb = xy_bounds(x, y, z)
return cls.from_bounds(xmin=bb.left, ymin=bb.bottom,
xmax=bb.right, ymax=bb.top,
crs=WEB_MERCATOR_CRS) | [
"def",
"from_xyz",
"(",
"cls",
",",
"x",
",",
"y",
",",
"z",
")",
":",
"bb",
"=",
"xy_bounds",
"(",
"x",
",",
"y",
",",
"z",
")",
"return",
"cls",
".",
"from_bounds",
"(",
"xmin",
"=",
"bb",
".",
"left",
",",
"ymin",
"=",
"bb",
".",
"bottom",... | Creates GeoVector from Mercator slippy map values. | [
"Creates",
"GeoVector",
"from",
"Mercator",
"slippy",
"map",
"values",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/vectors.py#L350-L357 |
14,584 | satellogic/telluric | telluric/vectors.py | GeoVector.cascaded_union | def cascaded_union(cls, vectors, dst_crs, prevalidate=False):
# type: (list, CRS, bool) -> GeoVector
"""Generate a GeoVector from the cascade union of the impute vectors."""
try:
shapes = [geometry.get_shape(dst_crs) for geometry in vectors]
if prevalidate:
... | python | def cascaded_union(cls, vectors, dst_crs, prevalidate=False):
# type: (list, CRS, bool) -> GeoVector
"""Generate a GeoVector from the cascade union of the impute vectors."""
try:
shapes = [geometry.get_shape(dst_crs) for geometry in vectors]
if prevalidate:
... | [
"def",
"cascaded_union",
"(",
"cls",
",",
"vectors",
",",
"dst_crs",
",",
"prevalidate",
"=",
"False",
")",
":",
"# type: (list, CRS, bool) -> GeoVector",
"try",
":",
"shapes",
"=",
"[",
"geometry",
".",
"get_shape",
"(",
"dst_crs",
")",
"for",
"geometry",
"in... | Generate a GeoVector from the cascade union of the impute vectors. | [
"Generate",
"a",
"GeoVector",
"from",
"the",
"cascade",
"union",
"of",
"the",
"impute",
"vectors",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/vectors.py#L384-L403 |
14,585 | satellogic/telluric | telluric/vectors.py | GeoVector.from_record | def from_record(cls, record, crs):
"""Load vector from record."""
if 'type' not in record:
raise TypeError("The data isn't a valid record.")
return cls(to_shape(record), crs) | python | def from_record(cls, record, crs):
"""Load vector from record."""
if 'type' not in record:
raise TypeError("The data isn't a valid record.")
return cls(to_shape(record), crs) | [
"def",
"from_record",
"(",
"cls",
",",
"record",
",",
"crs",
")",
":",
"if",
"'type'",
"not",
"in",
"record",
":",
"raise",
"TypeError",
"(",
"\"The data isn't a valid record.\"",
")",
"return",
"cls",
"(",
"to_shape",
"(",
"record",
")",
",",
"crs",
")"
] | Load vector from record. | [
"Load",
"vector",
"from",
"record",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/vectors.py#L444-L449 |
14,586 | satellogic/telluric | telluric/vectors.py | GeoVector.get_bounding_box | def get_bounding_box(self, crs):
"""Gets bounding box as GeoVector in a specified CRS."""
return self.from_bounds(*self.get_bounds(crs), crs=crs) | python | def get_bounding_box(self, crs):
"""Gets bounding box as GeoVector in a specified CRS."""
return self.from_bounds(*self.get_bounds(crs), crs=crs) | [
"def",
"get_bounding_box",
"(",
"self",
",",
"crs",
")",
":",
"return",
"self",
".",
"from_bounds",
"(",
"*",
"self",
".",
"get_bounds",
"(",
"crs",
")",
",",
"crs",
"=",
"crs",
")"
] | Gets bounding box as GeoVector in a specified CRS. | [
"Gets",
"bounding",
"box",
"as",
"GeoVector",
"in",
"a",
"specified",
"CRS",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/vectors.py#L464-L466 |
14,587 | satellogic/telluric | telluric/vectors.py | GeoVector.polygonize | def polygonize(self, width, cap_style_line=CAP_STYLE.flat, cap_style_point=CAP_STYLE.round):
"""Turns line or point into a buffered polygon."""
shape = self._shape
if isinstance(shape, (LineString, MultiLineString)):
return self.__class__(
shape.buffer(width / 2, cap_... | python | def polygonize(self, width, cap_style_line=CAP_STYLE.flat, cap_style_point=CAP_STYLE.round):
"""Turns line or point into a buffered polygon."""
shape = self._shape
if isinstance(shape, (LineString, MultiLineString)):
return self.__class__(
shape.buffer(width / 2, cap_... | [
"def",
"polygonize",
"(",
"self",
",",
"width",
",",
"cap_style_line",
"=",
"CAP_STYLE",
".",
"flat",
",",
"cap_style_point",
"=",
"CAP_STYLE",
".",
"round",
")",
":",
"shape",
"=",
"self",
".",
"_shape",
"if",
"isinstance",
"(",
"shape",
",",
"(",
"Line... | Turns line or point into a buffered polygon. | [
"Turns",
"line",
"or",
"point",
"into",
"a",
"buffered",
"polygon",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/vectors.py#L504-L518 |
14,588 | satellogic/telluric | telluric/vectors.py | GeoVector.tiles | def tiles(self, zooms, truncate=False):
"""
Iterator over the tiles intersecting the bounding box of the vector
Parameters
----------
zooms : int or sequence of int
One or more zoom levels.
truncate : bool, optional
Whether or not to trunc... | python | def tiles(self, zooms, truncate=False):
"""
Iterator over the tiles intersecting the bounding box of the vector
Parameters
----------
zooms : int or sequence of int
One or more zoom levels.
truncate : bool, optional
Whether or not to trunc... | [
"def",
"tiles",
"(",
"self",
",",
"zooms",
",",
"truncate",
"=",
"False",
")",
":",
"west",
",",
"south",
",",
"east",
",",
"north",
"=",
"self",
".",
"get_bounds",
"(",
"WGS84_CRS",
")",
"return",
"tiles",
"(",
"west",
",",
"south",
",",
"east",
"... | Iterator over the tiles intersecting the bounding box of the vector
Parameters
----------
zooms : int or sequence of int
One or more zoom levels.
truncate : bool, optional
Whether or not to truncate inputs to web mercator limits.
Yields
-... | [
"Iterator",
"over",
"the",
"tiles",
"intersecting",
"the",
"bounding",
"box",
"of",
"the",
"vector"
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/vectors.py#L520-L536 |
14,589 | satellogic/telluric | telluric/util/raster_utils.py | _join_masks_from_masked_array | def _join_masks_from_masked_array(data):
"""Union of masks."""
if not isinstance(data.mask, np.ndarray):
# workaround to handle mask compressed to single value
mask = np.empty(data.data.shape, dtype=np.bool)
mask.fill(data.mask)
return mask
mask = data.mask[0].copy()
for ... | python | def _join_masks_from_masked_array(data):
"""Union of masks."""
if not isinstance(data.mask, np.ndarray):
# workaround to handle mask compressed to single value
mask = np.empty(data.data.shape, dtype=np.bool)
mask.fill(data.mask)
return mask
mask = data.mask[0].copy()
for ... | [
"def",
"_join_masks_from_masked_array",
"(",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
".",
"mask",
",",
"np",
".",
"ndarray",
")",
":",
"# workaround to handle mask compressed to single value",
"mask",
"=",
"np",
".",
"empty",
"(",
"data",
".",
... | Union of masks. | [
"Union",
"of",
"masks",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/util/raster_utils.py#L27-L37 |
14,590 | satellogic/telluric | telluric/util/raster_utils.py | _creation_options_for_cog | def _creation_options_for_cog(creation_options, source_profile, blocksize):
"""
it uses the profile of the source raster, override anything using the creation_options
and guarantees we will have tiled raster and blocksize
"""
if not(creation_options):
creation_options = {}
creation_opti... | python | def _creation_options_for_cog(creation_options, source_profile, blocksize):
"""
it uses the profile of the source raster, override anything using the creation_options
and guarantees we will have tiled raster and blocksize
"""
if not(creation_options):
creation_options = {}
creation_opti... | [
"def",
"_creation_options_for_cog",
"(",
"creation_options",
",",
"source_profile",
",",
"blocksize",
")",
":",
"if",
"not",
"(",
"creation_options",
")",
":",
"creation_options",
"=",
"{",
"}",
"creation_options",
"[",
"\"blocksize\"",
"]",
"=",
"blocksize",
"cre... | it uses the profile of the source raster, override anything using the creation_options
and guarantees we will have tiled raster and blocksize | [
"it",
"uses",
"the",
"profile",
"of",
"the",
"source",
"raster",
"override",
"anything",
"using",
"the",
"creation_options",
"and",
"guarantees",
"we",
"will",
"have",
"tiled",
"raster",
"and",
"blocksize"
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/util/raster_utils.py#L70-L84 |
14,591 | satellogic/telluric | telluric/util/raster_utils.py | convert_to_cog | def convert_to_cog(source_file, destination_file, resampling=rasterio.enums.Resampling.gauss, blocksize=256,
overview_blocksize=256, creation_options=None):
"""Convert source file to a Cloud Optimized GeoTiff new file.
:param source_file: path to the original raster
:param destination_fi... | python | def convert_to_cog(source_file, destination_file, resampling=rasterio.enums.Resampling.gauss, blocksize=256,
overview_blocksize=256, creation_options=None):
"""Convert source file to a Cloud Optimized GeoTiff new file.
:param source_file: path to the original raster
:param destination_fi... | [
"def",
"convert_to_cog",
"(",
"source_file",
",",
"destination_file",
",",
"resampling",
"=",
"rasterio",
".",
"enums",
".",
"Resampling",
".",
"gauss",
",",
"blocksize",
"=",
"256",
",",
"overview_blocksize",
"=",
"256",
",",
"creation_options",
"=",
"None",
... | Convert source file to a Cloud Optimized GeoTiff new file.
:param source_file: path to the original raster
:param destination_file: path to the new raster
:param resampling: which Resampling to use on reading, default Resampling.gauss
:param blocksize: the size of the blocks default 256
:param over... | [
"Convert",
"source",
"file",
"to",
"a",
"Cloud",
"Optimized",
"GeoTiff",
"new",
"file",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/util/raster_utils.py#L87-L119 |
14,592 | satellogic/telluric | telluric/util/raster_utils.py | warp | def warp(source_file, destination_file, dst_crs=None, resolution=None, dimensions=None,
src_bounds=None, dst_bounds=None, src_nodata=None, dst_nodata=None,
target_aligned_pixels=False, check_invert_proj=True,
creation_options=None, resampling=Resampling.cubic, **kwargs):
"""Warp a raster ... | python | def warp(source_file, destination_file, dst_crs=None, resolution=None, dimensions=None,
src_bounds=None, dst_bounds=None, src_nodata=None, dst_nodata=None,
target_aligned_pixels=False, check_invert_proj=True,
creation_options=None, resampling=Resampling.cubic, **kwargs):
"""Warp a raster ... | [
"def",
"warp",
"(",
"source_file",
",",
"destination_file",
",",
"dst_crs",
"=",
"None",
",",
"resolution",
"=",
"None",
",",
"dimensions",
"=",
"None",
",",
"src_bounds",
"=",
"None",
",",
"dst_bounds",
"=",
"None",
",",
"src_nodata",
"=",
"None",
",",
... | Warp a raster dataset.
Parameters
------------
source_file: str, file object or pathlib.Path object
Source file.
destination_file: str, file object or pathlib.Path object
Destination file.
dst_crs: rasterio.crs.CRS, optional
Target coordinate reference system.
resolution... | [
"Warp",
"a",
"raster",
"dataset",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/util/raster_utils.py#L261-L360 |
14,593 | satellogic/telluric | telluric/util/raster_utils.py | build_overviews | def build_overviews(source_file, factors=None, minsize=256, external=False,
blocksize=256, interleave='pixel', compress='lzw',
resampling=Resampling.gauss, **kwargs):
"""Build overviews at one or more decimation factors for all
bands of the dataset.
Parameters
--... | python | def build_overviews(source_file, factors=None, minsize=256, external=False,
blocksize=256, interleave='pixel', compress='lzw',
resampling=Resampling.gauss, **kwargs):
"""Build overviews at one or more decimation factors for all
bands of the dataset.
Parameters
--... | [
"def",
"build_overviews",
"(",
"source_file",
",",
"factors",
"=",
"None",
",",
"minsize",
"=",
"256",
",",
"external",
"=",
"False",
",",
"blocksize",
"=",
"256",
",",
"interleave",
"=",
"'pixel'",
",",
"compress",
"=",
"'lzw'",
",",
"resampling",
"=",
... | Build overviews at one or more decimation factors for all
bands of the dataset.
Parameters
------------
source_file : str, file object or pathlib.Path object
Source file.
factors : list, optional
A list of integral overview levels to build.
minsize : int, optional
Maximu... | [
"Build",
"overviews",
"at",
"one",
"or",
"more",
"decimation",
"factors",
"for",
"all",
"bands",
"of",
"the",
"dataset",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/util/raster_utils.py#L363-L411 |
14,594 | satellogic/telluric | telluric/util/raster_utils.py | build_vrt | def build_vrt(source_file, destination_file, **kwargs):
"""Make a VRT XML document and write it in file.
Parameters
----------
source_file : str, file object or pathlib.Path object
Source file.
destination_file : str
Destination file.
kwargs : optional
Additional argumen... | python | def build_vrt(source_file, destination_file, **kwargs):
"""Make a VRT XML document and write it in file.
Parameters
----------
source_file : str, file object or pathlib.Path object
Source file.
destination_file : str
Destination file.
kwargs : optional
Additional argumen... | [
"def",
"build_vrt",
"(",
"source_file",
",",
"destination_file",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"rasterio",
".",
"open",
"(",
"source_file",
")",
"as",
"src",
":",
"vrt_doc",
"=",
"boundless_vrt_doc",
"(",
"src",
",",
"*",
"*",
"kwargs",
")",... | Make a VRT XML document and write it in file.
Parameters
----------
source_file : str, file object or pathlib.Path object
Source file.
destination_file : str
Destination file.
kwargs : optional
Additional arguments passed to rasterio.vrt._boundless_vrt_doc
Returns
-... | [
"Make",
"a",
"VRT",
"XML",
"document",
"and",
"write",
"it",
"in",
"file",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/util/raster_utils.py#L414-L437 |
14,595 | satellogic/telluric | telluric/util/histogram.py | stretch_histogram | def stretch_histogram(img, dark_clip_percentile=None, bright_clip_percentile=None,
dark_clip_value=None, bright_clip_value=None, ignore_zero=True):
"""Stretch img histogram.
2 possible modes: by percentile (pass dark/bright_clip_percentile), or by value (pass dark/bright_clip_value)
:... | python | def stretch_histogram(img, dark_clip_percentile=None, bright_clip_percentile=None,
dark_clip_value=None, bright_clip_value=None, ignore_zero=True):
"""Stretch img histogram.
2 possible modes: by percentile (pass dark/bright_clip_percentile), or by value (pass dark/bright_clip_value)
:... | [
"def",
"stretch_histogram",
"(",
"img",
",",
"dark_clip_percentile",
"=",
"None",
",",
"bright_clip_percentile",
"=",
"None",
",",
"dark_clip_value",
"=",
"None",
",",
"bright_clip_value",
"=",
"None",
",",
"ignore_zero",
"=",
"True",
")",
":",
"# verify stretchin... | Stretch img histogram.
2 possible modes: by percentile (pass dark/bright_clip_percentile), or by value (pass dark/bright_clip_value)
:param dark_clip_percentile: percent of pixels that will be saturated to min_value
:param bright_clip_percentile: percent of pixels that will be saturated to max_value
:p... | [
"Stretch",
"img",
"histogram",
"."
] | e752cd3ee71e339f79717e526fde362e80055d9e | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/util/histogram.py#L10-L53 |
14,596 | AndrewAnnex/SpiceyPy | getspice.py | GetCSPICE._distribution_info | def _distribution_info(self):
"""Creates the distribution name and the expected extension for the
CSPICE package and returns it.
:return (distribution, extension) tuple where distribution is the best
guess from the strings available within the platform_urls list
... | python | def _distribution_info(self):
"""Creates the distribution name and the expected extension for the
CSPICE package and returns it.
:return (distribution, extension) tuple where distribution is the best
guess from the strings available within the platform_urls list
... | [
"def",
"_distribution_info",
"(",
"self",
")",
":",
"print",
"(",
"'Gathering information...'",
")",
"system",
"=",
"platform",
".",
"system",
"(",
")",
"# Cygwin system is CYGWIN-NT-xxx.",
"system",
"=",
"'cygwin'",
"if",
"'CYGWIN'",
"in",
"system",
"else",
"syst... | Creates the distribution name and the expected extension for the
CSPICE package and returns it.
:return (distribution, extension) tuple where distribution is the best
guess from the strings available within the platform_urls list
of strings, and extension is either "zip"... | [
"Creates",
"the",
"distribution",
"name",
"and",
"the",
"expected",
"extension",
"for",
"the",
"CSPICE",
"package",
"and",
"returns",
"it",
"."
] | fc20a9b9de68b58eed5b332f0c051fb343a6e335 | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/getspice.py#L153-L180 |
14,597 | AndrewAnnex/SpiceyPy | getspice.py | GetCSPICE._download | def _download(self):
"""Support function that encapsulates the OpenSSL transfer of the CSPICE
package to the self._local io.ByteIO stream.
:raises RuntimeError if there has been any issue with the HTTPS
communication
.. note::
Handling of CSPICE... | python | def _download(self):
"""Support function that encapsulates the OpenSSL transfer of the CSPICE
package to the self._local io.ByteIO stream.
:raises RuntimeError if there has been any issue with the HTTPS
communication
.. note::
Handling of CSPICE... | [
"def",
"_download",
"(",
"self",
")",
":",
"# Use urllib3 (based on PyOpenSSL).",
"if",
"ssl",
".",
"OPENSSL_VERSION",
"<",
"'OpenSSL 1.0.1g'",
":",
"# Force urllib3 to use pyOpenSSL",
"import",
"urllib3",
".",
"contrib",
".",
"pyopenssl",
"urllib3",
".",
"contrib",
"... | Support function that encapsulates the OpenSSL transfer of the CSPICE
package to the self._local io.ByteIO stream.
:raises RuntimeError if there has been any issue with the HTTPS
communication
.. note::
Handling of CSPICE downloads from HTTPS
... | [
"Support",
"function",
"that",
"encapsulates",
"the",
"OpenSSL",
"transfer",
"of",
"the",
"CSPICE",
"package",
"to",
"the",
"self",
".",
"_local",
"io",
".",
"ByteIO",
"stream",
"."
] | fc20a9b9de68b58eed5b332f0c051fb343a6e335 | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/getspice.py#L182-L247 |
14,598 | AndrewAnnex/SpiceyPy | getspice.py | GetCSPICE._unpack | def _unpack(self):
"""Unpacks the CSPICE package on the given root directory. Note that
Package could either be the zipfile.ZipFile class for Windows platforms
or tarfile.TarFile for other platforms.
"""
if self._ext == 'zip':
with ZipFile(self._local, 'r') as archive... | python | def _unpack(self):
"""Unpacks the CSPICE package on the given root directory. Note that
Package could either be the zipfile.ZipFile class for Windows platforms
or tarfile.TarFile for other platforms.
"""
if self._ext == 'zip':
with ZipFile(self._local, 'r') as archive... | [
"def",
"_unpack",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ext",
"==",
"'zip'",
":",
"with",
"ZipFile",
"(",
"self",
".",
"_local",
",",
"'r'",
")",
"as",
"archive",
":",
"archive",
".",
"extractall",
"(",
"self",
".",
"_root",
")",
"else",
":",... | Unpacks the CSPICE package on the given root directory. Note that
Package could either be the zipfile.ZipFile class for Windows platforms
or tarfile.TarFile for other platforms. | [
"Unpacks",
"the",
"CSPICE",
"package",
"on",
"the",
"given",
"root",
"directory",
".",
"Note",
"that",
"Package",
"could",
"either",
"be",
"the",
"zipfile",
".",
"ZipFile",
"class",
"for",
"Windows",
"platforms",
"or",
"tarfile",
".",
"TarFile",
"for",
"othe... | fc20a9b9de68b58eed5b332f0c051fb343a6e335 | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/getspice.py#L249-L261 |
14,599 | AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | spiceErrorCheck | def spiceErrorCheck(f):
"""
Decorator for spiceypy hooking into spice error system.
If an error is detected, an output similar to outmsg
:type f: builtins.function
:return:
:rtype:
"""
@functools.wraps(f)
def with_errcheck(*args, **kwargs):
try:
res = f(*args, *... | python | def spiceErrorCheck(f):
"""
Decorator for spiceypy hooking into spice error system.
If an error is detected, an output similar to outmsg
:type f: builtins.function
:return:
:rtype:
"""
@functools.wraps(f)
def with_errcheck(*args, **kwargs):
try:
res = f(*args, *... | [
"def",
"spiceErrorCheck",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"with_errcheck",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"res",
"=",
"f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")... | Decorator for spiceypy hooking into spice error system.
If an error is detected, an output similar to outmsg
:type f: builtins.function
:return:
:rtype: | [
"Decorator",
"for",
"spiceypy",
"hooking",
"into",
"spice",
"error",
"system",
".",
"If",
"an",
"error",
"is",
"detected",
"an",
"output",
"similar",
"to",
"outmsg"
] | fc20a9b9de68b58eed5b332f0c051fb343a6e335 | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L64-L83 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.