Ejemplo n.º 1
0
 def bbox_filter(self,
                 west=None,
                 east=None,
                 north=None,
                 south=None,
                 crs=None,
                 left=None,
                 right=None,
                 top=None,
                 bottom=None,
                 srs=None) -> 'ImageCollection':
     """Drops observations from a collection that are located outside
         of a given bounding box.
         :param left: left boundary (longitude / easting)
         :param right: right boundary (longitude / easting)
         :param top: top boundary (latitude / northing)
         :param bottom: top boundary (latitude / northing)
         :param srs: spatial reference system of boundaries as
                     proj4 or EPSG:12345 like string
         :return An ImageCollection instance
     """
     process_id = 'filter_bbox'
     args = {
         'imagery': self.graph,
         'extent': {
             'west': first_not_none(west, left),
             'east': first_not_none(east, right),
             'north': first_not_none(north, top),
             'south': first_not_none(south, bottom),
             'crs': first_not_none(crs, srs),
         }
     }
     return self.graph_add_process(process_id, args)
Ejemplo n.º 2
0
    def bbox_filter(self,
                    west=None,
                    east=None,
                    north=None,
                    south=None,
                    crs=None,
                    left=None,
                    right=None,
                    top=None,
                    bottom=None,
                    srs=None,
                    base=None,
                    height=None) -> 'ImageCollection':
        """
        Specifies a bounding box to filter input image collections.
        DEPRECATED: use :func:`openeo.ImageCollection.filter_bbox`

        :param left:
        :param right:
        :param top:
        :param bottom:
        :param srs:
        :return: An image collection cropped to the specified bounding box.
        """
        return self.filter_bbox(west=first_not_none(west, left),
                                east=first_not_none(east, right),
                                north=first_not_none(north, top),
                                south=first_not_none(south, bottom),
                                base=base,
                                height=height,
                                crs=first_not_none(crs, srs))
    def bbox_filter(self, west=None, east=None, north=None, south=None, crs=None,left=None, right=None, top=None, bottom=None, srs=None) -> 'ImageCollection':
        """Drops observations from a collection that are located outside
            of a given bounding box.

            :param east: east boundary (longitude / easting)
            :param west: west boundary (longitude / easting)
            :param north: north boundary (latitude / northing)
            :param south: south boundary (latitude / northing)
            :param srs: coordinate reference system of boundaries as
                        proj4 or EPSG:12345 like string
            :return: An ImageCollection instance
        """

        process_id = 'filter_bbox'
        args = {
                'data': {'from_node': self.node_id},
                'extent': {
                    'west': first_not_none(west, left),
                    'east': first_not_none(east, right),
                    'north': first_not_none(north, top),
                    'south': first_not_none(south, bottom),
                    'crs': first_not_none(crs, srs)
                }
            }
        return self.graph_add_process(process_id, args)
Ejemplo n.º 4
0
def test_first_not_none_failures():
    with pytest.raises(ValueError):
        first_not_none()
    with pytest.raises(ValueError):
        first_not_none(None)
    with pytest.raises(ValueError):
        first_not_none(None, None)
Ejemplo n.º 5
0
def test_first_not_none(input, expected):
    assert expected == first_not_none(*input)