_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q224500
MimeType.canonical_extension
train
def canonical_extension(fmt_ext): """ Canonical extension of file format extension Converts the format extension fmt_ext into the canonical extension for that format. For example, ``canonical_extension('tif') == 'tiff'``. Here we agree that the canonical extension for format F is F.value ...
python
{ "resource": "" }
q224501
MimeType.is_image_format
train
def is_image_format(self): """ Checks whether file format is an image format Example: ``MimeType.PNG.is_image_format()`` or ``MimeType.is_image_format(MimeType.PNG)`` :param self: File format :type self: MimeType :return: ``True`` if file is in image format, ``False`` otherwise...
python
{ "resource": "" }
q224502
MimeType.is_tiff_format
train
def is_tiff_format(self): """ Checks whether file format is a TIFF image format Example: ``MimeType.TIFF.is_tiff_format()`` or ``MimeType.is_tiff_format(MimeType.TIFF)`` :param self: File format :type self: MimeType :return: ``True`` if file is in image format, ``False`` otherw...
python
{ "resource": "" }
q224503
MimeType.get_string
train
def get_string(self): """ Get file format as string :return: String describing the file format :rtype: str """ if self in [MimeType.TIFF_d8, MimeType.TIFF_d16, MimeType.TIFF_d32f]: return 'image/{}'.format(self.value) if self is MimeType.JP2: retu...
python
{ "resource": "" }
q224504
MimeType.get_expected_max_value
train
def get_expected_max_value(self): """ Returns max value of image `MimeType` format and raises an error if it is not an image format Note: For `MimeType.TIFF_d32f` it will return ``1.0`` as that is expected maximum for an image even though it could be higher. :return: A maximum value of...
python
{ "resource": "" }
q224505
OgcService._filter_dates
train
def _filter_dates(dates, time_difference): """ Filters out dates within time_difference, preserving only the oldest date. :param dates: a list of datetime objects :param time_difference: a ``datetime.timedelta`` representing the time difference threshold :return: an ordered list...
python
{ "resource": "" }
q224506
OgcService._sentinel1_product_check
train
def _sentinel1_product_check(product_id, data_source): """Checks if Sentinel-1 product ID matches Sentinel-1 DataSource configuration :param product_id: Sentinel-1 product ID :type product_id: str :param data_source: One of the supported Sentinel-1 data sources :type data_source...
python
{ "resource": "" }
q224507
OgcImageService.get_url
train
def get_url(self, request, *, date=None, size_x=None, size_y=None, geometry=None): """ Returns url to Sentinel Hub's OGC service for the product specified by the OgcRequest and date. :param request: OGC-type request with specified bounding box, cloud coverage for specific product. :type request...
python
{ "resource": "" }
q224508
OgcImageService.get_base_url
train
def get_base_url(self, request): """ Creates base url string. :param request: OGC-type request with specified bounding box, cloud coverage for specific product. :type request: OgcRequest or GeopediaRequest :return: base string for url to Sentinel Hub's OGC service for this product. ...
python
{ "resource": "" }
q224509
OgcImageService._get_common_url_parameters
train
def _get_common_url_parameters(request): """ Returns parameters common dictionary for WMS, WCS and FIS request. :param request: OGC-type request with specified bounding box, cloud coverage for specific product. :type request: OgcRequest or GeopediaRequest :return: dictionary with param...
python
{ "resource": "" }
q224510
OgcImageService._get_wms_wcs_url_parameters
train
def _get_wms_wcs_url_parameters(request, date): """ Returns parameters common dictionary for WMS and WCS request. :param request: OGC-type request with specified bounding box, cloud coverage for specific product. :type request: OgcRequest or GeopediaRequest :param date: acquisition dat...
python
{ "resource": "" }
q224511
OgcImageService._get_fis_parameters
train
def _get_fis_parameters(request, geometry): """ Returns parameters dictionary for FIS request. :param request: OGC-type request with specified bounding box, cloud coverage for specific product. :type request: OgcRequest or GeopediaRequest :param geometry: list of bounding boxes or geome...
python
{ "resource": "" }
q224512
OgcImageService.get_filename
train
def get_filename(request, date, size_x, size_y): """ Get filename location Returns the filename's location on disk where data is or is going to be stored. The files are stored in the folder specified by the user when initialising OGC-type of request. The name of the file has the followi...
python
{ "resource": "" }
q224513
OgcImageService.filename_add_custom_url_params
train
def filename_add_custom_url_params(filename, request): """ Adds custom url parameters to filename string :param filename: Initial filename :type filename: str :param request: OGC-type request with specified bounding box, cloud coverage for specific product. :type request: OgcReq...
python
{ "resource": "" }
q224514
OgcImageService.finalize_filename
train
def finalize_filename(filename, file_format=None): """ Replaces invalid characters in filename string, adds image extension and reduces filename length :param filename: Incomplete filename string :type filename: str :param file_format: Format which will be used for filename extension ...
python
{ "resource": "" }
q224515
OgcImageService.get_dates
train
def get_dates(self, request): """ Get available Sentinel-2 acquisitions at least time_difference apart List of all available Sentinel-2 acquisitions for given bbox with max cloud coverage and the specified time interval. When a single time is specified the request will return that specific date...
python
{ "resource": "" }
q224516
OgcImageService.get_image_dimensions
train
def get_image_dimensions(request): """ Verifies or calculates image dimensions. :param request: OGC-type request :type request: WmsRequest or WcsRequest :return: horizontal and vertical dimensions of requested image :rtype: (int or str, int or str) """ if...
python
{ "resource": "" }
q224517
WebFeatureService._fetch_features
train
def _fetch_features(self): """Collects data from WFS service :return: dictionary containing info about product tiles :rtype: dict """ if self.feature_offset is None: return main_url = '{}{}/{}?'.format(self.base_url, ServiceType.WFS.value, self.instance_id) ...
python
{ "resource": "" }
q224518
WebFeatureService.get_dates
train
def get_dates(self): """ Returns a list of acquisition times from tile info data :return: List of acquisition times in the order returned by WFS service. :rtype: list(datetime.datetime) """ return [datetime.datetime.strptime('{}T{}'.format(tile_info['properties']['date'], ...
python
{ "resource": "" }
q224519
WebFeatureService._parse_tile_url
train
def _parse_tile_url(tile_url): """ Extracts tile name, data and AWS index from tile URL :param tile_url: Location of tile at AWS :type: tile_url: str :return: Tuple in a form (tile_name, date, aws_index) :rtype: (str, str, int) """ props = tile_url.rsplit('/', 7)...
python
{ "resource": "" }
q224520
get_dates_in_range
train
def get_dates_in_range(start_date, end_date): """ Get all dates within input start and end date in ISO 8601 format :param start_date: start date in ISO 8601 format :type start_date: str :param end_date: end date in ISO 8601 format :type end_date: str :return: list of dates between start_date an...
python
{ "resource": "" }
q224521
iso_to_datetime
train
def iso_to_datetime(date): """ Convert ISO 8601 time format to datetime format This function converts a date in ISO format, e.g. ``2017-09-14`` to a `datetime` instance, e.g. ``datetime.datetime(2017,9,14,0,0)`` :param date: date in ISO 8601 format :type date: str :return: datetime instance ...
python
{ "resource": "" }
q224522
datetime_to_iso
train
def datetime_to_iso(date, only_date=True): """ Convert datetime format to ISO 8601 time format This function converts a date in datetime instance, e.g. ``datetime.datetime(2017,9,14,0,0)`` to ISO format, e.g. ``2017-09-14`` :param date: datetime instance to convert :type date: datetime :param ...
python
{ "resource": "" }
q224523
aws
train
def aws(product, tile, folder, redownload, info, entire, bands, l2a): """Download Sentinel-2 data from Sentinel-2 on AWS to ESA SAFE format. Download uses multiple threads. \b Examples with Sentinel-2 L1C data: sentinelhub.aws --product S2A_MSIL1C_20170414T003551_N0204_R016_T54HVH_20170414T003551 ...
python
{ "resource": "" }
q224524
_config_options
train
def _config_options(func): """ A helper function which joins click.option functions of each parameter from config.json """ for param in SHConfig().get_params()[-1::-1]: func = click.option('--{}'.format(param), param, help='Set new values to configuration parameter "{}"'....
python
{ "resource": "" }
q224525
config
train
def config(show, reset, **params): """Inspect and configure parameters in your local sentinelhub configuration file \b Example: sentinelhub.config --show sentinelhub.config --instance_id <new instance id> sentinelhub.config --max_download_attempts 5 --download_sleep_time 20 --download_tim...
python
{ "resource": "" }
q224526
download
train
def download(url, filename, redownload): """Download from custom created URL into custom created file path \b Example: sentinelhub.download http://sentinel-s2-l1c.s3.amazonaws.com/tiles/54/H/VH/2017/4/14/0/metadata.xml home/example.xml """ data_folder, filename = filename.rsplit('/', 1) dow...
python
{ "resource": "" }
q224527
SHConfig.save
train
def save(self): """Method that saves configuration parameter changes from instance of SHConfig class to global config class and to `config.json` file. Example of use case ``my_config = SHConfig()`` \n ``my_config.instance_id = '<new instance id>'`` \n ``my_co...
python
{ "resource": "" }
q224528
SHConfig._reset_param
train
def _reset_param(self, param): """ Resets a single parameter :param param: A configuration parameter :type param: str """ if param not in self._instance.CONFIG_PARAMS: raise ValueError("Cannot reset unknown parameter '{}'".format(param)) setattr(self, param, ...
python
{ "resource": "" }
q224529
SHConfig.get_config_dict
train
def get_config_dict(self): """ Get a dictionary representation of `SHConfig` class :return: A dictionary with configuration parameters :rtype: OrderedDict """ return OrderedDict((prop, getattr(self, prop)) for prop in self._instance.CONFIG_PARAMS)
python
{ "resource": "" }
q224530
bbox_to_resolution
train
def bbox_to_resolution(bbox, width, height): """ Calculates pixel resolution in meters for a given bbox of a given width and height. :param bbox: bounding box :type bbox: geometry.BBox :param width: width of bounding box in pixels :type width: int :param height: height of bounding box in pixels...
python
{ "resource": "" }
q224531
get_image_dimension
train
def get_image_dimension(bbox, width=None, height=None): """ Given bounding box and one of the parameters width or height it will return the other parameter that will best fit the bounding box dimensions :param bbox: bounding box :type bbox: geometry.BBox :param width: image width or None if height ...
python
{ "resource": "" }
q224532
to_utm_bbox
train
def to_utm_bbox(bbox): """ Transform bbox into UTM CRS :param bbox: bounding box :type bbox: geometry.BBox :return: bounding box in UTM CRS :rtype: geometry.BBox """ if CRS.is_utm(bbox.crs): return bbox lng, lat = bbox.middle utm_crs = get_utm_crs(lng, lat, source_crs=bbox.c...
python
{ "resource": "" }
q224533
get_utm_bbox
train
def get_utm_bbox(img_bbox, transform): """ Get UTM coordinates given a bounding box in pixels and a transform :param img_bbox: boundaries of bounding box in pixels as `[row1, col1, row2, col2]` :type img_bbox: list :param transform: georeferencing transform of the image, e.g. `(x_upper_left, res_x, 0, ...
python
{ "resource": "" }
q224534
wgs84_to_utm
train
def wgs84_to_utm(lng, lat, utm_crs=None): """ Convert WGS84 coordinates to UTM. If UTM CRS is not set it will be calculated automatically. :param lng: longitude in WGS84 system :type lng: float :param lat: latitude in WGS84 system :type lat: float :param utm_crs: UTM coordinate reference system...
python
{ "resource": "" }
q224535
utm_to_pixel
train
def utm_to_pixel(east, north, transform, truncate=True): """ Convert UTM coordinate to image coordinate given a transform :param east: east coordinate of point :type east: float :param north: north coordinate of point :type north: float :param transform: georeferencing transform of the image, e...
python
{ "resource": "" }
q224536
pixel_to_utm
train
def pixel_to_utm(row, column, transform): """ Convert pixel coordinate to UTM coordinate given a transform :param row: row pixel coordinate :type row: int or float :param column: column pixel coordinate :type column: int or float :param transform: georeferencing transform of the image, e.g. `(x...
python
{ "resource": "" }
q224537
wgs84_to_pixel
train
def wgs84_to_pixel(lng, lat, transform, utm_epsg=None, truncate=True): """ Convert WGS84 coordinates to pixel image coordinates given transform and UTM CRS. If no CRS is given it will be calculated it automatically. :param lng: longitude of point :type lng: float :param lat: latitude of point :...
python
{ "resource": "" }
q224538
transform_point
train
def transform_point(point, source_crs, target_crs): """ Maps point form src_crs to tgt_crs :param point: a tuple `(x, y)` :type point: (float, float) :param source_crs: source CRS :type source_crs: constants.CRS :param target_crs: target CRS :type target_crs: constants.CRS :return: poin...
python
{ "resource": "" }
q224539
transform_bbox
train
def transform_bbox(bbox, target_crs): """ Maps bbox from current crs to target_crs :param bbox: bounding box :type bbox: geometry.BBox :param target_crs: target CRS :type target_crs: constants.CRS :return: bounding box in target CRS :rtype: geometry.BBox """ warnings.warn("This func...
python
{ "resource": "" }
q224540
get_safe_format
train
def get_safe_format(product_id=None, tile=None, entire_product=False, bands=None, data_source=DataSource.SENTINEL2_L1C): """ Returns .SAFE format structure in form of nested dictionaries. Either ``product_id`` or ``tile`` must be specified. :param product_id: original ESA product identification string. Def...
python
{ "resource": "" }
q224541
download_safe_format
train
def download_safe_format(product_id=None, tile=None, folder='.', redownload=False, entire_product=False, bands=None, data_source=DataSource.SENTINEL2_L1C): """ Downloads .SAFE format structure in form of nested dictionaries. Either ``product_id`` or ``tile`` must be specified. ...
python
{ "resource": "" }
q224542
DataRequest.save_data
train
def save_data(self, *, data_filter=None, redownload=False, max_threads=None, raise_download_errors=False): """ Saves data to disk. If ``redownload=True`` then the data is redownloaded using ``max_threads`` workers. :param data_filter: Used to specify which items will be returned by the method a...
python
{ "resource": "" }
q224543
DataRequest._execute_data_download
train
def _execute_data_download(self, data_filter, redownload, max_threads, raise_download_errors): """Calls download module and executes the download process :param data_filter: Used to specify which items will be returned by the method and in which order. E.g. with `data_filter=[0, 2, -1]` the...
python
{ "resource": "" }
q224544
DataRequest._filter_repeating_items
train
def _filter_repeating_items(download_list): """ Because of data_filter some requests in download list might be the same. In order not to download them again this method will reduce the list of requests. It will also return a mapping list which can be used to reconstruct the previous list of down...
python
{ "resource": "" }
q224545
DataRequest._preprocess_request
train
def _preprocess_request(self, save_data, return_data): """ Prepares requests for download and creates empty folders :param save_data: Tells whether to save data or not :type: bool :param return_data: Tells whether to return data or not :type: bool """ if ...
python
{ "resource": "" }
q224546
DataRequest._add_saved_data
train
def _add_saved_data(self, data_list, data_filter, raise_download_errors): """ Adds already saved data that was not redownloaded to the requested data list. """ filtered_download_list = self.download_list if data_filter is None else \ [self.download_list[index] for index in da...
python
{ "resource": "" }
q224547
GeopediaImageRequest.create_request
train
def create_request(self, reset_gpd_iterator=False): """Set a list of download requests Set a list of DownloadRequests for all images that are under the given property of the Geopedia's Vector layer. :param reset_gpd_iterator: When re-running the method this flag is used to reset/keep e...
python
{ "resource": "" }
q224548
GeopediaSession.provide_session
train
def provide_session(self, start_new=False): """ Makes sure that session is still valid and provides session info :param start_new: If `True` it will always create a new session. Otherwise it will create a new session only if no session exists or the previous session timed out. :type...
python
{ "resource": "" }
q224549
GeopediaSession._start_new_session
train
def _start_new_session(self): """ Starts a new session and calculates when the new session will end. If username and password are provided it will also make login. """ self._session_start = datetime.datetime.now() session_id = self._parse_session_id(self._session_info) if self._...
python
{ "resource": "" }
q224550
GeopediaSession._make_login
train
def _make_login(self): """ Private method that makes login """ login_url = '{}data/v1/session/login?user={}&pass={}&sid={}'.format(self.base_url, self.username, self.password, self._parse_session_id(self._session_info)) ...
python
{ "resource": "" }
q224551
GeopediaImageService._get_items
train
def _get_items(self, request): """ Collects data from Geopedia layer and returns list of features """ if request.gpd_iterator is None: self.gpd_iterator = GeopediaFeatureIterator(request.layer, bbox=request.bbox, base_url=self.base_url, ...
python
{ "resource": "" }
q224552
GeopediaImageService._get_filename
train
def _get_filename(request, item): """ Creates a filename """ if request.keep_image_names: filename = OgcImageService.finalize_filename(item['niceName'].replace(' ', '_')) else: filename = OgcImageService.finalize_filename( '_'.join([str(GeopediaSer...
python
{ "resource": "" }
q224553
GeopediaFeatureIterator._fetch_features
train
def _fetch_features(self): """ Retrieves a new page of features from Geopedia """ if self.next_page_url is None: return response = get_json(self.next_page_url, post_values=self.query, headers=self.gpd_session.session_headers) self.features.extend(response['features'...
python
{ "resource": "" }
q224554
get_folder_list
train
def get_folder_list(folder='.'): """ Get list of sub-folders contained in input folder :param folder: input folder to list sub-folders. Default is ``'.'`` :type folder: str :return: list of sub-folders :rtype: list(str) """ dir_list = get_content_list(folder) return [f for f in dir_list...
python
{ "resource": "" }
q224555
create_parent_folder
train
def create_parent_folder(filename): """ Create parent folder for input filename recursively :param filename: input filename :type filename: str :raises: error if folder cannot be created """ path = os.path.dirname(filename) if path != '': make_folder(path)
python
{ "resource": "" }
q224556
make_folder
train
def make_folder(path): """ Create folder at input path recursively Create a folder specified by input path if one does not exist already :param path: input path to folder to be created :type path: str :raises: os.error if folder cannot be created """ if not os.path.exists(path): ...
python
{ "resource": "" }
q224557
rename
train
def rename(old_path, new_path, edit_folders=True): """ Rename files or folders :param old_path: name of file or folder to rename :param new_path: name of new file or folder :param edit_folders: flag to allow recursive renaming of folders. Default is ``True`` :type old_path: str :type new_path: ...
python
{ "resource": "" }
q224558
size
train
def size(pathname): """ Returns size of a file or folder in Bytes :param pathname: path to file or folder to be sized :type pathname: str :return: size of file or folder in Bytes :rtype: int :raises: os.error if file is not accessible """ if os.path.isfile(pathname): return os.p...
python
{ "resource": "" }
q224559
BBox.middle
train
def middle(self): """ Returns the middle point of the bounding box :return: middle point :rtype: (float, float) """ return (self.min_x + self.max_x) / 2, (self.min_y + self.max_y) / 2
python
{ "resource": "" }
q224560
BBox.reverse
train
def reverse(self): """ Returns a new BBox object where x and y coordinates are switched :return: New BBox object with switched coordinates :rtype: BBox """ return BBox((self.min_y, self.min_x, self.max_y, self.max_x), crs=self.crs)
python
{ "resource": "" }
q224561
BBox.transform
train
def transform(self, crs): """ Transforms BBox from current CRS to target CRS :param crs: target CRS :type crs: constants.CRS :return: Bounding box in target CRS :rtype: BBox """ new_crs = CRS(crs) return BBox((transform_point(self.lower_left, self.crs, ne...
python
{ "resource": "" }
q224562
BBox.get_polygon
train
def get_polygon(self, reverse=False): """ Returns a tuple of coordinates of 5 points describing a polygon. Points are listed in clockwise order, first point is the same as the last. :param reverse: `True` if x and y coordinates should be switched and `False` otherwise :type reverse: boo...
python
{ "resource": "" }
q224563
BBox.get_partition
train
def get_partition(self, num_x=1, num_y=1): """ Partitions bounding box into smaller bounding boxes of the same size. :param num_x: Number of parts BBox will be horizontally divided into. :type num_x: int :param num_y: Number of parts BBox will be vertically divided into. :type n...
python
{ "resource": "" }
q224564
BBox.get_transform_vector
train
def get_transform_vector(self, resx, resy): """ Given resolution it returns a transformation vector :param resx: Resolution in x direction :type resx: float or int :param resy: Resolution in y direction :type resy: float or int :return: A tuple with 6 numbers representin...
python
{ "resource": "" }
q224565
BBox._parse_resolution
train
def _parse_resolution(res): """ Helper method for parsing given resolution. It will also try to parse a string into float :return: A float value of resolution :rtype: float """ if isinstance(res, str): return float(res.strip('m')) if isinstance(res, (int, flo...
python
{ "resource": "" }
q224566
BBox._tuple_from_list_or_tuple
train
def _tuple_from_list_or_tuple(bbox): """ Converts a list or tuple representation of a bbox into a flat tuple representation. :param bbox: a list or tuple with 4 coordinates that is either flat or nested :return: tuple (min_x,min_y,max_x,max_y) :raises: TypeError """ if l...
python
{ "resource": "" }
q224567
BBox._tuple_from_str
train
def _tuple_from_str(bbox): """ Parses a string of numbers separated by any combination of commas and spaces :param bbox: e.g. str of the form `min_x ,min_y max_x, max_y` :return: tuple (min_x,min_y,max_x,max_y) """ return tuple([float(s) for s in bbox.replace(',', ' ').split() ...
python
{ "resource": "" }
q224568
Geometry.reverse
train
def reverse(self): """ Returns a new Geometry object where x and y coordinates are switched :return: New Geometry object with switched coordinates :rtype: Geometry """ return Geometry(shapely.ops.transform(lambda x, y: (y, x), self.geometry), crs=self.crs)
python
{ "resource": "" }
q224569
Geometry.transform
train
def transform(self, crs): """ Transforms Geometry from current CRS to target CRS :param crs: target CRS :type crs: constants.CRS :return: Geometry in target CRS :rtype: Geometry """ new_crs = CRS(crs) geometry = self.geometry if new_crs is not se...
python
{ "resource": "" }
q224570
Geometry._parse_geometry
train
def _parse_geometry(geometry): """ Parses given geometry into shapely object :param geometry: :return: Shapely polygon or multipolygon :rtype: shapely.geometry.Polygon or shapely.geometry.MultiPolygon :raises TypeError """ if isinstance(geometry, str): ...
python
{ "resource": "" }
q224571
BBoxCollection.transform
train
def transform(self, crs): """ Transforms BBoxCollection from current CRS to target CRS :param crs: target CRS :type crs: constants.CRS :return: BBoxCollection in target CRS :rtype: BBoxCollection """ return BBoxCollection([bbox.transform(crs) for bbox in self.bbo...
python
{ "resource": "" }
q224572
BBoxCollection._get_geometry
train
def _get_geometry(self): """ Creates a multipolygon of bounding box polygons """ return shapely.geometry.MultiPolygon([bbox.geometry for bbox in self.bbox_list])
python
{ "resource": "" }
q224573
BBoxCollection._parse_bbox_list
train
def _parse_bbox_list(bbox_list): """ Helper method for parsing a list of bounding boxes """ if isinstance(bbox_list, BBoxCollection): return bbox_list.bbox_list, bbox_list.crs if not isinstance(bbox_list, list) or not bbox_list: raise ValueError('Expected non-emp...
python
{ "resource": "" }
q224574
read_data
train
def read_data(filename, data_format=None): """ Read image data from file This function reads input data from file. The format of the file can be specified in ``data_format``. If not specified, the format is guessed from the extension of the filename. :param filename: filename to read data from ...
python
{ "resource": "" }
q224575
read_jp2_image
train
def read_jp2_image(filename): """ Read data from JPEG2000 file :param filename: name of JPEG2000 file to be read :type filename: str :return: data stored in JPEG2000 file """ # Other option: # return glymur.Jp2k(filename)[:] image = read_image(filename) with open(filename, 'rb') as...
python
{ "resource": "" }
q224576
read_csv
train
def read_csv(filename, delimiter=CSV_DELIMITER): """ Read data from CSV file :param filename: name of CSV file to be read :type filename: str :param delimiter: type of CSV delimiter. Default is ``;`` :type delimiter: str :return: data stored in CSV file as list """ with open(filename, '...
python
{ "resource": "" }
q224577
write_data
train
def write_data(filename, data, data_format=None, compress=False, add=False): """ Write image data to file Function to write image data to specified file. If file format is not provided explicitly, it is guessed from the filename extension. If format is TIFF, geo information and compression can be optio...
python
{ "resource": "" }
q224578
write_tiff_image
train
def write_tiff_image(filename, image, compress=False): """ Write image data to TIFF file :param filename: name of file to write data to :type filename: str :param image: image data to write to file :type image: numpy array :param compress: whether to compress data. If ``True``, lzma compression...
python
{ "resource": "" }
q224579
write_image
train
def write_image(filename, image): """ Write image data to PNG, JPG file :param filename: name of PNG or JPG file to write data to :type filename: str :param image: image data to write to file :type image: numpy array """ data_format = get_data_format(filename) if data_format is MimeType...
python
{ "resource": "" }
q224580
write_text
train
def write_text(filename, data, add=False): """ Write image data to text file :param filename: name of text file to write data to :type filename: str :param data: image data to write to text file :type data: numpy array :param add: whether to append to existing file or not. Default is ``False`` ...
python
{ "resource": "" }
q224581
write_csv
train
def write_csv(filename, data, delimiter=CSV_DELIMITER): """ Write image data to CSV file :param filename: name of CSV file to write data to :type filename: str :param data: image data to write to CSV file :type data: numpy array :param delimiter: delimiter used in CSV file. Default is ``;`` ...
python
{ "resource": "" }
q224582
write_json
train
def write_json(filename, data): """ Write data to JSON file :param filename: name of JSON file to write data to :type filename: str :param data: data to write to JSON file :type data: list, tuple """ with open(filename, 'w') as file: json.dump(data, file, indent=4, sort_keys=True)
python
{ "resource": "" }
q224583
get_jp2_bit_depth
train
def get_jp2_bit_depth(stream): """Reads bit encoding depth of jpeg2000 file in binary stream format :param stream: binary stream format :type stream: Binary I/O (e.g. io.BytesIO, io.BufferedReader, ...) :return: bit depth :rtype: int """ stream.seek(0) while True: read_buffer = ...
python
{ "resource": "" }
q224584
fix_jp2_image
train
def fix_jp2_image(image, bit_depth): """Because Pillow library incorrectly reads JPEG 2000 images with 15-bit encoding this function corrects the values in image. :param image: image read by opencv library :type image: numpy array :param bit_depth: bit depth of jp2 image encoding :type bit_dept...
python
{ "resource": "" }
q224585
download_data
train
def download_data(request_list, redownload=False, max_threads=None): """ Download all requested data or read data from disk, if already downloaded and available and redownload is not required. :param request_list: list of DownloadRequests :type request_list: list of DownloadRequests :param redownlo...
python
{ "resource": "" }
q224586
_check_if_must_download
train
def _check_if_must_download(request_list, redownload): """ Updates request.will_download attribute of each request in request_list. **Note:** the function mutates the elements of the list! :param request_list: a list of ``DownloadRequest`` instances :type: list[DownloadRequest] :param redownlo...
python
{ "resource": "" }
q224587
execute_download_request
train
def execute_download_request(request): """ Executes download request. :param request: DownloadRequest to be executed :type request: DownloadRequest :return: downloaded data or None :rtype: numpy array, other possible data type or None :raises: DownloadFailedException """ if request.save...
python
{ "resource": "" }
q224588
_is_temporal_problem
train
def _is_temporal_problem(exception): """ Checks if the obtained exception is temporal and if download attempt should be repeated :param exception: Exception raised during download :type exception: Exception :return: True if exception is temporal and False otherwise :rtype: bool """ try: ...
python
{ "resource": "" }
q224589
_create_download_failed_message
train
def _create_download_failed_message(exception, url): """ Creates message describing why download has failed :param exception: Exception raised during download :type exception: Exception :param url: An URL from where download was attempted :type url: str :return: Error message :rtype: str ...
python
{ "resource": "" }
q224590
decode_data
train
def decode_data(response_content, data_type, entire_response=None): """ Interprets downloaded data and returns it. :param response_content: downloaded data (i.e. json, png, tiff, xml, zip, ... file) :type response_content: bytes :param data_type: expected downloaded data type :type data_type: const...
python
{ "resource": "" }
q224591
decode_image
train
def decode_image(data, image_type): """ Decodes the image provided in various formats, i.e. png, 16-bit float tiff, 32-bit float tiff, jp2 and returns it as an numpy array :param data: image in its original format :type data: any of possible image types :param image_type: expected image format ...
python
{ "resource": "" }
q224592
get_json
train
def get_json(url, post_values=None, headers=None): """ Download request as JSON data type :param url: url to Sentinel Hub's services or other sources from where the data is downloaded :type url: str :param post_values: form encoded data to send in POST request. Default is ``None`` :type post_values...
python
{ "resource": "" }
q224593
get_xml
train
def get_xml(url): """ Download request as XML data type :param url: url to Sentinel Hub's services or other sources from where the data is downloaded :type url: str :return: request response as XML instance :rtype: XML instance or None :raises: RunTimeError """ request = DownloadRequest...
python
{ "resource": "" }
q224594
DownloadRequest.is_downloaded
train
def is_downloaded(self): """ Checks if data for this request has already been downloaded and is saved to disk. :return: returns ``True`` if data for this request has already been downloaded and is saved to disk. :rtype: bool """ if self.file_path is None: return Fals...
python
{ "resource": "" }
q224595
get_area_info
train
def get_area_info(bbox, date_interval, maxcc=None): """ Get information about all images from specified area and time range :param bbox: bounding box of requested area :type bbox: geometry.BBox :param date_interval: a pair of time strings in ISO8601 format :type date_interval: tuple(str) :param...
python
{ "resource": "" }
q224596
get_area_dates
train
def get_area_dates(bbox, date_interval, maxcc=None): """ Get list of times of existing images from specified area and time range :param bbox: bounding box of requested area :type bbox: geometry.BBox :param date_interval: a pair of time strings in ISO8601 format :type date_interval: tuple(str) :...
python
{ "resource": "" }
q224597
search_iter
train
def search_iter(tile_id=None, bbox=None, start_date=None, end_date=None, absolute_orbit=None): """ A generator function that implements OpenSearch search queries and returns results All parameters for search are optional. :param tile_id: original tile identification string provided by ESA (e.g. ...
python
{ "resource": "" }
q224598
_prepare_url_params
train
def _prepare_url_params(tile_id, bbox, end_date, start_date, absolute_orbit): """ Constructs dict with URL params :param tile_id: original tile identification string provided by ESA (e.g. 'S2A_OPER_MSI_L1C_TL_SGS__20160109T230542_A002870_T10UEV_N02.01') :type tile_id: str :param bbo...
python
{ "resource": "" }
q224599
_edit_name
train
def _edit_name(name, code, add_code=None, delete_end=False): """ Helping function for creating file names in .SAFE format :param name: initial string :type name: str :param code: :type code: str :param add_code: :type add_code: str or None :param delete_end: :type delete_end: bo...
python
{ "resource": "" }