Skip to content

Instantly share code, notes, and snippets.

@kse0202
Created June 28, 2021 07:26
Show Gist options
  • Select an option

  • Save kse0202/57983ef5381eafdf4649ab803d9b58dc to your computer and use it in GitHub Desktop.

Select an option

Save kse0202/57983ef5381eafdf4649ab803d9b58dc to your computer and use it in GitHub Desktop.
hddd 형식으로 표현된 좌표를 wgs84 형식으로 변환하는 함수 정의

hddd_to_wgs84(table,x,y) 함수 정의 -> 이걸 이용해서 변환한다

hddd.ddddd“ 는 도 단위를 더욱 세분화 하기 위해 도 단위의 소수 자리까지 표현한 형태

# table = 좌표를 계산해야 할 테이블 명
# x, y  = table안의 x, y 컬럼 명, 'x','y'로 넣어준다

def hddd_to_wgs84(table,x,y):
    table['x_1'] = table[x].apply(lambda x : int(str(x)[:3]))

    table['x_2'] = table[x].apply(lambda x : float("%0.3f" % float(str(x)[3:])))

    table['y_1'] = table[y].apply(lambda x : int(str(x)[:2]))

    table['y_2'] = table[y].apply(lambda x : float("%0.3f" % float(str(x)[2:])))

    for i in  range(table.shape[0]):
        table.iloc[i,table.columns.get_loc('x')] = table.iloc[i,table.columns.get_loc('x_1')] +table.iloc[i,table.columns.get_loc('x_2')]/60
        table.iloc[i,table.columns.get_loc('y')] = table.iloc[i,table.columns.get_loc('y_1')]+table.iloc[i,table.columns.get_loc('y_2')]/60

    table.drop(['x_1','x_2','y_1','y_2'],axis=1, inplace=True)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment