Skip to content

pygeoapi query samples

Joost van Ulden edited this page Mar 31, 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 < 1.0 AND ername = 'Kootenay'

{
  "query": {
    "bool" : {
      "must_not" : {
        "range": {      
            "properties.WFi": { "gt": 1.0 }
        }
      },
      "must" : {
        "match" : {
          "properties.ername" : "Kootenay"
        }
      }
    }
  }
}

OR

Identify all the places where at least considerable building damage could occur, considering earthquake, flood, fire or cyclone.

Eqt_PGAt > 0.18 OR FLt_500 > 1.0 OR WFi > 2000 OR CYi_500 > 154

{
  "query": {
    "query_string": {
      "query": "(properties.Eqt_PGAt > 0.18) OR (properties.FLt_500 > 1.0) OR (properties.WFi > 2000) OR (properties.CYi_500 > 154)"
    }
  }
}

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"
          }
        }
      }
    }
  }
}