Example #1
0
 def test_bbox_to_resolution(self):
     bbox = BBox(((111.644, 8.655), (111.7, 8.688)), CRS.WGS84)
     resx, resy = geo_utils.bbox_to_resolution(bbox, 512, 512)
     expected_resx = 12.02
     expected_resy = 7.15
     self.assertAlmostEqual(resx, expected_resx, delta=1E-2,
                            msg='Expected resx {}, got {}'.format(str(expected_resx), str(resx)))
     self.assertAlmostEqual(resy, expected_resy, delta=1E-2,
                            msg='Expected resy {}, got {}'.format(str(expected_resy), str(resy)))
    """

    # this is a personal code number. You need to add your own to work
    INSTANCE_ID = '7748e676-f55c-4843-900b-1d3e2962a7f1'

    # define study area.
    # coordinate system is (longitude and latitude coordinates of upper left and lower right corners)
    cauquenes_coords_wgs84 = [-72.802, -35.653, -72.030, -36.320]
    cauquenes_bbox = BBox(bbox=cauquenes_coords_wgs84, crs=CRS.WGS84)

    # check for pixels sizes to download the images
    """
    20m: width=3570, height=3600
    """
    geo_utils.bbox_to_resolution(cauquenes_bbox, 1570, 1600)

    ########################################################
    ### Sentinel-2

    # check for the last available S-2 image with less than 30% cloud cover
    # only in RGB color for visualization
    wms_true_color_request = WmsRequest(layer='TRUE-COLOR-S2-L1C',
                                        bbox=cauquenes_bbox,
                                        time=('2017-12-01', '2017-12-31'),
                                        maxcc=0.2,
                                        width=3570, height=3600,
                                        instance_id=INSTANCE_ID)
    # get all images to python session
    wms_true_color_img = wms_true_color_request.get_data()
    """

    # this is a personal code number. You need to add your own to work
    INSTANCE_ID = '7748e676-f55c-4843-900b-1d3e2962a7f1'

    # define study area.
    # coordinate system is (longitude and latitude coordinates of upper left and lower right corners)
    cauquenes_coords_wgs84 = [-72.802, -35.653, -72.030, -36.320]
    cauquenes_bbox = BBox(bbox=cauquenes_coords_wgs84, crs=CRS.WGS84)

    # check for pixels sizes to download the images
    """
    20m: width=3570, height=3600
    """
    geo_utils.bbox_to_resolution(cauquenes_bbox, 1570, 1600)

    ########################################################
    ### Sentinel-2

    # check for the last available S-2 image with less than 30% cloud cover
    # only in RGB color for visualization
    wms_true_color_request = WmsRequest(layer='TRUE-COLOR-S2-L1C',
                                        bbox=cauquenes_bbox,
                                        time=('2017-12-01', '2017-12-31'),
                                        maxcc=0.2,
                                        width=3570, height=3600,
                                        instance_id=INSTANCE_ID)
    # get all images to python session
    wms_true_color_img = wms_true_color_request.get_data()