Skip to content

Instantly share code, notes, and snippets.

@hansonkim
Created November 21, 2022 16:01
Show Gist options
  • Save hansonkim/7a35fde69982695854d07689fb81f428 to your computer and use it in GitHub Desktop.
Save hansonkim/7a35fde69982695854d07689fb81f428 to your computer and use it in GitHub Desktop.
WGS84 좌표계 카텍 좌표계 변환.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyPUWGc96iTuXsjncO4jX+OL",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/hansonkim/7a35fde69982695854d07689fb81f428/wgs84.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"WGS84 -> 카텍 좌표게 변환\n",
"\n",
"카텍 좌표계 변환 계수 참조 문헌\n",
"- OSgeo 토론 그룹 논의를 참조함(https://groups.google.com/g/osgeo-kr/c/0oMKjzyLPW4)\n",
"- https://www.osgeo.kr/17\n"
],
"metadata": {
"id": "d5wQPHL81L-L"
}
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "De0Xe_9YipTb",
"outputId": "04d32a21-0443-47bf-bc78-bc9fe9e93825"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
"Collecting pyproj\n",
" Downloading pyproj-3.2.1-cp37-cp37m-manylinux2010_x86_64.whl (6.3 MB)\n",
"\u001b[K |████████████████████████████████| 6.3 MB 4.8 MB/s \n",
"\u001b[?25hRequirement already satisfied: certifi in /usr/local/lib/python3.7/dist-packages (from pyproj) (2022.9.24)\n",
"Installing collected packages: pyproj\n",
"Successfully installed pyproj-3.2.1\n"
]
}
],
"source": [
"pip install pyproj"
]
},
{
"cell_type": "code",
"source": [
"from pyproj import CRS, Transformer\n",
"\n",
"WGS84 = {'proj': 'longlat', 'datum': 'WGS84', 'ellps': 'WGS84', 'no_defs': True}\n",
"\n",
"# katech\n",
"TM128 = {'proj': 'tmerc', 'lat_0': '38', 'lon_0': '128', 'ellps': 'bessel',\n",
" 'x_0': '400000', 'y_0': '600000', 'k': '0.9999',\n",
" 'units': 'm', 'no_defs': True,\n",
" 'towgs84': '-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43'}\n",
"\n",
"CRS_WGS84 = CRS(**WGS84)\n",
"CRS_TM128 = CRS(**TM128)\n",
"\n",
"def wgs84_to_tm128(lng, lat):\n",
" transformer = Transformer.from_crs(CRS_WGS84, CRS_TM128).transform(lng, lat)\n",
" return transformer"
],
"metadata": {
"id": "-C0k6hqHiwnl"
},
"execution_count": 17,
"outputs": []
},
{
"cell_type": "code",
"source": [
"lng = 123.833463561418 \n",
"lat = 37.4156067393756\n",
"katec_lng, katec_lat = wgs84_to_tm128(lng, lat)\n",
"print(f\"{round(katec_lng)}, {round(katec_lat)}\")"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "RkKfhNjVjA5Q",
"outputId": "446a8139-d90b-4057-bec3-cce5083560e4"
},
"execution_count": 20,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"31300, 542990\n"
]
}
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "oKhs7tOP3sx-"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment