Exemplo n.º 1
0
    def setUpClass(cls):
        super().setUpClass()

        bbox = BBox(bbox=[(2947363, 4629723), (3007595, 4669471)],
                    crs=CRS.POP_WEB)
        bbox.transform(CRS.WGS84)
        query_filter1 = 'f12458==32632'
        query_filter2 = 'f12458==32635'

        cls.test_cases = [
            TestCaseContainer('All features',
                              GeopediaFeatureIterator(1749),
                              min_features=100,
                              min_size=1609),
            TestCaseContainer('BBox filter',
                              GeopediaFeatureIterator(1749, bbox=bbox),
                              min_features=21),
            TestCaseContainer('Query Filter',
                              GeopediaFeatureIterator(
                                  1749, query_filter=query_filter1),
                              min_features=76),
            TestCaseContainer('Both filters - No data',
                              GeopediaFeatureIterator(
                                  1749, bbox=bbox, query_filter=query_filter1),
                              min_features=0),
            TestCaseContainer('Both filters - Some data',
                              GeopediaFeatureIterator(
                                  1749, bbox=bbox, query_filter=query_filter2),
                              min_features=21)
        ]
Exemplo n.º 2
0
def utils_args():
    coor = [
        6887893.492833803, 5009377.085697314, 7200979.560689886,
        5322463.153553395
    ]

    # coor = [7200979.560689886, 5009377.085697314,
    #         7514065.628545968, 5322463.153553395]

    coor = [
        7712190.405861145, 5053404.813989572, 7714636.390766275,
        5055850.798894699
    ]

    coor = [
        6887893.492833803, 7200979.560689886, 5009377.085697314,
        5322463.153553395
    ]

    coor = [
        7200979.560689886, 7514065.628545968, 5009377.085697314,
        5322463.153553395
    ]
    bbox = BBox(bbox=coor, crs=CRS.POP_WEB)
    bbox = bbox.transform(crs=CRS.WGS84)
    coor = [45.0, 43.07, 64.69, 55.78]
    # print(coor)
    # coor = [64.4784, 39.6 / 648, 64.8162, 39.9222]
    # coor = [46.2014, -15.9906, 46.6051, -15.5961]
    # print(bbox)
    return bbox
Exemplo n.º 3
0
    def test_transform(self):
        bbox1 = BBox([46.07, 13.23, 46.24, 13.57], CRS.WGS84)
        bbox2 = bbox1.transform(CRS.POP_WEB).transform(CRS.WGS84)

        for coord1, coord2 in zip(bbox1, bbox2):
            self.assertAlmostEqual(coord1, coord2, delta=1e-8)
        self.assertEqual(bbox1.crs, bbox2.crs)
Exemplo n.º 4
0
    def test_bbox_transform(self):
        bbox = BBox(((111.644, 8.655), (111.7, 8.688)), CRS.WGS84)
        new_bbox = bbox.transform(CRS.POP_WEB)
        expected_bbox = BBox((12428153.23, 967155.41, 12434387.12, 970871.43),
                             CRS.POP_WEB)

        for coord, expected_coord in zip(new_bbox, expected_bbox):
            self.assertAlmostEqual(coord,
                                   expected_coord,
                                   delta=1E-2,
                                   msg='Expected coord {}, got {}'.format(
                                       expected_coord, coord))
        self.assertEqual(
            new_bbox.crs, expected_bbox.crs,
            'Expected CRS {}, got {}'.format(expected_bbox.crs, new_bbox.crs))
Exemplo n.º 5
0
def new_coordinates(data, crs, new_crs):
    """ Returns coordinates for xarray DataArray/Dataset in new crs.

    :param data: data for converting coordinates for
    :type data: xarray.DataArray or xarray.Dataset
    :param crs: old crs
    :type crs: sentinelhub.CRS
    :param new_crs: new crs
    :type new_crs: sentinelhub.CRS
    :return: new x and y coordinates
    :rtype: (float, float)
    """
    x_values = data.coords['x'].values
    y_values = data.coords['y'].values
    bbox = BBox((x_values[0], y_values[0], x_values[-1], y_values[-1]), crs=crs)
    bbox = bbox.transform(new_crs)
    xmin, ymin = bbox.lower_left
    xmax, ymax = bbox.upper_right
    new_xs = np.linspace(xmin, xmax, len(x_values))
    new_ys = np.linspace(ymin, ymax, len(y_values))

    return new_xs, new_ys