obspy.geodetics.base.inside_geobounds

inside_geobounds(obj, minlatitude=None, maxlatitude=None, minlongitude=None, maxlongitude=None, latitude=None, longitude=None, minradius=None, maxradius=None)[source]

Check whether an object is within a given latitude and/or longitude range, or within a given distance range from a reference geographic point.

The object must have latitude and longitude attributes, expressed in degrees.

Parameters
  • obj (object) – An object with latitude and longitude attributes.

  • minlatitude (float) – Minimum latitude in degrees.

  • maxlatitude (float) – Maximum latitude in degrees. If this value is smaller than minlatitude, then 360 degrees are added to this value (i.e., wrapping around latitude of +/- 180 degrees)

  • minlongitude (float) – Minimum longitude in degrees.

  • maxlongitude (float) – Minimum longitude in degrees.

  • latitude (float) – Latitude of the reference point, in degrees, for distance range selection.

  • longitude (float) – Longitude of the reference point, in degrees, for distance range selection.

  • minradius (float) – Minimum distance, in degrees, from the reference geographic point defined by the latitude and longitude parameters.

  • maxradius (float) – Maximum distance, in degrees, from the reference geographic point defined by the latitude and longitude parameters.

Returns

True if the object is within the given range, False otherwise.

Example

>>> from obspy.geodetics import inside_geobounds
>>> from obspy import read_events
>>> ev = read_events()[0]
>>> orig = ev.origins[0]
>>> inside_geobounds(orig, minlatitude=40, maxlatitude=42)
True
>>> inside_geobounds(orig, minlatitude=40, maxlatitude=42,
...                  minlongitude=78, maxlongitude=79)
False
>>> inside_geobounds(orig, latitude=40, longitude=80,
...                  minradius=1, maxradius=10)
True