예제 #1
0
    def test_cloud_cover(self):
        failed = "/imagery/c1/L8/020/035/LC08_L1TP_020035_20171028_20171108_01_T1"
        metadata = Metadata(failed)
        self.assertIsNotNone(metadata)
        metadata.parse_mtl("LC08_L1TP_020035_20171028_20171108_01_T1_MTL.json")
        self.assertIsNotNone(metadata.cloud_cover)

        self.assertIsNotNone(metadata.date_acquired)
        self.assertIsNotNone(metadata.sensing_time)

        self.assertEqual(metadata.sensing_time.date().isoformat(), metadata.date_acquired)
        self.assertNotEqual(metadata.date_acquired, metadata.date_processed.date())
예제 #2
0
 def test_bounds(self):
     row = (
         'LC80330352017072LGN00', '', 'LANDSAT_8', 'OLI_TIRS', '2017-03-13',
         '2017-03-13T17:38:14.0196140Z', 'PRE', 'N/A', 'L1T', 33, 35, 1.2,
         37.10422, 34.96178, -106.85883, -104.24596, 1067621299,
         'gs://gcp-public-data-landsat/LC08/PRE/033/035/LC80330352017072LGN00'
     )
     metadata = Metadata(row)
     self.assertIsNotNone(metadata)
     geom_wkb = metadata.get_wrs_polygon()
     self.assertIsNotNone(geom_wkb)
     bounding_polygon = box(*metadata.bounds)
     wrs_polygon = shapely.wkb.loads(geom_wkb)
     self.assertTrue(bounding_polygon.contains(wrs_polygon))
예제 #3
0
 def test_json_txt_mtl(self):
     failed_2 = "/imagery/c1/L8/089/078/LC08_L1TP_089078_20180612_20180613_01_RT"
     metadata2 = Metadata(failed_2)
     self.assertIsNotNone(metadata2)
     self.assertEqual(89, metadata2.wrs_path)
     self.assertEqual(78, metadata2.wrs_row)
     date(2018, 6, 12).isoformat()
     self.assertGreaterEqual(date(2018, 6, 12).isoformat(), metadata2.date_acquired)
예제 #4
0
 def test_utm_epsg(self):
     row = (
         'LC80330352017072LGN00', '', 'LANDSAT_8', 'OLI_TIRS', '2017-03-13',
         '2017-03-13T17:38:14.0196140Z', 'PRE', 'N/A', 'L1T', 33, 35, 1.2,
         37.10422, 34.96178, -106.85883, -104.24596, 1067621299,
         'gs://gcp-public-data-landsat/LC08/PRE/033/035/LC80330352017072LGN00'
     )
     metadata = Metadata(row)
     self.assertIsNotNone(metadata)
     self.assertEqual(32613, metadata.utm_epsg_code)
예제 #5
0
 def test_doy(self):
     row = (
         'LC80330352017072LGN00_FAKED', '', 'LANDSAT_8', 'OLI_TIRS',
         '2017-11-04', '2017-11-04T17:38:14.0196140Z', 'PRE', 'N/A', 'L1T',
         33, 35, 1.2, 37.10422, 34.96178, -106.85883, -104.24596,
         1067621299,
         'gs://gcp-public-data-landsat/LC08/PRE/033/035/LC80330352017072LGN00_FAKE'
     )
     metadata = Metadata(row)
     self.assertIsNotNone(metadata)
     self.assertEqual(308, metadata.doy)
예제 #6
0
    def test_peewee_1(self):
        a = LandsatQueryFilters()
        a.scene_id.set_value("LC80270312016188LGN00")
        sql_stuff = a.get_sql()

        client = bigquery.Client()
        query = client.run_sync_query(sql_stuff)
        query.timeout_ms = 1000
        query.run()

        for row in query.rows:
            metadata = Metadata(row)
            self.assertEqual(metadata.scene_id, "LC80270312016188LGN00")
