Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Construction of filters for the Planet Data API #150

Open
arunasank opened this issue Sep 9, 2020 · 0 comments
Open

Construction of filters for the Planet Data API #150

arunasank opened this issue Sep 9, 2020 · 0 comments

Comments

@arunasank
Copy link
Contributor

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"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant