dmit.geotools module

Tools for different geographical procedures often used.

dmit.geotools.bearing(lon1, lat1, lon2, lat2)[source]

Calculate bearing between two points

Parameters
  • lon1 (float) – Longitude of first point in degrees

  • lat1 (float) – Latitude of first point in degrees

  • lon2 (float) – Longitude of second point in degrees

  • lat2 (float) – Latitude of second point in degrees

Returns

bearing – Bearing in radians

Return type

float

dmit.geotools.distance(lon1, lat1, lon2, lat2)[source]

Calculate great-circle distance in kilometers

Parameters
  • lon1 (float) – Longitude of first point in degrees

  • lat1 (float) – Latitude of first point in degrees

  • lon2 (float) – Longitude of second point in degrees

  • lat2 (float) – Latitude of second point in degrees

Returns

d – Great-circle distance in kilometers

Return type

float

dmit.geotools.find_nearest_gridpoint(grid_lat, grid_lon, olat, olon, nx, ny, dx, dy, data)[source]

Find nearest gridpoint in a regular grid

Parameters
  • grid_lat (list) – List of latitudes in regular grid

  • grid_lon (list) – List of longitudes in regular grid

  • olat (float) – Latitude of point of interest

  • olon (float) – Longitude of point of interest

  • nx (integer) – Number of gridpoints in x-direction

  • ny (integer) – Number of gridpoints in y-direction

  • dx (float) – Horisontal resolution in degrees in x-direction

  • dy (float) – Horisontal resolution in degrees in y-direction

  • data (list) – List of data

Returns

datapoint – The nearest value from data

Return type

float

dmit.geotools.lon_lat_to_cartesian(lon, lat, R=1) tuple[source]

Calculates cartesian coordinates of a point on a sphere with radius R

Parameters
  • lon (float) – Longitude

  • lat (float) – Latitude

  • R (float (optional)) – Radius of sphere, defaults to 1.

Returns

  • x (float) – x-coordinate

  • y (float) – y-coordinate

  • z (float) – z-coordinate

dmit.geotools.point_inside_polygon(x, y, poly)[source]

Checks if a point (x,y) is inside a polygon

Parameters
  • x (float) – x-coordinate

  • y (float) – y-coordinate

  • poly (list) – List of tuples with points of the polygon

Returns

inside – True if inside, False if outside

Return type

boolean