yannforget / landsatxplore

Search and download Landsat scenes from EarthExplorer.
MIT License
223 stars 98 forks source link

Add “path” and “row” to serach #43

Open zhangte113 opened 3 years ago

zhangte113 commented 3 years ago

Hello, Thanks for the great tool of API. Sometimes I want to select images by Path/Row, so I did a small change to your code.

def search(self, dataset, longitude=None, latitude=None, bbox=None, max_cloud_cover=None, start_date=None, end_date=None, months=None, wrs_path=None, wrs_row=None, max_results=10000,):
    .
    .
    .
    r = self.request(
        "scene-search",
        params={
            "datasetName": dataset,
            "sceneFilter": scene_filter,
            "maxResults": max_results,
            "metadataType": "full",
        },
    )
    # where the change were did
    scenes = [_parse_metadata(scene) for scene in r.get("results")]

    if wrs_path and wrs_row:
        return [scene for scene in scenes if wrs_path == scene['wrs_path'] and wrs_row == scene['wrs_row']]
    else:
        return scenes