utm2dd/utm2dd.py
def column_transform(df, column_name, lat_column, lon_column, new_cols=False, easting_northing=True):
    """Parse a column of UTM coordinate strings from a Pandas Dataframe into Latitude Longitude columns.

    For populating Lat Lon columns in a dataframe or creating those columns from a UTM coordinate column

    Parameters
    ----------
    df : pandas dataframe

    column_name: str
        column name containing UTM coordinate strings
    
    lat_column: str
        name of column to populate with latitude coordinates
    
    lon_column: str
        name of column to populate with longitude coordinates

    new_cols: bool
        Default=False. Set to true to generate new columns for latitude and longitude coordinates rather than populate existing columns.

    easting_northing : bool, optional
        Default=True. Set to False if UTM is formated with mN before mE.

    Returns
    -------
    A pandas dataframe copy of the input dataframe with the transformations

    """
    # Initialize df copy
    df = df.copy()
    #For populating existing Lat Lon columns:
    if new_cols == False:
        for coordinate in df.loc[:,column_name].astype(str):
            if coordinate != 'nan': #In case the column has empty entries
                latlong = string_transform(coordinate, easting_northing=easting_northing)
                df.loc[df[column_name]==coordinate, lat_column] = latlong[0]
                df.loc[df[column_name]==coordinate, lon_column] = latlong[1]
                
    #For generating new La Lon columns:            
    elif new_cols == True:
        #Initialize strings that will become columns
        lat = []
        lon = []

        for coordinate in df.loc[:,column_name].astype(str):
            if coordinate != 'nan':
                latlong = string_transform(coordinate, easting_northing=easting_northing)
                lat.append(latlong[0])
                lon.append(latlong[1])
               
            else:
                lat.append(np.nan)
                lon.append(np.nan)
                
        #Create columns using user input column names
        df[lat_column] = lat
        df[lon_column] = lon
    #Print the count report    
    return df
Parse a column of UTM coordinate strings from a Pandas Dataframe into Latitude Longitude columns.

    For populating Lat Lon columns in a dataframe or creating those columns from a UTM coordinate column

    Parameters
    ----------
    df : pandas dataframe

    column_name: str
        column name containing UTM coordinate strings
    
    lat_column: str
        name of column to populate with latitude coordinates
    
    lon_column: str
        name of column to populate with longitude coordinates

    new_cols: bool
        Default=False. Set to true to generate new columns for latitude and longitude coordinates rather than populate existing columns.

    easting_northing : bool, optional
        Default=True. Set to False if UTM is formated with mN before mE.

    Returns
    -------
    A pandas dataframe copy of the input dataframe with the transformations

    
Parse a column of UTM coordinate strings from a Pandas Dataframe into Latitude Longitude columns.
For populating Lat Lon columns in a dataframe or creating those columns from a UTM coordinate column
Parse a column of UTM coordinate strings from a Pandas Dataframe into Latitude Longitude columns . For populating Lat Lon columns in a dataframe or creating those columns from a UTM coordinate column
def column_transform(df, column_name, lat_column, lon_column, new_cols=False, easting_northing=True):
    df = df.copy()
    if new_cols == False:
        for coordinate in df.loc[:,column_name].astype(str):
            if coordinate != 'nan': 
                latlong = string_transform(coordinate, easting_northing=easting_northing)
                df.loc[df[column_name]==coordinate, lat_column] = latlong[0]
                df.loc[df[column_name]==coordinate, lon_column] = latlong[1]
    elif new_cols == True:
        lat = []
        lon = []
        for coordinate in df.loc[:,column_name].astype(str):
            if coordinate != 'nan':
                latlong = string_transform(coordinate, easting_northing=easting_northing)
                lat.append(latlong[0])
                lon.append(latlong[1])
            else:
                lat.append(np.nan)
                lon.append(np.nan)
        df[lat_column] = lat
        df[lon_column] = lon
    return df
def column_transform ( df , column_name , lat_column , lon_column , new_cols = False , easting_northing = True ) : df = df . copy ( ) if new_cols == False : for coordinate in df . loc [ : , column_name ] . astype ( str ) : if coordinate != 'nan' : latlong = string_transform ( coordinate , easting_northing = easting_northing ) df . loc [ df [ column_name ] == coordinate , lat_column ] = latlong [ 0 ] df . loc [ df [ column_name ] == coordinate , lon_column ] = latlong [ 1 ] elif new_cols == True : lat = [ ] lon = [ ] for coordinate in df . loc [ : , column_name ] . astype ( str ) : if coordinate != 'nan' : latlong = string_transform ( coordinate , easting_northing = easting_northing ) lat . append ( latlong [ 0 ] ) lon . append ( latlong [ 1 ] ) else : lat . append ( np . nan ) lon . append ( np . nan ) df [ lat_column ] = lat df [ lon_column ] = lon return df
Parse a column of UTM coordinate strings from a Pandas Dataframe into Latitude Longitude columns.
Parse a column of UTM coordinate strings from a Pandas Dataframe into Latitude Longitude columns .
"""Parse a column of UTM coordinate strings from a Pandas Dataframe into Latitude Longitude columns.

    For populating Lat Lon columns in a dataframe or creating those columns from a UTM coordinate column

    Parameters
    ----------
    df : pandas dataframe

    column_name: str
        column name containing UTM coordinate strings
    
    lat_column: str
        name of column to populate with latitude coordinates
    
    lon_column: str
        name of column to populate with longitude coordinates

    new_cols: bool
        Default=False. Set to true to generate new columns for latitude and longitude coordinates rather than populate existing columns.

    easting_northing : bool, optional
        Default=True. Set to False if UTM is formated with mN before mE.

    Returns
    -------
    A pandas dataframe copy of the input dataframe with the transformations

    """ # Initialize df copy
 #For populating existing Lat Lon columns:
 #In case the column has empty entries
 #For generating new La Lon columns:            
 #Initialize strings that will become columns
 #Create columns using user input column names
 #Print the count report    

None
A pandas dataframe copy of the input dataframe with the transformations

df
None
column_name
column name containing UTM coordinate strings
column name containing UTM coordinate strings
lat_column
name of column to populate with latitude coordinates
name of column to populate with latitude coordinates
lon_column
name of column to populate with longitude coordinates
name of column to populate with longitude coordinates
new_cols
Default=False. Set to true to generate new columns for latitude and longitude coordinates rather than populate existing columns.
Default = False . Set to true to generate new columns for latitude and longitude coordinates rather than populate existing columns .
easting_northing
Default=True. Set to False if UTM is formated with mN before mE.
Default = True . Set to False if UTM is formated with mN before mE .