landsat package¶
Submodules¶
landsat.downloader module¶
landsat.image module¶
landsat.landsat module¶
landsat.mixins module¶
-
class
landsat.mixins.
VerbosityMixin
[source]¶ Bases:
object
Verbosity Mixin that generates beautiful stdout outputs.
-
exit
(message)[source]¶ outputs an exit message and exits
Parameters: message (String) – The message to be outputed Returns: void
-
output
(value, normal=False, color=None, error=False, arrow=False, indent=None)[source]¶ Handles verbosity of this calls. if priority is set to 1, the value is printed
if class instance verbose is True, the value is printed
Parameters: - value (String) – a string representing the message to be printed
- normal (String) – if set to true the message is always printed, otherwise it is only shown if verbosity is set
- color – The color of the message, choices: ‘red’, ‘green’, ‘blue’
- error (Boolean) – if set to true the message appears in red
- arrow (Boolean) – if set to true an arrow appears before the message
- indent (Boolean) – indents the message based on the number provided
Returns: void
-
subprocess
(argv)[source]¶ Execute subprocess commands with proper ouput. This is no longer used in landsat-util
Parameters: argv (List) – A list of subprocess arguments Returns: void
-
verbose
= False¶
-
landsat.ndvi module¶
landsat.search module¶
-
class
landsat.search.
Search
[source]¶ Bases:
object
The search class
-
address_builder
(address)[source]¶ Builds lat and lon query from a geocoded address.
Parameters: address (String) – The address Returns: String
-
cloud_cover_prct_range_builder
(min=0, max=100)[source]¶ Builds cloud cover percentage range query.
Parameters: - min (float) – float specifying the minimum percentage. Default is 0
- max (float) – float specifying the maximum percentage. Default is 100
Returns: String
-
date_range_builder
(start='2013-02-11', end=None)[source]¶ Builds date range query.
Parameters: - start (String) – Date string. format: YYYY-MM-DD
- end (String) – date string. format: YYYY-MM-DD
Returns: String
-
lat_lon_builder
(lat=0, lon=0)[source]¶ Builds lat and lon query.
Parameters: - lat (float) – The latitude. Default is 0
- lon (float) – The The longitude. Default is 0
Returns: String
-
query_builder
(paths_rows=None, lat=None, lon=None, address=None, start_date=None, end_date=None, cloud_min=None, cloud_max=None)[source]¶ Builds the proper search syntax (query) for Landsat API.
Parameters: - paths_rows (String) – A string in this format: “003,003,004,004”. Must be in pairs and separated by comma.
- lat (String, float, integer) – The latitude
- lon (String, float, integer) – The The longitude
- address (String) – The address
- start_date (String) – Date string. format: YYYY-MM-DD
- end_date (String) – date string. format: YYYY-MM-DD
- cloud_min (float) – float specifying the minimum percentage. e.g. 4.3
- cloud_max (float) – float specifying the maximum percentage. e.g. 78.9
Returns: String
-
row_path_builder
(path='', row='')[source]¶ Builds row and path query.
Parameters: - path (String) – Landsat path. Must be three digits
- row (String) – Landsat row. Must be three digits
Returns: String
-
search
(paths_rows=None, lat=None, lon=None, address=None, start_date=None, end_date=None, cloud_min=None, cloud_max=None, limit=1, geojson=False)[source]¶ The main method of Search class. It searches Development Seed’s Landsat API.
Parameters: - paths_rows (String) – A string in this format: “003,003,004,004”. Must be in pairs and separated by comma.
- lat (String, float, integer) – The latitude
- lon (String, float, integer) – The The longitude
- address (String) – The address
- start_date (String) – Date string. format: YYYY-MM-DD
- end_date (String) – date string. format: YYYY-MM-DD
- cloud_min (float) – float specifying the minimum percentage. e.g. 4.3
- cloud_max (float) – float specifying the maximum percentage. e.g. 78.9
- limit (integer) – integer specigying the maximum results return.
- geojson (boolean) – boolean specifying whether to return a geojson object
Returns: dict
Example: >>> search = Search() >>> search('003,003', '2014-01-01', '2014-06-01') >>> { 'status': u'SUCCESS', 'total_returned': 1, 'total': 1, 'limit': 1 'results': [ { 'sat_type': u'L8', 'sceneID': u'LC80030032014142LGN00', 'date': u'2014-05-22', 'path': u'003', 'thumbnail': u'http://....../landsat_8/2014/003/003/LC80030032014142LGN00.jpg', 'cloud': 33.36, 'row': u'003 } ] }
-
landsat.settings module¶
landsat.uploader module¶
landsat.utils module¶
-
class
landsat.utils.
Capturing
[source]¶ Bases:
list
Captures a subprocess stdout.
Usage: >>> with Capturing(): ... subprocess(args)
-
landsat.utils.
adjust_bounding_box
(bounds1, bounds2)[source]¶ If the bounds 2 corners are outside of bounds1, they will be adjusted to bounds1 corners
@params bounds1 - The source bounding box bounds2 - The target bounding box that has to be within bounds1
@return A bounding box tuple in (y1, x1, y2, x2) format
-
landsat.utils.
check_create_folder
(folder_path)[source]¶ Check whether a folder exists, if not the folder is created.
Parameters: folder_path (String) – Path to the folder Returns: (String) the path to the folder
-
landsat.utils.
convert_to_float_list
(value)[source]¶ Converts a comma separate string to a list
Parameters: value (String) – the format must be 1.2,-3.5 (commas with no space)
Returns: List
Example: >>> convert_to_integer_list('003,003,004,004') [1.2, -3.5]
-
landsat.utils.
convert_to_integer_list
(value)[source]¶ Converts a comma separate string to a list
Parameters: value (String) – the format must be 003,003,004,004 (commas with no space)
Returns: List
Example: >>> convert_to_integer_list('003,003,004,004') ['003', '003', '004', '004']
-
landsat.utils.
create_paired_list
(value)[source]¶ Create a list of paired items from a string.
Parameters: value (String) – the format must be 003,003,004,004 (commas with no space)
Returns: List
Example: >>> create_paired_list('003,003,004,004') [['003','003'], ['004', '004']]
-
landsat.utils.
exit
(message, code=0)[source]¶ output a message to stdout and terminates the process.
Parameters: - message (String) – Message to be outputed.
- code (int) – The termination code. Default is 0
Returns: void
-
landsat.utils.
geocode
(address, required_precision_km=1.0)[source]¶ Identifies the coordinates of an address
Parameters: - address – the address to be geocoded
- required_precision_km (float) – the maximum permissible geographic uncertainty for the geocoding
Returns: dict
Example: >>> geocode('1600 Pennsylvania Ave NW, Washington, DC 20500') {'lat': 38.89767579999999, 'lon': -77.0364827}
-
landsat.utils.
georgian_day
(date)[source]¶ Returns the number of days passed since the start of the year.
Parameters: date (String) – The string date with this format %m/%d/%Y
Returns: int
Example: >>> georgian_day('05/1/2015') 121
-
landsat.utils.
get_file
(path)[source]¶ Separate the name of the file or folder from the path and return it.
Parameters: path (String) – Path to the folder
Returns: (String) the filename
Example: >>> get_file('/path/to/file.jpg') 'file.jpg'
-
landsat.utils.
get_filename
(path)[source]¶ Return the filename without extension.
Parameters: path (String) – Path to the folder
Returns: (String) the filename without extension
Example: >>> get_filename('/path/to/file.jpg') 'file'
-
landsat.utils.
reformat_date
(date, new_fmt='%Y-%m-%d')[source]¶ Returns reformated date.
Parameters: - date (String) – The string date with this format %m/%d/%Y
- new_fmt – date format string. Default is ‘%Y-%m-%d’
Returns: int
Example: >>> reformat_date('05/1/2015', '%d/%m/%Y') '1/05/2015'
-
landsat.utils.
three_digit
(number)[source]¶ Add 0s to inputs that their length is less than 3.
Parameters: number (int) – The number to convert
Returns: String
Example: >>> three_digit(1) '001'