yannforget / landsatxplore

Search and download Landsat scenes from EarthExplorer.
MIT License
217 stars 95 forks source link

error correction #71

Open zerolvpengfei opened 2 years ago

zerolvpengfei commented 2 years ago

def _parse_metadata(response, parse_browse_field=False): """Parse the full response returned by the API when requesting metadata.""" metadata = {} for key, value in response.items(): name = _camel_to_snake(key) if key == "browse": if parse_browse_field: metadata[name] = _parse_browse_metadata(value) else: continue elif key == "spatialCoverage": metadata[name] = shape(value) elif key == "spatialBounds":

        metadata[name] = shape(value)
    elif key == "temporalCoverage":
        start, end = value["endDate"], value["startDate"]
        metadata[name] = [_to_date(start), _to_date(end)]
    elif key == "metadata":
        metadata.update(_parse_metadata_field(value))
    else:
        # Do not parse numeric IDs. Keep them as strings.
        if name.endswith("_id"):
            metadata[name] = str(value).strip()
        else:
            metadata[name] = _parse_value(value)
if "acquisition_date" not in metadata:
    metadata["acquisition_date"] = metadata["temporal_coverage"][0]
return metadata