Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from gbdxtools.images.base import RDABaseImage
from gbdxtools.images.drivers import IdahoDriver
from gbdxtools.images.util import vector_services_query
from gbdxtools.rda.util import calc_toa_gain_offset, ortho_params
from gbdxtools.rda.interface import RDA
from shapely import wkt
from shapely.geometry import box
rda = RDA()
class IdahoImage(RDABaseImage):
""" Image based on IDAHO virtual tiles
Like a CatalogImage, but takes an IDAHO ID when initialized.
Band_type and pansharpen arguments are not supported because IDAHO multispectral and panchromatic images are stored separately.
Args:
(str): IDAHO ID
Example:
>>> img = IdahoImage('87a5b5a7-5438-44bf-926a-c8c7bc153713')
"""
__Driver__ = IdahoDriver
@property
def idaho_id(self):
return self.__rda_id__
band_types = {
'MS': 'multispectral',
'ms': 'multispectral',
'Panchromatic': 'panchromatic',
'Pan': 'panchromatic',
'pan': 'panchromatic',
'thermal': 'thermal'
}
class LandsatDriver(RDADaskImageDriver):
__default_options__ = {}
image_option_support = ["band_type", "proj", "pansharpen"]
__image_option_defaults__ = {"band_type": "MS", "proj": None, "pansharpen": False}
class LandsatImage(RDABaseImage):
"""
Dask based access to landsat image backed by rda Graphs.
"""
__Driver__ = LandsatDriver
@property
def _id(self):
return self.__rda_id__
@property
def _spec(self):
return self.options["band_type"]
@property
def _rgb_bands(self):
return [3,2,1]
return [1,3]
@classmethod
def _build_graph(cls, prefix, spec="10m", proj=None, **kwargs):
sentinel2 = rda.Sentinel2Template(sentinelId=prefix, sentinelProductSpec=spec, nodeId="Sentinel2Read")
if proj is not None:
sentinel2 = sentinel2(nodeId="Reproject", **reproject_params(proj))
return sentinel2
class Sentinel1Driver(RDADaskImageDriver):
image_option_support = ["polarization", "proj"]
__image_option_defaults__ = {"polarization": "VH", "proj": None}
class Sentinel1(RDABaseImage):
"""
Dask based access to Sentinel1 images backed by rda Graphs.
Args:
catID (str): The Sentinel CatalogID from the Sentinel1 Catalog Item
polarization (str): The Polarization type. Defaults to 'VH' (default), 'VV', 'HH', or 'VV'
proj (str): EPSG code for the resulting image.
"""
__Driver__ = Sentinel1Driver
@property
def _id(self):
return self.__rda_id__
@property
def polarization(self):
import os
from gbdxtools.images.base import RDABaseImage
from gbdxtools.images.drivers import RDADaskImageDriver
from gbdxtools.rda.util import ortho_params
from gbdxtools.rda.interface import RDA
rda = RDA()
class RadarsatDriver(RDADaskImageDriver):
image_option_support = ["calibration", "proj"]
__image_option_defaults__ = {"calibration": "uncalibrated", "proj": "EPSG:4326"}
class Radarsat(RDABaseImage):
"""
Dask based access to Radarsat images backed by rda Graphs.
Args:
catID (str): The Radarsat record from the Radarsat Catalog Item
calibration (str): Data calibration. Options are 'uncalibrated' (default), 'beta0', 'sigma0' or 'gamma'.
proj (str): EPSG code for the resulting image.
gsd (str): Resolution for the resulting image.
"""
__Driver__ = RadarsatDriver
@property
def _id(self):
return self.__rda_id__
@property
from gbdxtools.images.base import RDABaseImage
from gbdxtools.images.drivers import RDADaskImageDriver
from gbdxtools.images.util.image import reproject_params
from gbdxtools.rda.interface import RDA
rda = RDA()
class ModisDriver(RDADaskImageDriver):
image_option_support = ["proj"]
__image_option_defaults__ = {"proj": None}
class Modis(RDABaseImage):
"""
Dask based access to Modis images backed by rda Graphs.
Args:
catalog_id (str): The Catalog ID for the modis image.
"""
__Driver__ = ModisDriver
@property
def _id(self):
return self.__rda_id__
@property
def _rgb_bands(self):
return [1,4,3]
from gbdxtools.rda.interface import RDA
from gbdxtools.rda.error import MissingIdahoImages, AcompUnavailable
rda = RDA()
RDA_DTYPES = {
None: '4',
'uint8': "0",
'uint16': "1",
'int16': "2",
'int32': "3",
'float32': "4",
'float64': "5"
}
class WorldViewImage(RDABaseImage):
__Driver__ = WorldViewDriver
_parts = None
@property
def cat_id(self):
return self.__rda_id__
@property
def parts(self):
if self._parts is None:
self._parts = [IdahoImage(rec['properties']['attributes']['idahoImageId'],
proj=self.options["proj"],
bucket=rec['properties']['attributes']['bucketName'],
gsd=self.options["gsd"],
acomp=self.options["acomp"])
for rec in self._find_parts(self.cat_id, self.options["band_type"])]
rda = RDA()
band_types = {
'MS': 'multispectral',
'ms': 'multispectral',
'Panchromatic': 'panchromatic',
'Pan': 'panchromatic',
'pan': 'panchromatic',
'thermal': 'thermal'
}
class IkonosDriver(RDADaskImageDriver):
image_option_support = ["proj", "gsd", "band_type", "pansharpen"]
__image_option_defaults__ = {"gsd": None, "band_type": "MS", "pansharpen": False}
class IkonosImage(RDABaseImage):
"""
Dask based access to ikonos images backed by RDA Graphs.
"""
__Driver__ = IkonosDriver
@property
def _record(self):
return self.__rda_id__
@property
def _spec(self):
return self.options["band_type"]
@property
def _gsd(self):
return self.options["gsd"]
from gbdxtools.images.base import RDABaseImage
from gbdxtools.images.drivers import RDADaskImageDriver
from gbdxtools.rda.util import reproject_params
from gbdxtools.rda.interface import RDA
rda = RDA()
from shapely.geometry import box
class DemDriver(RDADaskImageDriver):
image_option_support = ["proj", "bbox"]
__image_option_defaults__ = {"bbox": None}
class DemImage(RDABaseImage):
''' Image class for Digital Elevation Model (DEM) data from the NED/SRTM dataset.
This class has no Catalog IDs and is created by passing an AOI. It shares most of the same methods as CatalogImage objects.
Args:
aoi (list): list of coordinate in BBOX format
proj (str): (optional) EPSG string of projection reproject to. Native projection is "EPSG:4326" (WGS84)
Example:
>>> dem = DemImage(aoi=[5.279, 60.358, 5.402, 60.419])'''
__Driver__ = DemDriver
__rda_id__ = "dgdem-v20180406-DEFLATED-ca4649c5acb"
def __post_new_hook__(self, **kwargs):
self = self.aoi(**kwargs)
from gbdxtools.images.base import RDABaseImage
from gbdxtools.images.drivers import RDADaskImageDriver
from gbdxtools.images.util.image import reproject_params
from gbdxtools.rda.interface import RDA
rda = RDA()
class Sentinel2Driver(RDADaskImageDriver):
image_option_support = ["spec", "proj"]
__image_option_defaults__ = {"spec": "10m", "proj": None}
class Sentinel2(RDABaseImage):
"""
Dask based access to Sentinel2 images backed by rda Graphs.
Args:
prefix (str): The Sentinel data location from Catalog metadata item 'bucketPrefix'
spec (str): Sensor group to use, values are '10m' (default), '20m', and '60m'
proj (str): EPSG code for the resulting image, defaults to EPSG:4326 (WGS 84 Lat/Lon)
"""
__Driver__ = Sentinel2Driver
@property
def _id(self):
return self.__rda_id__
@property
def _spec(self):
def __new__(cls, rda_id=None, **kwargs):
cls = cls.__Driver__(rda_id=rda_id, **kwargs).drive(cls, **kwargs)
self = super(RDABaseImage, cls).__new__(cls, cls.__driver__.payload, **kwargs)
return self.__post_new_hook__(**kwargs)