Skip to content

Construction of filters for the Planet Data API #150

Open
@arunasank

Description

@arunasank

Hi, thanks again for these resources.

I wanted to report another issue about the construction of filters for the data API. This is related to #149.

As I was debugging that issue, I tried to simplify the filter to practice filter construction. The reconstructed filter is much simpler than the original one, since it simply ANDs all the filter conditions. However the simplified filter does not work. Again the issue seems to be in combining the cloud_cover and the visiblity_percent -- there seems to be only one way of combining them, and deviating from that method causes the filter to not work as expected. I have tested it with both the Planet Data API and the Planet CLI and can confirm that I see the issue in both places.

Filter recommended by Planet Explorer

Explorer GeoJSON
{
  "filter": {
    "type": "AndFilter",
    "config": [{
      "type": "GeometryFilter",
      "field_name": "geometry",
      "config": {
        "type": "Polygon",
        "coordinates": [
          [
            [-126.4743, 71.7742],
            [-126.4743, 72.044],
            [-125.6473, 72.044],
            [-125.6473, 71.7742],
            [-126.4743, 71.7742]
          ]
        ]
      }
    }, {
      "type": "OrFilter",
      "config": [{
        "type": "AndFilter",
        "config": [{
          "type": "StringInFilter",
          "field_name": "item_type",
          "config": ["Sentinel2L1C"]
        }, {
          "type": "OrFilter",
          "config": [{
            "type": "RangeFilter",
            "field_name": "visible_percent",
            "config": {
              "gte": 100,
              "lte": 100
            }
          }, {
            "type": "AndFilter",
            "config": [{
              "type": "NotFilter",
              "config": {
                "type": "RangeFilter",
                "field_name": "visible_percent",
                "config": {
                  "gte": 0,
                  "lte": 100
                }
              }
            }, {
              "type": "RangeFilter",
              "field_name": "cloud_cover",
              "config": {
                "gte": 0,
                "lte": 0
              }
            }]
          }]
        }]
      }]
    }, {
      "type": "OrFilter",
      "config": [{
        "type": "DateRangeFilter",
        "field_name": "acquired",
        "config": {
          "gte": "2020-06-01T16:00:00.000Z",
          "lte": "2020-08-31T23:59:59.999Z"
        }
      }]
    }, {
      "type": "PermissionFilter",
      "config": ["assets:download"]
    }]
  },
  "item_types": ["Sentinel2L1C"]
}

Simplified filter as constructed by me

Simplified GeoJSON
{
	"filter": {
		"type": "AndFilter",
		"config": [{
				"type": "GeometryFilter",
				"field_name": "geometry",
				"config": {
					"type": "Polygon",
					"coordinates": [
						[
							[-126.4743, 71.7742],
							[-126.4743, 72.044],
							[-125.6473, 72.044],
							[-125.6473, 71.7742],
							[-126.4743, 71.7742]
						]
					]
				}
			},
			{
				"type": "StringInFilter",
				"field_name": "item_type",
				"config": ["Sentinel2L1C"]
			},
			{
				"type": "RangeFilter",
				"field_name": "visible_percent",
				"config": {
					"gte": 100,
					"lte": 100
				}
			},
			{
				"type": "RangeFilter",
				"field_name": "cloud_cover",
				"config": {
					"gte": 0,
					"lte": 0
				}
			},
			{
				"type": "DateRangeFilter",
				"field_name": "acquired",
				"config": {
					"gte": "2020-06-01T16:00:00.000Z",
					"lte": "2020-08-31T23:59:59.999Z"
				}
			},
			{
				"type": "PermissionFilter",
				"config": ["assets:download"]
			}
		]
	},
	"item_types": ["Sentinel2L1C"]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions