Exemple #1
0
    def _pansharpen_graph(self):
        pan_graph = {}
        ms_graph = {}
        for part in self.metadata['parts']:
            for k, p in part.items():
                _id = p['properties']['idahoImageId']
                if k == 'PAN':
                    pan_graph[_id] = ipe.Orthorectify(
                        ipe.IdahoRead(bucketName="idaho-images",
                                      imageId=_id,
                                      objectStore="S3"),
                        **ortho_params(self._proj))
                else:
                    ms_graph[_id] = ipe.Orthorectify(
                        ipe.IdahoRead(bucketName="idaho-images",
                                      imageId=_id,
                                      objectStore="S3"),
                        **ortho_params(self._proj))

        pan_mosaic = self._mosaic(pan_graph, suffix='-pan')
        pan = ipe.Format(ipe.MultiplyConst(pan_mosaic['toa_reflectance-pan'],
                                           constants=json.dumps([1000])),
                         dataType="1")
        ms_mosaic = self._mosaic(ms_graph, suffix='-ms')
        ms = ipe.Format(ipe.MultiplyConst(ms_mosaic['toa_reflectance-ms'],
                                          constants=json.dumps([1000] * 8)),
                        dataType="1")
        return {
            'ms_mosaic': ms_mosaic,
            'pan_mosiac': pan_mosaic,
            'pansharpened': ipe.LocallyProjectivePanSharpen(ms, pan)
        }
Exemple #2
0
    def _build_standard_products(idaho_id, proj, gsd=None):
        dn_op = ipe.IdahoRead(bucketName="idaho-images",
                              imageId=idaho_id,
                              objectStore="S3")
        params = ortho_params(proj, gsd=gsd)
        ortho_op = ipe.Orthorectify(dn_op, **params)

        # TODO: Switch to direct metadata access (ie remove this block)
        idaho_md = requests.get(
            'http://idaho.timbr.io/{}.json'.format(idaho_id)).json()
        meta = idaho_md["properties"]
        gains_offsets = calc_toa_gain_offset(meta)
        radiance_scales, reflectance_scales, radiance_offsets = zip(
            *gains_offsets)
        # ---

        toa_reflectance_op = ipe.MultiplyConst(ipe.AddConst(
            ipe.MultiplyConst(ipe.Format(ortho_op, dataType="4"),
                              constants=radiance_scales),
            constants=radiance_offsets),
                                               constants=reflectance_scales)

        return {
            "1b": dn_op,
            "ortho": ortho_op,
            "toa_reflectance": toa_reflectance_op
        }
Exemple #3
0
    def _build_standard_products(idaho_id,
                                 proj,
                                 bucket=None,
                                 gsd=None,
                                 acomp=False):
        if bucket is None:
            vectors = Vectors()
            aoi = wkt.dumps(box(-180, -90, 180, 90))
            query = "item_type:IDAHOImage AND id:{}".format(idaho_id)
            result = vectors.query(aoi, query=query)
            if len(result):
                bucket = result[0]["properties"]["attributes"][
                    "tileBucketName"]

        dn_op = ipe.IdahoRead(bucketName=bucket,
                              imageId=idaho_id,
                              objectStore="S3")
        params = ortho_params(proj, gsd=gsd)

        graph = {
            "1b":
            dn_op,
            "ortho":
            ipe.Orthorectify(dn_op, **params),
            "acomp":
            ipe.Format(ipe.Orthorectify(ipe.Acomp(dn_op), **params),
                       dataType="4"),
            "toa_reflectance":
            ipe.Format(ipe.Orthorectify(ipe.TOAReflectance(dn_op), **params),
                       dataType="4")
        }

        return graph
Exemple #4
0
 def _build_standard_products(record, spec, proj):
     prefix = record['properties']['attributes']['bucketPrefix']
     bucket = record['properties']['attributes']['bucketName']
     ikonos = ipe.IkonosRead(
         path="{}/{}/{}_0000000:{}".format(bucket, prefix, prefix, spec))
     ikonos = ipe.Orthorectify(ikonos, **ortho_params(proj))
     return {"ikonos": ikonos}
Exemple #5
0
 def _build_standard_products(rec, proj):
     s3path = "/vsis3/{}/{}/{}".format(
         rec['properties']['attributes']['bucketName'],
         rec['properties']['attributes']['bucketPrefix'],
         rec['properties']['attributes']['imageFile'])
     ge = ipe.GdalImageRead(path=s3path)
     ortho = ipe.Orthorectify(ge, **ortho_params(proj))
     return {"ortho": ortho}
Exemple #6
0
    def _init_graphs(self):
        graph = {}
        ids = []
        if self._node_id == 'pansharpened' and self._pansharpen:
            return self._pansharpen_graph()
        else:
            for part in self.metadata['parts']:
                for k, p in part.items():
                    if k == band_types[self._band_type]:
                        _id = p['properties']['idahoImageId']
                        graph[_id] = ipe.Orthorectify(
                            ipe.IdahoRead(bucketName="idaho-images",
                                          imageId=_id,
                                          objectStore="S3"),
                            **ortho_params(self._proj))

            return self._mosaic(graph)
Exemple #7
0
 def _init_graphs(self):
     meta = self.idaho_md["properties"]
     gains_offsets = calc_toa_gain_offset(meta)
     radiance_scales, reflectance_scales, radiance_offsets = zip(
         *gains_offsets)
     ortho = ipe.Orthorectify(
         ipe.IdahoRead(bucketName="idaho-images",
                       imageId=self._gid,
                       objectStore="S3"), **ortho_params(self._proj))
     radiance = ipe.AddConst(ipe.MultiplyConst(ipe.Format(ortho,
                                                          dataType="4"),
                                               constants=radiance_scales),
                             constants=radiance_offsets)
     toa_reflectance = ipe.MultiplyConst(radiance,
                                         constants=reflectance_scales)
     return {
         "ortho": ortho,
         "radiance": radiance,
         "toa_reflectance": toa_reflectance
     }