watex.utils.funcutils.get_xy_coordinates#
- watex.utils.funcutils.get_xy_coordinates(d, /, as_frame=False, drop_xy=False, raise_exception=True, verbose=0)[source]#
Check whether the coordinate values exists in the data
- Parameters:
d (Dataframe) – Frame that is expected to contain the longitude/latitude or easting/northing coordinates. Note if all types of coordinates are included in the data frame, the longitude/latitude takes the priority.
as_frame (bool, default= False,) – Returns the coordinates values if included in the data as a frame rather than computing the middle points of the line
drop_xy (bool, default=False,) – Drop the coordinates in the data and return the data transformed inplace
raise_exception (bool, default=True) – raise error message if data is not a dataframe. If set to
False, exception is converted to a warning instead. To mute the warning set raise_exception tomuteverbose (int, default=0) – Send message whether coordinates are detected.
- Returns:
xy, d, xynames –
- xytuple of float ( longitude, latitude) or (easting/northing )
if as_frame is set to
True.
d: Dataframe transformed (coordinated removed ) or not xynames: str, the name of coordinates detected.
- Return type:
Tuple
Examples
>>> import watex as wx >>> from watex.utils.funcutils import get_xy_coordinates >>> testdata = wx.make_erp ( n_stations =7, seed =42 ).frame >>> xy, d, xynames = get_xy_coordinates ( testdata, ) >>> xy , xynames ((110.48627946874444, 26.051952363176344), ('longitude', 'latitude')) >>> xy, d, xynames = get_xy_coordinates ( testdata, as_frame =True ) >>> xy.head(2) longitude latitude easting northing 0 110.485833 26.051389 448565.380621 2.881476e+06 1 110.485982 26.051577 448580.339199 2.881497e+06 >>> # remove longitude and lat in data >>> testdata = testdata.drop (columns =['longitude', 'latitude']) >>> xy, d, xynames = get_xy_coordinates ( testdata, as_frame =True ) >>> xy.head(2) easting northing 0 448565.380621 2.881476e+06 1 448580.339199 2.881497e+06 >>> # note testdata should be transformed inplace when drop_xy is set to True >>> xy, d, xynames = get_xy_coordinates ( testdata, drop_xy =True) >>> xy, xynames ((448610.25612032827, 2881538.4380570543), ('easting', 'northing')) >>> d.head(2) station resistivity 0 0.0 1.0 1 20.0 167.5 >>> testdata.head(2) # coordinates are henceforth been dropped station resistivity 0 0.0 1.0 1 20.0 167.5 >>> xy, d, xynames = get_xy_coordinates ( testdata, drop_xy =True) >>> xy, xynames (None, ()) >>> d.head(2) station resistivity 0 0.0 1.0 1 20.0 167.5