watex.utils.coreutils.fill_coordinates#
- watex.utils.coreutils.fill_coordinates(data=None, lon=None, lat=None, east=None, north=None, epsg=None, utm_zone=None, datum='WGS84', verbose=0)[source]#
Assert and recompute coordinates values based on geographical coordinates systems.
Compute the couples (easting, northing) or (longitude, latitude ) and set the new calculated values into a dataframe.
- Parameters
data (dataframe,) – Dataframe contains the lat, lon or east and north. All data don’t need to be provided. If (‘lat’, ‘lon’) and (east, north) are given, (’easting, northing’) should be overwritten.
lat (array-like float or string (DD:MM:SS.ms)) – Values composing the longitude of point
lon (array-like float or string (DD:MM:SS.ms)) – Values composing the longitude of point
east (array-like float) – Values composing the northing coordinate in meters
north (array-like float) – Values composing the northing coordinate in meters
datum (string) – well known datum ex. WGS84, NAD27, etc.
projection (string) – projected point in lat and lon in Datum latlon, as decimal degrees or ‘UTM’.
epsg (int) – epsg number defining projection (see http://spatialreference.org/ref/ for moreinfo). Overrides utm_zone if both are provided
utm_zone (string) – zone number and ‘S’ or ‘N’ e.g. ‘55S’. Defaults to the centre point of the provided points
verbose (int,default=0) – warning user if UTMZONE is not supplied when computing the latitude/longitude from easting/northing
- Returns
- `data` (Dataframe with new coodinates values computed)
- `utm_zone` (zone number and ‘S’ or ‘N’)
Examples
>>> from watex.utils.coreutils import fill_coordinates >>> from watex.utils import read_data >>> data = read_data ('data/erp/l2_gbalo.xlsx') >>> # rename columns 'x' and 'y' to 'easting' and 'northing' inplace >>> data.rename (columns ={"x":'easting', "y":'northing'} , inplace =True ) >>> # transform the data by computing latitude/longitude by specifying the utm zone >>> data_include,_ = fill_coordinates (data , utm_zone ='49N' ) >>> data.head(2) easting northing rho longitude latitude 0 790752 1092750.0 1101 113 9 10 790747 1092758.0 1147 113 9 >>> # doing the revert action >>> datalalon = data_include[['pk', 'longitude', 'latitude']] >>> data_east_north, _ = fill_coordinates (datalalon ) >>> data_east_north.head(2) pk longitude latitude easting northing 0 0 113 9 719870 995452 1 10 113 9 719870 995452