Skip to content

pygeoapi query samples

Joost van Ulden edited this page Mar 25, 2021 · 16 revisions

Test dataset

Sample queries

Note: these samples are written in Elasticsearch query syntax

Comparison

Range

{  
    "query": {    
        "range": {      
            "properties.MHn_Intensity": {        
                "gte": 0.59,        
                "lte": 0.60      
            }   
        }  
    }
}
{  
    "query": {    
        "range": {      
            "properties.MHn_Intensity": {        
                "gte": 0.59    
            }   
        }  
    }
}

Equal

{  
    "query": {    
        "match": {      
            "properties.MHt_Concrete" : 4.0    
        }  
    }
}

Logical (and, or)

AND (WFi > 2000 AND CYt_Bldgs > 200)

{
  "query": {
    "bool" : {
      "must" : {
        "range": {      
            "properties.WFi": { "gt": 2000 }
        }
      },
      "must_not" : {
        "range" : {
          "properties.CYt_Bldgs" : { "lte" : 200 }
        }
      }
    }
  }
}

Spatial

Nearest

{
  "query": {
    "geo_shape": {
      "geometry": {
        "shape": {
          "type": "circle",
          "radius": "20km",
          "coordinates": [ -118, 49 ]
        }
      }
    }
  }
}

Bounding Box

{
  "query": {
    "bool": {
      "must": {
        "match_all": {}
      },
      "filter": {
        "geo_shape": {
          "geometry": {
            "shape": {
              "type": "envelope",
              "coordinates": [ [ -118.7, 50 ], [ -118.4, 49.9 ] ]
            },
            "relation": "intersects"
          }
        }
      }
    }
  }
}