shakemap.utils.layers

shakemap.utils.layers.validate_config(mydict, install_path, data_path, global_data_path)[source]

Recursively validate select.conf.

Parameters:
  • mydict (dict) – Full or partial config dictionary.

  • install_path (str) –

shakemap.utils.layers.nearest_edge(elon, elat, poly)[source]

Return the distance from a point to the nearest edge of a polygon.

Parameters:
  • elon (float) – The longitude of the reference point.

  • elat (float) – The latitude of the reference point.

  • poly (Polygon) – An instance of a shapely Polygon.

Returns:

The distance (in km) from the reference point to the nearest edge (or vertex) of the polygon.

Return type:

float

shakemap.utils.layers.dist_to_layer(elon, elat, geom)[source]

Return the distance from a point to the polygon(s) in a layer; zero if the point is inside the polygon. If the nearest edge of the polygon is greater than 5000 km from the point, the point cannot be inside the polygon and the distance reported will be the distance to the nearest edge. So don’t make polygons too big.

Parameters:
  • elon (float) – The longitude of the reference point.

  • elat (float) – The latitude of the reference point.

  • geom (Polygon or MultiPolygon) – An instance of a shapely Polygon or MultiPolygon.

Returns:

The distance (in km) from the reference point to the nearest polygon in the layer. The distance will be zero if the point lies inside the polygon.

Return type:

float

shakemap.utils.layers.get_layer_distances(elon, elat, layer_dir)[source]

Return the distances from a point to the nearest polygon in each layer file found in ‘layer_dir’. The distance will be zero if the point is inside a polygon. If the nearest edge of a polygon is greater than 5000 km from the point, the point cannot be inside the polygon and the distance reported will be the distance to the nearest edge. So don’t make polygons too big.

The layer files should be written in Well-Known Text (with .wkt extensions), and should contain either a single POLYGON or MULTIPOLYGON object. The layer name will be the file’s basename.

Parameters:
  • elon (float) – The longitude of the reference point.

  • elat (float) – The latitude of the reference point.

  • layer_dir (str) – The path to the directory containg the layer files.

Returns:

A dictionary where the keys are the layer names, and the values are the distance (in km) from the reference point to the nearest polygon in the layer. The distance will be zero if the point lies inside the polygon.

Return type:

dict

shakemap.utils.layers.update_config_regions(lat, lon, config)[source]