GIS Utilities#

This module contains tools to help project between coordinate systems. The module will first use GDAL if installed. If GDAL is not installed then pyproj is used. Main functions are:

  • project_point_ll2utm

  • project_point_utm2ll

These can take in a point or an array or list of points to project.

latitude and longitude can be input as:
  • ‘DD:mm:ss.ms’

  • ‘DD.decimal_degrees’

  • float(DD.decimal_degrees)

watex.utils.gistools.assert_elevation_value(elevation)[source]#

make sure elevation is a floating point number

watex.utils.gistools.assert_lat_value(latitude)[source]#

make sure latitude is in decimal degrees

watex.utils.gistools.assert_lon_value(longitude)[source]#

make sure longitude is in decimal degrees

watex.utils.gistools.convert_position_float2str(position)[source]#

convert position float to a string in the format of DD:MM:SS

Parameters:

**position** (float) – decimal degrees of latitude or longitude

Returns:

**position_str** – latitude or longitude in format of DD:MM:SS.ms

Return type:

string

Example

>>> import watex.utils.gis_tools as gis_tools
>>> gis_tools.convert_position_float2str(-118.34563)
watex.utils.gistools.convert_position_str2float(position_str)[source]#

Convert a position string in the format of DD:MM:SS to decimal degrees

Parameters:

**position_str** (string ('DD:MM:SS.ms')) – degrees of latitude or longitude

Returns:

**position** – latitude or longitude in decimal degrees

Return type:

float

Example

>>> import watex.utils.gis_tools as gis_tools
>>> gis_tools.convert_position_str2float('-118:34:56.3')
watex.utils.gistools.epsg_project(x, y, epsg_from, epsg_to)[source]#

project some xy points using the pyproj modules

watex.utils.gistools.get_epsg(latitude, longitude)[source]#

get epsg code for the utm projection (WGS84 datum) of a given latitude and longitude pair

watex.utils.gistools.get_utm_string_from_sr(spatialreference)[source]#

return utm zone string from spatial reference instance

watex.utils.gistools.get_utm_zone(latitude, longitude)[source]#

Get utm zone from a given latitude and longitude

watex.utils.gistools.ll_to_utm(reference_ellipsoid, lat, lon)[source]#

converts lat/long to UTM coords. Equations from USGS Bulletin 1532 East Longitudes are positive, West longitudes are negative. North latitudes are positive, South latitudes are negative Lat and Long are in decimal degrees Written by Chuck Gantz- chuck.gantz@globalstar.com

Outputs:

UTMzone, easting, northing

watex.utils.gistools.project_point_ll2utm(lat, lon, datum='WGS84', utm_zone=None, epsg=None)[source]#

Project a point that is in Lat, Lon (will be converted to decimal degrees) into UTM coordinates.

Parameters:
  • **lat** (float or string (DD:MM:SS.ms)) – latitude of point

  • **lon** (float or string (DD:MM:SS.ms)) – longitude of point

  • **datum** (string) – well known datum ex. WGS84, NAD27, NAD83, etc.

  • **utm_zone** (string) – zone number and ‘S’ or ‘N’ e.g. ‘55S’

  • **epsg** (int) – epsg number defining projection (see http://spatialreference.org/ref/ for moreinfo) Overrides utm_zone if both are provided

Returns:

**proj_point** – projected point in UTM in Datum

Return type:

tuple(easting, northing, zone)

watex.utils.gistools.project_point_utm2ll(easting, northing, utm_zone, datum='WGS84', epsg=None)[source]#

Project a point that is in Lat, Lon (will be converted to decimal degrees) into UTM coordinates.

Parameters:
  • **easting** (float) – easting coordinate in meters

  • **northing** (float) – northing coordinate in meters

  • **utm_zone** (string (##N or ##S)) – utm zone in the form of number and North or South hemisphere, 10S or 03N

  • **datum** (string) – well known datum ex. WGS84, NAD27, etc.

Returns:

**proj_point** – projected point in lat and lon in Datum, as decimal degrees.

Return type:

tuple(lat, lon)

watex.utils.gistools.project_points_ll2utm(lat, lon, datum='WGS84', utm_zone=None, epsg=None)[source]#

Project a list of points that is in Lat, Lon (will be converted to decimal degrees) into UTM coordinates.

Parameters:
  • **lat** (float or string (DD:MM:SS.ms)) – latitude of point

  • **lon** (float or string (DD:MM:SS.ms)) – longitude of point

  • **datum** (string) – well known datum ex. WGS84, NAD27, NAD83, etc.

  • **utm_zone** (string) – zone number and ‘S’ or ‘N’ e.g. ‘55S’. Defaults to the centre point of the provided points

  • **epsg** (int) – epsg number defining projection (see http://spatialreference.org/ref/ for moreinfo) Overrides utm_zone if both are provided

Returns:

**proj_point** – projected point in UTM in Datum

Return type:

tuple(easting, northing, zone)

watex.utils.gistools.utm_to_ll(reference_ellipsoid, northing, easting, zone)[source]#

converts UTM coords to lat/long. Equations from USGS Bulletin 1532 East Longitudes are positive, West longitudes are negative. North latitudes are positive, South latitudes are negative Lat and Long are in decimal degrees. Written by Chuck Gantz- chuck.gantz@globalstar.com Converted to Python by Russ Nelson <nelson@crynwr.com>

Outputs:

Lat,Lon

watex.utils.gistools.utm_wgs84_conv(lat, lon)[source]#

Bidirectional UTM-WGS84 converter Turbo87/utm :param lat: :param lon: :return: tuple(e, n, zone, lett)

watex.utils.gistools.utm_zone_to_epsg(zone_number, is_northern)[source]#

get epsg code (WGS84 datum) for a given utm zone