dragonfly.projection module

Utilities for converting X,Y coordinates in meters to longitude, latitude.

dragonfly.projection.lon_lat_to_polygon(polygon_lon_lat_coords, origin_lon_lat=(0, 0), conversion_factors=None)[source]

Convert an array of (longitude, latitude) coordinates to (X, Y) coordinates in meters.

The resulting coordinates will obey the WSG84 assumptions for the radius of the earth at the equator relative to the poles. Note that this function uses a simple formula and some distortion is possible when translating polygons several kilometers long.

Parameters:
  • polygon_lon_lat_coords – A nested array with each sub-array having 2 values for the (longitude, latitude) of a polygon boundary.

  • origin_lon_lat – An array of two numbers in degrees. The first value represents the longitude of the scene origin in degrees (between -180 and +180). The second value represents latitude of the scene origin in degrees (between -90 and +90). Note that the “scene origin” is the (0, 0) coordinate in the 2D space of the input polygon. Default: (0, 0).

  • conversion_factors – A tuple with two values used to translate between longitude, latitude and meters. If None, these values will be automatically calculated from the origin_lon_lat using the inverse of the factors computed from the meters_to_long_lat_factors method.

Returns:

An array of (X, Y) values for the boundary coordinates in meters.

dragonfly.projection.meters_to_long_lat_factors(origin_lon_lat=(0, 0))[source]

Get conversion factors for translating meters to longitude, latitude.

The resulting factors should obey the WSG84 assumptions for the radius of the earth at the equator relative to the poles.

Parameters:

origin_long_lat – An array of two numbers in degrees. The first value represents the longitude of the scene origin in degrees (between -180 and +180). The second value represents latitude of the scene origin in degrees (between -90 and +90). Default: (0, 0).

Returns:

meters_to_lon – conversion factor for changing meters to degrees longitude.

meters_to_lat – conversion factor for changing meters to degrees latitude.

Return type:

A tuple with two values

dragonfly.projection.origin_long_lat_from_location(location, point)[source]

Get the (longitude, latitude) of the scene origin from a location and a point.

Parameters:
  • location – A ladybug Location object possessing longitude and latitude data.

  • point – A ladybug_geometry Point2D for where the location object exists within the space of a scene. The coordinates of this point are expected to be in meters.

Returns:

An array of two numbers in degrees. The first value represents the longitude of the scene origin in degrees (between -180 and +180). The second value represents latitude of the scene origin in degrees (between -90 and +90).

dragonfly.projection.polygon_to_lon_lat(polygon, origin_lon_lat=(0, 0), conversion_factors=None)[source]

Get an array of (longitude, latitude) from a ladybug_geometry Polygon2D in meters.

The resulting coordinates should obey the WSG84 assumptions for the radius of the earth at the equator relative to the poles. Note that this function uses a simple formula and some distortion is possible when translating polygons several kilometers long.

Parameters:
  • polygon – An array of (X, Y) values for coordinates in meters.

  • origin_lon_lat – An array of two numbers in degrees. The first value represents the longitude of the scene origin in degrees (between -180 and +180). The second value represents latitude of the scene origin in degrees (between -90 and +90). Note that the “scene origin” is the (0, 0) coordinate in the 2D space of the input polygon. Default: (0, 0).

  • conversion_factors – A tuple with two values used to translate between meters and longitude, latitude. If None, these values will be automatically calculated from the origin_lon_lat using the meters_to_long_lat_factors method.

Returns:

A nested array with each sub-array having 2 values for the (longitude, latitude) of each polygon vertex.