Python script to convert latitude / longitude to mesh code

A Python script that converts latitude and longitude in decimal notation to mesh code. (Sometimes I try to contribute to the community ...)

Coordinate2MeshCode.py


def Coordinate2MeshCode( dLat, dLng ):
    # cf: http://white-bear.info/archives/1400
    # Make sure the input values are decimal 
    iMeshCode_1stMesh_Part_p = dLat *60 // 40;
    iMeshCode_1stMesh_Part_u = ( dLng - 100 ) // 1;
    iMeshCode_2ndMesh_Part_q = dLat *60 % 40 // 5;
    iMeshCode_2ndMesh_Part_v = ( ( dLng - 100 ) % 1 ) * 60 // 7.5;
    iMeshCode_3rdMesh_Part_r = dLat *60 % 40 % 5 * 60 // 30;
    iMeshCode_3rdMesh_Part_w = ( ( dLng - 100 ) % 1 ) * 60 % 7.5 * 60 // 45;
    iMeshCode = iMeshCode_1stMesh_Part_p * 1000000 + iMeshCode_1stMesh_Part_u * 10000 + iMeshCode_2ndMesh_Part_q * 1000 + iMeshCode_2ndMesh_Part_v * 100 + iMeshCode_3rdMesh_Part_r * 10 + iMeshCode_3rdMesh_Part_w;
    return iMeshCode;

It also served as an upload test from Kobito.

Change log

Jan7,2017: Fixed a fatal issue for the time being (Thanks to @shiracamus for pointing this out)

  1. Mistake in operation order
  2. Embarrassing English mistake I think it's better to learn how to write beautiful code as a programmer, rather than Python. .. .. Check the calculation result and then correct it.

Recommended Posts

Python script to convert latitude / longitude to mesh code
Python code to convert region mesh code to latitude / longitude
Convert cubic mesh code to WKT in Python
Convert python 3.x code to python 2.x
Rewrite Python2 code to Python3 (2to3)
Convert STL to Voxel mesh using Python VTK
Convert latitude, longitude, GPS altitude to 3D Cartesian coordinates
Convert numpy int64 to python int
[Python] Convert list to Pandas [Pandas]
Convert Scratch project to Python
[Python] Convert Shift_JIS to UTF-8
Convert markdown to PDF in Python
Workflow to convert formula (image) to python
Convert list to DataFrame with python
[python] Copy script to generate copy log
Python> list> Convert double list to single list
[Python] Convert natural numbers to ordinal numbers
Convert decimal numbers to n-ary numbers [python]
Python> tuple> Convert double tuple to single tuple
Articles to read when Blender Python script code doesn't work in 2.80
[Good By Excel] python script to generate sql to convert csv to table
[Python] How to convert db file to csv
I wrote a code to convert quaternions to z-y-x Euler angles in Python
Convert memo at once with Python 2to3
Convert Python> two value sequence to dictionary
[Python] How to convert a 2D list to a 1D list
How to convert Python to an exe file
[Python] Convert csv file delimiters to tab delimiters
Pin current directory to script directory in Python
Try converting latitude / longitude and world coordinates to each other with python
Convert psd file to png in Python
Sample script to trap signals in Python
Convert Excel data to JSON with python
Convert Hiragana to Romaji with Python (Beta)
Convert from katakana to vowel kana [python]
Convert FX 1-minute data to 5-minute data with Python
python> Convert tuple to list> aList = list (pi_tuple)
I made a script in python to convert .md files to Scrapbox format
Convert Python date types to RFC822 format
Convert HEIC files to PNG files with Python
Convert Chinese numerals to Arabic numerals with Python
Convert from Markdown to HTML in Python
Convert absolute URLs to relative URLs in Python
How to run a Maya Python script
Sample to convert image to Wavelet with Python
Convert the cURL API to a Python script (using IBM Cloud object storage)
Convert PDF to image (JPEG / PNG) with Python
Convert "number" of excel date to python datetime
Convert PDFs to images in bulk with Python
[Python] Convert from DICOM to PNG or CSV
Python beginners tried to code some energy drinks
Latitude / longitude coordinates ↔ UTM coordinate conversion with python
Convert svg file to png / ico with Python
Personal notes to doc Python code in Sphinx
[Automation] Convert Python code into an exe file
Convert Windows epoch values to date with python
How to convert SVG to PDF and PNG [Python]
[Improved version] Script to monitor CPU with Python
Write a script to convert a MySQL dump to TSV
List of Python code to move and remember
Convert the character code of the file with Python3