bevingtona / planetR

(early development) R tools to search, activate and download satellite imagery from the Planet API.
Apache License 2.0
45 stars 14 forks source link

Error in API request #20

Closed yiluansong closed 1 year ago

yiluansong commented 1 year ago

https://github.com/bevingtona/planetR/blob/a135a7947625a18453bcad3bf4de78ab807f2415/R/planet_search.R#L93-L117

I noticed that the API request for ground control and quality category in the planet_search function is wrongly written. With the "NotFilter", I suspect we are requesting for the opposite category, leading to significantly fewer and low-quality results. I suggest the following changes.

# filter by ground control, quality
  gq_filter <- list(
    type= jsonlite::unbox("AndFilter"),
    config = list(
      list(
        field_name= jsonlite::unbox("ground_control"),
        type= jsonlite::unbox("StringInFilter"),
        config = list(jsonlite::unbox(tolower(ground_control)))
      ),
      list(
        field_name= jsonlite::unbox("quality_category"),
        type= jsonlite::unbox("StringInFilter"),
        config = list(jsonlite::unbox(quality))
      ))
  )

  # combine filters
  filter_configs <- list(
    type= jsonlite::unbox("AndFilter"),
    config = list(date_range_filter, cloud_cover_filter, gq_filter, geometry_filter) #, coverage_filter
  )
bevingtona commented 1 year ago

Good catch! I added the changes. Cheers