예제 #7
0
 def test_aws_from_image_key(self):
     sqs_message = {
         "Type": "Notification",
         "MessageId": "27f57c3d-9d2e-5fa3-8f83-2e41a3aa5634",
         "TopicArn": "arn:aws:sns:us-west-2:274514004127:NewSceneHTML",
         "Subject": "Amazon S3 Notification",
         "Message": "{\"Records\":[{\"eventVersion\":\"2.0\",\"eventSource\":\"aws:s3\",\"awsRegion\":\"us-west-2\",\"eventTime\":\"2017-11-07T23:05:40.162Z\",\"eventName\":\"ObjectCreated:Put\",\"userIdentity\":{\"principalId\":\"AWS:AIDAILHHXPNIKSGVUGOZK\"},\"requestParameters\":{\"sourceIPAddress\":\"35.193.238.175\"},\"responseElements\":{\"x-amz-request-id\":\"F96A6CC9816FC5EF\",\"x-amz-id-2\":\"yehs3XxTY8utc9kgKfNbMe1wdtV7F0wEMUXUQtIu7zMRtGvboxahzwncrmG046yI327j5IRh8nE=\"},\"s3\":{\"s3SchemaVersion\":\"1.0\",\"configurationId\":\"C1-NewHTML\",\"bucket\":{\"name\":\"landsat-pds\",\"ownerIdentity\":{\"principalId\":\"A3LZTVCZQ87CNW\"},\"arn\":\"arn:aws:s3:::landsat-pds\"},\"object\":{\"key\":\"c1/L8/115/062/LC08_L1TP_115062_20171107_20171107_01_RT/index.html\",\"size\":5391,\"eTag\":\"0f06667fca1f707894bf579bd667e221\",\"sequencer\":\"005A023C441A8F8403\"}}}]}",
         "Timestamp": "2017-11-07T23:05:40.219Z",
         "SignatureVersion": "1",
         "Signature": "bqrW1x6CgJntCz6f0F5uncyPZR+6ZM/tZ3OrRZDiudBv5DAtMyYR9n6KQ0aT+iYP5INfpL2GuIm8Uqco8ZHzg5AqEhHtNkpzGBQpQHvlF3t0ut9K27YNwJ6ZmnS14BgsLWyXIthVRjvHf1Hhx3ZInPMJrzTcKCOhOmBcM9zOpfWrHfnynuifpN3FaldDz6VY2d9QM0Rn8Fo8XZ4F+j01eAJVlydnRbSBbLewleuvhPQh6EG5r2EeekeniOIETrodS7o43ZClFr8OSgRE7BvpecVnnUEXBUIDDtRAPnIxo3Io0AmfPRI8xRfeKNhBIhPq3W3clm7Dxkp3N96OKoVUBw==",
         "SigningCertURL": "https://sns.us-west-2.amazonaws.com/SimpleNotificationService-433026a4050d206028891664da859041.pem",
         "UnsubscribeURL": "https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:274514004127:NewSceneHTML:7997d757-d1c6-4064-8935-34111968c8cc"
     }
     message_json = json.loads(sqs_message['Message'])
     image_key = message_json['Records'][0]['s3']['object']['key']
     path_name = '/imagery/' + os.path.dirname(image_key)
     # basename = os.path.basename(path_name)
     metadata = Metadata(path_name)
     self.assertEqual(115, metadata.wrs_path)
     self.assertEqual(62, metadata.wrs_row)
예제 #8
0
    def test_epsg_codes(self):
        self.assertEqual(32601, Metadata.get_utm_epsg_code(-180, 45))
        self.assertEqual(32701, Metadata.get_utm_epsg_code(-180, -45))
        self.assertEqual(32601, Metadata.get_utm_epsg_code(-174, 45))
        self.assertEqual(32701, Metadata.get_utm_epsg_code(-174, -45))

        self.assertEqual(32602, Metadata.get_utm_epsg_code(-173.99, 45))
        self.assertEqual(32702, Metadata.get_utm_epsg_code(-173.99, -45))
        self.assertEqual(32602, Metadata.get_utm_epsg_code(-168, 45))
        self.assertEqual(32702, Metadata.get_utm_epsg_code(-168, -45))

        self.assertEqual(32603, Metadata.get_utm_epsg_code(-167.99, 45))
        self.assertEqual(32703, Metadata.get_utm_epsg_code(-167.99, -45))
        self.assertEqual(32603, Metadata.get_utm_epsg_code(-162, 45))
        self.assertEqual(32703, Metadata.get_utm_epsg_code(-162, -45))

        self.assertEqual(32660, Metadata.get_utm_epsg_code(180, 45))
        self.assertEqual(32760, Metadata.get_utm_epsg_code(180, -45))
        self.assertEqual(32660, Metadata.get_utm_epsg_code(174.00001, 45))
        self.assertEqual(32760, Metadata.get_utm_epsg_code(174.00001, -45))

        self.assertEqual(32659, Metadata.get_utm_epsg_code(174, 45))
        self.assertEqual(32759, Metadata.get_utm_epsg_code(174, -45))
        self.assertEqual(32659, Metadata.get_utm_epsg_code(168.00001, 45))
        self.assertEqual(32759, Metadata.get_utm_epsg_code(168.00001, -45))