Latlon to DGGS
Latitude/Longitude to DGGS Conversion Module
This module provides functions to convert latitude and longitude coordinates to various Discrete Global Grid System (DGGS) cell identifiers. It supports multiple DGGS types including H3, S2, A5, RHEALPix, ISEA4T, ISEA3H, DGGRID, DGGAL, EASE, QTM, OLC, Geohash, GEOREF, MGRS, Tilecode, Quadkey, Maidenhead, GARS, and DIGIPIN.
Each DGGS type has its own resolution range and addressing scheme. The module includes both programmatic functions and command-line interfaces (CLI) for each conversion type.
Each function follows the pattern: latlon2
CLI Usage Examples
latlon2h3 10.775275567242561 106.70679737574993 13 latlon2s2 10.775275567242561 106.70679737574993 21 latlon2dggrid ISEA7H 10.775275567242561 106.70679737574993 13 latlon2dggal gnosis 10.775275567242561 106.70679737574993 8 latlon2digipin 28.6139 77.2090 10
latlon2a5(lat, lon, res)
¶
Convert latitude and longitude to A5 cell identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
A5 resolution level [0-29] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
A5 cell identifier in hexadecimal format |
Example
latlon2a5(10.775275567242561, 106.70679737574993, 15) 'a5c8b9a8b9a8b9a8'
Source code in vgrid/conversion/latlon2dggs.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
latlon2a5_cli()
¶
Command-line interface for latlon2a5.
Source code in vgrid/conversion/latlon2dggs.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
latlon2dggal(dggs_type, lat, lon, res)
¶
Convert latitude and longitude to DGGAL zone identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dggs_type
|
str
|
DGGAL DGGS type (e.g., 'gnosis', 'dggrid') |
required |
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
Resolution level. Defaults to type-specific default. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
DGGAL zone identifier |
Example
latlon2dggal('gnosis', 10.775275567242561, 106.70679737574993, 8) '123456789012345'
Source code in vgrid/conversion/latlon2dggs.py
1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 | |
latlon2dggal_cli()
¶
Command-line interface for latlon2dggal.
Usage: latlon2dggal
Source code in vgrid/conversion/latlon2dggs.py
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 | |
latlon2dggrid(dggrid_instance, dggs_type, lat, lon, res, output_address_type='SEQNUM')
¶
Convert latitude and longitude to DGGRID cell identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dggrid_instance
|
DGGRID instance for processing |
required | |
dggs_type
|
str
|
DGGRID DGGS type (e.g., 'ISEA7H', 'ISEA4T') |
required |
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
Resolution level. Defaults to type-specific default. |
required |
output_address_type
|
str
|
Output address format ('SEQNUM', 'INTERLEAVE', etc.) |
'SEQNUM'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
DGGRID cell identifier in specified format |
Example
dggrid_instance = create_dggrid_instance() latlon2dggrid(dggrid_instance, 'ISEA7H', 10.775275567242561, 106.70679737574993, 13) '123456789012345'
Source code in vgrid/conversion/latlon2dggs.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
latlon2dggrid_cli()
¶
Command-line interface for latlon2dggrid.
Source code in vgrid/conversion/latlon2dggs.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
latlon2digipin(lat, lon, res=None)
¶
Convert latitude and longitude to DIGIPIN code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees (must be between 2.5 and 38.5) |
required |
lon
|
float
|
Longitude in decimal degrees (must be between 63.5 and 99.5) |
required |
res
|
int
|
DIGIPIN resolution [1-15] (number of characters in the code) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
DIGIPIN identifier with dashes (e.g., 'F3K-492-6P96') |
Example
latlon2digipin(28.6139, 77.2090, 10) 'F3K-492-6P96'
Note
DIGIPIN is a geocoding system for India. Coordinates outside the bounds (lat: 2.5-38.5, lon: 63.5-99.5) will return 'Out of Bound'.
Source code in vgrid/conversion/latlon2dggs.py
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 | |
latlon2digipin_cli()
¶
Command-line interface for latlon2digipin.
Source code in vgrid/conversion/latlon2dggs.py
1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 | |
latlon2ease(lat, lon, res)
¶
Convert latitude and longitude to EASE-DGGS cell identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
EASE resolution level [0-6] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
EASE-DGGS cell identifier |
Example
latlon2ease(10.775275567242561, 106.70679737574993, 3) '0123456789abcdef'
Source code in vgrid/conversion/latlon2dggs.py
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 | |
latlon2ease_cli()
¶
Command-line interface for latlon2isea3h.
Source code in vgrid/conversion/latlon2dggs.py
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | |
latlon2gars(lat, lon, res)
¶
Convert latitude and longitude to GARS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
GARS resolution [1-4] (1=30min, 2=15min, 3=5min, 4=1min) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
GARS identifier |
Example
latlon2gars(10.775275567242561, 106.70679737574993, 2) '123456789012345'
Source code in vgrid/conversion/latlon2dggs.py
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 | |
latlon2gars_cli()
¶
Command-line interface for latlon2gars.
Source code in vgrid/conversion/latlon2dggs.py
1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 | |
latlon2geohash(lat, lon, res)
¶
Convert latitude and longitude to Geohash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
Geohash precision [1-10] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
Geohash string |
Example
latlon2geohash(10.775275567242561, 106.70679737574993, 6) 'w8k3x2'
Source code in vgrid/conversion/latlon2dggs.py
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 | |
latlon2geohash_cli()
¶
Command-line interface for latlon2geohash.
Source code in vgrid/conversion/latlon2dggs.py
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | |
latlon2georef(lat, lon, res)
¶
Convert latitude and longitude to GEOREF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
GEOREF resolution [0-10] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
GEOREF code |
Example
latlon2georef(10.775275567242561, 106.70679737574993, 5) 'MK1234567890'
Source code in vgrid/conversion/latlon2dggs.py
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 | |
latlon2georef_cli()
¶
Command-line interface for latlon2georef.
Source code in vgrid/conversion/latlon2dggs.py
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | |
latlon2h3(lat, lon, res)
¶
Convert latitude and longitude to H3 cell identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
H3 resolution level [0-15] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
H3 cell identifier |
Example
latlon2h3(10.775275567242561, 106.70679737574993, 13) '8b194e64992ffff'
Source code in vgrid/conversion/latlon2dggs.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
latlon2h3_cli()
¶
Command-line interface for latlon2h3.
Source code in vgrid/conversion/latlon2dggs.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
latlon2isea3h(lat, lon, res)
¶
Convert latitude and longitude to ISEA3H cell identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
ISEA3H resolution level [0-40] (Windows only) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
ISEA3H cell identifier |
Example
latlon2isea3h(10.775275567242561, 106.70679737574993, 27) '0123456789abcdef012345678'
Note
This function is only available on Windows systems. Resolution 27 is suitable for geocoding applications.
Source code in vgrid/conversion/latlon2dggs.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | |
latlon2isea3h_cli()
¶
Command-line interface for latlon2isea3h.
Source code in vgrid/conversion/latlon2dggs.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 | |
latlon2isea4t(lat, lon, res)
¶
Convert latitude and longitude to ISEA4T cell identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
ISEA4T resolution level [0-39] (Windows only) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
ISEA4T cell identifier |
Example
latlon2isea4t(10.775275567242561, 106.70679737574993, 20) '0123456789abcdef012345'
Note
This function is only available on Windows systems.
Source code in vgrid/conversion/latlon2dggs.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
latlon2isea4t_cli()
¶
Command-line interface for latlon2isea4t.
Source code in vgrid/conversion/latlon2dggs.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
latlon2maidenhead(lat, lon, res)
¶
Convert latitude and longitude to Maidenhead grid square.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
Maidenhead precision [1-4] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
Maidenhead grid square |
Example
latlon2maidenhead(10.775275567242561, 106.70679737574993, 2) 'OK12'
Source code in vgrid/conversion/latlon2dggs.py
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 | |
latlon2maidenhead_cli()
¶
Command-line interface for latlon2maidenhead.
Source code in vgrid/conversion/latlon2dggs.py
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 | |
latlon2mgrs(lat, lon, res)
¶
Convert latitude and longitude to MGRS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
MGRS precision [0-5] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
MGRS coordinate |
Example
latlon2mgrs(10.775275567242561, 106.70679737574993, 3) '48PXV123456'
Source code in vgrid/conversion/latlon2dggs.py
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 | |
latlon2mgrs_cli()
¶
Command-line interface for latlon2mgrs.
Source code in vgrid/conversion/latlon2dggs.py
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 | |
latlon2olc(lat, lon, res)
¶
Convert latitude and longitude to Open Location Code (OLC/Plus Code).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
OLC code length [2,4,6,8,10-15] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
Open Location Code |
Example
latlon2olc(10.775275567242561, 106.70679737574993, 12) '6P5XQ2+2Q'
Source code in vgrid/conversion/latlon2dggs.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 | |
latlon2olc_cli()
¶
Command-line interface for latlon2olc.
Source code in vgrid/conversion/latlon2dggs.py
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | |
latlon2qtm(lat, lon, res)
¶
Convert latitude and longitude to QTM cell identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
QTM resolution level [1-24] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
QTM cell identifier |
Example
latlon2qtm(10.775275567242561, 106.70679737574993, 12) '0123456789ab'
Source code in vgrid/conversion/latlon2dggs.py
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | |
latlon2qtm_cli()
¶
Command-line interface for latlon2qtm.
Source code in vgrid/conversion/latlon2dggs.py
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | |
latlon2quadkey(lat, lon, res)
¶
Convert latitude and longitude to Quadkey.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
Quadkey zoom level [0-29] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
Quadkey identifier |
Example
latlon2quadkey(10.775275567242561, 106.70679737574993, 15) '123456789012345'
Source code in vgrid/conversion/latlon2dggs.py
934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 | |
latlon2quadkey_cli()
¶
Command-line interface for latlon2tilecode.
Source code in vgrid/conversion/latlon2dggs.py
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 | |
latlon2rhealpix(lat, lon, res)
¶
Convert latitude and longitude to RHEALPix cell identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
RHEALPix resolution level [0-15] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
RHEALPix cell identifier |
Example
latlon2rhealpix(10.775275567242561, 106.70679737574993, 8) 'N:1:8:1:2:3:4:5:6:7:8'
Source code in vgrid/conversion/latlon2dggs.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
latlon2rhealpix_cli()
¶
Command-line interface for latlon2rhealpix.
Source code in vgrid/conversion/latlon2dggs.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
latlon2s2(lat, lon, res=None)
¶
Convert latitude and longitude to S2 cell identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
S2 resolution level [0-30] |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
S2 cell token |
Example
latlon2s2(10.775275567242561, 106.70679737574993, 21) '1d4b9b0b8c8c8c8c'
Source code in vgrid/conversion/latlon2dggs.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
latlon2s2_cli()
¶
Command-line interface for latlon2s2.
Source code in vgrid/conversion/latlon2dggs.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
latlon2tilecode(lat, lon, res)
¶
Convert latitude and longitude to Tilecode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Latitude in decimal degrees |
required |
lon
|
float
|
Longitude in decimal degrees |
required |
res
|
int
|
Tile zoom level [0-29] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
Tilecode identifier |
Example
latlon2tilecode(10.775275567242561, 106.70679737574993, 15) '123456789012345'
Source code in vgrid/conversion/latlon2dggs.py
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 | |
latlon2tilecode_cli()
¶
Command-line interface for latlon2tilecode.
Source code in vgrid/conversion/latlon2dggs.py
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 | |