1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 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 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 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 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 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 344 345 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 376 377 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 408 409 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 438 439 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 470 471 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 520 521 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 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 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 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 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 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 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 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 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 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 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 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 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 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 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 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 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 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 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 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 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 1092 1093 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 1119 1120 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 1148 1149 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 1176 1177 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 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>PostGIS 1.5.3 Manual</title><link rel="stylesheet" type="text/css" href="style.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><meta name="description" content="PostGIS is an extension to the PostgreSQL object-relational database system which allows GIS (Geographic Information Systems) objects to be stored in the database. PostGIS includes support for GiST-based R-Tree spatial indexes, and functions for analysis and processing of GIS objects. This is the manual for version 1.5.3"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" title="PostGIS 1.5.3 Manual"><div class="titlepage"><div><div><h1 class="title"><a name="id36098545"></a>PostGIS 1.5.3 Manual</h1></div><div><div class="abstract" title="Abstract"><p class="title"><b>Abstract</b></p><p>PostGIS is an extension to the PostgreSQL object-relational
database system which allows GIS (Geographic Information Systems)
objects to be stored in the database. PostGIS includes support for
GiST-based R-Tree spatial indexes, and functions for analysis and
processing of GIS objects.</p><p>This is the manual for version 1.5.3</p></div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="chapter"><a href="#id36132670">1. Introduction</a></span></dt><dd><dl><dt><span class="sect1"><a href="#psc">1.1. Project Steering Committee</a></span></dt><dt><span class="sect1"><a href="#credits">1.2. Contributors Past and Present</a></span></dt><dt><span class="sect1"><a href="#id36132959">1.3. More Information</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id36133424">2. Installation</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id36133433">2.1. Short Version</a></span></dt><dt><span class="sect1"><a href="#id36133466">2.2. Requirements</a></span></dt><dt><span class="sect1"><a href="#id36133694">2.3. Getting the Source</a></span></dt><dt><span class="sect1"><a href="#PGInstall">2.4. Installation</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36133798">2.4.1. Configuration</a></span></dt><dt><span class="sect2"><a href="#id36134008">2.4.2. Building</a></span></dt><dt><span class="sect2"><a href="#id36134048">2.4.3. Testing</a></span></dt><dt><span class="sect2"><a href="#id36134123">2.4.4. Installation</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36134234">2.5. Create a spatially-enabled database</a></span></dt><dt><span class="sect1"><a href="#templatepostgis">2.6. Create a spatially-enabled database from a template</a></span></dt><dt><span class="sect1"><a href="#upgrading">2.7. Upgrading</a></span></dt><dd><dl><dt><span class="sect2"><a href="#soft_upgrade">2.7.1. Soft upgrade</a></span></dt><dt><span class="sect2"><a href="#hard_upgrade">2.7.2. Hard upgrade</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36134540">2.8. Common Problems</a></span></dt><dt><span class="sect1"><a href="#id36134621">2.9. JDBC</a></span></dt><dt><span class="sect1"><a href="#id36134688">2.10. Loader/Dumper</a></span></dt></dl></dd><dt><span class="chapter"><a href="#PostGIS_FAQ">3. Frequently Asked Questions</a></span></dt><dt><span class="chapter"><a href="#id36137207">4. Using PostGIS: Data Management and Queries</a></span></dt><dd><dl><dt><span class="sect1"><a href="#RefObject">4.1. GIS Objects</a></span></dt><dd><dl><dt><span class="sect2"><a href="#OpenGISWKBWKT">4.1.1. OpenGIS WKB and WKT</a></span></dt><dt><span class="sect2"><a href="#EWKB_EWKT">4.1.2. PostGIS EWKB, EWKT and Canonical Forms</a></span></dt><dt><span class="sect2"><a href="#SQL_MM_Part3">4.1.3. SQL-MM Part 3</a></span></dt></dl></dd><dt><span class="sect1"><a href="#PostGIS_Geography">4.2. PostGIS Geography Type</a></span></dt><dd><dl><dt><span class="sect2"><a href="#Geography_Basics">4.2.1. Geography Basics</a></span></dt><dt><span class="sect2"><a href="#PostGIS_GeographyVSGeometry">4.2.2. When to use Geography Data type over Geometry data type</a></span></dt><dt><span class="sect2"><a href="#PostGIS_Geography_AdvancedFAQ">4.2.3. Geography Advanced FAQ</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36137988">4.3. Using OpenGIS Standards</a></span></dt><dd><dl><dt><span class="sect2"><a href="#spatial_ref_sys">4.3.1. The SPATIAL_REF_SYS Table and Spatial Reference Systems</a></span></dt><dt><span class="sect2"><a href="#geometry_columns">4.3.2. The GEOMETRY_COLUMNS Table</a></span></dt><dt><span class="sect2"><a href="#Create_Spatial_Table">4.3.3. Creating a Spatial Table</a></span></dt><dt><span class="sect2"><a href="#Manual_Register_Spatial_Column">4.3.4. Manually Registering Geometry Columns in geometry_columns</a></span></dt><dt><span class="sect2"><a href="#OGC_Validity">4.3.5. Ensuring OpenGIS compliancy of geometries</a></span></dt><dt><span class="sect2"><a href="#DE-9IM">4.3.6. Dimensionally Extended 9 Intersection Model (DE-9IM)</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36140438">4.4. Loading GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36140449">4.4.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#shp2pgsql_usage">4.4.2. Using the Loader</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36140779">4.5. Retrieving GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36140925">4.5.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id36141047">4.5.2. Using the Dumper</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36141205">4.6. Building Indexes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36141247">4.6.1. GiST Indexes</a></span></dt><dt><span class="sect2"><a href="#id36141296">4.6.2. Using Indexes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36141388">4.7. Complex Queries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36141402">4.7.1. Taking Advantage of Indexes</a></span></dt><dt><span class="sect2"><a href="#id36141469">4.7.2. Examples of Spatial SQL</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id36146016">5. Using PostGIS: Building Applications</a></span></dt><dd><dl><dt><span class="sect1"><a href="#Using_MapServer">5.1. Using MapServer</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36146064">5.1.1. Basic Usage</a></span></dt><dt><span class="sect2"><a href="#id36146276">5.1.2. Frequently Asked Questions</a></span></dt><dt><span class="sect2"><a href="#id36146431">5.1.3. Advanced Usage</a></span></dt><dt><span class="sect2"><a href="#id36146521">5.1.4. Examples</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36146598">5.2. Java Clients (JDBC)</a></span></dt><dt><span class="sect1"><a href="#id36146641">5.3. C Clients (libpq)</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36146649">5.3.1. Text Cursors</a></span></dt><dt><span class="sect2"><a href="#id36146659">5.3.2. Binary Cursors</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id36147299">6. Performance tips</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id36147305">6.1. Small tables of large geometries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36147310">6.1.1. Problem description</a></span></dt><dt><span class="sect2"><a href="#id36147348">6.1.2. Workarounds</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36147399">6.2. CLUSTERing on geometry indices</a></span></dt><dt><span class="sect1"><a href="#id36147441">6.3. Avoiding dimension conversion</a></span></dt><dt><span class="sect1"><a href="#id36147469">6.4. Tuning your configuration</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36147498">6.4.1. Startup</a></span></dt><dt><span class="sect2"><a href="#id36147606">6.4.2. Runtime</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#reference">7. PostGIS Reference</a></span></dt><dd><dl><dt><span class="sect1"><a href="#PostGIS_Types">7.1. PostgreSQL PostGIS Types</a></span></dt><dt><span class="sect1"><a href="#Management_Functions">7.2. Management Functions</a></span></dt><dt><span class="sect1"><a href="#Geometry_Constructors">7.3. Geometry Constructors</a></span></dt><dt><span class="sect1"><a href="#Geometry_Accessors">7.4. Geometry Accessors</a></span></dt><dt><span class="sect1"><a href="#Geometry_Editors">7.5. Geometry Editors</a></span></dt><dt><span class="sect1"><a href="#Geometry_Outputs">7.6. Geometry Outputs</a></span></dt><dt><span class="sect1"><a href="#Operators">7.7. Operators</a></span></dt><dt><span class="sect1"><a href="#Spatial_Relationships_Measurements">7.8. Spatial Relationships and Measurements</a></span></dt><dt><span class="sect1"><a href="#Geometry_Processing">7.9. Geometry Processing Functions</a></span></dt><dt><span class="sect1"><a href="#Linear_Referencing">7.10. Linear Referencing</a></span></dt><dt><span class="sect1"><a href="#Long_Transactions_Support">7.11. Long Transactions Support</a></span></dt><dt><span class="sect1"><a href="#Miscellaneous_Functions">7.12. Miscellaneous Functions</a></span></dt><dt><span class="sect1"><a href="#Exceptional_Functions">7.13. Exceptional Functions</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id36258574">8. PostGIS Special Functions Index</a></span></dt><dd><dl><dt><span class="sect1"><a href="#PostGIS_Aggregate_Functions">8.1. PostGIS Aggregate Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_SQLMM_Functions">8.2. PostGIS SQL-MM Compliant Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_GeographyFunctions">8.3. PostGIS Geography Support Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_Geometry_DumpFunctions">8.4. PostGIS Geometry Dump Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_BoxFunctions">8.5. PostGIS Box Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_3D_Functions">8.6. PostGIS Functions that support 3D</a></span></dt><dt><span class="sect1"><a href="#PostGIS_Curved_GeometryFunctions">8.7. PostGIS Curved Geometry Support Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_TypeFunctionMatrix">8.8. PostGIS Function Support Matrix</a></span></dt><dt><span class="sect1"><a href="#NewFunctions">8.9. New PostGIS Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#NewFunctions_1_5">8.9.1. PostGIS Functions new, behavior changed, or enhanced in 1.5</a></span></dt><dt><span class="sect2"><a href="#NewFunctions_1_4">8.9.2. PostGIS Functions new, behavior changed, or enhanced in 1.4</a></span></dt><dt><span class="sect2"><a href="#NewFunctions_1_3">8.9.3. PostGIS Functions new in 1.3</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id36279034">9. Reporting Problems</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id36279040">9.1. Reporting Software Bugs</a></span></dt><dt><span class="sect1"><a href="#id36279094">9.2. Reporting Documentation Issues</a></span></dt></dl></dd><dt><span class="appendix"><a href="#release_notes">A. Appendix</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id36279370">A.1. Release 1.5.3</a></span></dt><dt><span class="sect1"><a href="#id36279459">A.2. Release 1.5.2</a></span></dt><dt><span class="sect1"><a href="#id36279562">A.3. Release 1.5.1</a></span></dt><dt><span class="sect1"><a href="#id36279618">A.4. Release 1.5.0</a></span></dt><dt><span class="sect1"><a href="#id36279818">A.5. Release 1.4.0</a></span></dt><dt><span class="sect1"><a href="#id36280015">A.6. Release 1.3.6</a></span></dt><dt><span class="sect1"><a href="#id36280031">A.7. Release 1.3.5</a></span></dt><dt><span class="sect1"><a href="#id36280046">A.8. Release 1.3.4</a></span></dt><dt><span class="sect1"><a href="#id36280067">A.9. Release 1.3.3</a></span></dt><dt><span class="sect1"><a href="#id36280082">A.10. Release 1.3.2</a></span></dt><dt><span class="sect1"><a href="#id36280097">A.11. Release 1.3.1</a></span></dt><dt><span class="sect1"><a href="#id36280112">A.12. Release 1.3.0</a></span></dt><dt><span class="sect1"><a href="#id36280179">A.13. Release 1.2.1</a></span></dt><dt><span class="sect1"><a href="#id36280220">A.14. Release 1.2.0</a></span></dt><dt><span class="sect1"><a href="#id36280249">A.15. Release 1.1.6</a></span></dt><dt><span class="sect1"><a href="#id36280354">A.16. Release 1.1.5</a></span></dt><dt><span class="sect1"><a href="#id36280453">A.17. Release 1.1.4</a></span></dt><dt><span class="sect1"><a href="#id36280560">A.18. Release 1.1.3</a></span></dt><dt><span class="sect1"><a href="#id36280844">A.19. Release 1.1.2</a></span></dt><dt><span class="sect1"><a href="#id36280963">A.20. Release 1.1.1</a></span></dt><dt><span class="sect1"><a href="#id36281079">A.21. Release 1.1.0</a></span></dt><dt><span class="sect1"><a href="#id36281369">A.22. Release 1.0.6</a></span></dt><dt><span class="sect1"><a href="#id36281467">A.23. Release 1.0.5</a></span></dt><dt><span class="sect1"><a href="#id36281587">A.24. Release 1.0.4</a></span></dt><dt><span class="sect1"><a href="#rel_1.0.3_upgrading">A.25. Release 1.0.3</a></span></dt><dt><span class="sect1"><a href="#id36281806">A.26. Release 1.0.2</a></span></dt><dt><span class="sect1"><a href="#id36281878">A.27. Release 1.0.1</a></span></dt><dt><span class="sect1"><a href="#id36281969">A.28. Release 1.0.0</a></span></dt><dt><span class="sect1"><a href="#id36282059">A.29. Release 1.0.0RC6</a></span></dt><dt><span class="sect1"><a href="#id36282127">A.30. Release 1.0.0RC5</a></span></dt><dt><span class="sect1"><a href="#id36282193">A.31. Release 1.0.0RC4</a></span></dt><dt><span class="sect1"><a href="#id36282307">A.32. Release 1.0.0RC3</a></span></dt><dt><span class="sect1"><a href="#id36282462">A.33. Release 1.0.0RC2</a></span></dt><dt><span class="sect1"><a href="#id36282553">A.34. Release 1.0.0RC1</a></span></dt></dl></dd></dl></div><div class="chapter" title="Chapter1.Introduction"><div class="titlepage"><div><div><h2 class="title"><a name="id36132670"></a>Chapter1.Introduction</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#psc">1.1. Project Steering Committee</a></span></dt><dt><span class="sect1"><a href="#credits">1.2. Contributors Past and Present</a></span></dt><dt><span class="sect1"><a href="#id36132959">1.3. More Information</a></span></dt></dl></div><p>PostGIS is developed by Refractions Research Inc, as a spatial
database technology research project. Refractions is a GIS and database
consulting company in Victoria, British Columbia, Canada, specializing in
data integration and custom software development. We plan on supporting and
developing PostGIS to support a range of important GIS functionality,
including full OpenGIS support, advanced topological constructs (coverages,
surfaces, networks), desktop user interface tools for viewing and editing
GIS data, and web-based access tools.</p><div class="sect1" title="1.1.Project Steering Committee"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="psc"></a>1.1.Project Steering Committee</h2></div></div></div><p>
The PostGIS Project Steering Committee (PSC) coordinates the general direction,
release cycles, documentation, and outreach efforts for the PostGIS project. In addition
the PSC provides general user support, accepts and approves patches from the general PostGIS community
and votes on miscellaneous issues involving PostGIS such as developer commit access, new PSC members
or significant API changes.
</p><div class="variablelist"><dl><dt><span class="term">Mark Cave-Ayland</span></dt><dd><p>Coordinates bug fixing and maintenance effort, alignment of
PostGIS with PostgreSQL releases, spatial index selectivity and binding, windows production builds, integration of new
GEOS functionality, and new function enhancements.</p></dd><dt><span class="term">Paul Ramsey</span></dt><dd><p>Co-founder of PostGIS project. General bug fixing, geography support, GEOS functionality integration and alignment with
GEOS releases.</p></dd><dt><span class="term">Kevin Neufeld</span></dt><dd><p>Documentation, Hudson automated build, advanced user support
on PostGIS newsgroup, and postgis maintenance function enhancements.</p></dd><dt><span class="term">Regina Obe</span></dt><dd><p>Documentation, general user support on PostGIS newsgroup, windows production and experimental builds, and
smoke testing new functionality or major code changes.</p></dd></dl></div></div><div class="sect1" title="1.2.Contributors Past and Present"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="credits"></a>1.2.Contributors Past and Present</h2></div></div></div><div class="variablelist"><dl><dt><span class="term">Sandro Santilli</span></dt><dd><p>Bug fixes and maintenance and integration of new GEOS
functionality. WKT Raster support.</p></dd><dt><span class="term">Dave Blasby</span></dt><dd><p>The original developer/Co-founder of PostGIS. Dave wrote the server side
objects, index bindings, and many of the server side analytical
functions.</p></dd><dt><span class="term">Jeff Lounsbury</span></dt><dd><p>Original development of the Shape file loader/dumper. Current PostGIS Project Owner representative.</p></dd><dt><span class="term">Mark Leslie</span></dt><dd><p>Ongoing maintenance and development of core functions. Enhanced curve support.</p></dd><dt><span class="term">Olivier Courtin</span></dt><dd><p>Input output XML (KML,GML)/GeoJSON functions and bug fixes.</p></dd><dt><span class="term">Pierre Racine</span></dt><dd><p>WKT Raster overall architecture and programming support</p></dd><dt><span class="term">Mateusz Loskot</span></dt><dd><p>WKT Raster support</p></dd><dt><span class="term">Chris Hodgson</span></dt><dd><p>General development</p></dd><dt><span class="term">Nicklas Avn</span></dt><dd><p>Distance function enhancements and additions, Windows testing, and general user support</p></dd><dt><span class="term">Jorge Arevalo</span></dt><dd><p>WKT Raster development</p></dd><dt><span class="term">Stephen Frost</span></dt><dd><p>Tiger geocoder development</p></dd><dt><span class="term">Other contributors</span></dt><dd><p>In alphabetical order: Alex Bodnaru, Alex Mayrhofer, Barbara
Phillipot, Ben Jubb, Bernhard Reiter, Bruce Rindahl, Bruno Wolff
III, Carl Anderson, Charlie Savage, Dane Springmeyer, David Skea,
David Techer, Eduin Carrillo, IIDA Tetsushi, George Silva, Geographic Data BC,
Gerald Fenoy, Gino Lucrezi, Greg Stark, Guillaume Lelarge, Klaus Foerster, Kris Jurka, Mark
Sondheim, Markus Schaber, Maxime Guillaud, Maxime van Noppen, Michael Fuhr, Nikita Shulga, Norman Vine,
Ralph Mason, Steffen Macke, Vincent Picavet</p></dd><dt><span class="term">Important Support Libraries</span></dt><dd><p>The <a class="ulink" href="http://trac.osgeo.org/geos/" target="_top">GEOS</a>
geometry operations library, and the algorithmic work of Martin
Davis in making it all work, ongoing maintenance and support of
Mateusz Loskot, Paul Ramsey and others.</p><p>The <a class="ulink" href="http://trac.osgeo.org/proj/" target="_top">Proj4</a>
cartographic projection library, and the work of Gerald Evenden and
Frank Warmerdam in creating and maintaining it.</p></dd></dl></div></div><div class="sect1" title="1.3.More Information"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36132959"></a>1.3.More Information</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>The latest software, documentation and news items are available
at the PostGIS web site, <a class="ulink" href="http://postgis.refractions.net" target="_top">http://postgis.refractions.net</a>.</p></li><li class="listitem"><p>More information about the GEOS geometry operations library is
available at<a class="ulink" href="http://trac.osgeo.org/geos/" target="_top">
http://trac.osgeo.org/geos/</a>.</p></li><li class="listitem"><p>More information about the Proj4 reprojection library is
available at <a class="ulink" href="http://trac.osgeo.org/proj/" target="_top">http://trac.osgeo.org/proj/</a>.</p></li><li class="listitem"><p>More information about the PostgreSQL database server is
available at the PostgreSQL main site <a class="ulink" href="http://www.postgresql.org" target="_top">http://www.postgresql.org</a>.</p></li><li class="listitem"><p>More information about GiST indexing is available at the
PostgreSQL GiST development site, <a class="ulink" href="http://www.sai.msu.su/~megera/postgres/gist/" target="_top">http://www.sai.msu.su/~megera/postgres/gist/</a>.</p></li><li class="listitem"><p>More information about MapServer internet map server is
available at <a class="ulink" href="http://mapserver.gis.umn.edu/" target="_top">http://mapserver.gis.umn.edu</a>.</p></li><li class="listitem"><p>The "<a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">Simple Features for
Specification for SQL</a>" is available at the OpenGIS Consortium
web site: <a class="ulink" href="http://www.opengeospatial.org/" target="_top">http://www.opengeospatial.org/</a>.</p></li></ul></div></div></div><div class="chapter" title="Chapter2.Installation"><div class="titlepage"><div><div><h2 class="title"><a name="id36133424"></a>Chapter2.Installation</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#id36133433">2.1. Short Version</a></span></dt><dt><span class="sect1"><a href="#id36133466">2.2. Requirements</a></span></dt><dt><span class="sect1"><a href="#id36133694">2.3. Getting the Source</a></span></dt><dt><span class="sect1"><a href="#PGInstall">2.4. Installation</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36133798">2.4.1. Configuration</a></span></dt><dt><span class="sect2"><a href="#id36134008">2.4.2. Building</a></span></dt><dt><span class="sect2"><a href="#id36134048">2.4.3. Testing</a></span></dt><dt><span class="sect2"><a href="#id36134123">2.4.4. Installation</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36134234">2.5. Create a spatially-enabled database</a></span></dt><dt><span class="sect1"><a href="#templatepostgis">2.6. Create a spatially-enabled database from a template</a></span></dt><dt><span class="sect1"><a href="#upgrading">2.7. Upgrading</a></span></dt><dd><dl><dt><span class="sect2"><a href="#soft_upgrade">2.7.1. Soft upgrade</a></span></dt><dt><span class="sect2"><a href="#hard_upgrade">2.7.2. Hard upgrade</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36134540">2.8. Common Problems</a></span></dt><dt><span class="sect1"><a href="#id36134621">2.9. JDBC</a></span></dt><dt><span class="sect1"><a href="#id36134688">2.10. Loader/Dumper</a></span></dt></dl></div><p>
This chapter details the steps required to install PostGIS.
</p><div class="sect1" title="2.1.Short Version"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36133433"></a>2.1.Short Version</h2></div></div></div><pre class="programlisting">tar xvfz postgis-1.5.3.tar.gz
cd postgis-1.5.3
./configure
make
make install
#BEGIN OPTIONAL -- this is already part of the tar
# only really need this if installing from SVN
cd doc/
make comments-install
#END OPTIONAL
createdb yourdatabase
createlang plpgsql yourdatabase
psql -d yourdatabase -f postgis.sql
psql -d yourdatabase -f postgis_comments.sql
psql -d yourdatabase -f spatial_ref_sys.sql</pre><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>
NOTE: The postgis.sql and spatial_ref_sys.sql will be installed in the
/share/contrib/postgis-1.5
of your PostGIS install. If you didn't install the OPTIONAL comments section, you will need to manually copy the
postgis_comments.sql file from the doc folder of your source install to your /share/contrib/postgis-1.5
folder.
</p></td></tr></table></div><p>
The rest of this chapter goes into detail each of the above installation
steps.
</p></div><div class="sect1" title="2.2.Requirements"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36133466"></a>2.2.Requirements</h2></div></div></div><p>
PostGIS has the following requirements for building and usage:
</p><p>
<span class="bold"><strong>Required</strong></span>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
PostgreSQL 8.3 or higher. A complete installation of PostgreSQL
(including server headers) is required. PostgreSQL is available from
<a class="ulink" href="http://www.postgresql.org" target="_top">
http://www.postgresql.org
</a>
.
</p><p>For a full PostgreSQL / PostGIS support matrix and PostGIS/GEOS support matrix refer to
<a class="ulink" href="http://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS" target="_top">http://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS</a>
</p></li><li class="listitem"><p>
GNU C compiler (<code class="filename">gcc</code>). Some other ANSI C compilers
can be used to compile PostGIS, but we find far fewer problems when
compiling with <code class="filename">gcc</code>.
</p></li><li class="listitem"><p>
GNU Make (<code class="filename">gmake</code> or <code class="filename">make</code>).
For many systems, GNU <code class="filename">make</code> is the default version
of make. Check the version by invoking <code class="filename">make -v</code>.
Other versions of <code class="filename">make</code> may not process the
PostGIS <code class="filename">Makefile</code> properly.
</p></li><li class="listitem"><p>
Proj4 reprojection library, version 4.6.0 or greater. The Proj4
library is used to provide coordinate reprojection support within
PostGIS. Proj4 is available for download from
<a class="ulink" href="http://trac.osgeo.org/proj/" target="_top">
http://trac.osgeo.org/proj/
</a>
.
</p></li><li class="listitem"><p>
GEOS geometry library, version 3.1.1 or greater, but GEOS 3.2 is recommended. Without GEOS 3.2,
you will be missing some major enhancements with handling of topological exceptions and improvements to ST_Buffer that allow beveling and mitre and much faster buffering. The GEOS library is
used to provide geometry tests (ST_Touches(), ST_Contains(),
ST_Intersects()) and operations (ST_Buffer(), ST_Union(),ST_Intersection()
ST_Difference()) within PostGIS. GEOS is available for download from
<a class="ulink" href="http://trac.osgeo.org/geos/" target="_top">
http://trac.osgeo.org/geos/
</a>
.
</p></li><li class="listitem"><p>
LibXML2, version 2.5.x or higher. LibXML2 is currently used in some imports
functions (ST_GeomFromGML and ST_GeomFromKML). LibXML2 is available for download from
<a class="ulink" href="http://xmlsoft.org/downloads.html" target="_top">http://xmlsoft.org/downloads.html</a>.
</p></li></ul></div><p>
<span class="bold"><strong>Optional</strong></span>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
GTK (requires GTK+2.0) to compile the shp2pgsql-gui shape file loader.
<a class="ulink" href="http://www.gtk.org/" target="_top">
http://www.gtk.org/
</a>
.
</p></li><li class="listitem"><p>
CUnit (<code class="filename">CUnit</code>). This is needed for regression tests. <a class="ulink" href="http://cunit.sourceforge.net/" target="_top">http://cunit.sourceforge.net/</a>
</p></li><li class="listitem"><p>
Apache Ant (<code class="filename">ant</code>) is required for building any of
the drivers under the <code class="filename">java</code> directory. Ant is
available from
<a class="ulink" href="http://ant.apache.org" target="_top">
http://ant.apache.org
</a>
.
</p></li><li class="listitem"><p>
DocBook (<code class="filename">xsltproc</code>) is required for building the
documentation. Docbook is available from
<a class="ulink" href="http://www.docbook.org/" target="_top">
http://www.docbook.org/
</a>
.
</p></li><li class="listitem"><p>
DBLatex (<code class="filename">dblatex</code>) is required for building the
documentation in PDF format. DBLatex is available from
<a class="ulink" href="http://dblatex.sourceforge.net/" target="_top">
http://dblatex.sourceforge.net/
</a>
.
</p></li><li class="listitem"><p>
ImageMagick (<code class="filename">convert</code>) is required to generate the
images used in the documentation. ImageMagick is available from
<a class="ulink" href="http://www.imagemagick.org/" target="_top">
http://www.imagemagick.org/
</a>
.
</p></li></ul></div></div><div class="sect1" title="2.3.Getting the Source"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36133694"></a>2.3.Getting the Source</h2></div></div></div><p>
Retrieve the PostGIS source archive from the downloads website
<a class="ulink" href="http://www.postgis.org/download/postgis-1.5.3.tar.gz" target="_top">
http://www.postgis.org/download/postgis-1.5.3.tar.gz
</a>
</p><pre class="programlisting">wget http://www.postgis.org/download/postgis-1.5.3.tar.gz
tar -xvzf postgis-1.5.3.tar.gz</pre><p>
This will create a directory called
<code class="varname">postgis-1.5.3</code> in the current working
directory.
</p><p>
Alternatively, checkout the source from the
<a class="ulink" href="http://subversion.tigris.org/" target="_top">
svn
</a>
repository
<a class="ulink" href="http://svn.osgeo.org/postgis/trunk/" target="_top">
http://svn.osgeo.org/postgis/trunk/
</a>
.
</p><pre class="programlisting">svn checkout http://svn.osgeo.org/postgis/trunk/ postgis-1.5.3</pre><p>
Change into the newly created
<code class="varname">postgis-1.5.3</code> directory to continue
the installation.
</p></div><div class="sect1" title="2.4.Installation"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PGInstall"></a>2.4.Installation</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#id36133798">2.4.1. Configuration</a></span></dt><dt><span class="sect2"><a href="#id36134008">2.4.2. Building</a></span></dt><dt><span class="sect2"><a href="#id36134048">2.4.3. Testing</a></span></dt><dt><span class="sect2"><a href="#id36134123">2.4.4. Installation</a></span></dt></dl></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>
Many OS systems now include pre-built packages for PostgreSQL/PostGIS.
In many cases compilation is only necessary if you want the most
bleeding edge versions or you are a package maintainer.
</p></td></tr></table></div><p>
The PostGIS module is an extension to the PostgreSQL backend server. As
such, PostGIS 1.5.3 <span class="emphasis"><em>requires</em></span> full
PostgreSQL server headers access in order to compile. It can be built
against PostgreSQL versions 8.3 or higher. Earlier versions of
PostgreSQL are <span class="emphasis"><em>not</em></span> supported.
</p><p>
Refer to the PostgreSQL installation guides if you haven't already
installed PostgreSQL.
<a class="ulink" href="http://www.postgresql.org" target="_top">
http://www.postgresql.org
</a>
.
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>
For GEOS functionality, when you install PostgresSQL you may need to
explicitly link PostgreSQL against the standard C++ library:
</p><pre class="programlisting">LDFLAGS=-lstdc++ ./configure [YOUR OPTIONS HERE]</pre><p>
This is a workaround for bogus C++ exceptions interaction with older
development tools. If you experience weird problems (backend
unexpectedly closed or similar things) try this trick. This will require
recompiling your PostgreSQL from scratch, of course.
</p></td></tr></table></div><p>
The following steps outline the configuration and compilation of the
PostGIS source. They are written for Linux users and will not work on
Windows or Mac.
</p><div class="sect2" title="2.4.1.Configuration"><div class="titlepage"><div><div><h3 class="title"><a name="id36133798"></a>2.4.1.Configuration</h3></div></div></div><p>
As with most linux installations, the first step is to generate the
Makefile that will be used to build the source code. This is done by
running the shell script
</p><p>
<span class="command"><strong>./configure</strong></span>
</p><p>
With no additional parameters, this command will attempt to
automatically locate the required components and libraries needed to
build the PostGIS source code on your system. Although this is the most
common usage of <span class="command"><strong>./configure</strong></span>, the script accepts
several parameters for those who have the required libraries and
programs in non-standard locations.
</p><p>
The following list shows only the most commonly used parameters. For a
complete list, use the <span class="command"><strong>--help</strong></span> or
<span class="command"><strong>--help=short</strong></span> parameters.
</p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>--prefix=<span class="emphasis"><em>PREFIX</em></span></strong></span></span></dt><dd><p>
This is the location the PostGIS libraries and SQL scripts will be
installed to. By default, this location is the same as the
detected PostgreSQL installation.
</p><div class="caution" title="Caution" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Caution"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>
This paramater is currently broken, as the package will only
install into the PostgreSQL installation directory. Visit
<a class="ulink" href="http://trac.osgeo.org/postgis/ticket/160" target="_top">
http://trac.osgeo.org/postgis/ticket/160
</a>
to track this bug.
</p></td></tr></table></div></dd><dt><span class="term"><span class="command"><strong>--with-pgconfig=<span class="emphasis"><em>FILE</em></span></strong></span></span></dt><dd><p>
PostgreSQL provides a utility called <span class="command"><strong>pg_config</strong></span>
to enable extensions like PostGIS to locate the PostgreSQL
installation directory. Use this parameter
(<span class="command"><strong>--with-pgconfig=/path/to/pg_config</strong></span>) to
manually specify a particular PostgreSQL installation that PostGIS
will build against.
</p></dd><dt><span class="term"><span class="command"><strong>--with-geosconfig=<span class="emphasis"><em>FILE</em></span></strong></span></span></dt><dd><p>
GEOS, a required geometry library, provides a utility called
<span class="command"><strong>geos-config</strong></span> to enable software installations to
locate the GEOS installation directory. Use this parameter
(<span class="command"><strong>--with-geosconfig=/path/to/geos-config</strong></span>) to
manually specify a particular GEOS installation that PostGIS will
build against.
</p></dd><dt><span class="term"><span class="command"><strong>--with-projdir=<span class="emphasis"><em>DIR</em></span></strong></span></span></dt><dd><p>
Proj4 is a reprojection library required by PostGIS. Use this
parameter (<span class="command"><strong>--with-projdir=/path/to/projdir</strong></span>) to
manually specify a particular Proj4 installation directory that
PostGIS will build against.
</p></dd><dt><span class="term"><span class="command"><strong>--with-gui</strong></span></span></dt><dd><p>
Compile the data import GUI (requires GTK+2.0). This will create shp2pgsql-gui graphical interface
to shp2pgsql.
</p></dd></dl></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>
If you obtained PostGIS from the SVN
<a class="ulink" href="http://svn.osgeo.org/postgis/trunk/" target="_top">
repository
</a>
, the first step is really to run the script
</p><p>
<span class="command"><strong>./autogen.sh</strong></span>
</p><p>
This script will generate the <span class="command"><strong>configure</strong></span> script that
in turn is used to customize the intallation of PostGIS.
</p><p>
If you instead obtained PostGIS as a tarball, running
<span class="command"><strong>./autogen.sh</strong></span> is not necessary as
<span class="command"><strong>configure</strong></span> has already been generated.
</p></td></tr></table></div></div><div class="sect2" title="2.4.2.Building"><div class="titlepage"><div><div><h3 class="title"><a name="id36134008"></a>2.4.2.Building</h3></div></div></div><p>
Once the Makefile has been generated, building PostGIS is as simple as
running
</p><p>
<span class="command"><strong>make</strong></span>
</p><p>
The last line of the output should be "<code class="code">PostGIS was built
successfully. Ready to install.</code>"
</p><p>
As of PostGIS v1.4.0, all the functions have comments generated from the
documentation. If you wish to install these comments into your spatial
databases later, run the command which requires docbook. The postgis_comments.sql
is also packaged in the tar.gz distribution in the doc folder so no need to make comments
if installing from the tar ball.
</p><p>
<span class="command"><strong>make comments</strong></span>
</p></div><div class="sect2" title="2.4.3.Testing"><div class="titlepage"><div><div><h3 class="title"><a name="id36134048"></a>2.4.3.Testing</h3></div></div></div><p>
If you wish to test the PostGIS build, run
</p><p>
<span class="command"><strong>make check</strong></span>
</p><p>
The above command will run through various checks and regression tests
using the generated library against an actual PostgreSQL database.
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>
If you configured PostGIS using non-standard PostgreSQL, GEOS, or
Proj4 locations, you may need to add their library locations to the
LD_LIBRARY_PATH environment variable.
</p></td></tr></table></div><div class="caution" title="Caution" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Caution"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>
Currently, the <span class="command"><strong>make check</strong></span> relies on the
<code class="code">PATH</code> and <code class="code">PGPORT</code> environment variables when
performing the checks - it does <span class="emphasis"><em>not</em></span> use the
PostgreSQL version that may have been specified using the
configuration paramter <span class="command"><strong>--with-pgconfig</strong></span>. So make
sure to modify your PATH to match the detected PostgreSQL installation
during configuration or be prepared to deal with the impending
headaches. Visit
<a class="ulink" href="http://trac.osgeo.org/postgis/ticket/186" target="_top">
http://trac.osgeo.org/postgis/ticket/186
</a>
to track this bug.
</p></td></tr></table></div><p>
If successful, the output of the test should be similiar to the
following:
</p><pre class="programlisting"> CUnit - A Unit testing framework for C - Version 2.1-0
http://cunit.sourceforge.net/
Suite: PostGIS Computational Geometry Suite
Test: test_lw_segment_side() ... passed
Test: test_lw_segment_intersects() ... passed
Test: test_lwline_crossing_short_lines() ... passed
Test: test_lwline_crossing_long_lines() ... passed
Test: test_lwpoint_set_ordinate() ... passed
Test: test_lwpoint_get_ordinate() ... passed
Test: test_lwpoint_interpolate() ... passed
Test: test_lwline_clip() ... passed
Test: test_lwline_clip_big() ... passed
Test: test_lwmline_clip() ... passed
Test: test_geohash_point() ... passed
Test: test_geohash_precision() ... passed
Test: test_geohash() ... passed
Suite: PostGIS Measures Suite
Test: test_mindistance2d_recursive_tolerance() ... passed
--Run Summary: Type Total Ran Passed Failed
suites 2 2 n/a 0
tests 14 14 14 0
asserts 84 84 84 0
Creating spatial db postgis_reg
TMPDIR is /tmp/pgis_reg_15328
PostgreSQL 8.3.7 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
Postgis 1.4.0SVN - 2009-05-25 20:21:55
GEOS: 3.1.0-CAPI-1.5.0
PROJ: Rel. 4.6.1, 21 August 2008
Running tests
loader/Point.............. ok
loader/PointM.............. ok
loader/PointZ.............. ok
loader/MultiPoint.............. ok
loader/MultiPointM.............. ok
loader/MultiPointZ.............. ok
loader/Arc.............. ok
loader/ArcM.............. ok
loader/ArcZ.......... ok
loader/Polygon.............. ok
loader/PolygonM.............. ok
loader/PolygonZ.............. ok
regress. ok
regress_index. ok
regress_index_nulls. ok
lwgeom_regress. ok
regress_lrs. ok
removepoint. ok
setpoint. ok
simplify. ok
snaptogrid. ok
affine. ok
wkt. ok
measures. ok
long_xact. ok
ctors. ok
sql-mm-serialize. ok
sql-mm-circularstring. ok
sql-mm-compoundcurve. ok
sql-mm-curvepoly. ok
sql-mm-general. ok
sql-mm-multicurve. ok
sql-mm-multisurface. ok
geojson. ok
gml. ok
svg. ok
kml. ok
regress_ogc. ok
regress_bdpoly. ok
regress_proj. ok
regress_ogc_cover. ok
regress_ogc_prep. ok
Run tests: 42
Failed: 0</pre></div><div class="sect2" title="2.4.4.Installation"><div class="titlepage"><div><div><h3 class="title"><a name="id36134123"></a>2.4.4.Installation</h3></div></div></div><p>
To install PostGIS, type
</p><p>
<span class="command"><strong>make install</strong></span>
</p><p>
This will copy the PostGIS installation files into their appropriate
subdirectory specified by the <span class="command"><strong>--prefix</strong></span> configuration
parameter. In particular:
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
The loader and dumper binaries are installed in
<code class="filename">[prefix]/bin</code>.
</p></li><li class="listitem"><p>
The SQL files, such as <code class="filename">postgis.sql</code>, are
installed in <code class="filename">[prefix]/share/contrib</code>.
</p></li><li class="listitem"><p>
The PostGIS libraries are installed in
<code class="filename">[prefix]/lib</code>.
</p></li></ul></div><p>
If you previously ran the <span class="command"><strong>make comments</strong></span> command to
generate the <code class="filename">postgis_comments.sql</code> file, install the
sql file by running
</p><p>
<span class="command"><strong>make comments-install</strong></span>
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>
<code class="filename">postgis_comments.sql</code> was separated from the
typical build and installation targets since with it comes the extra
dependency of <span class="command"><strong>xsltproc</strong></span>.
</p></td></tr></table></div></div></div><div class="sect1" title="2.5.Create a spatially-enabled database"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36134234"></a>2.5.Create a spatially-enabled database</h2></div></div></div><p>
The first step in creating a PostGIS database is to create a simple
PostgreSQL database.
</p><p>
<span class="command"><strong>createdb [yourdatabase]</strong></span>
</p><p>
Many of the PostGIS functions are written in the PL/pgSQL procedural
language. As such, the next step to create a PostGIS database is to enable
the PL/pgSQL language in your new database. This is accomplish by the
command
</p><p>
<span class="command"><strong>createlang plpgsql [yourdatabase]</strong></span>
</p><p>
Now load the PostGIS object and function definitions into your database by
loading the <code class="filename">postgis.sql</code> definitions file (located in
<code class="filename">[prefix]/share/contrib</code> as specified during the
configuration step).
</p><p>
<span class="command"><strong>psql -d [yourdatabase] -f postgis.sql</strong></span>
</p><p>
For a complete set of EPSG coordinate system definition identifiers, you
can also load the <code class="filename">spatial_ref_sys.sql</code> definitions
file and populate the <code class="varname">spatial_ref_sys</code> table. This will
permit you to perform ST_Transform() operations on geometries.
</p><p>
<span class="command"><strong>psql -d [yourdatabase] -f spatial_ref_sys.sql</strong></span>
</p><p>
If you wish to add comments to the PostGIS functions, the final step is to
load the <code class="filename">postgis_comments.sql</code> into your spatial
database. The comments can be viewed by simply typing <span class="command"><strong>\dd
[function_name]</strong></span> from a <span class="command"><strong>psql</strong></span> terminal window.
</p><p>
<span class="command"><strong>psql -d [yourdatabase] -f postgis_comments.sql</strong></span>
</p></div><div class="sect1" title="2.6.Create a spatially-enabled database from a template"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="templatepostgis"></a>2.6.Create a spatially-enabled database from a template</h2></div></div></div><p>
Some packaged distributions of PostGIS (in particular the Win32 installers
for PostGIS >= 1.1.5) load the PostGIS functions into a template
database called <code class="varname">template_postgis</code>. If the
<code class="varname">template_postgis</code> database exists in your PostgreSQL
installation then it is possible for users and/or applications to create
spatially-enabled databases using a single command. Note that in both
cases, the database user must have been granted the privilege to create
new databases.
</p><p>
From the shell:
</p><pre class="programlisting"># createdb -T template_postgis my_spatial_db</pre><p>
From SQL:
</p><pre class="programlisting">postgres=# CREATE DATABASE my_spatial_db TEMPLATE=template_postgis</pre></div><div class="sect1" title="2.7.Upgrading"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="upgrading"></a>2.7.Upgrading</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#soft_upgrade">2.7.1. Soft upgrade</a></span></dt><dt><span class="sect2"><a href="#hard_upgrade">2.7.2. Hard upgrade</a></span></dt></dl></div><p>
Upgrading existing spatial databases can be tricky as it requires
replacement or introduction of new PostGIS object definitions.
</p><p>
Unfortunately not all definitions can be easily replaced in a live
database, so sometimes your best bet is a dump/reload process.
</p><p>
PostGIS provides a SOFT UPGRADE procedure for minor or bugfix releases,
and an HARD UPGRADE procedure for major releases.
</p><p>
Before attempting to upgrade postgis, it is always worth to backup your
data. If you use the -Fc flag to pg_dump you will always be able to
restore the dump with an HARD UPGRADE.
</p><div class="sect2" title="2.7.1.Soft upgrade"><div class="titlepage"><div><div><h3 class="title"><a name="soft_upgrade"></a>2.7.1.Soft upgrade</h3></div></div></div><p>
After compiling you should find several <code class="filename">postgis_upgrade*.sql</code> files. Install the one
for your version of PostGIS. For example <code class="filename">postgis_upgrade_13_to_15.sql</code> should be used if you are upgrading
from postgis 1.3 to 1.5.
</p><pre class="programlisting">$ psql -f postgis_upgrade_13_to_15.sql -d your_spatial_database</pre><p>
If a soft upgrade is not possible the script will abort and you will be
warned about HARD UPGRADE being required, so do not hesitate to try a
soft upgrade first.
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>
If you can't find the <code class="filename">postgis_upgrade*.sql</code> files
you are probably using a version prior to 1.1 and must generate that
file by yourself. This is done with the following command:
</p><pre class="programlisting">$ utils/postgis_proc_upgrade.pl postgis.sql > postgis_upgrade.sql</pre></td></tr></table></div></div><div class="sect2" title="2.7.2.Hard upgrade"><div class="titlepage"><div><div><h3 class="title"><a name="hard_upgrade"></a>2.7.2.Hard upgrade</h3></div></div></div><p>
By HARD UPGRADE we intend full dump/reload of postgis-enabled databases.
You need an HARD UPGRADE when postgis objects' internal storage changes
or when SOFT UPGRADE is not possible. The
<a class="link" href="#release_notes" title="AppendixA.Appendix">Release Notes</a>
appendix reports for each version whether you need a dump/reload (HARD
UPGRADE) to upgrade.
</p><p>
PostGIS provides an utility script to restore a dump produced with the
pg_dump -Fc command. It is experimental so redirecting its output to a
file will help in case of problems. The procedure is as follow:
</p><p>
Create a "custom-format" dump of the database you want to upgrade (let's
call it "olddb")
</p><pre class="programlisting">$ pg_dump -Fc olddb > olddb.dump</pre><p>
Restore the dump contextually upgrading postgis into a new database. The
new database doesn't have to exist. postgis_restore accepts createdb
parameters after the dump file name, and that can for instance be used
if you are using a non-default character encoding for your database.
Let's call it "newdb", with UNICODE as the character encoding:
</p><pre class="programlisting">$ sh utils/postgis_restore.pl postgis.sql newdb olddb.dump -E=UNICODE > restore.log</pre><p>
Check that all restored dump objects really had to be restored from dump
and do not conflict with the ones defined in postgis.sql
</p><pre class="programlisting">$ grep ^KEEPING restore.log | less</pre><p>
If upgrading from PostgreSQL < 8.0 to >= 8.0 you might want to
drop the attrelid, varattnum and stats columns in the geometry_columns
table, which are no-more needed. Keeping them won't hurt. DROPPING THEM
WHEN REALLY NEEDED WILL DO HURT !
</p><pre class="programlisting">$ psql newdb -c "ALTER TABLE geometry_columns DROP attrelid"
$ psql newdb -c "ALTER TABLE geometry_columns DROP varattnum"
$ psql newdb -c "ALTER TABLE geometry_columns DROP stats"</pre><p>
spatial_ref_sys table is restore from the dump, to ensure your custom
additions are kept, but the distributed one might contain modification
so you should backup your entries, drop the table and source the new
one. If you did make additions we assume you know how to backup them
before upgrading the table. Replace of it with the new one is done like
this:
</p><pre class="programlisting">$ psql newdb
newdb=> truncate spatial_ref_sys;
TRUNCATE
newdb=> \i spatial_ref_sys.sql</pre></div></div><div class="sect1" title="2.8.Common Problems"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36134540"></a>2.8.Common Problems</h2></div></div></div><p>
There are several things to check when your installation or upgrade
doesn't go as you expected.
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
Check that you you have installed PostgreSQL 8.1 or newer, and that
you are compiling against the same version of the PostgreSQL source as
the version of PostgreSQL that is running. Mix-ups can occur when your
(Linux) distribution has already installed PostgreSQL, or you have
otherwise installed PostgreSQL before and forgotten about it. PostGIS
will only work with PostgreSQL 8.1 or newer, and strange, unexpected
error messages will result if you use an older version. To check the
version of PostgreSQL which is running, connect to the database using
psql and run this query:
</p><pre class="programlisting">SELECT version();</pre><p>
If you are running an RPM based distribution, you can check for the
existence of pre-installed packages using the <span class="command"><strong>rpm</strong></span>
command as follows: <span class="command"><strong>rpm -qa | grep postgresql</strong></span>
</p></li></ol></div><p>
Also check that configure has correctly detected the location and version
of PostgreSQL, the Proj4 library and the GEOS library.
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
The output from configure is used to generate the
<code class="filename">postgis_config.h</code> file. Check that the
<code class="varname">POSTGIS_PGSQL_VERSION</code>,
<code class="varname">POSTGIS_PROJ_VERSION</code> and
<code class="varname">POSTGIS_GEOS_VERSION</code> variables have been set
correctly.
</p></li></ol></div></div><div class="sect1" title="2.9.JDBC"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36134621"></a>2.9.JDBC</h2></div></div></div><p>
The JDBC extensions provide Java objects corresponding to the internal
PostGIS types. These objects can be used to write Java clients which query
the PostGIS database and draw or do calculations on the GIS data in
PostGIS.
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
Enter the <code class="filename">java/jdbc</code> sub-directory of the PostGIS
distribution.
</p></li><li class="listitem"><p>
Run the <code class="filename">ant</code> command. Copy the
<code class="filename">postgis.jar</code> file to wherever you keep your java
libraries.
</p></li></ol></div><p>
The JDBC extensions require a PostgreSQL JDBC driver to be present in the
current CLASSPATH during the build process. If the PostgreSQL JDBC driver
is located elsewhere, you may pass the location of the JDBC driver JAR
separately using the -D parameter like this:
</p><pre class="programlisting"># ant -Dclasspath=/path/to/postgresql-jdbc.jar</pre><p>
PostgreSQL JDBC drivers can be downloaded from
<a class="ulink" href="http://jdbc.postgresql.org" target="_top">
http://jdbc.postgresql.org
</a>
.
</p></div><div class="sect1" title="2.10.Loader/Dumper"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36134688"></a>2.10.Loader/Dumper</h2></div></div></div><p>
The data loader and dumper are built and installed automatically as part
of the PostGIS build. To build and install them manually:
</p><pre class="programlisting"># cd postgis-1.5.3/loader
# make
# make install</pre><p>
The loader is called <code class="filename">shp2pgsql</code> and converts ESRI
Shape files into SQL suitable for loading in PostGIS/PostgreSQL. The
dumper is called <code class="filename">pgsql2shp</code> and converts PostGIS
tables (or queries) into ESRI Shape files. For more verbose documentation,
see the online help, and the manual pages.
</p></div></div><div class="chapter" title="Chapter3.Frequently Asked Questions"><div class="titlepage"><div><div><h2 class="title"><a name="PostGIS_FAQ"></a>Chapter3.Frequently Asked Questions</h2></div></div></div><div class="qandaset" title="Frequently Asked Questions"><a name="id36136072"></a><dl><dt>3.1. <a href="#id36136074">I'm running PostgreSQL 9.0 and I can no longer read/view geometries in OpenJump, Safe FME, and some other tools?</a></dt><dt>3.2. <a href="#id36136126">I tried to use PgAdmin to view my geometry column and it is blank, what gives?</a></dt><dt>3.3. <a href="#id36136157">What kind of geometric objects can I store?</a></dt><dt>3.4. <a href="#id36136177">I'm all confused. Which data store should I use geometry or geography?</a></dt><dt>3.5. <a href="#id36136218">I have more intense questions about geography, such as how big of a geographic region can I stuff in a geography column and
still get reasonable answers. Are there limitations such as poles, everything in the field must fit in a hemisphere (like SQL Server 2008 has), speed etc?</a></dt><dt>3.6. <a href="#id36136241">How do I insert a GIS object into the database?</a></dt><dt>3.7. <a href="#id36136325">How do I construct a spatial query?</a></dt><dt>3.8. <a href="#id36136373">How do I speed up spatial queries on large tables?</a></dt><dt>3.9. <a href="#id36136440">Why aren't PostgreSQL R-Tree indexes supported?</a></dt><dt>3.10. <a href="#id36136483">Why should I use the AddGeometryColumn()
function and all the other OpenGIS stuff?</a></dt><dt>3.11. <a href="#id36136521">What is the best way to find all objects within a radius of
another object?</a></dt><dt>3.12. <a href="#id36136559">How do I perform a coordinate reprojection as part of a
query?</a></dt><dt>3.13. <a href="#id36136585">I did an ST_AsEWKT and ST_AsText on my rather large geometry and it returned blank field. What gives?</a></dt><dt>3.14. <a href="#id36136610">When I do an ST_Intersects, it says my two geometries don't intersect when I KNOW THEY DO. What gives?</a></dt></dl><table border="0" width="100%" summary="Q and A Set"><col align="left" width="1%"><col><tbody><tr class="question" title="3.1."><td align="left" valign="top"><a name="id36136074"></a><a name="id36136076"></a><p><b>3.1.</b></p></td><td align="left" valign="top"><p>I'm running PostgreSQL 9.0 and I can no longer read/view geometries in OpenJump, Safe FME, and some other tools?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>In PostgreSQL 9.0+, the default encoding for bytea data has been changed to hex and older JDBC drivers still assume escape format. This has affected some applications
such as Java applications using older JDBC drivers or .NET applications that use the older npgsql driver
that expect the old behavior of ST_AsBinary. There are two approaches to getting this to work again.</p><p>You can upgrade your JDBC driver to the latest PostgreSQL 9.0 version which you can get from
<a class="ulink" href="http://jdbc.postgresql.org/download.html" target="_top">http://jdbc.postgresql.org/download.html</a></p><p>If you are running a .NET app, you can use Npgsql 2.0.11 or higher which you can download from
<a class="ulink" href="http://pgfoundry.org/frs/?group_id=1000140" target="_top">http://pgfoundry.org/frs/?group_id=1000140</a> and
as described on <a class="ulink" href="http://fxjr.blogspot.com/2010/11/npgsql-2011-released.html" target="_top">Francisco Figueiredo's NpgSQL 2.0.11 released blog entry</a></p><p>If upgrading your PostgreSQL driver is not an option, then you can set the default back to the old behavior with the following change:</p><pre class="programlisting">ALTER DATABASE mypostgisdb SET bytea_output='escape';</pre></td></tr><tr class="question" title="3.2."><td align="left" valign="top"><a name="id36136126"></a><a name="id36136128"></a><p><b>3.2.</b></p></td><td align="left" valign="top"><p>I tried to use PgAdmin to view my geometry column and it is blank, what gives?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>PgAdmin doesn't show anything for large geometries. The best ways to verify you do have day in your geometry columns are?</p><pre class="programlisting">-- this should return no records if all your geom fields are filled in
SELECT somefield FROM mytable WHERE geom IS NULL;</pre><pre class="programlisting">-- To tell just how large your geometry is do a query of the form
--which will tell you the most number of points you have in any of your geometry columns
SELECT MAX(ST_NPoints(geom)) FROM sometable;</pre></td></tr><tr class="question" title="3.3."><td align="left" valign="top"><a name="id36136157"></a><a name="id36136159"></a><p><b>3.3.</b></p></td><td align="left" valign="top"><p>What kind of geometric objects can I store?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>You can store point, line, polygon, multipoint, multiline,
multipolygon, and geometrycollections. These are specified in the Open
GIS Well Known Text Format (with XYZ,XYM,XYZM extensions). There are two data types currently supported.
The standard OGC geometry data type which uses a planar coordinate system for measurement and the
geography data type which uses a geodetic coordinate system. Only WGS 84 long lat (SRID:4326) is supported
by the geography data type.</p></td></tr><tr class="question" title="3.4."><td align="left" valign="top"><a name="id36136177"></a><a name="id36136179"></a><p><b>3.4.</b></p></td><td align="left" valign="top"><p>I'm all confused. Which data store should I use geometry or geography?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Short Answer: geography is a new data type that supports long range distances measurements, but most computations on it are currently
slower than they are on geometry. If
you use geography -- you don't need to learn much about planar coordinate systems. Geography is generally best
if all you care about is measuring distances and lengths and you have data from all over the world.
Geometry data type is an older data type that has many more functions supporting it, enjoys greater support from third party tools,
and operations on it are generally faster -- sometimes as much as 10 fold faster for larger geometries.
Geometry is best if you are pretty comfortable with spatial reference systems or you are dealing with localized data
where all your data fits in a single <a class="link" href="#spatial_ref_sys" title="4.3.1.The SPATIAL_REF_SYS Table and Spatial Reference Systems">spatial reference system (SRID)</a>, or you need to do a lot of spatial processing.
Note: It is fairly easy to do one-off conversions between the two types to gain the benefits of each.
Refer to <a class="xref" href="#PostGIS_TypeFunctionMatrix" title="8.8.PostGIS Function Support Matrix">Section8.8, “PostGIS Function Support Matrix”</a> to see what is currently supported and what is not.
</p><p>
Long Answer: Refer to our more lengthy discussion in the <a class="xref" href="#PostGIS_GeographyVSGeometry" title="4.2.2.When to use Geography Data type over Geometry data type">Section4.2.2, “When to use Geography Data type over Geometry data type”</a> and <a class="link" href="#PostGIS_TypeFunctionMatrix" title="8.8.PostGIS Function Support Matrix">function type matrix</a>.
</p></td></tr><tr class="question" title="3.5."><td align="left" valign="top"><a name="id36136218"></a><a name="id36136220"></a><p><b>3.5.</b></p></td><td align="left" valign="top"><p>I have more intense questions about geography, such as how big of a geographic region can I stuff in a geography column and
still get reasonable answers. Are there limitations such as poles, everything in the field must fit in a hemisphere (like SQL Server 2008 has), speed etc?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Your questions are too deep and complex to be adequately answered in this section. Please refer to our
<a class="xref" href="#PostGIS_Geography_AdvancedFAQ" title="4.2.3.Geography Advanced FAQ">Section4.2.3, “Geography Advanced FAQ”</a> .</p></td></tr><tr class="question" title="3.6."><td align="left" valign="top"><a name="id36136241"></a><a name="id36136243"></a><p><b>3.6.</b></p></td><td align="left" valign="top"><p>How do I insert a GIS object into the database?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>First, you need to create a table with a column of type
"geometry" or "geography" to hold your GIS data.
Storing geography type data is a little different than storing geometry. Refer
to <a class="xref" href="#Geography_Basics" title="4.2.1.Geography Basics">Section4.2.1, “Geography Basics”</a> for details on storing geography. </p><p>
For geometry: Connect to your database with
<code class="filename">psql</code> and try the following SQL:</p><pre class="programlisting">CREATE TABLE gtest ( ID int4, NAME varchar(20) );
SELECT AddGeometryColumn('', 'gtest','geom',-1,'LINESTRING',2);</pre><p>If the geometry column addition fails, you probably have not
loaded the PostGIS functions and objects into this database. See the
<a class="xref" href="#PGInstall" title="2.4.Installation">Section2.4, “Installation”</a>.</p><p>Then, you can insert a geometry into the table using a SQL
insert statement. The GIS object itself is formatted using the OpenGIS
Consortium "well-known text" format:</p><pre class="programlisting">INSERT INTO gtest (ID, NAME, GEOM)
VALUES (
1,
'First Geometry',
ST_GeomFromText('LINESTRING(2 3,4 5,6 5,7 8)', -1)
);</pre><p>For more information about other GIS objects, see the <a class="link" href="#RefObject" title="4.1.GIS Objects">object reference</a>.</p><p>To view your GIS data in the table:</p><pre class="programlisting">SELECT id, name, ST_AsText(geom) AS geom FROM gtest;</pre><p>The return value should look something like this:</p><pre class="programlisting"> id | name | geom
----+----------------+-----------------------------
1 | First Geometry | LINESTRING(2 3,4 5,6 5,7 8)
(1 row)</pre></td></tr><tr class="question" title="3.7."><td align="left" valign="top"><a name="id36136325"></a><a name="id36136327"></a><p><b>3.7.</b></p></td><td align="left" valign="top"><p>How do I construct a spatial query?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>The same way you construct any other database query, as an SQL
combination of return values, functions, and boolean tests.</p><p>For spatial queries, there are two issues that are important to
keep in mind while constructing your query: is there a spatial index
you can make use of; and, are you doing expensive calculations on a
large number of geometries.</p><p>In general, you will want to use the "intersects operator"
(&&) which tests whether the bounding boxes of features
intersect. The reason the && operator is useful is because if
a spatial index is available to speed up the test, the &&
operator will make use of this. This can make queries much much
faster.</p><p>You will also make use of spatial functions, such as Distance(),
ST_Intersects(), ST_Contains() and ST_Within(), among others, to
narrow down the results of your search. Most spatial queries include
both an indexed test and a spatial function test. The index test
serves to limit the number of return tuples to only tuples that
<span class="emphasis"><em>might</em></span> meet the condition of interest. The spatial
functions are then use to test the condition exactly.</p><pre class="programlisting">SELECT id, the_geom
FROM thetable
WHERE
ST_Contains(the_geom,'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');</pre></td></tr><tr class="question" title="3.8."><td align="left" valign="top"><a name="id36136373"></a><a name="id36136375"></a><p><b>3.8.</b></p></td><td align="left" valign="top"><p>How do I speed up spatial queries on large tables?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Fast queries on large tables is the <span class="emphasis"><em>raison
d'etre</em></span> of spatial databases (along with transaction
support) so having a good index is important.</p><p>To build a spatial index on a table with a
<code class="varname">geometry</code> column, use the "CREATE INDEX" function as
follows:</p><pre class="programlisting">CREATE INDEX [indexname] ON [tablename] USING GIST ( [geometrycolumn] );</pre><p>The "USING GIST" option tells the server to use a GiST
(Generalized Search Tree) index.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>GiST indexes are assumed to be lossy. Lossy indexes uses a
proxy object (in the spatial case, a bounding box) for building the
index.</p></td></tr></table></div><p>You should also ensure that the PostgreSQL query planner has
enough information about your index to make rational decisions about
when to use it. To do this, you have to "gather statistics" on your
geometry tables.</p><p>For PostgreSQL 8.0.x and greater, just run the <span class="command"><strong>VACUUM
ANALYZE</strong></span> command.</p><p>For PostgreSQL 7.4.x and below, run the <span class="command"><strong>SELECT
UPDATE_GEOMETRY_STATS()</strong></span> command.</p></td></tr><tr class="question" title="3.9."><td align="left" valign="top"><a name="id36136440"></a><a name="id36136442"></a><p><b>3.9.</b></p></td><td align="left" valign="top"><p>Why aren't PostgreSQL R-Tree indexes supported?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Early versions of PostGIS used the PostgreSQL R-Tree indexes.
However, PostgreSQL R-Trees have been completely discarded since
version 0.6, and spatial indexing is provided with an R-Tree-over-GiST
scheme.</p><p>Our tests have shown search speed for native R-Tree and GiST to
be comparable. Native PostgreSQL R-Trees have two limitations which
make them undesirable for use with GIS features (note that these
limitations are due to the current PostgreSQL native R-Tree
implementation, not the R-Tree concept in general):</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>R-Tree indexes in PostgreSQL cannot handle features which
are larger than 8K in size. GiST indexes can, using the "lossy"
trick of substituting the bounding box for the feature
itself.</p></li><li class="listitem"><p>R-Tree indexes in PostgreSQL are not "null safe", so
building an index on a geometry column which contains null
geometries will fail.</p></li></ul></div></td></tr><tr class="question" title="3.10."><td align="left" valign="top"><a name="id36136483"></a><a name="id36136485"></a><p><b>3.10.</b></p></td><td align="left" valign="top"><p>Why should I use the <code class="varname">AddGeometryColumn()</code>
function and all the other OpenGIS stuff?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you do not want to use the OpenGIS support functions, you do
not have to. Simply create tables as in older versions, defining your
geometry columns in the CREATE statement. All your geometries will
have SRIDs of -1, and the OpenGIS meta-data tables will
<span class="emphasis"><em>not</em></span> be filled in properly. However, this will
cause most applications based on PostGIS to fail, and it is generally
suggested that you do use <code class="varname">AddGeometryColumn()</code> to
create geometry tables.</p><p>MapServer is one application which makes use of the
<code class="varname">geometry_columns</code> meta-data. Specifically, MapServer
can use the SRID of the geometry column to do on-the-fly reprojection
of features into the correct map projection.</p></td></tr><tr class="question" title="3.11."><td align="left" valign="top"><a name="id36136521"></a><a name="id36136523"></a><p><b>3.11.</b></p></td><td align="left" valign="top"><p>What is the best way to find all objects within a radius of
another object?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>To use the database most efficiently, it is best to do radius
queries which combine the radius test with a bounding box test: the
bounding box test uses the spatial index, giving fast access to a
subset of data which the radius test is then applied to.</p><p>The <code class="varname">ST_DWithin(geometry, geometry, distance)</code>
function is a handy way of performing an indexed distance search. It
works by creating a search rectangle large enough to enclose the
distance radius, then performing an exact distance search on the
indexed subset of results.</p><p>For example, to find all objects with 100 meters of POINT(1000
1000) the following query would work well:</p><pre class="programlisting">SELECT * FROM geotable
WHERE ST_DWithin(geocolumn, 'POINT(1000 1000)', 100.0);</pre></td></tr><tr class="question" title="3.12."><td align="left" valign="top"><a name="id36136559"></a><a name="id36136561"></a><p><b>3.12.</b></p></td><td align="left" valign="top"><p>How do I perform a coordinate reprojection as part of a
query?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>To perform a reprojection, both the source and destination
coordinate systems must be defined in the SPATIAL_REF_SYS table, and
the geometries being reprojected must already have an SRID set on
them. Once that is done, a reprojection is as simple as referring to
the desired destination SRID. The below projects a geometry to NAD 83 long lat.
The below will only work if the srid of the_geom is not -1 (not undefined spatial ref)</p><pre class="programlisting">SELECT ST_Transform(the_geom,4269) FROM geotable;</pre></td></tr><tr class="question" title="3.13."><td align="left" valign="top"><a name="id36136585"></a><a name="id36136588"></a><p><b>3.13.</b></p></td><td align="left" valign="top"><p>I did an ST_AsEWKT and ST_AsText on my rather large geometry and it returned blank field. What gives?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>You are probably using PgAdmin or some other tool that doesn't output large text. If your geometry is big
enough, it will appear blank in these tools. Use PSQL if you really need to see it or output it in WKT.</p><pre class="programlisting">
--To check number of geometries are really blank
SELECT count(gid) FROM geotable WHERE the_geom IS NULL;</pre></td></tr><tr class="question" title="3.14."><td align="left" valign="top"><a name="id36136610"></a><a name="id36136612"></a><p><b>3.14.</b></p></td><td align="left" valign="top"><p>When I do an ST_Intersects, it says my two geometries don't intersect when I KNOW THEY DO. What gives?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>This generally happens in two common cases. Your geometry is invalid -- check <a class="xref" href="#ST_IsValid" title="ST_IsValid">ST_IsValid</a>
or you are assuming they intersect because ST_AsText truncates the numbers and you have lots of decimals after
it is not showing you.</p></td></tr></tbody></table></div></div><div class="chapter" title="Chapter4.Using PostGIS: Data Management and Queries"><div class="titlepage"><div><div><h2 class="title"><a name="id36137207"></a>Chapter4.Using PostGIS: Data Management and Queries</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#RefObject">4.1. GIS Objects</a></span></dt><dd><dl><dt><span class="sect2"><a href="#OpenGISWKBWKT">4.1.1. OpenGIS WKB and WKT</a></span></dt><dt><span class="sect2"><a href="#EWKB_EWKT">4.1.2. PostGIS EWKB, EWKT and Canonical Forms</a></span></dt><dt><span class="sect2"><a href="#SQL_MM_Part3">4.1.3. SQL-MM Part 3</a></span></dt></dl></dd><dt><span class="sect1"><a href="#PostGIS_Geography">4.2. PostGIS Geography Type</a></span></dt><dd><dl><dt><span class="sect2"><a href="#Geography_Basics">4.2.1. Geography Basics</a></span></dt><dt><span class="sect2"><a href="#PostGIS_GeographyVSGeometry">4.2.2. When to use Geography Data type over Geometry data type</a></span></dt><dt><span class="sect2"><a href="#PostGIS_Geography_AdvancedFAQ">4.2.3. Geography Advanced FAQ</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36137988">4.3. Using OpenGIS Standards</a></span></dt><dd><dl><dt><span class="sect2"><a href="#spatial_ref_sys">4.3.1. The SPATIAL_REF_SYS Table and Spatial Reference Systems</a></span></dt><dt><span class="sect2"><a href="#geometry_columns">4.3.2. The GEOMETRY_COLUMNS Table</a></span></dt><dt><span class="sect2"><a href="#Create_Spatial_Table">4.3.3. Creating a Spatial Table</a></span></dt><dt><span class="sect2"><a href="#Manual_Register_Spatial_Column">4.3.4. Manually Registering Geometry Columns in geometry_columns</a></span></dt><dt><span class="sect2"><a href="#OGC_Validity">4.3.5. Ensuring OpenGIS compliancy of geometries</a></span></dt><dt><span class="sect2"><a href="#DE-9IM">4.3.6. Dimensionally Extended 9 Intersection Model (DE-9IM)</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36140438">4.4. Loading GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36140449">4.4.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#shp2pgsql_usage">4.4.2. Using the Loader</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36140779">4.5. Retrieving GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36140925">4.5.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id36141047">4.5.2. Using the Dumper</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36141205">4.6. Building Indexes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36141247">4.6.1. GiST Indexes</a></span></dt><dt><span class="sect2"><a href="#id36141296">4.6.2. Using Indexes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36141388">4.7. Complex Queries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36141402">4.7.1. Taking Advantage of Indexes</a></span></dt><dt><span class="sect2"><a href="#id36141469">4.7.2. Examples of Spatial SQL</a></span></dt></dl></dd></dl></div><div class="sect1" title="4.1.GIS Objects"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="RefObject"></a>4.1.GIS Objects</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#OpenGISWKBWKT">4.1.1. OpenGIS WKB and WKT</a></span></dt><dt><span class="sect2"><a href="#EWKB_EWKT">4.1.2. PostGIS EWKB, EWKT and Canonical Forms</a></span></dt><dt><span class="sect2"><a href="#SQL_MM_Part3">4.1.3. SQL-MM Part 3</a></span></dt></dl></div><p>The GIS objects supported by PostGIS are a superset of the "Simple
Features" defined by the OpenGIS Consortium (OGC). As of version 0.9,
PostGIS supports all the objects and functions specified in the OGC
"Simple Features for SQL" specification.</p><p>PostGIS extends the standard with support for 3DZ,3DM and 4D
coordinates.</p><div class="sect2" title="4.1.1.OpenGIS WKB and WKT"><div class="titlepage"><div><div><h3 class="title"><a name="OpenGISWKBWKT"></a>4.1.1.OpenGIS WKB and WKT</h3></div></div></div><p>The OpenGIS specification defines two standard ways of expressing
spatial objects: the Well-Known Text (WKT) form and the Well-Known
Binary (WKB) form. Both WKT and WKB include information about the type
of the object and the coordinates which form the object.</p><p>Examples of the text representations (WKT) of the spatial objects
of the features are as follows:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>POINT(0 0)</p></li><li class="listitem"><p>LINESTRING(0 0,1 1,1 2)</p></li><li class="listitem"><p>POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))</p></li><li class="listitem"><p>MULTIPOINT(0 0,1 2)</p></li><li class="listitem"><p>MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4))</p></li><li class="listitem"><p>MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)),
((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))</p></li><li class="listitem"><p>GEOMETRYCOLLECTION(POINT(2 3),LINESTRING(2 3,3 4))</p></li></ul></div><p>The OpenGIS specification also requires that the internal storage
format of spatial objects include a spatial referencing system
identifier (SRID). The SRID is required when creating spatial objects
for insertion into the database.</p><p>Input/Output of these formats are available using the following
interfaces:</p><pre class="programlisting">bytea WKB = ST_AsBinary(geometry);
text WKT = ST_AsText(geometry);
geometry = ST_GeomFromWKB(bytea WKB, SRID);
geometry = ST_GeometryFromText(text WKT, SRID);</pre><p>For example, a valid insert statement to create and insert an OGC
spatial object would be:</p><pre class="programlisting">INSERT INTO geotable ( the_geom, the_name )
VALUES ( ST_GeomFromText('POINT(-126.4 45.32)', 312), 'A Place');</pre></div><div class="sect2" title="4.1.2.PostGIS EWKB, EWKT and Canonical Forms"><div class="titlepage"><div><div><h3 class="title"><a name="EWKB_EWKT"></a>4.1.2.PostGIS EWKB, EWKT and Canonical Forms</h3></div></div></div><p>OGC formats only support 2d geometries, and the associated SRID is
*never* embedded in the input/output representations.</p><p>PostGIS extended formats are currently superset of OGC one (every
valid WKB/WKT is a valid EWKB/EWKT) but this might vary in the future,
specifically if OGC comes out with a new format conflicting with our
extensions. Thus you SHOULD NOT rely on this feature!</p><p>PostGIS EWKB/EWKT add 3dm,3dz,4d coordinates support and embedded
SRID information.</p><p>Examples of the text representations (EWKT) of the extended
spatial objects of the features are as follows:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>POINT(0 0 0) -- XYZ</p></li><li class="listitem"><p>SRID=32632;POINT(0 0) -- XY with SRID</p></li><li class="listitem"><p>POINTM(0 0 0) -- XYM</p></li><li class="listitem"><p>POINT(0 0 0 0) -- XYZM</p></li><li class="listitem"><p>SRID=4326;MULTIPOINTM(0 0 0,1 2 1) -- XYM with SRID</p></li><li class="listitem"><p>MULTILINESTRING((0 0 0,1 1 0,1 2 1),(2 3 1,3 2 1,5 4
1))</p></li><li class="listitem"><p>POLYGON((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2 0,1 2
0,1 1 0))</p></li><li class="listitem"><p>MULTIPOLYGON(((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2
0,1 2 0,1 1 0)),((-1 -1 0,-1 -2 0,-2 -2 0,-2 -1 0,-1 -1 0)))</p></li><li class="listitem"><p>GEOMETRYCOLLECTIONM(POINTM(2 3 9), LINESTRINGM(2 3 4, 3 4
5))</p></li></ul></div><p>Input/Output of these formats are available using the following
interfaces:</p><pre class="programlisting">bytea EWKB = ST_AsEWKB(geometry);
text EWKT = ST_AsEWKT(geometry);
geometry = ST_GeomFromEWKB(bytea EWKB);
geometry = ST_GeomFromEWKT(text EWKT);</pre><p>For example, a valid insert statement to create and insert a
PostGIS spatial object would be:</p><pre class="programlisting">INSERT INTO geotable ( the_geom, the_name )
VALUES ( ST_GeomFromEWKT('SRID=312;POINTM(-126.4 45.32 15)'), 'A Place' )</pre><p>The "canonical forms" of a PostgreSQL type are the representations
you get with a simple query (without any function call) and the one
which is guaranteed to be accepted with a simple insert, update or copy.
For the postgis 'geometry' type these are: </p><pre class="programlisting">- Output
- binary: EWKB
ascii: HEXEWKB (EWKB in hex form)
- Input
- binary: EWKB
ascii: HEXEWKB|EWKT </pre><p>For example this statement reads EWKT and returns HEXEWKB in the
process of canonical ascii input/output:</p><pre class="programlisting">=# SELECT 'SRID=4;POINT(0 0)'::geometry;
geometry
----------------------------------------------------
01010000200400000000000000000000000000000000000000
(1 row)</pre></div><div class="sect2" title="4.1.3.SQL-MM Part 3"><div class="titlepage"><div><div><h3 class="title"><a name="SQL_MM_Part3"></a>4.1.3.SQL-MM Part 3</h3></div></div></div><p>The SQL Multimedia Applications Spatial specification extends the
simple features for SQL spec by defining a number of circularly
interpolated curves.</p><p>The SQL-MM definitions include 3dm, 3dz and 4d coordinates, but do
not allow the embedding of SRID information.</p><p>The well-known text extensions are not yet fully supported.
Examples of some simple curved geometries are shown below:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>CIRCULARSTRING(0 0, 1 1, 1 0)</p><p>CIRCULARSTRING(0 0, 4 0, 4 4, 0 4, 0 0)</p><p>The CIRCULARSTRING is the basic curve type, similar to a
LINESTRING in the linear world. A single segment required three
points, the start and end points (first and third) and any other
point on the arc. The exception to this is for a closed circle,
where the start and end points are the same. In this case the
second point MUST be the center of the arc, ie the opposite side of
the circle. To chain arcs together, the last point of the previous
arc becomes the first point of the next arc, just like in
LINESTRING. This means that a valid circular string must have an
odd number of points greated than 1.</p></li><li class="listitem"><p>COMPOUNDCURVE(CIRCULARSTRING(0 0, 1 1, 1 0),(1 0, 0 1))</p><p>A compound curve is a single, continuous curve that has both
curved (circular) segments and linear segments. That means that
in addition to having well-formed components, the end point of
every component (except the last) must be coincident with the
start point of the following component.</p></li><li class="listitem"><p>CURVEPOLYGON(CIRCULARSTRING(0 0, 4 0, 4 4, 0 4, 0 0),(1 1, 3
3, 3 1, 1 1))</p><p>Example compound curve in a curve polygon:
CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0,2 0, 2 1, 2 3, 4 3),(4 3, 4 5, 1 4, 0 0)),
CIRCULARSTRING(1.7 1, 1.4 0.4, 1.6 0.4, 1.6 0.5, 1.7 1) )
</p><p>A CURVEPOLYGON is just like a polygon, with an outer ring
and zero or more inner rings. The difference is that a ring can
take the form of a circular string, linear string or compound
string.</p><p>As of PostGIS 1.4 PostGIS supports compound curves in a curve polygon.</p></li><li class="listitem"><p>MULTICURVE((0 0, 5 5),CIRCULARSTRING(4 0, 4 4, 8 4))</p><p>The MULTICURVE is a collection of curves, which can include
linear strings, circular strings or compound strings.</p></li><li class="listitem"><p>MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(0 0, 4 0, 4 4, 0 4, 0
0),(1 1, 3 3, 3 1, 1 1)),((10 10, 14 12, 11 10, 10 10),(11 11, 11.5
11, 11 11.5, 11 11)))</p><p>This is a collection of surfaces, which can be (linear)
polygons or curve polygons.</p></li></ul></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>PostGIS prior to 1.4 does not support compound curves in a curve polygon, but
PostGIS 1.4 and above do support the use of Compound Curves in
a Curve Polygon.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>All floating point comparisons within the SQL-MM implementation
are performed to a specified tolerance, currently 1E-8.</p></td></tr></table></div></div></div><div class="sect1" title="4.2.PostGIS Geography Type"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PostGIS_Geography"></a>4.2.PostGIS Geography Type</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#Geography_Basics">4.2.1. Geography Basics</a></span></dt><dt><span class="sect2"><a href="#PostGIS_GeographyVSGeometry">4.2.2. When to use Geography Data type over Geometry data type</a></span></dt><dt><span class="sect2"><a href="#PostGIS_Geography_AdvancedFAQ">4.2.3. Geography Advanced FAQ</a></span></dt></dl></div><p>The geography type provides native support for spatial features represented on "geographic" coordinates (sometimes called "geodetic" coordinates, or "lat/lon", or "lon/lat"). Geographic coordinates are spherical coordinates expressed in angular units (degrees). </p><p>The basis for the PostGIS geometry type is a plane. The shortest path between two points on the plane is a straight line. That means calculations on geometries (areas, distances, lengths, intersections, etc) can be calculated using cartesian mathematics and straight line vectors.</p><p>The basis for the PostGIS geographic type is a sphere. The shortest path between two points on the sphere is a great circle arc. That means that calculations on geographies (areas, distances, lengths, intersections, etc) must be calculated on the sphere, using more complicated mathematics. For more accurate measurements, the calculations must take the actual spheroidal shape of the world into account, and the mathematics becomes very complicated indeed.</p><p>Because the underlying mathematics is much more complicated, there are fewer functions defined for the geography type than for the geometry type. Over time, as new algorithms are added, the capabilities of the geography type will expand.</p><p>One restriction is that it only supports WGS 84 long lat (SRID:4326). It uses a new data type called
geography. I None of the GEOS functions support this new
type. As a workaround one can convert back and forth between geometry and geography types.</p><p>The new geography type uses the PostgreSQL 8.3+ typmod definition format so that a table with a geography field
can be added in a single step. All the standard OGC formats except for curves are supported.</p><div class="sect2" title="4.2.1.Geography Basics"><div class="titlepage"><div><div><h3 class="title"><a name="Geography_Basics"></a>4.2.1.Geography Basics</h3></div></div></div><p>The geography type only supports the simplest of simple features. Standard geometry type data will autocast to geography if it is of SRID 4326. You can also use the EWKT and EWKB
conventions to insert data.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>POINT: Creating a table with 2d point geometry:</p><pre class="programlisting">CREATE TABLE testgeog(gid serial PRIMARY KEY, the_geog geography(POINT,4326) );</pre><p>Creating a table with z coordinate point</p><pre class="programlisting">CREATE TABLE testgeog(gid serial PRIMARY KEY, the_geog geography(POINTZ,4326) );</pre></li><li class="listitem"><p>LINESTRING</p></li><li class="listitem"><p>POLYGON</p></li><li class="listitem"><p>MULTIPOINT</p></li><li class="listitem"><p>MULTILINESTRING</p></li><li class="listitem"><p>MULTIPOLYGON</p></li><li class="listitem"><p>GEOMETRYCOLLECTION</p></li></ul></div><p>The new geography fields don't get registered in the geometry_columns. They get registered in a new view called
geography_columns which is a view against the system catalogs so is always automatically kept up to date without need
for an AddGeom... like function.</p><p>Now, check the "geography_columns" view and see that your table is listed.</p><p>You can create a new table with a GEOGRAPHY column using the CREATE TABLE syntax.
Unlike GEOMETRY, there is no need to run a separate AddGeometryColumns() process to register the column in metadata.</p><p>
</p><pre class="programlisting">CREATE TABLE global_points (
id SERIAL PRIMARY KEY,
name VARCHAR(64),
location GEOGRAPHY(POINT,4326)
);</pre><p>
</p><p>Note that the location column has type GEOGRAPHY and that geography type supports two optional modifier: a type modifier that restricts the kind of shapes and dimensions allowed in the column; an SRID modifier that restricts the coordinate reference identifier to a particular number.</p><p>Allowable values for the type modifier are: POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON. The modifier also supports dimensionality restrictions through suffixes: Z, M and ZM. So, for example a modifier of 'LINESTRINGM' would only allow line strings with three dimensions in, and would treat the third dimension as a measure.
Similarly, 'POINTZM' would expect four dimensional data.</p><p>The SRID modifier is currently of limited use: only 4326 (WGS84) is allowed as a value. If you do not specify an SRID, the a value 0 (undefined spheroid) will be used, and all calculations will proceed using WGS84 anyways.</p><p>In the future, alternate SRIDs will allow calculations on spheroids other than WGS84.</p><p>Once you have created your table, you can see it in the GEOGRAPHY_COLUMNS table:</p><pre class="programlisting">
-- See the contents of the metadata view
SELECT * FROM geography_columns;</pre><p>You can insert data into the table the same as you would if it was using a GEOMETRY column:</p><pre class="programlisting">-- Add some data into the test table
INSERT INTO global_points (name, location) VALUES ('Town', ST_GeographyFromText('SRID=4326;POINT(-110 30)') );
INSERT INTO global_points (name, location) VALUES ('Forest', ST_GeographyFromText('SRID=4326;POINT(-109 29)') );
INSERT INTO global_points (name, location) VALUES ('London', ST_GeographyFromText('SRID=4326;POINT(0 49)') );</pre><p>Creating an index works the same as GEOMETRY.
PostGIS will note that the column type is GEOGRAPHY and create an appropriate sphere-based index instead of the usual planar index used for GEOMETRY.</p><pre class="programlisting">-- Index the test table with a spherical index
CREATE INDEX global_points_gix ON global_points USING GIST ( location );</pre><p>
</p><p>Query and measurement functions use units of meters. So distance parameters should be expressed in meters, and return values should be expected in meters (or square meters for areas).</p><pre class="programlisting">-- Show a distance query and note, London is outside the 1000km tolerance
SELECT name FROM global_points WHERE ST_DWithin(location, ST_GeographyFromText('SRID=4326;POINT(-110 29)'), 1000000);</pre><p>
</p><p>You can see the power of GEOGRAPHY in action by calculating the how close a plane flying from Seattle to London (LINESTRING(-122.33 47.606, 0.0 51.5)) comes to Reykjavik (POINT(-21.96 64.15)).</p><pre class="programlisting">-- Distance calculation using GEOGRAPHY (122.2km)
SELECT ST_Distance('LINESTRING(-122.33 47.606, 0.0 51.5)'::geography, 'POINT(-21.96 64.15)':: geography);</pre><p>
</p><pre class="programlisting">-- Distance calculation using GEOMETRY (13.3 "degrees")
SELECT ST_Distance('LINESTRING(-122.33 47.606, 0.0 51.5)'::geometry, 'POINT(-21.96 64.15)':: geometry);</pre><p>
</p><p>The GEOGRAPHY type calculates the true shortest distance over the sphere between Reykjavik and the great circle flight path between Seattle and London.</p><p> <a class="ulink" href="http://gc.kls2.com/cgi-bin/gc?PATH=SEA-LHR" target="_top">Great Circle mapper</a>
The GEOMETRY type calculates a meaningless cartesian distance between Reykjavik and the straight line path from Seattle to London plotted on a flat map of the world. The nominal units of the result might be called "degrees", but the result doesn't correspond to any true angular difference between the points, so even calling them "degrees" is inaccurate.</p></div><div class="sect2" title="4.2.2.When to use Geography Data type over Geometry data type"><div class="titlepage"><div><div><h3 class="title"><a name="PostGIS_GeographyVSGeometry"></a>4.2.2.When to use Geography Data type over Geometry data type</h3></div></div></div><p>The new GEOGRAPHY type allows you to store data in longitude/latitude coordinates, but at a cost: there are fewer functions defined on GEOGRAPHY than there are on GEOMETRY; those functions that are defined take more CPU time to execute.</p><p>The type you choose should be conditioned on the expected working area of the application you are building. Will your data span the globe or a large continental area, or is it local to a state, county or municipality? </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">If your data is contained in a small area, you might find that choosing an appropriate projection and using GEOMETRY is the best solution, in terms of performance and functionality available.</li><li class="listitem">If your data is global or covers a continental region, you may find that GEOGRAPHY allows you to build a system without having to worry about projection details.
You store your data in longitude/latitude, and use the functions that have been defined on GEOGRAPHY.</li><li class="listitem">If you don't understand projections, and you don't want to learn about them, and you're prepared to accept the limitations in functionality available in GEOGRAPHY, then it might be easier for you to use GEOGRAPHY than GEOMETRY.
Simply load your data up as longitude/latitude and go from there.</li></ul></div><p>Refer to <a class="xref" href="#PostGIS_TypeFunctionMatrix" title="8.8.PostGIS Function Support Matrix">Section8.8, “PostGIS Function Support Matrix”</a> for compare between
what is supported for Geography vs. Geometry. For a brief listing and description of Geography functions, refer to
<a class="xref" href="#PostGIS_GeographyFunctions" title="8.3.PostGIS Geography Support Functions">Section8.3, “PostGIS Geography Support Functions”</a>
</p></div><div class="sect2" title="4.2.3.Geography Advanced FAQ"><div class="titlepage"><div><div><h3 class="title"><a name="PostGIS_Geography_AdvancedFAQ"></a>4.2.3.Geography Advanced FAQ</h3></div></div></div><div class="qandaset" title="Frequently Asked Questions"><a name="id36137891"></a><dl><dt>4.2.3.1. <a href="#id36137893">Do you calculate on the sphere or the spheroid?</a></dt><dt>4.2.3.2. <a href="#id36137917">What about the date-line and the poles?</a></dt><dt>4.2.3.3. <a href="#id36137935">What is the longest arc you can process?</a></dt><dt>4.2.3.4. <a href="#id36137958">Why is it so slow to calculate the area of Europe / Russia / insert big geographic region here ?</a></dt></dl><table border="0" width="100%" summary="Q and A Set"><col align="left" width="1%"><col><tbody><tr class="question" title="4.2.3.1."><td align="left" valign="top"><a name="id36137893"></a><a name="id36137895"></a><p><b>4.2.3.1.</b></p></td><td align="left" valign="top"><p>Do you calculate on the sphere or the spheroid?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> By default, all distance and area calculations are done on the spheroid. You should find that the results of calculations in local areas match up will with local planar results in good local projections.
Over larger areas, the spheroidal calculations will be more accurate than any calculation done on a projected plane.
</p><p>All the geography functions have the option of using a sphere calculation, by setting a final boolean parameter to 'FALSE'. This will somewhat speed up calculations, particularly for cases where the geometries are very simple.</p></td></tr><tr class="question" title="4.2.3.2."><td align="left" valign="top"><a name="id36137917"></a><a name="id36137919"></a><p><b>4.2.3.2.</b></p></td><td align="left" valign="top"><p>What about the date-line and the poles?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> All the calculations have no conception of date-line or poles, the coordinates are spherical (longitude/latitude)
so a shape that crosses the dateline is, from a calculation point of view, no different from any other shape.
</p></td></tr><tr class="question" title="4.2.3.3."><td align="left" valign="top"><a name="id36137935"></a><a name="id36137937"></a><p><b>4.2.3.3.</b></p></td><td align="left" valign="top"><p>What is the longest arc you can process?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>We use great circle arcs as the "interpolation line" between two points. That means any two points are actually joined up two ways, depending on which direction you travel along the great circle. All our code assumes that the points are joined by the *shorter* of the two paths along the great circle.
As a consequence, shapes that have arcs of more than 180 degrees will not be correctly modelled.</p></td></tr><tr class="question" title="4.2.3.4."><td align="left" valign="top"><a name="id36137958"></a><a name="id36137961"></a><p><b>4.2.3.4.</b></p></td><td align="left" valign="top"><p>Why is it so slow to calculate the area of Europe / Russia / insert big geographic region here ?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Because the polygon is so darned huge! Big areas are bad for two reasons: their bounds are huge,
so the index tends to pull the feature no matter what query you run; the number of vertices is huge,
and tests (distance, containment) have to traverse the vertex list at least once and sometimes N times
(with N being the number of vertices in the other candidate feature).
</p><p>As with GEOMETRY, we recommend that when you have very large polygons, but are doing queries in small areas, you "denormalize" your geometric data into smaller chunks so that the index can effectively subquery parts of the object and so queries don't have to pull out the whole object every time.
Just because you *can* store all of Europe in one polygon doesn't mean you *should*.</p></td></tr></tbody></table></div></div></div><div class="sect1" title="4.3.Using OpenGIS Standards"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36137988"></a>4.3.Using OpenGIS Standards</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#spatial_ref_sys">4.3.1. The SPATIAL_REF_SYS Table and Spatial Reference Systems</a></span></dt><dt><span class="sect2"><a href="#geometry_columns">4.3.2. The GEOMETRY_COLUMNS Table</a></span></dt><dt><span class="sect2"><a href="#Create_Spatial_Table">4.3.3. Creating a Spatial Table</a></span></dt><dt><span class="sect2"><a href="#Manual_Register_Spatial_Column">4.3.4. Manually Registering Geometry Columns in geometry_columns</a></span></dt><dt><span class="sect2"><a href="#OGC_Validity">4.3.5. Ensuring OpenGIS compliancy of geometries</a></span></dt><dt><span class="sect2"><a href="#DE-9IM">4.3.6. Dimensionally Extended 9 Intersection Model (DE-9IM)</a></span></dt></dl></div><p>The OpenGIS "Simple Features Specification for SQL" defines standard
GIS object types, the functions required to manipulate them, and a set of
meta-data tables. In order to ensure that meta-data remain consistent,
operations such as creating and removing a spatial column are carried out
through special procedures defined by OpenGIS.</p><p>There are two OpenGIS meta-data tables:
<code class="varname">SPATIAL_REF_SYS</code> and
<code class="varname">GEOMETRY_COLUMNS</code>. The
<code class="varname">SPATIAL_REF_SYS</code> table holds the numeric IDs and textual
descriptions of coordinate systems used in the spatial database.</p><div class="sect2" title="4.3.1.The SPATIAL_REF_SYS Table and Spatial Reference Systems"><div class="titlepage"><div><div><h3 class="title"><a name="spatial_ref_sys"></a>4.3.1.The SPATIAL_REF_SYS Table and Spatial Reference Systems</h3></div></div></div><p>The spatial_ref_sys table is a PostGIS included and OGC compliant database table that lists over 3000
known <a class="ulink" href="http://www.sharpgis.net/post/2007/05/Spatial-references2c-coordinate-systems2c-projections2c-datums2c-ellipsoids-e28093-confusing.aspx" target="_top">spatial reference systems</a>
and details needed to transform/reproject between them.</p><p>Although the PostGIS spatial_ref_sys table contains over 3000 of the more commonly used spatial reference system definitions that can be handled by the proj library, it does not contain all known to man and
you can even define your own custom projection if you are familiar with proj4 constructs. Keep in mind that most spatial reference systems are regional and have no meaning when used outside of the bounds they were intended for.</p><p>An excellent resource for finding spatial reference systems not defined in the core set is <a class="ulink" href="http://spatialreference.org/" target="_top">http://spatialreference.org/</a></p><p>Some of the more commonly used spatial reference systems are: <a class="ulink" href="http://spatialreference.org/ref/epsg/4326/" target="_top">4326 - WGS 84 Long Lat</a>,
<a class="ulink" href="http://spatialreference.org/ref/epsg/4269/" target="_top">4269 - NAD 83 Long Lat</a>,
<a class="ulink" href="http://spatialreference.org/ref/epsg/3395/" target="_top">3395 - WGS 84 World Mercator</a>,
<a class="ulink" href="http://spatialreference.org/ref/epsg/2163/" target="_top">2163 - US National Atlas Equal Area</a>,
Spatial reference systems for each NAD 83, WGS 84 UTM zone - UTM zones are one of the most ideal for measurement, but only cover 6-degree regions.
</p><p>
Various US state plane spatial reference systems (meter or feet based) - usually one or 2 exists per US state. Most of the meter ones are in the core set, but many of the
feet based ones or ESRI created ones you will need to pull from <a class="ulink" href="http://spatialreference.org" target="_top">spatialreference.org</a>.
</p><p>
For details on determining which UTM zone to use for your area of interest, check out the <a class="ulink" href="http://trac.osgeo.org/postgis/wiki/UsersWikiplpgsqlfunctionsDistance" target="_top">utmzone PostGIS plpgsql helper function</a>.
</p><p>The <code class="varname">SPATIAL_REF_SYS</code> table definition is as
follows:</p><pre class="programlisting">CREATE TABLE spatial_ref_sys (
srid INTEGER NOT NULL PRIMARY KEY,
auth_name VARCHAR(256),
auth_srid INTEGER,
srtext VARCHAR(2048),
proj4text VARCHAR(2048)
)</pre><p>The <code class="varname">SPATIAL_REF_SYS</code> columns are as
follows:</p><div class="variablelist"><dl><dt><span class="term"><a class="ulink" href="http://en.wikipedia.org/wiki/SRID" target="_top">SRID</a></span></dt><dd><p>An integer value that uniquely identifies the Spatial
Referencing System (SRS) within the database.</p></dd><dt><span class="term">AUTH_NAME</span></dt><dd><p>The name of the standard or standards body that is being
cited for this reference system. For example, "EPSG" would be a
valid <code class="varname">AUTH_NAME</code>.</p></dd><dt><span class="term">AUTH_SRID</span></dt><dd><p>The ID of the Spatial Reference System as defined by the
Authority cited in the <code class="varname">AUTH_NAME</code>. In the case
of EPSG, this is where the EPSG projection code would go.</p></dd><dt><span class="term">SRTEXT</span></dt><dd><p>The Well-Known Text representation of the Spatial Reference
System. An example of a WKT SRS representation is:</p><pre class="programlisting">PROJCS["NAD83 / UTM Zone 10N",
GEOGCS["NAD83",
DATUM["North_American_Datum_1983",
SPHEROID["GRS 1980",6378137,298.257222101]
],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]
],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-123],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1]
]</pre><p>For a listing of EPSG projection codes and their
corresponding WKT representations, see <a class="ulink" href="http://www.opengeospatial.org/" target="_top">http://www.opengeospatial.org/</a>.
For a discussion of WKT in general, see the OpenGIS "Coordinate
Transformation Services Implementation Specification" at <a class="ulink" href="http://www.opengeospatial.org/standards" target="_top">http://www.opengeospatial.org/standards</a>.
For information on the European Petroleum Survey Group (EPSG) and
their database of spatial reference systems, see <a class="ulink" href="http://www.epsg.org/" target="_top">http://www.epsg.org</a>.</p></dd><dt><span class="term">PROJ4TEXT</span></dt><dd><p>PostGIS uses the Proj4 library to provide coordinate
transformation capabilities. The <code class="varname">PROJ4TEXT</code>
column contains the Proj4 coordinate definition string for a
particular SRID. For example:</p><pre class="programlisting">+proj=utm +zone=10 +ellps=clrk66 +datum=NAD27 +units=m</pre><p>For more information about, see the Proj4 web site at <a class="ulink" href="http://trac.osgeo.org/proj/" target="_top">http://trac.osgeo.org/proj/</a>.
The <code class="filename">spatial_ref_sys.sql</code> file contains both
<code class="varname">SRTEXT</code> and <code class="varname">PROJ4TEXT</code>
definitions for all EPSG projections.</p></dd></dl></div></div><div class="sect2" title="4.3.2.The GEOMETRY_COLUMNS Table"><div class="titlepage"><div><div><h3 class="title"><a name="geometry_columns"></a>4.3.2.The GEOMETRY_COLUMNS Table</h3></div></div></div><p>The <code class="varname">GEOMETRY_COLUMNS</code> table definition is as
follows:</p><pre class="programlisting">CREATE TABLE geometry_columns (
f_table_catalog VARRCHAR(256) NOT NULL,
f_table_schema VARCHAR(256) NOT NULL,
f_table_name VARCHAR(256) NOT NULL,
f_geometry_column VARCHAR(256) NOT NULL,
coord_dimension INTEGER NOT NULL,
srid INTEGER NOT NULL,
type VARCHAR(30) NOT NULL
)</pre><p>The columns are as follows:</p><div class="variablelist"><dl><dt><span class="term">F_TABLE_CATALOG, F_TABLE_SCHEMA, F_TABLE_NAME</span></dt><dd><p>The fully qualified name of the feature table containing the
geometry column. Note that the terms "catalog" and "schema" are
Oracle-ish. There is not PostgreSQL analogue of "catalog" so that
column is left blank -- for "schema" the PostgreSQL schema name is
used (<code class="varname">public</code> is the default).</p></dd><dt><span class="term">F_GEOMETRY_COLUMN</span></dt><dd><p>The name of the geometry column in the feature table.</p></dd><dt><span class="term">COORD_DIMENSION</span></dt><dd><p>The spatial dimension (2, 3 or 4 dimensional) of the
column.</p></dd><dt><span class="term">SRID</span></dt><dd><p>The ID of the spatial reference system used for the
coordinate geometry in this table. It is a foreign key reference
to the <code class="varname">SPATIAL_REF_SYS</code>.</p></dd><dt><span class="term">TYPE</span></dt><dd><p>The type of the spatial object. To restrict the spatial
column to a single type, use one of: POINT, LINESTRING, POLYGON,
MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION or
corresponding XYM versions POINTM, LINESTRINGM, POLYGONM,
MULTIPOINTM, MULTILINESTRINGM, MULTIPOLYGONM, GEOMETRYCOLLECTIONM.
For heterogeneous (mixed-type) collections, you can use "GEOMETRY"
as the type.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This attribute is (probably) not part of the OpenGIS
specification, but is required for ensuring type
homogeneity.</p></td></tr></table></div></dd></dl></div></div><div class="sect2" title="4.3.3.Creating a Spatial Table"><div class="titlepage"><div><div><h3 class="title"><a name="Create_Spatial_Table"></a>4.3.3.Creating a Spatial Table</h3></div></div></div><p>Creating a table with spatial data is done in two stages:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Create a normal non-spatial table.</p><p>For example: <span class="command"><strong>CREATE TABLE ROADS_GEOM ( ID int4, NAME
varchar(25) )</strong></span></p></li><li class="listitem"><p>Add a spatial column to the table using the OpenGIS
"AddGeometryColumn" function.</p><p>The syntax is: </p><pre class="programlisting">AddGeometryColumn(
<schema_name>,
<table_name>,
<column_name>,
<srid>,
<type>,
<dimension>
)</pre><p> Or, using current schema: </p><pre class="programlisting">AddGeometryColumn(
<table_name>,
<column_name>,
<srid>,
<type>,
<dimension>
)</pre><p>Example1: <span class="command"><strong>SELECT AddGeometryColumn('public',
'roads_geom', 'geom', 423, 'LINESTRING', 2)</strong></span></p><p>Example2: <span class="command"><strong>SELECT AddGeometryColumn( 'roads_geom',
'geom', 423, 'LINESTRING', 2)</strong></span></p></li></ul></div><p>Here is an example of SQL used to create a table and add a spatial
column (assuming that an SRID of 128 exists already):</p><pre class="programlisting">CREATE TABLE parks (
park_id INTEGER,
park_name VARCHAR,
park_date DATE,
park_type VARCHAR
);
SELECT AddGeometryColumn('parks', 'park_geom', 128, 'MULTIPOLYGON', 2 );</pre><p>Here is another example, using the generic "geometry" type and the
undefined SRID value of -1:</p><pre class="programlisting">CREATE TABLE roads (
road_id INTEGER,
road_name VARCHAR
);
SELECT AddGeometryColumn( 'roads', 'roads_geom', -1, 'GEOMETRY', 3 );</pre></div><div class="sect2" title="4.3.4.Manually Registering Geometry Columns in geometry_columns"><div class="titlepage"><div><div><h3 class="title"><a name="Manual_Register_Spatial_Column"></a>4.3.4.Manually Registering Geometry Columns in geometry_columns</h3></div></div></div><p>The AddGeometryColumn() approach creates a geometry column and also registers the new
column in the geometry_columns table. If your software utilizes geometry_columns, then
any geometry columns you need to query by must be registered in this table. Two of the cases
where you want a geometry column to be registered in the geometry_columns table, but you can't use
AddGeometryColumn, is in the case of SQL Views and bulk inserts. For these cases, you must register the column in the
geometry_columns table manually. Below is a simple script to do that.</p><pre class="programlisting">
--Lets say you have a view created like this
CREATE VIEW public.vwmytablemercator AS
SELECT gid, ST_Transform(the_geom,3395) As the_geom, f_name
FROM public.mytable;
--To register this table in AddGeometry columns - do the following
INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type")
SELECT '', 'public', 'vwmytablemercator', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom)
FROM public.vwmytablemercator LIMIT 1;
</pre><pre class="programlisting">
--Lets say you created a derivative table by doing a bulk insert
SELECT poi.gid, poi.the_geom, citybounds.city_name
INTO myschema.myspecialpois
FROM poi INNER JOIN citybounds ON ST_Intersects(citybounds.the_geom, poi.the_geom);
--Create index on new table
CREATE INDEX idx_myschema_myspecialpois_geom_gist
ON myschema.myspecialpois USING gist(the_geom);
--To manually register this new table's geometry column in geometry_columns
-- we do the same thing as with view
INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type")
SELECT '', 'myschema', 'myspecialpois', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom)
FROM public.myschema.myspecialpois LIMIT 1;
</pre></div><div class="sect2" title="4.3.5.Ensuring OpenGIS compliancy of geometries"><div class="titlepage"><div><div><h3 class="title"><a name="OGC_Validity"></a>4.3.5.Ensuring OpenGIS compliancy of geometries</h3></div></div></div><p>PostGIS is compliant with the Open Geospatial Consortium’s (OGC)
OpenGIS Specifications. As such, many PostGIS methods require, or more
accurately, assume that geometries that are operated on are both simple
and valid. for example, it does not make sense to calculate the area of
a polygon that has a hole defined outside of the polygon, or to construct
a polygon from a non-simple boundary line.</p><p>According to the OGC Specifications, a <span class="emphasis"><em>simple</em></span>
geometry is one that has no anomalous geometric points, such as self
intersection or self tangency and primarily refers to 0 or 1-dimensional
geometries (i.e. <code class="varname">[MULTI]POINT, [MULTI]LINESTRING</code>).
Geometry validity, on the other hand, primarily refers to 2-dimensional
geometries (i.e. <code class="varname">[MULTI]POLYGON)</code> and defines the set
of assertions that characterizes a valid polygon. The description of each
geometric class includes specific conditions that further detail geometric
simplicity and validity.</p><p>A <code class="varname">POINT</code> is inheritably <span class="emphasis"><em>simple</em></span>
as a 0-dimensional geometry object.</p><p><code class="varname">MULTIPOINT</code>s are <span class="emphasis"><em>simple</em></span> if
no two coordinates (<code class="varname">POINT</code>s) are equal (have identical
coordinate values).</p><p>A <code class="varname">LINESTRING</code> is <span class="emphasis"><em>simple</em></span> if
it does not pass through the same <code class="varname">POINT</code> twice (except
for the endpoints, in which case it is referred to as a linear ring and
additionally considered closed).</p><div class="informaltable"><table border="0"><colgroup><col><col></colgroup><tbody><tr><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_issimple01.png"><div class="caption"><p><span class="bold"><strong>(a)</strong></span></p></div></div></div></td><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_issimple02.png"><div class="caption"><p><span class="bold"><strong>(b)</strong></span></p></div></div></div></td></tr><tr><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_issimple03.png"><div class="caption"><p><span class="bold"><strong>(c)</strong></span></p></div></div></div></td><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_issimple04.png"><div class="caption"><p><span class="bold"><strong>(d)</strong></span></p></div></div></div></td></tr></tbody></table><table border="0"><colgroup><col></colgroup><tbody><tr><td><p><span class="bold"><strong>(a)</strong></span> and
<span class="bold"><strong>(c)</strong></span> are simple
<code class="varname">LINESTRING</code>s, <span class="bold"><strong>(b)</strong></span>
and <span class="bold"><strong>(d)</strong></span> are not.</p></td></tr></tbody></table></div><p>A <code class="varname">MULTILINESTRING</code> is <span class="emphasis"><em>simple</em></span>
only if all of its elements are simple and the only intersection between
any two elements occurs at <code class="varname">POINT</code>s that are on the
boundaries of both elements. </p><div class="informaltable"><table border="0"><colgroup><col><col><col></colgroup><tbody><tr><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_issimple05.png"><div class="caption"><p><span class="bold"><strong>(e)</strong></span></p></div></div></div></td><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_issimple06.png"><div class="caption"><p><span class="bold"><strong>(f)</strong></span></p></div></div></div></td><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_issimple07.png"><div class="caption"><p><span class="bold"><strong>(g)</strong></span></p></div></div></div></td></tr></tbody></table><table border="0"><colgroup><col></colgroup><tbody><tr><td><p><span class="bold"><strong>(e)</strong></span> and
<span class="bold"><strong>(f)</strong></span> are simple
<code class="varname">MULTILINESTRING</code>s, <span class="bold"><strong>(g)</strong></span>
is not.</p></td></tr></tbody></table></div><p>By definition, a <code class="varname">POLYGON</code> is always
<span class="emphasis"><em>simple</em></span>. It is <span class="emphasis"><em>valid</em></span> if no two
rings in the boundary (made up of an exterior ring and interior rings)
cross. The boundary of a <code class="varname">POLYGON</code> may intersect at a
<code class="varname">POINT</code> but only as a tangent (i.e. not on a line).
A <code class="varname">POLYGON</code> may not have cut lines or spikes and the
interior rings must be contained entirely within the exterior ring.</p><div class="informaltable"><table border="0"><colgroup><col><col><col></colgroup><tbody><tr><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_isvalid01.png"><div class="caption"><p><span class="bold"><strong>(h)</strong></span></p></div></div></div></td><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_isvalid02.png"><div class="caption"><p><span class="bold"><strong>(i)</strong></span></p></div></div></div></td><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_isvalid03.png"><div class="caption"><p><span class="bold"><strong>(j)</strong></span></p></div></div></div></td></tr><tr><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_isvalid04.png"><div class="caption"><p><span class="bold"><strong>(k)</strong></span></p></div></div></div></td><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_isvalid05.png"><div class="caption"><p><span class="bold"><strong>(l)</strong></span></p></div></div></div></td><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_isvalid06.png"><div class="caption"><p><span class="bold"><strong>(m)</strong></span></p></div></div></div></td></tr></tbody></table><table border="0"><colgroup><col></colgroup><tbody><tr><td><p><span class="bold"><strong>(h)</strong></span> and
<span class="bold"><strong>(i)</strong></span> are valid
<code class="varname">POLYGON</code>s, <span class="bold"><strong>(j-m)</strong></span>
cannot be represented as single <code class="varname">POLYGON</code>s, but
<span class="bold"><strong>(j)</strong></span> and <span class="bold"><strong>(m)</strong></span>
could be represented as a valid <code class="varname">MULTIPOLYGON</code>.
</p></td></tr></tbody></table></div><p>A <code class="varname">MULTIPOLYGON</code> is <span class="emphasis"><em>valid</em></span>
if and only if all of its elements are valid and the interiors of no two
elements intersect. The boundaries of any two elements may touch, but
only at a finite number of <code class="varname">POINT</code>s.</p><div class="informaltable"><table border="0"><colgroup><col><col></colgroup><tbody><tr><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_isvalid07.png"><div class="caption"><p><span class="bold"><strong>(n)</strong></span></p></div></div></div></td><td align="center"><div class="informalfigure"><div class="mediaobject"><img src="images/st_isvalid08.png"><div class="caption"><p><span class="bold"><strong>(o)</strong></span></p></div></div></div></td></tr></tbody></table><table border="0"><colgroup><col></colgroup><tbody><tr><td><p><span class="bold"><strong>(n)</strong></span> and
<span class="bold"><strong>(o)</strong></span> are not valid
<code class="varname">MULTIPOLYGON</code>s.</p></td></tr></tbody></table></div><p>Most of the functions implemented by the GEOS library rely on the
assumption that your geometries are valid as specified by the OpenGIS
Simple Feature Specification. To check simplicity or validity of
geometries you can use the <a class="link" href="#ST_IsSimple" title="ST_IsSimple">ST_IsSimple()</a> and
<a class="link" href="#ST_IsValid" title="ST_IsValid">ST_IsValid()</a></p><pre class="programlisting">-- Typically, it doesn't make sense to check
-- for validity on linear features since it will always return TRUE.
-- But in this example, PostGIS extends the definition of the OGC IsValid
-- by returning false if a LinearRing (start and end points are the same)
-- has less than 2 vertices.
gisdb=# SELECT
ST_IsValid('LINESTRING(0 0, 1 1)'),
ST_IsValid('LINESTRING(0 0, 0 0)');
st_isvalid | st_isvalid
------------+-----------
t | f</pre><p>By default, PostGIS does not apply this validity check on geometry
input, because testing for validity needs lots of CPU time for complex
geometries, especially polygons. If you do not trust your data sources,
you can manually enforce such a check to your tables by adding a check
constraint:</p><pre class="programlisting">ALTER TABLE mytable
ADD CONSTRAINT geometry_valid_check
CHECK (ST_IsValid(the_geom));</pre><p>If you encounter any strange error messages such as "GEOS
Intersection() threw an error!" or "JTS Intersection() threw an error!"
when calling PostGIS functions with valid input geometries, you likely
found an error in either PostGIS or one of the libraries it uses, and
you should contact the PostGIS developers. The same is true if a PostGIS
function returns an invalid geometry for valid input.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Strictly compliant OGC geometries cannot have Z or M values. The
<a class="link" href="#ST_IsValid" title="ST_IsValid">ST_IsValid()</a> function won't consider
higher dimensioned geometries invalid! Invocations of <a class="link" href="#AddGeometryColumn" title="AddGeometryColumn">AddGeometryColumn()</a> will add a
constraint checking geometry dimensions, so it is enough to specify 2
there.</p></td></tr></table></div></div><div class="sect2" title="4.3.6.Dimensionally Extended 9 Intersection Model (DE-9IM)"><div class="titlepage"><div><div><h3 class="title"><a name="DE-9IM"></a>4.3.6.Dimensionally Extended 9 Intersection Model (DE-9IM)</h3></div></div></div><p>It is sometimes the case that the typical spatial predicates
(<a class="xref" href="#ST_Contains" title="ST_Contains">ST_Contains</a>, <a class="xref" href="#ST_Crosses" title="ST_Crosses">ST_Crosses</a>,
<a class="xref" href="#ST_Intersects" title="ST_Intersects">ST_Intersects</a>, <a class="xref" href="#ST_Touches" title="ST_Touches">ST_Touches</a>, ...) are
insufficient in and of themselves to adequately provide that desired
spatial filter.</p><div class="informaltable"><table border="0"><colgroup><col></colgroup><tbody><tr><td><div class="informalfigure-float" style="float: left;"><div class="informalfigure"><div align="left"><img src="images/de9im01.png" align="left"></div></div></div><p>For example, consider a linear
dataset representing a road network. It may be the task of a
GIS analyst to identify all road segments that cross
each other, not at a point, but on a line, perhaps invalidating
some business rule. In this case, <a class="xref" href="#ST_Crosses" title="ST_Crosses">ST_Crosses</a> does not
adequately provide the necessary spatial filter since, for
linear features, it returns <code class="varname">true</code> only where
they cross at a point.</p> <p>One two-step solution
might be to first perform the actual intersection
(<a class="xref" href="#ST_Intersection" title="ST_Intersection">ST_Intersection</a>) of pairs of road segments that spatially
intersect (<a class="xref" href="#ST_Intersects" title="ST_Intersects">ST_Intersects</a>), and then compare the intersection's
<a class="xref" href="#ST_GeometryType" title="ST_GeometryType">ST_GeometryType</a> with '<code class="varname">LINESTRING</code>' (properly
dealing with cases that return
<code class="varname">GEOMETRYCOLLECTION</code>s of
<code class="varname">[MULTI]POINT</code>s,
<code class="varname">[MULTI]LINESTRING</code>s, etc.).</p> <p>A
more elegant / faster solution may indeed be
desirable.</p></td></tr></tbody></table></div><div class="informaltable"><table border="0"><colgroup><col></colgroup><tbody><tr><td><p> </p><div class="informalfigure-float" style="float: right;"><div class="informalfigure"><div align="right"><img src="images/de9im02.png" align="right"></div></div></div> <p>A second [theoretical]
example may be that of a GIS analyst trying to locate all
wharfs or docks that intersect a lake's boundary on a line and
where only one end of the wharf is up on shore. In other
words, where a wharf is within, but not completely within a
lake, intersecting the boundary of a lake on a line, and where
the wharf's endpoints are both completely within and on the
boundary of the lake. The analyst may need to use a
combination of spatial predicates to isolate the sought after
features:</p> <div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><a class="xref" href="#ST_Contains" title="ST_Contains">ST_Contains</a>(lake, wharf) = TRUE</p></li><li class="listitem"><p><a class="xref" href="#ST_ContainsProperly" title="ST_ContainsProperly">ST_ContainsProperly</a>(lake, wharf) = FALSE</p></li><li class="listitem"><p><a class="xref" href="#ST_GeometryType" title="ST_GeometryType">ST_GeometryType</a>(<a class="xref" href="#ST_Intersection" title="ST_Intersection">ST_Intersection</a>(wharf, lake)) =
'LINESTRING'</p></li><li class="listitem"><p><a class="xref" href="#ST_NumGeometries" title="ST_NumGeometries">ST_NumGeometries</a>(<a class="xref" href="#ST_Multi" title="ST_Multi">ST_Multi</a>(<a class="xref" href="#ST_Intersection" title="ST_Intersection">ST_Intersection</a>(<a class="xref" href="#ST_Boundary" title="ST_Boundary">ST_Boundary</a>(wharf),
<a class="xref" href="#ST_Boundary" title="ST_Boundary">ST_Boundary</a>(lake)))) = 1</p><p>... (needless to say, this could get quite
complicated)</p></li></ul></div></td></tr></tbody></table></div><p>So enters the Dimensionally Extended 9 Intersection Model, or
DE-9IM for short.</p><div class="sect3" title="4.3.6.1.Theory"><div class="titlepage"><div><div><h4 class="title"><a name="id36139513"></a>4.3.6.1.Theory</h4></div></div></div><p>According to the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple
Features Implementation Specification for SQL</a>, "the basic
approach to comparing two geometries is to make pair-wise tests of
the intersections between the Interiors, Boundaries and Exteriors of
the two geometries and to classify the relationship between the two
geometries based on the entries in the resulting 'intersection'
matrix."</p><div class="glosslist"><dl><dt>Boundary</dt><dd><p>The boundary of a geometry is the set of geometries of
the next lower dimension. For <code class="varname">POINT</code>s, which
have a dimension of 0, the boundary is the empty set. The
boundary of a <code class="varname">LINESTRING</code> are the two
endpoints. For <code class="varname">POLYGON</code>s, the boundary is
the linework that make up the exterior and interior
rings.</p></dd><dt>Interior</dt><dd><p>The interior of a geometry are those points of a
geometry that are left when the boundary is removed. For
<code class="varname">POINT</code>s, the interior is the
<code class="varname">POINT</code> itself. The interior of a
<code class="varname">LINESTRING</code> are the set of real points
between the endpoints. For <code class="varname">POLYGON</code>s, the
interior is the areal surface inside the polygon.</p></dd><dt>Exterior</dt><dd><p>The exterior of a geometry is the universe, an areal
surface, not on the interior or boundary of the
geometry.</p></dd></dl></div><p>Given geometry <span class="emphasis"><em>a</em></span>, where the
<span class="emphasis"><em>I(a)</em></span>, <span class="emphasis"><em>B(a)</em></span>, and
<span class="emphasis"><em>E(a)</em></span> are the <span class="emphasis"><em>Interior</em></span>,
<span class="emphasis"><em>Boundary</em></span>, and <span class="emphasis"><em>Exterior</em></span> of
a, the mathematical representation of the matrix is:</p><div class="styledtable"><table border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th align="center"></th><th align="center"><span class="bold"><strong>Interior</strong></span></th><th align="center"><span class="bold"><strong>Boundary</strong></span></th><th align="center"><span class="bold"><strong>Exterior</strong></span></th></tr></thead><tbody><tr><td align="center"><span class="bold"><strong>Interior</strong></span></td><td align="center"><span class="emphasis"><em><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="block">
<mml:mrow>
<mml:mtext mathvariant="italic">dim(
I(a)</mml:mtext>
<mml:mo>∩</mml:mo>
<mml:mtext mathvariant="italic">I(b) )</mml:mtext>
</mml:mrow>
</mml:math></em></span></td><td align="center"><span class="emphasis"><em><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="block">
<mml:mrow>
<mml:mtext mathvariant="italic">dim(
I(a)</mml:mtext>
<mml:mo>∩</mml:mo>
<mml:mtext mathvariant="italic">B(b) )</mml:mtext>
</mml:mrow>
</mml:math></em></span></td><td align="center"><span class="emphasis"><em><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="block">
<mml:mrow>
<mml:mtext mathvariant="italic">dim(
I(a)</mml:mtext>
<mml:mo>∩</mml:mo>
<mml:mtext mathvariant="italic">E(b) )</mml:mtext>
</mml:mrow>
</mml:math></em></span></td></tr><tr><td align="center"><span class="bold"><strong>Boundary</strong></span></td><td align="center"><span class="emphasis"><em><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="block">
<mml:mrow>
<mml:mtext mathvariant="italic">dim(
B(a)</mml:mtext>
<mml:mo>∩</mml:mo>
<mml:mtext mathvariant="italic">I(b) )</mml:mtext>
</mml:mrow>
</mml:math></em></span></td><td align="center"><span class="emphasis"><em><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="block">
<mml:mrow>
<mml:mtext mathvariant="italic">dim(
B(a)</mml:mtext>
<mml:mo>∩</mml:mo>
<mml:mtext mathvariant="italic">B(b) )</mml:mtext>
</mml:mrow>
</mml:math></em></span></td><td align="center"><span class="emphasis"><em><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="block">
<mml:mrow>
<mml:mtext mathvariant="italic">dim(
B(a)</mml:mtext>
<mml:mo>∩</mml:mo>
<mml:mtext mathvariant="italic">E(b) )</mml:mtext>
</mml:mrow>
</mml:math></em></span></td></tr><tr><td align="center"><span class="bold"><strong>Exterior</strong></span></td><td align="center"><span class="emphasis"><em><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="block">
<mml:mrow>
<mml:mtext mathvariant="italic">dim(
E(a)</mml:mtext>
<mml:mo>∩</mml:mo>
<mml:mtext mathvariant="italic">I(b) )</mml:mtext>
</mml:mrow>
</mml:math></em></span></td><td align="center"><span class="emphasis"><em><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="block">
<mml:mrow>
<mml:mtext mathvariant="italic">dim(
E(a)</mml:mtext>
<mml:mo>∩</mml:mo>
<mml:mtext mathvariant="italic">B(b) )</mml:mtext>
</mml:mrow>
</mml:math></em></span></td><td align="center"><span class="emphasis"><em><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="block">
<mml:mrow>
<mml:mtext mathvariant="italic">dim(
E(a)</mml:mtext>
<mml:mo>∩</mml:mo>
<mml:mtext mathvariant="italic">E(b) )</mml:mtext>
</mml:mrow>
</mml:math></em></span></td></tr></tbody></table></div><p>Where <span class="emphasis"><em>dim(a)</em></span> is the dimension of
<span class="emphasis"><em>a</em></span> as specified by
<a class="xref" href="#ST_Dimension" title="ST_Dimension">ST_Dimension</a> but has the domain of
<code class="literal">{0,1,2,T,F,*}</code></p><div class="itemizedlist"><ul class="itemizedlist" type="disc" compact><li class="listitem"><p><code class="literal">0</code> => point</p></li><li class="listitem"><p><code class="literal">1</code> => line</p></li><li class="listitem"><p><code class="literal">2</code> => area</p></li><li class="listitem"><p><code class="literal">T</code> =>
<code class="literal">{0,1,2}</code></p></li><li class="listitem"><p><code class="literal">F</code> => empty set</p></li><li class="listitem"><p><code class="literal">*</code> => don't care</p></li></ul></div><p>Visually, for two overlapping polygonal geometries, this looks
like:</p><div class="informaltable"><table border="0"><colgroup><col width="80pt"><col></colgroup><tbody><tr><td></td><td align="center"><div class="informalfigure"><div align="center"><table border="0" summary="manufactured viewport for HTML img" cellspacing="0" cellpadding="0"><tr><td align="center" valign="middle"><img src="images/de9im04.png" align="middle"></td></tr></table></div></div></td></tr><tr><td align="center" valign="middle"><div class="informalfigure"><div align="center"><table border="0" summary="manufactured viewport for HTML img" cellspacing="0" cellpadding="0"><tr><td align="center" valign="middle"><img src="images/de9im03.png" align="middle"></td></tr></table></div></div></td><td><p> </p><div class="styledtable"><table border="1"><colgroup><col><col><col><col></colgroup><thead valign="middle"><tr><th align="center" valign="middle"></th><th align="center" valign="middle"><span class="bold"><strong>Interior</strong></span></th><th align="center" valign="middle"><span class="bold"><strong>Boundary</strong></span></th><th align="center" valign="middle"><span class="bold"><strong>Exterior</strong></span></th></tr></thead><tbody valign="middle"><tr><td align="center" valign="middle"><span class="bold"><strong>Interior</strong></span></td><td align="center" valign="middle"><div class="informalfigure"><div><img src="images/de9im05.png"></div></div><p><span class="emphasis"><em>dim(...) =
</em></span><span class="bold"><strong>2</strong></span></p></td><td align="center" valign="middle"><div class="informalfigure"><div><img src="images/de9im06.png"></div></div><p><span class="emphasis"><em>dim(...) =
</em></span><span class="bold"><strong>1</strong></span></p></td><td align="center" valign="middle"><div class="informalfigure"><div><img src="images/de9im07.png"></div></div><p><span class="emphasis"><em>dim(...) =
</em></span><span class="bold"><strong>2</strong></span></p></td></tr><tr><td align="center" valign="middle"><span class="bold"><strong>Boundary</strong></span></td><td align="center" valign="middle"><div class="informalfigure"><div><img src="images/de9im08.png"></div></div><p><span class="emphasis"><em>dim(...) =
</em></span><span class="bold"><strong>1</strong></span></p></td><td align="center" valign="middle"><div class="informalfigure"><div><img src="images/de9im09.png"></div></div><p><span class="emphasis"><em>dim(...) =
</em></span><span class="bold"><strong>0</strong></span></p></td><td align="center" valign="middle"><div class="informalfigure"><div><img src="images/de9im10.png"></div></div><p><span class="emphasis"><em>dim(...) =
</em></span><span class="bold"><strong>1</strong></span></p></td></tr><tr><td align="center" valign="middle"><span class="bold"><strong>Exterior</strong></span></td><td align="center" valign="middle"><div class="informalfigure"><div><img src="images/de9im11.png"></div></div><p><span class="emphasis"><em>dim(...) =
</em></span><span class="bold"><strong>2</strong></span></p></td><td align="center" valign="middle"><div class="informalfigure"><div><img src="images/de9im12.png"></div></div><p><span class="emphasis"><em>dim(...) =
</em></span><span class="bold"><strong>1</strong></span></p></td><td align="center" valign="middle"><div class="informalfigure"><div><img src="images/de9im13.png"></div></div><p><span class="emphasis"><em>dim(...) =
</em></span><span class="bold"><strong>2</strong></span></p></td></tr></tbody></table></div></td></tr></tbody></table></div><p>Read from left to right and from top to bottom, the dimensional matrix is
represented, '<span class="bold"><strong>212101212</strong></span>'.</p><p>A relate matrix that would therefore represent our first
example of two lines that intersect on a line would be: '<span class="bold"><strong>1*1***1**</strong></span>'</p><pre class="programlisting">-- Identify road segments that cross on a line
SELECT a.id
FROM roads a, roads b
WHERE a.id != b.id
AND a.geom && b.geom
AND ST_Relate(a.geom, b.geom, '1*1***1**');</pre><p>A relate matrix that represents the second example of wharfs
partly on the lake's shoreline would be '<span class="bold"><strong>102101FF2</strong></span>'</p><pre class="programlisting">-- Identify wharfs partly on a lake's shoreline
SELECT a.lake_id, b.wharf_id
FROM lakes a, wharfs b
WHERE a.geom && b.geom
AND ST_Relate(a.geom, b.geom, '102101FF2');</pre><p>For more information or reading, see:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc" compact><li class="listitem"><p><a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple
Features Implementation Specification for SQL</a> (version 1.1, section 2.1.13.2)</p></li><li class="listitem"><p><a class="ulink" href="http://gis.hsr.ch/wiki/images/3/3d/9dem_springer.pdf" target="_top">Dimensionally
Extended Nine-Intersection Model (DE-9IM) by Christian Strobl</a></p></li><li class="listitem"><p><a class="ulink" href="http://docs.codehaus.org/display/GEOTDOC/Point+Set+Theory+and+the+DE-9IM+Matrix#PointSetTheoryandtheDE-9IMMatrix-9IntersectionMatrix" target="_top">GeoTools: Dimensionally Extended Nine-Intersection Matrix</a></p></li><li class="listitem"><p><span class="emphasis"><em>Encyclopedia of GIS</em></span> By Hui Xiong</p></li></ul></div></div></div></div><div class="sect1" title="4.4.Loading GIS Data"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36140438"></a>4.4.Loading GIS Data</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#id36140449">4.4.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#shp2pgsql_usage">4.4.2. Using the Loader</a></span></dt></dl></div><p>Once you have created a spatial table, you are ready to upload GIS
data to the database. Currently, there are two ways to get data into a
PostGIS/PostgreSQL database: using formatted SQL statements or using the
Shape file loader/dumper.</p><div class="sect2" title="4.4.1.Using SQL"><div class="titlepage"><div><div><h3 class="title"><a name="id36140449"></a>4.4.1.Using SQL</h3></div></div></div><p>If you can convert your data to a text representation, then using
formatted SQL might be the easiest way to get your data into PostGIS. As
with Oracle and other SQL databases, data can be bulk loaded by piping a
large text file full of SQL "INSERT" statements into the SQL terminal
monitor.</p><p>A data upload file (<code class="filename">roads.sql</code> for example)
might look like this:</p><pre class="programlisting">BEGIN;
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (1,ST_GeomFromText('LINESTRING(191232 243118,191108 243242)',-1),'Jeff Rd');
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (2,ST_GeomFromText('LINESTRING(189141 244158,189265 244817)',-1),'Geordie Rd');
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (3,ST_GeomFromText('LINESTRING(192783 228138,192612 229814)',-1),'Paul St');
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (4,ST_GeomFromText('LINESTRING(189412 252431,189631 259122)',-1),'Graeme Ave');
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (5,ST_GeomFromText('LINESTRING(190131 224148,190871 228134)',-1),'Phil Tce');
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (6,ST_GeomFromText('LINESTRING(198231 263418,198213 268322)',-1),'Dave Cres');
COMMIT;</pre><p>The data file can be piped into PostgreSQL very easily using the
"psql" SQL terminal monitor:</p><pre class="programlisting">psql -d [database] -f roads.sql</pre></div><div class="sect2" title="4.4.2.Using the Loader"><div class="titlepage"><div><div><h3 class="title"><a name="shp2pgsql_usage"></a>4.4.2.Using the Loader</h3></div></div></div><p>
The <code class="filename">shp2pgsql</code> data loader converts ESRI Shape files into SQL suitable for
insertion into a PostGIS/PostgreSQL database either in geometry or geography format. The loader has several operating modes
distinguished by command line flags:
</p><p>In addition to the shp2pgsql command-line loader, there is an <code class="filename">shp2pgsql-gui</code> graphical interface with most
of the options as the command-line loader, but may be easier to use for one-off non-scripted loading or if you are new to PostGIS.
It can also be configured as a plugin to PgAdminIII.
</p><div class="variablelist"><dl><dt><span class="term">(c|a|d|p) These are mutually exclusive options:</span></dt><dd><p>
</p><div class="variablelist"><dl><dt><span class="term">-c</span></dt><dd><p>
Creates a new table and populates it from the shapefile. <span class="emphasis"><em>This is the
default mode.</em></span>
</p></dd><dt><span class="term">-a</span></dt><dd><p>
Appends data from the Shape file into the database table. Note that to use this
option to load multiple files, the files must have the same attributes and same
data types.
</p></dd><dt><span class="term">-d</span></dt><dd><p>
Drops the database table before creating a new table with the data in the Shape
file.
</p></dd><dt><span class="term">-p</span></dt><dd><p>
Only produces the table creation SQL code, without adding any actual data. This
can be used if you need to completely separate the table creation and data loading
steps.
</p></dd></dl></div><p>
</p></dd><dt><span class="term">-?</span></dt><dd><p>
Display help screen.
</p></dd><dt><span class="term">-D</span></dt><dd><p>
Use the PostgreSQL "dump" format for the output data. This can be combined with -a, -c and
-d. It is much faster to load than the default "insert" SQL format. Use this for very
large data sets.
</p></dd><dt><span class="term">-s <SRID></span></dt><dd><p>
Creates and populates the geometry tables with the specified SRID.
</p></dd><dt><span class="term">-k</span></dt><dd><p>
Keep identifiers' case (column, schema and attributes). Note that attributes in Shapefile
are all UPPERCASE.
</p></dd><dt><span class="term">-i</span></dt><dd><p>
Coerce all integers to standard 32-bit integers, do not create 64-bit bigints, even if the
DBF header signature appears to warrant it.
</p></dd><dt><span class="term">-I</span></dt><dd><p>
Create a GiST index on the geometry column.
</p></dd><dt><span class="term">-w</span></dt><dd><p>
Output WKT format, for use with older (0.x) versions of PostGIS. Note that this will
introduce coordinate drifts and will drop M values from shapefiles.
</p></dd><dt><span class="term">-W <encoding></span></dt><dd><p>
Specify encoding of the input data (dbf file). When used, all attributes of the dbf are
converted from the specified encoding to UTF8. The resulting SQL output will contain a
<code class="code">SET CLIENT_ENCODING to UTF8</code> command, so that the backend will be able to
reconvert from UTF8 to whatever encoding the database is configured to use internally.
</p></dd><dt><span class="term">-N <policy></span></dt><dd><p>
NULL geometries handling policy (insert*,skip,abort)
</p></dd><dt><span class="term">-n</span></dt><dd><p>
-n Only import DBF file. If your data has no corresponding shapefile, it will automatically switch to this mode
and load just the dbf. So setting this flag is only needed if you have a full shapefile set, and you only want the attribute data and no geometry.
</p></dd><dt><span class="term">-G</span></dt><dd><p>
Use geography type instead of geometry (requires lon/lat data) in WGS84 long lat (SRID=4326)
</p></dd></dl></div><p>
An example session using the loader to create an input file and uploading it might look like
this:
</p><pre class="programlisting"># shp2pgsql -c -D -s 4269 -i -I shaperoads.shp myschema.roadstable > roads.sql
# psql -d roadsdb -f roads.sql</pre><p>
A conversion and upload can be done all in one step using UNIX pipes:
</p><pre class="programlisting"># shp2pgsql shaperoads.shp myschema.roadstable | psql -d roadsdb</pre></div></div><div class="sect1" title="4.5.Retrieving GIS Data"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36140779"></a>4.5.Retrieving GIS Data</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#id36140925">4.5.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id36141047">4.5.2. Using the Dumper</a></span></dt></dl></div><p>Data can be extracted from the database using either SQL or the
Shape file loader/dumper. In the section on SQL we will discuss some of
the operators available to do comparisons and queries on spatial
tables.</p><div class="sect2" title="4.5.1.Using SQL"><div class="titlepage"><div><div><h3 class="title"><a name="id36140925"></a>4.5.1.Using SQL</h3></div></div></div><p>The most straightforward means of pulling data out of the database
is to use a SQL select query and dump the resulting columns into a
parsable text file:</p><pre class="programlisting">db=# SELECT road_id, ST_AsText(road_geom) AS geom, road_name FROM roads;
road_id | geom | road_name
--------+-----------------------------------------+-----------
1 | LINESTRING(191232 243118,191108 243242) | Jeff Rd
2 | LINESTRING(189141 244158,189265 244817) | Geordie Rd
3 | LINESTRING(192783 228138,192612 229814) | Paul St
4 | LINESTRING(189412 252431,189631 259122) | Graeme Ave
5 | LINESTRING(190131 224148,190871 228134) | Phil Tce
6 | LINESTRING(198231 263418,198213 268322) | Dave Cres
7 | LINESTRING(218421 284121,224123 241231) | Chris Way
(6 rows)</pre><p>However, there will be times when some kind of restriction is
necessary to cut down the number of fields returned. In the case of
attribute-based restrictions, just use the same SQL syntax as normal
with a non-spatial table. In the case of spatial restrictions, the
following operators are available/useful:</p><div class="variablelist"><dl><dt><span class="term">&&</span></dt><dd><p>This operator tells whether the bounding box of one geometry
intersects the bounding box of another.</p></dd><dt><span class="term">~=</span></dt><dd><p>This operators tests whether two geometries are
geometrically identical. For example, if 'POLYGON((0 0,1 1,1 0,0
0))' is the same as 'POLYGON((0 0,1 1,1 0,0 0))' (it is).</p></dd><dt><span class="term">=</span></dt><dd><p>This operator is a little more naive, it only tests whether
the bounding boxes of two geometries are the same.</p></dd></dl></div><p>Next, you can use these operators in queries. Note that when
specifying geometries and boxes on the SQL command line, you must
explicitly turn the string representations into geometries by using the
"GeomFromText()" function. So, for example:</p><pre class="programlisting">SELECT road_id, road_name
FROM roads
WHERE roads_geom ~= ST_GeomFromText('LINESTRING(191232 243118,191108 243242)',-1);</pre><p>The above query would return the single record from the
"ROADS_GEOM" table in which the geometry was equal to that value.</p><p>When using the "&&" operator, you can specify either a
BOX3D as the comparison feature or a GEOMETRY. When you specify a
GEOMETRY, however, its bounding box will be used for the
comparison.</p><pre class="programlisting">SELECT road_id, road_name
FROM roads
WHERE roads_geom && ST_GeomFromText('POLYGON((...))',-1);</pre><p>The above query will use the bounding box of the polygon for
comparison purposes.</p><p>The most common spatial query will probably be a "frame-based"
query, used by client software, like data browsers and web mappers, to
grab a "map frame" worth of data for display. Using a "BOX3D" object for
the frame, such a query looks like this:</p><pre class="programlisting">SELECT ST_AsText(roads_geom) AS geom
FROM roads
WHERE
roads_geom && SetSRID('BOX3D(191232 243117,191232 243119)'::box3d,-1);</pre><p>Note the use of the SRID, to specify the projection of the BOX3D.
The value -1 is used to indicate no specified SRID.</p></div><div class="sect2" title="4.5.2.Using the Dumper"><div class="titlepage"><div><div><h3 class="title"><a name="id36141047"></a>4.5.2.Using the Dumper</h3></div></div></div><p>The <code class="filename">pgsql2shp</code> table dumper connects directly
to the database and converts a table (possibly defined by a query) into
a shape file. The basic syntax is:</p><pre class="programlisting">pgsql2shp [<options>] <database> [<schema>.]<table></pre><pre class="programlisting">pgsql2shp [<options>] <database> <query></pre><p>The commandline options are:</p><div class="variablelist"><dl><dt><span class="term">-f <filename></span></dt><dd><p>Write the output to a particular filename.</p></dd><dt><span class="term">-h <host></span></dt><dd><p>The database host to connect to.</p></dd><dt><span class="term">-p <port></span></dt><dd><p>The port to connect to on the database host.</p></dd><dt><span class="term">-P <password></span></dt><dd><p>The password to use when connecting to the database.</p></dd><dt><span class="term">-u <user></span></dt><dd><p>The username to use when connecting to the database.</p></dd><dt><span class="term">-g <geometry column></span></dt><dd><p>In the case of tables with multiple geometry columns, the
geometry column to use when writing the shape file.</p></dd><dt><span class="term">-b</span></dt><dd><p>Use a binary cursor. This will make the operation faster,
but will not work if any NON-geometry attribute in the table lacks
a cast to text.</p></dd><dt><span class="term">-r</span></dt><dd><p>Raw mode. Do not drop the <code class="varname">gid</code> field, or
escape column names.</p></dd><dt><span class="term">-d</span></dt><dd><p>For backward compatibility: write a 3-dimensional shape file
when dumping from old (pre-1.0.0) postgis databases (the default
is to write a 2-dimensional shape file in that case). Starting
from postgis-1.0.0+, dimensions are fully encoded.</p></dd></dl></div></div></div><div class="sect1" title="4.6.Building Indexes"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36141205"></a>4.6.Building Indexes</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#id36141247">4.6.1. GiST Indexes</a></span></dt><dt><span class="sect2"><a href="#id36141296">4.6.2. Using Indexes</a></span></dt></dl></div><p>Indexes are what make using a spatial database for large data sets
possible. Without indexing, any search for a feature would require a
"sequential scan" of every record in the database. Indexing speeds up
searching by organizing the data into a search tree which can be quickly
traversed to find a particular record. PostgreSQL supports three kinds of
indexes by default: B-Tree indexes, R-Tree indexes, and GiST
indexes.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>B-Trees are used for data which can be sorted along one axis;
for example, numbers, letters, dates. GIS data cannot be rationally
sorted along one axis (which is greater, (0,0) or (0,1) or (1,0)?) so
B-Tree indexing is of no use for us.</p></li><li class="listitem"><p>R-Trees break up data into rectangles, and sub-rectangles, and
sub-sub rectangles, etc. R-Trees are used by some spatial databases to
index GIS data, but the PostgreSQL R-Tree implementation is not as
robust as the GiST implementation.</p></li><li class="listitem"><p>GiST (Generalized Search Trees) indexes break up data into
"things to one side", "things which overlap", "things which are
inside" and can be used on a wide range of data-types, including GIS
data. PostGIS uses an R-Tree index implemented on top of GiST to index
GIS data.</p></li></ul></div><div class="sect2" title="4.6.1.GiST Indexes"><div class="titlepage"><div><div><h3 class="title"><a name="id36141247"></a>4.6.1.GiST Indexes</h3></div></div></div><p>GiST stands for "Generalized Search Tree" and is a generic form of
indexing. In addition to GIS indexing, GiST is used to speed up searches
on all kinds of irregular data structures (integer arrays, spectral
data, etc) which are not amenable to normal B-Tree indexing.</p><p>Once a GIS data table exceeds a few thousand rows, you will want
to build an index to speed up spatial searches of the data (unless all
your searches are based on attributes, in which case you'll want to
build a normal index on the attribute fields).</p><p>The syntax for building a GiST index on a "geometry" column is as
follows:</p><pre class="programlisting">CREATE INDEX [indexname] ON [tablename] USING GIST ( [geometryfield] ); </pre><p>Building a spatial index is a computationally intensive exercise:
on tables of around 1 million rows, on a 300MHz Solaris machine, we have
found building a GiST index takes about 1 hour. After building an index,
it is important to force PostgreSQL to collect table statistics, which
are used to optimize query plans:</p><pre class="programlisting">VACUUM ANALYZE [table_name] [column_name];
-- This is only needed for PostgreSQL 7.4 installations and below
SELECT UPDATE_GEOMETRY_STATS([table_name], [column_name]);</pre><p>GiST indexes have two advantages over R-Tree indexes in
PostgreSQL. Firstly, GiST indexes are "null safe", meaning they can
index columns which include null values. Secondly, GiST indexes support
the concept of "lossiness" which is important when dealing with GIS
objects larger than the PostgreSQL 8K page size. Lossiness allows
PostgreSQL to store only the "important" part of an object in an index
-- in the case of GIS objects, just the bounding box. GIS objects larger
than 8K will cause R-Tree indexes to fail in the process of being
built.</p></div><div class="sect2" title="4.6.2.Using Indexes"><div class="titlepage"><div><div><h3 class="title"><a name="id36141296"></a>4.6.2.Using Indexes</h3></div></div></div><p>Ordinarily, indexes invisibly speed up data access: once the index
is built, the query planner transparently decides when to use index
information to speed up a query plan. Unfortunately, the PostgreSQL
query planner does not optimize the use of GiST indexes well, so
sometimes searches which should use a spatial index instead default to a
sequence scan of the whole table.</p><p>If you find your spatial indexes are not being used (or your
attribute indexes, for that matter) there are a couple things you can
do:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Firstly, make sure statistics are gathered about the number
and distributions of values in a table, to provide the query planner
with better information to make decisions around index usage. For
PostgreSQL 7.4 installations and below this is done by running
<span class="command"><strong>update_geometry_stats([table_name, column_name])</strong></span>
(compute distribution) and <span class="command"><strong>VACUUM ANALYZE [table_name]
[column_name]</strong></span> (compute number of values). Starting with
PostgreSQL 8.0 running <span class="command"><strong>VACUUM ANALYZE</strong></span> will do
both operations. You should regularly vacuum your databases anyways
-- many PostgreSQL DBAs have <span class="command"><strong>VACUUM</strong></span> run as an
off-peak cron job on a regular basis.</p></li><li class="listitem"><p>If vacuuming does not work, you can force the planner to use
the index information by using the <span class="command"><strong>SET
ENABLE_SEQSCAN=OFF</strong></span> command. You should only use this
command sparingly, and only on spatially indexed queries: generally
speaking, the planner knows better than you do about when to use
normal B-Tree indexes. Once you have run your query, you should
consider setting <code class="varname">ENABLE_SEQSCAN</code> back on, so that
other queries will utilize the planner as normal.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>As of version 0.6, it should not be necessary to force the
planner to use the index with
<code class="varname">ENABLE_SEQSCAN</code>.</p></td></tr></table></div></li><li class="listitem"><p>If you find the planner wrong about the cost of sequential vs
index scans try reducing the value of random_page_cost in
postgresql.conf or using SET random_page_cost=#. Default value for
the parameter is 4, try setting it to 1 or 2. Decrementing the value
makes the planner more inclined of using Index scans.</p></li></ul></div></div></div><div class="sect1" title="4.7.Complex Queries"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36141388"></a>4.7.Complex Queries</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#id36141402">4.7.1. Taking Advantage of Indexes</a></span></dt><dt><span class="sect2"><a href="#id36141469">4.7.2. Examples of Spatial SQL</a></span></dt></dl></div><p>The <span class="emphasis"><em>raison d'etre</em></span> of spatial database
functionality is performing queries inside the database which would
ordinarily require desktop GIS functionality. Using PostGIS effectively
requires knowing what spatial functions are available, and ensuring that
appropriate indexes are in place to provide good performance.</p><div class="sect2" title="4.7.1.Taking Advantage of Indexes"><div class="titlepage"><div><div><h3 class="title"><a name="id36141402"></a>4.7.1.Taking Advantage of Indexes</h3></div></div></div><p>When constructing a query it is important to remember that only
the bounding-box-based operators such as && can take advantage
of the GiST spatial index. Functions such as
<code class="varname">distance()</code> cannot use the index to optimize their
operation. For example, the following query would be quite slow on a
large table:</p><pre class="programlisting">SELECT the_geom
FROM geom_table
WHERE ST_Distance(the_geom, ST_GeomFromText('POINT(100000 200000)', -1)) < 100</pre><p>This query is selecting all the geometries in geom_table which are
within 100 units of the point (100000, 200000). It will be slow because
it is calculating the distance between each point in the table and our
specified point, ie. one <code class="varname">ST_Distance()</code> calculation
for each row in the table. We can avoid this by using the &&
operator to reduce the number of distance calculations required:</p><pre class="programlisting">SELECT the_geom
FROM geom_table
WHERE the_geom && 'BOX3D(90900 190900, 100100 200100)'::box3d
AND
ST_Distance(the_geom, ST_GeomFromText('POINT(100000 200000)', -1)) < 100</pre><p>This query selects the same geometries, but it does it in a more
efficient way. Assuming there is a GiST index on the_geom, the query
planner will recognize that it can use the index to reduce the number of
rows before calculating the result of the <code class="varname">distance()</code>
function. Notice that the <code class="varname">BOX3D</code> geometry which is
used in the && operation is a 200 unit square box centered on
the original point - this is our "query box". The && operator
uses the index to quickly reduce the result set down to only those
geometries which have bounding boxes that overlap the "query box".
Assuming that our query box is much smaller than the extents of the
entire geometry table, this will drastically reduce the number of
distance calculations that need to be done.</p><div class="note" title="Change in Behavior" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note: Change in Behavior"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Change in Behavior</th></tr><tr><td align="left" valign="top"><p>As of PostGIS 1.3.0, most of the Geometry Relationship
Functions, with the notable exceptions of ST_Disjoint and ST_Relate,
include implicit bounding box overlap operators.</p></td></tr></table></div></div><div class="sect2" title="4.7.2.Examples of Spatial SQL"><div class="titlepage"><div><div><h3 class="title"><a name="id36141469"></a>4.7.2.Examples of Spatial SQL</h3></div></div></div><p>The examples in this section will make use of two tables, a table
of linear roads, and a table of polygonal municipality boundaries. The
table definitions for the <code class="varname">bc_roads</code> table is:</p><pre class="programlisting">Column | Type | Description
------------+-------------------+-------------------
gid | integer | Unique ID
name | character varying | Road Name
the_geom | geometry | Location Geometry (Linestring)</pre><p>The table definition for the <code class="varname">bc_municipality</code>
table is:</p><pre class="programlisting">Column | Type | Description
-----------+-------------------+-------------------
gid | integer | Unique ID
code | integer | Unique ID
name | character varying | City / Town Name
the_geom | geometry | Location Geometry (Polygon)</pre><div class="qandaset" title="Frequently Asked Questions"><a name="id36141502"></a><dl><dt>4.7.2.1. <a href="#id36141504">What is the total length of all roads, expressed in
kilometers?</a></dt><dt>4.7.2.2. <a href="#id36141527">How large is the city of Prince George, in hectares?</a></dt><dt>4.7.2.3. <a href="#id36141551">What is the largest municipality in the province, by
area?</a></dt><dt>4.7.2.4. <a href="#id36141582">What is the length of roads fully contained within each
municipality?</a></dt><dt>4.7.2.5. <a href="#id36141616">Create a new table with all the roads within the city of
Prince George.</a></dt><dt>4.7.2.6. <a href="#id36141643">What is the length in kilometers of "Douglas St" in
Victoria?</a></dt><dt>4.7.2.7. <a href="#id36141664">What is the largest municipality polygon that has a
hole?</a></dt></dl><table border="0" width="100%" summary="Q and A Set"><col align="left" width="1%"><col><tbody><tr class="question" title="4.7.2.1."><td align="left" valign="top"><a name="id36141504"></a><a name="id36141506"></a><p><b>4.7.2.1.</b></p></td><td align="left" valign="top"><p>What is the total length of all roads, expressed in
kilometers?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>You can answer this question with a very simple piece of
SQL:</p><pre class="programlisting">SELECT sum(ST_Length(the_geom))/1000 AS km_roads FROM bc_roads;
km_roads
------------------
70842.1243039643
(1 row)</pre></td></tr><tr class="question" title="4.7.2.2."><td align="left" valign="top"><a name="id36141527"></a><a name="id36141529"></a><p><b>4.7.2.2.</b></p></td><td align="left" valign="top"><p>How large is the city of Prince George, in hectares?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>This query combines an attribute condition (on the
municipality name) with a spatial calculation (of the
area):</p><pre class="programlisting">SELECT
ST_Area(the_geom)/10000 AS hectares
FROM bc_municipality
WHERE name = 'PRINCE GEORGE';
hectares
------------------
32657.9103824927
(1 row)</pre></td></tr><tr class="question" title="4.7.2.3."><td align="left" valign="top"><a name="id36141551"></a><a name="id36141553"></a><p><b>4.7.2.3.</b></p></td><td align="left" valign="top"><p>What is the largest municipality in the province, by
area?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>This query brings a spatial measurement into the query
condition. There are several ways of approaching this problem, but
the most efficient is below:</p><pre class="programlisting">SELECT
name,
ST_Area(the_geom)/10000 AS hectares
FROM
bc_municipality
ORDER BY hectares DESC
LIMIT 1;
name | hectares
---------------+-----------------
TUMBLER RIDGE | 155020.02556131
(1 row)</pre><p>Note that in order to answer this query we have to calculate
the area of every polygon. If we were doing this a lot it would
make sense to add an area column to the table that we could
separately index for performance. By ordering the results in a
descending direction, and them using the PostgreSQL "LIMIT"
command we can easily pick off the largest value without using an
aggregate function like max().</p></td></tr><tr class="question" title="4.7.2.4."><td align="left" valign="top"><a name="id36141582"></a><a name="id36141584"></a><p><b>4.7.2.4.</b></p></td><td align="left" valign="top"><p>What is the length of roads fully contained within each
municipality?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>This is an example of a "spatial join", because we are
bringing together data from two tables (doing a join) but using a
spatial interaction condition ("contained") as the join condition
rather than the usual relational approach of joining on a common
key:</p><pre class="programlisting">SELECT
m.name,
sum(ST_Length(r.the_geom))/1000 as roads_km
FROM
bc_roads AS r,
bc_municipality AS m
WHERE
ST_Contains(m.the_geom,r.the_geom)
GROUP BY m.name
ORDER BY roads_km;
name | roads_km
----------------------------+------------------
SURREY | 1539.47553551242
VANCOUVER | 1450.33093486576
LANGLEY DISTRICT | 833.793392535662
BURNABY | 773.769091404338
PRINCE GEORGE | 694.37554369147
...</pre><p>This query takes a while, because every road in the table is
summarized into the final result (about 250K roads for our
particular example table). For smaller overlays (several thousand
records on several hundred) the response can be very fast.</p></td></tr><tr class="question" title="4.7.2.5."><td align="left" valign="top"><a name="id36141616"></a><a name="id36141618"></a><p><b>4.7.2.5.</b></p></td><td align="left" valign="top"><p>Create a new table with all the roads within the city of
Prince George.</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>This is an example of an "overlay", which takes in two
tables and outputs a new table that consists of spatially clipped
or cut resultants. Unlike the "spatial join" demonstrated above,
this query actually creates new geometries. An overlay is like a
turbo-charged spatial join, and is useful for more exact analysis
work:</p><pre class="programlisting">CREATE TABLE pg_roads as
SELECT
ST_Intersection(r.the_geom, m.the_geom) AS intersection_geom,
ST_Length(r.the_geom) AS rd_orig_length,
r.*
FROM
bc_roads AS r,
bc_municipality AS m
WHERE m.name = 'PRINCE GEORGE' AND ST_Intersects(r.the_geom, m.the_geom);</pre></td></tr><tr class="question" title="4.7.2.6."><td align="left" valign="top"><a name="id36141643"></a><a name="id36141645"></a><p><b>4.7.2.6.</b></p></td><td align="left" valign="top"><p>What is the length in kilometers of "Douglas St" in
Victoria?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><pre class="programlisting">SELECT
sum(ST_Length(r.the_geom))/1000 AS kilometers
FROM
bc_roads r,
bc_municipality m
WHERE r.name = 'Douglas St' AND m.name = 'VICTORIA'
AND ST_Contains(m.the_geom, r.the_geom) ;
kilometers
------------------
4.89151904172838
(1 row)</pre></td></tr><tr class="question" title="4.7.2.7."><td align="left" valign="top"><a name="id36141664"></a><a name="id36141666"></a><p><b>4.7.2.7.</b></p></td><td align="left" valign="top"><p>What is the largest municipality polygon that has a
hole?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><pre class="programlisting">SELECT gid, name, ST_Area(the_geom) AS area
FROM bc_municipality
WHERE ST_NRings(the_geom) > 1
ORDER BY area DESC LIMIT 1;
gid | name | area
-----+--------------+------------------
12 | SPALLUMCHEEN | 257374619.430216
(1 row)</pre></td></tr></tbody></table></div></div></div></div><div class="chapter" title="Chapter5.Using PostGIS: Building Applications"><div class="titlepage"><div><div><h2 class="title"><a name="id36146016"></a>Chapter5.Using PostGIS: Building Applications</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#Using_MapServer">5.1. Using MapServer</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36146064">5.1.1. Basic Usage</a></span></dt><dt><span class="sect2"><a href="#id36146276">5.1.2. Frequently Asked Questions</a></span></dt><dt><span class="sect2"><a href="#id36146431">5.1.3. Advanced Usage</a></span></dt><dt><span class="sect2"><a href="#id36146521">5.1.4. Examples</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36146598">5.2. Java Clients (JDBC)</a></span></dt><dt><span class="sect1"><a href="#id36146641">5.3. C Clients (libpq)</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36146649">5.3.1. Text Cursors</a></span></dt><dt><span class="sect2"><a href="#id36146659">5.3.2. Binary Cursors</a></span></dt></dl></dd></dl></div><div class="sect1" title="5.1.Using MapServer"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Using_MapServer"></a>5.1.Using MapServer</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#id36146064">5.1.1. Basic Usage</a></span></dt><dt><span class="sect2"><a href="#id36146276">5.1.2. Frequently Asked Questions</a></span></dt><dt><span class="sect2"><a href="#id36146431">5.1.3. Advanced Usage</a></span></dt><dt><span class="sect2"><a href="#id36146521">5.1.4. Examples</a></span></dt></dl></div><p>The Minnesota MapServer is an internet web-mapping server which
conforms to the OpenGIS Web Mapping Server specification.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>The MapServer homepage is at <a class="ulink" href="http://mapserver.org" target="_top">http://mapserver.org</a>.</p></li><li class="listitem"><p>The OpenGIS Web Map Specification is at <a class="ulink" href="http://www.opengeospatial.org/standards/wms" target="_top">http://www.opengeospatial.org/standards/wms</a>.</p></li></ul></div><div class="sect2" title="5.1.1.Basic Usage"><div class="titlepage"><div><div><h3 class="title"><a name="id36146064"></a>5.1.1.Basic Usage</h3></div></div></div><p>To use PostGIS with MapServer, you will need to know about how to
configure MapServer, which is beyond the scope of this documentation.
This section will cover specific PostGIS issues and configuration
details.</p><p>To use PostGIS with MapServer, you will need:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Version 0.6 or newer of PostGIS.</p></li><li class="listitem"><p>Version 3.5 or newer of MapServer.</p></li></ul></div><p>MapServer accesses PostGIS/PostgreSQL data like any other
PostgreSQL client -- using the <code class="filename">libpq</code> interface. This means that
MapServer can be installed on any machine with network access to the
PostGIS server, and use PostGIS as a source of data. The faster the connection
between the systems, the better.</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Compile and install MapServer, with whatever options you
desire, including the "--with-postgis" configuration option.</p></li><li class="listitem"><p>In your MapServer map file, add a PostGIS layer. For
example:</p><pre class="programlisting">LAYER
CONNECTIONTYPE postgis
NAME "widehighways"
# Connect to a remote spatial database
CONNECTION "user=dbuser dbname=gisdatabase host=bigserver"
PROCESSING "CLOSE_CONNECTION=DEFER"
# Get the lines from the 'geom' column of the 'roads' table
DATA "geom from roads using srid=4326 using unique gid"
STATUS ON
TYPE LINE
# Of the lines in the extents, only render the wide highways
FILTER "type = 'highway' and numlanes >= 4"
CLASS
# Make the superhighways brighter and 2 pixels wide
EXPRESSION ([numlanes] >= 6)
STYLE
COLOR 255 22 22
WIDTH 2
END
END
CLASS
# All the rest are darker and only 1 pixel wide
EXPRESSION ([numlanes] < 6)
STYLE
COLOR 205 92 82
END
END
END</pre><p>In the example above, the PostGIS-specific directives are as
follows:</p><div class="variablelist"><dl><dt><span class="term">CONNECTIONTYPE</span></dt><dd><p>For PostGIS layers, this is always "postgis".</p></dd><dt><span class="term">CONNECTION</span></dt><dd><p>The database connection is governed by the a 'connection
string' which is a standard set of keys and values like this
(with the default values in <>):</p><p>user=<username> password=<password>
dbname=<username> hostname=<server>
port=<5432></p><p>An empty connection string is still valid, and any of
the key/value pairs can be omitted. At a minimum you will
generally supply the database name and username to connect
with.</p></dd><dt><span class="term">DATA</span></dt><dd><p>The form of this parameter is "<geocolumn> from
<tablename> using srid=<srid> using unique <primary key>" where the column is the spatial column to
be rendered to the map, the SRID is SRID used by the column and the primary key is the table primary key (or any
other uniquely-valued column with an index).</p><p>You can omit the "using srid" and "using unique" clauses and MapServer will automatically determine the
correct values if possible, but at the cost of running a few extra queries on the server for each map
draw.</p></dd><dt><span class="term">PROCESSING</span></dt><dd><p>Putting in a CLOSE_CONNECTION=DEFER if you have multiple layers reuses existing connections instead of closing them. This improves
speed. Refer to for <a class="ulink" href="http://blog.cleverelephant.ca/2008/10/mapserverpostgis-performance-tips.html" target="_top">MapServer PostGIS Performance Tips</a> for a more detailed explanation. </p></dd><dt><span class="term">FILTER</span></dt><dd><p>The filter must be a valid SQL string corresponding to
the logic normally following the "WHERE" keyword in a SQL
query. So, for example, to render only roads with 6 or more
lanes, use a filter of "num_lanes >= 6".</p></dd></dl></div></li><li class="listitem"><p>In your spatial database, ensure you have spatial (GiST)
indexes built for any the layers you will be drawing.</p><pre class="programlisting">CREATE INDEX [indexname] ON [tablename] USING GIST ( [geometrycolumn] );</pre></li><li class="listitem"><p>If you will be querying your layers using MapServer you will
also need to use the "using unique" clause in your DATA statement.</p><p>MapServer requires unique identifiers for each spatial record
when doing queries, and the PostGIS module of MapServer uses the
unique value you specify in order to provide these unique
identifiers. Using the table primary key is the best practice.</p></li></ol></div></div><div class="sect2" title="5.1.2.Frequently Asked Questions"><div class="titlepage"><div><div><h3 class="title"><a name="id36146276"></a>5.1.2.Frequently Asked Questions</h3></div></div></div><div class="qandaset" title="Frequently Asked Questions"><a name="id36146281"></a><dl><dt>5.1.2.1. <a href="#id36146284">When I use an EXPRESSION in my map file,
the condition never returns as true, even though I know the values
exist in my table.</a></dt><dt>5.1.2.2. <a href="#id36146313">The FILTER I use for my Shape files is not working for my
PostGIS table of the same data.</a></dt><dt>5.1.2.3. <a href="#id36146337">My PostGIS layer draws much slower than my Shape file layer,
is this normal?</a></dt><dt>5.1.2.4. <a href="#id36146367">My PostGIS layer draws fine, but queries are really slow.
What is wrong?</a></dt><dt>5.1.2.5. <a href="#id36146401">Can I use "geography" columns (new in PostGIS 1.5) as a source for
MapServer layers?</a></dt></dl><table border="0" width="100%" summary="Q and A Set"><col align="left" width="1%"><col><tbody><tr class="question" title="5.1.2.1."><td align="left" valign="top"><a name="id36146284"></a><a name="id36146286"></a><p><b>5.1.2.1.</b></p></td><td align="left" valign="top"><p>When I use an <code class="varname">EXPRESSION</code> in my map file,
the condition never returns as true, even though I know the values
exist in my table.</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Unlike shape files, PostGIS field names have to be
referenced in EXPRESSIONS using <span class="emphasis"><em>lower
case</em></span>.</p><pre class="programlisting">EXPRESSION ([numlanes] >= 6)</pre></td></tr><tr class="question" title="5.1.2.2."><td align="left" valign="top"><a name="id36146313"></a><a name="id36146315"></a><p><b>5.1.2.2.</b></p></td><td align="left" valign="top"><p>The FILTER I use for my Shape files is not working for my
PostGIS table of the same data.</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Unlike shape files, filters for PostGIS layers use SQL
syntax (they are appended to the SQL statement the PostGIS
connector generates for drawing layers in MapServer).</p><pre class="programlisting">FILTER "type = 'highway' and numlanes >= 4"</pre></td></tr><tr class="question" title="5.1.2.3."><td align="left" valign="top"><a name="id36146337"></a><a name="id36146339"></a><p><b>5.1.2.3.</b></p></td><td align="left" valign="top"><p>My PostGIS layer draws much slower than my Shape file layer,
is this normal?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>In general, the more features you are drawing into a given map,
the more likely it is that PostGIS will be slower than Shape files.
For maps with relatively few features (100s), PostGIS will often be faster.
For maps with high feature density (1000s), PostGIS will always be slower.
</p><p>If you are finding substantial draw performance problems, it
is possible that you have not built a spatial index on your
table.</p><pre class="programlisting">postgis# CREATE INDEX geotable_gix ON geotable USING GIST ( geocolumn );
postgis# VACUUM ANALYZE;</pre></td></tr><tr class="question" title="5.1.2.4."><td align="left" valign="top"><a name="id36146367"></a><a name="id36146369"></a><p><b>5.1.2.4.</b></p></td><td align="left" valign="top"><p>My PostGIS layer draws fine, but queries are really slow.
What is wrong?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>For queries to be fast, you must have a unique key for your
spatial table and you must have an index on that unique
key.</p><p>You can specify what unique key for mapserver to use with
the <code class="varname">USING UNIQUE</code> clause in your
<code class="varname">DATA</code> line:</p><pre class="programlisting">DATA "the_geom FROM geotable USING UNIQUE gid"</pre></td></tr><tr class="question" title="5.1.2.5."><td align="left" valign="top"><a name="id36146401"></a><a name="id36146403"></a><p><b>5.1.2.5.</b></p></td><td align="left" valign="top"><p>Can I use "geography" columns (new in PostGIS 1.5) as a source for
MapServer layers?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes! MapServer understands geography columns as being the same as
geometry columns, but always using an SRID of 4326. Just make sure to include
a "using srid=4326" clause in your <code class="varname">DATA</code> statement. Everything else
works exactly the same as with geometry.</p><pre class="programlisting">DATA "the_geog FROM geogtable USING SRID=4326 USING UNIQUE gid"</pre></td></tr></tbody></table></div></div><div class="sect2" title="5.1.3.Advanced Usage"><div class="titlepage"><div><div><h3 class="title"><a name="id36146431"></a>5.1.3.Advanced Usage</h3></div></div></div><p>The <code class="varname">USING</code> pseudo-SQL clause is used to add some
information to help mapserver understand the results of more complex
queries. More specifically, when either a view or a subselect is used as
the source table (the thing to the right of "FROM" in a
<code class="varname">DATA</code> definition) it is more difficult for mapserver
to automatically determine a unique identifier for each row and also the
SRID for the table. The <code class="varname">USING</code> clause can provide
mapserver with these two pieces of information as follows:</p><pre class="programlisting">DATA "the_geom FROM (
SELECT
table1.the_geom AS the_geom,
table1.oid AS oid,
table2.data AS data
FROM table1
LEFT JOIN table2
ON table1.id = table2.id
) AS new_table USING UNIQUE gid USING SRID=-1"</pre><div class="variablelist"><dl><dt><span class="term">USING UNIQUE <uniqueid></span></dt><dd><p>MapServer requires a unique id for each row in order to
identify the row when doing map queries. Normally it identifies
the primary key from the system tables. However, views and subselects don't
automatically have an known unique column. If you want to use MapServer's
query functionality, you need to ensure your view
or subselect includes a uniquely valued column, and declare it with <code class="varname">USING UNIQUE</code>.
For example, you could explicitly select nee of the table's primary key
values for this purpose, or any other column which is guaranteed
to be unique for the result set.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>"Querying a Map" is the action of clicking on a map to ask
for information about the map features in that location. Don't
confuse "map queries" with the SQL query in a
<code class="varname">DATA</code> definition.</p></td></tr></table></div></dd><dt><span class="term">USING SRID=<srid></span></dt><dd><p>PostGIS needs to know which spatial referencing system is
being used by the geometries in order to return the correct data
back to MapServer. Normally it is possible to find this
information in the "geometry_columns" table in the PostGIS
database, however, this is not possible for tables which are
created on the fly such as subselects and views. So the
<code class="varname">USING SRID=</code> option allows the correct SRID to
be specified in the <code class="varname">DATA</code> definition.</p></dd></dl></div></div><div class="sect2" title="5.1.4.Examples"><div class="titlepage"><div><div><h3 class="title"><a name="id36146521"></a>5.1.4.Examples</h3></div></div></div><p>Lets start with a simple example and work our way up. Consider the
following MapServer layer definition:</p><pre class="programlisting">LAYER
CONNECTIONTYPE postgis
NAME "roads"
CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
DATA "the_geom from roads"
STATUS ON
TYPE LINE
CLASS
STYLE
COLOR 0 0 0
END
END
END</pre><p>This layer will display all the road geometries in the roads table
as black lines.</p><p>Now lets say we want to show only the highways until we get zoomed
in to at least a 1:100000 scale - the next two layers will achieve this
effect:</p><pre class="programlisting">LAYER
CONNECTIONTYPE postgis
CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
PROCESSING "CLOSE_CONNECTION=DEFER"
DATA "the_geom from roads"
MINSCALE 100000
STATUS ON
TYPE LINE
FILTER "road_type = 'highway'"
CLASS
COLOR 0 0 0
END
END
LAYER
CONNECTIONTYPE postgis
CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
PROCESSING "CLOSE_CONNECTION=DEFER"
DATA "the_geom from roads"
MAXSCALE 100000
STATUS ON
TYPE LINE
CLASSITEM road_type
CLASS
EXPRESSION "highway"
STYLE
WIDTH 2
COLOR 255 0 0
END
END
CLASS
STYLE
COLOR 0 0 0
END
END
END</pre><p>The first layer is used when the scale is greater than 1:100000,
and displays only the roads of type "highway" as black lines. The
<code class="varname">FILTER</code> option causes only roads of type "highway" to
be displayed.</p><p>The second layer is used when the scale is less than 1:100000, and
will display highways as double-thick red lines, and other roads as
regular black lines.</p><p>So, we have done a couple of interesting things using only
MapServer functionality, but our <code class="varname">DATA</code> SQL statement
has remained simple. Suppose that the name of the road is stored in
another table (for whatever reason) and we need to do a join to get it
and label our roads.</p><pre class="programlisting">LAYER
CONNECTIONTYPE postgis
CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
DATA "the_geom FROM (SELECT roads.oid AS oid, roads.the_geom AS the_geom,
road_names.name as name FROM roads LEFT JOIN road_names ON
roads.road_name_id = road_names.road_name_id)
AS named_roads USING UNIQUE oid USING SRID=-1"
MAXSCALE 20000
STATUS ON
TYPE ANNOTATION
LABELITEM name
CLASS
LABEL
ANGLE auto
SIZE 8
COLOR 0 192 0
TYPE truetype
FONT arial
END
END
END</pre><p>This annotation layer adds green labels to all the roads when the
scale gets down to 1:20000 or less. It also demonstrates how to use an
SQL join in a <code class="varname">DATA</code> definition.</p></div></div><div class="sect1" title="5.2.Java Clients (JDBC)"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36146598"></a>5.2.Java Clients (JDBC)</h2></div></div></div><p>Java clients can access PostGIS "geometry" objects in the PostgreSQL
database either directly as text representations or using the JDBC
extension objects bundled with PostGIS. In order to use the extension
objects, the "postgis.jar" file must be in your CLASSPATH along with the
"postgresql.jar" JDBC driver package.</p><pre class="programlisting">import java.sql.*;
import java.util.*;
import java.lang.*;
import org.postgis.*;
public class JavaGIS {
public static void main(String[] args) {
java.sql.Connection conn;
try {
/*
* Load the JDBC driver and establish a connection.
*/
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost:5432/database";
conn = DriverManager.getConnection(url, "postgres", "");
/*
* Add the geometry types to the connection. Note that you
* must cast the connection to the pgsql-specific connection
* implementation before calling the addDataType() method.
*/
((org.postgresql.PGConnection)conn).addDataType("geometry",Class.forName("org.postgis.PGgeometry"));
((org.postgresql.PGConnection)conn).addDataType("box3d",Class.forName("org.postgis.PGbox3d"));
/*
* Create a statement and execute a select query.
*/
Statement s = conn.createStatement();
ResultSet r = s.executeQuery("select geom,id from geomtable");
while( r.next() ) {
/*
* Retrieve the geometry as an object then cast it to the geometry type.
* Print things out.
*/
PGgeometry geom = (PGgeometry)r.getObject(1);
int id = r.getInt(2);
System.out.println("Row " + id + ":");
System.out.println(geom.toString());
}
s.close();
conn.close();
}
catch( Exception e ) {
e.printStackTrace();
}
}
}</pre><p>The "PGgeometry" object is a wrapper object which contains a
specific topological geometry object (subclasses of the abstract class
"Geometry") depending on the type: Point, LineString, Polygon, MultiPoint,
MultiLineString, MultiPolygon.</p><pre class="programlisting">PGgeometry geom = (PGgeometry)r.getObject(1);
if( geom.getType() == Geometry.POLYGON ) {
Polygon pl = (Polygon)geom.getGeometry();
for( int r = 0; r < pl.numRings(); r++) {
LinearRing rng = pl.getRing(r);
System.out.println("Ring: " + r);
for( int p = 0; p < rng.numPoints(); p++ ) {
Point pt = rng.getPoint(p);
System.out.println("Point: " + p);
System.out.println(pt.toString());
}
}
}</pre><p>The JavaDoc for the extension objects provides a reference for the
various data accessor functions in the geometric objects.</p></div><div class="sect1" title="5.3.C Clients (libpq)"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36146641"></a>5.3.C Clients (libpq)</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#id36146649">5.3.1. Text Cursors</a></span></dt><dt><span class="sect2"><a href="#id36146659">5.3.2. Binary Cursors</a></span></dt></dl></div><p>...</p><div class="sect2" title="5.3.1.Text Cursors"><div class="titlepage"><div><div><h3 class="title"><a name="id36146649"></a>5.3.1.Text Cursors</h3></div></div></div><p>...</p></div><div class="sect2" title="5.3.2.Binary Cursors"><div class="titlepage"><div><div><h3 class="title"><a name="id36146659"></a>5.3.2.Binary Cursors</h3></div></div></div><p>...</p></div></div></div><div class="chapter" title="Chapter6.Performance tips"><div class="titlepage"><div><div><h2 class="title"><a name="id36147299"></a>Chapter6.Performance tips</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#id36147305">6.1. Small tables of large geometries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36147310">6.1.1. Problem description</a></span></dt><dt><span class="sect2"><a href="#id36147348">6.1.2. Workarounds</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id36147399">6.2. CLUSTERing on geometry indices</a></span></dt><dt><span class="sect1"><a href="#id36147441">6.3. Avoiding dimension conversion</a></span></dt><dt><span class="sect1"><a href="#id36147469">6.4. Tuning your configuration</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id36147498">6.4.1. Startup</a></span></dt><dt><span class="sect2"><a href="#id36147606">6.4.2. Runtime</a></span></dt></dl></dd></dl></div><div class="sect1" title="6.1.Small tables of large geometries"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36147305"></a>6.1.Small tables of large geometries</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#id36147310">6.1.1. Problem description</a></span></dt><dt><span class="sect2"><a href="#id36147348">6.1.2. Workarounds</a></span></dt></dl></div><div class="sect2" title="6.1.1.Problem description"><div class="titlepage"><div><div><h3 class="title"><a name="id36147310"></a>6.1.1.Problem description</h3></div></div></div><p>Current PostgreSQL versions (including 8.0) suffer from a query
optimizer weakness regarding TOAST tables. TOAST tables are a kind of
"extension room" used to store large (in the sense of data size) values
that do not fit into normal data pages (like long texts, images or
complex geometries with lots of vertices), see
http://www.postgresql.org/docs/current/interactive/storage-toast.html for more
information).</p><p>The problem appears if you happen to have a table with rather
large geometries, but not too much rows of them (like a table containing
the boundaries of all European countries in high resolution). Then the
table itself is small, but it uses lots of TOAST space. In our example
case, the table itself had about 80 rows and used only 3 data pages, but
the TOAST table used 8225 pages.</p><p>Now issue a query where you use the geometry operator &&
to search for a bounding box that matches only very few of those rows.
Now the query optimizer sees that the table has only 3 pages and 80
rows. He estimates that a sequential scan on such a small table is much
faster than using an index. And so he decides to ignore the GIST index.
Usually, this estimation is correct. But in our case, the &&
operator has to fetch every geometry from disk to compare the bounding
boxes, thus reading all TOAST pages, too.</p><p>To see whether your suffer from this bug, use the "EXPLAIN
ANALYZE" postgresql command. For more information and the technical
details, you can read the thread on the postgres performance mailing
list:
http://archives.postgresql.org/pgsql-performance/2005-02/msg00030.php</p></div><div class="sect2" title="6.1.2.Workarounds"><div class="titlepage"><div><div><h3 class="title"><a name="id36147348"></a>6.1.2.Workarounds</h3></div></div></div><p>The PostgreSQL people are trying to solve this issue by making the
query estimation TOAST-aware. For now, here are two workarounds:</p><p>The first workaround is to force the query planner to use the
index. Send "SET enable_seqscan TO off;" to the server before issuing
the query. This basically forces the query planner to avoid sequential
scans whenever possible. So it uses the GIST index as usual. But this
flag has to be set on every connection, and it causes the query planner
to make misestimations in other cases, so you should "SET enable_seqscan
TO on;" after the query.</p><p>The second workaround is to make the sequential scan as fast as
the query planner thinks. This can be achieved by creating an additional
column that "caches" the bbox, and matching against this. In our
example, the commands are like:</p><pre class="programlisting">SELECT AddGeometryColumn('myschema','mytable','bbox','4326','GEOMETRY','2');
UPDATE mytable SET bbox = ST_Envelope(ST_Force_2d(the_geom));</pre><p>Now change your query to use the && operator against bbox
instead of geom_column, like:</p><pre class="programlisting">SELECT geom_column
FROM mytable
WHERE bbox && ST_SetSRID('BOX3D(0 0,1 1)'::box3d,4326);</pre><p>Of course, if you change or add rows to mytable, you have to keep
the bbox "in sync". The most transparent way to do this would be
triggers, but you also can modify your application to keep the bbox
column current or run the UPDATE query above after every
modification.</p></div></div><div class="sect1" title="6.2.CLUSTERing on geometry indices"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36147399"></a>6.2.CLUSTERing on geometry indices</h2></div></div></div><p>For tables that are mostly read-only, and where a single index is
used for the majority of queries, PostgreSQL offers the CLUSTER command.
This command physically reorders all the data rows in the same order as
the index criteria, yielding two performance advantages: First, for index
range scans, the number of seeks on the data table is drastically reduced.
Second, if your working set concentrates to some small intervals on the
indices, you have a more efficient caching because the data rows are
spread along fewer data pages. (Feel invited to read the CLUSTER command
documentation from the PostgreSQL manual at this point.)</p><p>However, currently PostgreSQL does not allow clustering on PostGIS
GIST indices because GIST indices simply ignores NULL values, you get an
error message like:</p><pre class="programlisting">lwgeom=# CLUSTER my_geom_index ON my_table;
ERROR: cannot cluster when index access method does not handle null values
HINT: You may be able to work around this by marking column "the_geom" NOT NULL.</pre><p>As the HINT message tells you, one can work around this deficiency
by adding a "not null" constraint to the table:</p><pre class="programlisting">lwgeom=# ALTER TABLE my_table ALTER COLUMN the_geom SET not null;
ALTER TABLE</pre><p>Of course, this will not work if you in fact need NULL values in
your geometry column. Additionally, you must use the above method to add
the constraint, using a CHECK constraint like "ALTER TABLE blubb ADD CHECK
(geometry is not null);" will not work.</p></div><div class="sect1" title="6.3.Avoiding dimension conversion"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36147441"></a>6.3.Avoiding dimension conversion</h2></div></div></div><p>Sometimes, you happen to have 3D or 4D data in your table, but
always access it using OpenGIS compliant ST_AsText() or ST_AsBinary()
functions that only output 2D geometries. They do this by internally
calling the ST_Force_2d() function, which introduces a significant
overhead for large geometries. To avoid this overhead, it may be feasible
to pre-drop those additional dimensions once and forever:</p><pre class="programlisting">UPDATE mytable SET the_geom = ST_Force_2d(the_geom);
VACUUM FULL ANALYZE mytable;</pre><p>Note that if you added your geometry column using
AddGeometryColumn() there'll be a constraint on geometry dimension. To
bypass it you will need to drop the constraint. Remember to update the
entry in the geometry_columns table and recreate the constraint
afterwards.</p><p>In case of large tables, it may be wise to divide this UPDATE into
smaller portions by constraining the UPDATE to a part of the table via a
WHERE clause and your primary key or another feasible criteria, and
running a simple "VACUUM;" between your UPDATEs. This drastically reduces
the need for temporary disk space. Additionally, if you have mixed
dimension geometries, restricting the UPDATE by "WHERE
dimension(the_geom)>2" skips re-writing of geometries that already are
in 2D.</p></div><div class="sect1" title="6.4.Tuning your configuration"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36147469"></a>6.4.Tuning your configuration</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#id36147498">6.4.1. Startup</a></span></dt><dt><span class="sect2"><a href="#id36147606">6.4.2. Runtime</a></span></dt></dl></div><p>These tips are taken from Kevin Neufeld's presentation "Tips for the
PostGIS Power User" at the FOSS4G 2007 conference. Depending on your
use of PostGIS (for example, static data and complex analysis vs frequently
updated data and lots of users) these changes can provide significant
speedups to your queries.</p><p>For a more tips (and better formatting), the original presentation
is at
<a class="ulink" href="http://2007.foss4g.org/presentations/view.php?abstract_id=117" target="_top">
http://2007.foss4g.org/presentations/view.php?abstract_id=117</a>.
</p><div class="sect2" title="6.4.1.Startup"><div class="titlepage"><div><div><h3 class="title"><a name="id36147498"></a>6.4.1.Startup</h3></div></div></div><p>
These settings are configured in postgresql.conf:
</p><p>
<a class="ulink" href="http://www.postgresql.org/docs/current/interactive/runtime-config-wal.html#GUC-CHECKPOINT-SEGMENTS" target="_top">checkpoint_segment_size</a>
(this setting is obsolete in newer versions of PostgreSQL) got replaced with
many configurations with names starting with checkpoint and WAL.
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
# of WAL files = 16MB each; default is 3
</p></li><li class="listitem"><p>
Set to at least 10 or 30 for databases with heavy write activity, or
more for large database loads. Another article on the topic worth reading <a class="ulink" href="http://www.westnet.com/~gsmith/content/postgresql/chkp-bgw-83.htm" target="_top">Greg Smith: Checkpoint and Background writer</a>
</p></li><li class="listitem"><p>
Possibly store the xlog on a separate disk device
</p></li></ul></div><p>
<a class="ulink" href="http://www.postgresql.org/docs/current/interactive/runtime-config-query.html#GUC-CONSTRAINT-EXCLUSION" target="_top">constraint_exclusion</a>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
Default: off (prior to PostgreSQL 8.4 and for PostgreSQL 8.4+ is set to partition)
</p></li><li class="listitem"><p>
This is generally used for table partitioning. If you are running PostgreSQL versions below 8.4, set to "on" to ensure the query planner will optimize as desired.
As of PostgreSQL 8.4, the default for this is set to "partition" which is ideal for PostgreSQL 8.4 and above since
it will force the planner to only analyze tables for constraint consideration if they are in an inherited hierarchy
and not pay the planner penalty otherwise.
</p></li></ul></div><p>
<a class="ulink" href="http://www.postgresql.org/docs/current/interactive/runtime-config-resource.html" target="_top">shared_buffers</a>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
Default: ~32MB
</p></li><li class="listitem"><p>
Set to about 1/3 to 3/4 of available RAM
</p></li></ul></div></div><div class="sect2" title="6.4.2.Runtime"><div class="titlepage"><div><div><h3 class="title"><a name="id36147606"></a>6.4.2.Runtime</h3></div></div></div><p>
<a class="ulink" href="http://www.postgresql.org/docs/current/interactive/runtime-config-resource.html#GUC-WORK-MEM" target="_top">work_mem</a> (the memory used for sort operations and complex queries)
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
Default: 1MB
</p></li><li class="listitem"><p>
Adjust up for large dbs, complex queries, lots of RAM
</p></li><li class="listitem"><p>
Adjust down for many concurrent users or low RAM.
</p></li><li class="listitem"><p>
If you have lots of RAM and few developers:
</p><pre class="programlisting">
SET work_mem TO 1200000;
</pre><p>
</p></li></ul></div><p>
<a class="ulink" href="http://www.postgresql.org/docs/current/interactive/runtime-config-resource.html#GUC-MAINTENANCE-WORK-MEM" target="_top">maintenance_work_mem</a> (used for VACUUM, CREATE INDEX, etc.)
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
Default: 16MB
</p></li><li class="listitem"><p>
Generally too low - ties up I/O, locks objects while swapping memory
</p></li><li class="listitem"><p>
Recommend 32MB to 256MB on production servers w/lots of RAM, but depends
on the # of concurrent users. If you have lots of RAM and few developers:
</p><pre class="programlisting">
SET maintainence_work_mem TO 1200000;
</pre><p>
</p></li></ul></div></div></div></div><div class="chapter" title="Chapter7.PostGIS Reference"><div class="titlepage"><div><div><h2 class="title"><a name="reference"></a>Chapter7.PostGIS Reference</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#PostGIS_Types">7.1. PostgreSQL PostGIS Types</a></span></dt><dt><span class="sect1"><a href="#Management_Functions">7.2. Management Functions</a></span></dt><dt><span class="sect1"><a href="#Geometry_Constructors">7.3. Geometry Constructors</a></span></dt><dt><span class="sect1"><a href="#Geometry_Accessors">7.4. Geometry Accessors</a></span></dt><dt><span class="sect1"><a href="#Geometry_Editors">7.5. Geometry Editors</a></span></dt><dt><span class="sect1"><a href="#Geometry_Outputs">7.6. Geometry Outputs</a></span></dt><dt><span class="sect1"><a href="#Operators">7.7. Operators</a></span></dt><dt><span class="sect1"><a href="#Spatial_Relationships_Measurements">7.8. Spatial Relationships and Measurements</a></span></dt><dt><span class="sect1"><a href="#Geometry_Processing">7.9. Geometry Processing Functions</a></span></dt><dt><span class="sect1"><a href="#Linear_Referencing">7.10. Linear Referencing</a></span></dt><dt><span class="sect1"><a href="#Long_Transactions_Support">7.11. Long Transactions Support</a></span></dt><dt><span class="sect1"><a href="#Miscellaneous_Functions">7.12. Miscellaneous Functions</a></span></dt><dt><span class="sect1"><a href="#Exceptional_Functions">7.13. Exceptional Functions</a></span></dt></dl></div><p>The functions given below are the ones which a user of PostGIS is
likely to need. There are other functions which are required support
functions to the PostGIS objects which are not of use to a general
user.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>PostGIS has begun a transition from the existing naming convention
to an SQL-MM-centric convention. As a result, most of the functions that
you know and love have been renamed using the standard spatial type (ST)
prefix. Previous functions are still available, though are not listed in
this document where updated functions are equivalent. The non ST_ functions not listed in this documentation are
deprecated and will be removed in a future release so STOP USING THEM.</p></td></tr></table></div><div class="sect1" title="7.1.PostgreSQL PostGIS Types"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PostGIS_Types"></a>7.1.PostgreSQL PostGIS Types</h2></div><div><div class="abstract" title="Abstract"><p class="title"><b>Abstract</b></p><p>This section lists the PostgreSQL data types installed by PostGIS. Note we describe the casting behavior of these which is very
important especially when designing your own functions.
</p><p>A Cast is when one type is coerced into another type. PostgreSQL
is unique from most databases in that it allows you to define casting behavior for custom types and the functions used for casting.
A cast can be specified as automatic in which case, you do not have to do a CAST(myfoo As otherfootype) or myfoo::otherfootype
if you are feeding it to a function that only works with otherfootype and there is an automatic cast in place for it.
</p><p>The danger of relying on automatic cast behavior is when you have an overloaded function say one that takes a box2d and one that takes a box3d
but no geometry. What happens is that both functions are equally good to use with geometry since geometry has an autocast for both
-- so you end up with an ambiguous function error. To force PostgreSQL to choose, you do a CAST(mygeom As box3d) or mygeom::box3d.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top">At least as of PostgreSQL 8.3 - Everything can be CAST to text (presumably because of the magical unknown type), so no defined CASTS for that need to be present for you to CAST an object to text.</td></tr></table></div></div></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#box2d">box2d</a></span><span class="refpurpose"> — A box composed of x min, ymin, xmax, ymax. Often used to return the 2d enclosing box of a geometry. </span></dt><dt><span class="refentrytitle"><a href="#box3d">box3d</a></span><span class="refpurpose"> — A box composed of x min, ymin, zmin, xmax, ymax, zmax. Often used to return the 3d extent of a geometry or collection of geometries. </span></dt><dt><span class="refentrytitle"><a href="#box3d_extent">box3d_extent</a></span><span class="refpurpose"> — A box composed of x min, ymin, zmin, xmax, ymax, zmax. Often used to return the extent of a geometry.</span></dt><dt><span class="refentrytitle"><a href="#geometry">geometry</a></span><span class="refpurpose"> — Planar spatial data type.</span></dt><dt><span class="refentrytitle"><a href="#geometry_dump">geometry_dump</a></span><span class="refpurpose"> — A spatial datatype with two fields - geom (holding a geometry object)
and path[] (a 1-d array holding the position of the geometry within the dumped object.)</span></dt><dt><span class="refentrytitle"><a href="#geography">geography</a></span><span class="refpurpose"> — Ellipsoidal spatial data type.</span></dt></dl></div><div class="refentry" title="box2d"><a name="box2d"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>box2d — A box composed of x min, ymin, xmax, ymax. Often used to return the 2d enclosing box of a geometry. </p></div><div class="refsection" title="Description"><a name="id36148186"></a><h2>Description</h2><p>box2d is a spatial data type used to represent the enclosing box of a geometry or set of geometries. ST_Extent in earlier versions prior to PostGIS 1.4 would return a box2d.</p></div></div><div class="refentry" title="box3d"><div class="refentry.separator"><hr></div><a name="box3d"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>box3d — A box composed of x min, ymin, zmin, xmax, ymax, zmax. Often used to return the 3d extent of a geometry or collection of geometries. </p></div><div class="refsection" title="Description"><a name="id36148213"></a><h2>Description</h2><p>box3d is a postgis spatial data type used to represent the enclosing box of a geometry or set of geometries. ST_Extent3D returns a box3d object.</p></div><div class="refsection" title="Casting Behavor"><a name="id36148224"></a><h2>Casting Behavor</h2><p>This section lists the automatic as well as explicit casts allowed for this data type</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td>Cast To</td><td>Behavior</td></tr><tr><td>box</td><td>automatic</td></tr><tr><td>box2d</td><td>automatic</td></tr><tr><td>geometry</td><td>automatic</td></tr></tbody></table></div></div></div><div class="refentry" title="box3d_extent"><div class="refentry.separator"><hr></div><a name="box3d_extent"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>box3d_extent — A box composed of x min, ymin, zmin, xmax, ymax, zmax. Often used to return the extent of a geometry.</p></div><div class="refsection" title="Description"><a name="id36148304"></a><h2>Description</h2><p>box3d_extent is a data type returned by ST_Extent. In versions prior to PostGIS 1.4, ST_Extent would return a box2d.</p></div><div class="refsection" title="Casting Behavor"><a name="id36148315"></a><h2>Casting Behavor</h2><p>This section lists the automatic as well as explicit casts allowed for this data type</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td>Cast To</td><td>Behavior</td></tr><tr><td>box2d</td><td>automatic</td></tr><tr><td>box3d</td><td>automatic</td></tr><tr><td>geometry</td><td>automatic</td></tr></tbody></table></div></div><div class="refsection" title="See Also"><a name="id36148379"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_BoxFunctions" title="8.5.PostGIS Box Functions">Section8.5, “PostGIS Box Functions”</a> </p></div></div><div class="refentry" title="geometry"><div class="refentry.separator"><hr></div><a name="geometry"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>geometry — Planar spatial data type.</p></div><div class="refsection" title="Description"><a name="id36148406"></a><h2>Description</h2><p>geometry is a fundamental postgis spatial data type used to represent a feature in the Euclidean coordinate system.</p></div><div class="refsection" title="Casting Behavor"><a name="id36148416"></a><h2>Casting Behavor</h2><p>This section lists the automatic as well as explicit casts allowed for this data type</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td>Cast To</td><td>Behavior</td></tr><tr><td>box</td><td>automatic</td></tr><tr><td>box2d</td><td>automatic</td></tr><tr><td>box3d</td><td>automatic</td></tr><tr><td>bytea</td><td>automatic</td></tr><tr><td>geography</td><td>automatic</td></tr><tr><td>text</td><td>automatic</td></tr></tbody></table></div></div><div class="refsection" title="See Also"><a name="id36148509"></a><h2>See Also</h2><p><a class="xref" href="#RefObject" title="4.1.GIS Objects">Section4.1, “GIS Objects”</a></p></div></div><div class="refentry" title="geometry_dump"><div class="refentry.separator"><hr></div><a name="geometry_dump"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>geometry_dump — A spatial datatype with two fields - geom (holding a geometry object)
and path[] (a 1-d array holding the position of the geometry within the dumped object.)</p></div><div class="refsection" title="Description"><a name="id36148537"></a><h2>Description</h2><p>geometry_dump is a compound data type consisting of a geometry object referenced by the .geom field
and path[] a 1-dimensional integer array (starting at 1 e.g. path[1] to get first element) array that defines the navigation path within the dumped geometry to find this element.
It is used by the ST_Dump* family of functions as an output type to explode a more complex geometry into its
constituent parts and location of parts.</p></div><div class="refsection" title="See Also"><a name="id36148550"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_Geometry_DumpFunctions" title="8.4.PostGIS Geometry Dump Functions">Section8.4, “PostGIS Geometry Dump Functions”</a> </p></div></div><div class="refentry" title="geography"><div class="refentry.separator"><hr></div><a name="geography"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>geography — Ellipsoidal spatial data type.</p></div><div class="refsection" title="Description"><a name="id36148577"></a><h2>Description</h2><p>geography is a spatial data type used to represent a feature in the round-earth coordinate system.</p></div><div class="refsection" title="Casting Behavor"><a name="id36148588"></a><h2>Casting Behavor</h2><p>This section lists the automatic as well as explicit casts allowed for this data type</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td>Cast To</td><td>Behavior</td></tr><tr><td>geometry</td><td>explicit</td></tr></tbody></table></div></div><div class="refsection" title="See Also"><a name="id36148633"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_GeographyFunctions" title="8.3.PostGIS Geography Support Functions">Section8.3, “PostGIS Geography Support Functions”</a>,<a class="xref" href="#PostGIS_Geography" title="4.2.PostGIS Geography Type">Section4.2, “PostGIS Geography Type”</a></p></div></div></div><div class="sect1" title="7.2.Management Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Management_Functions"></a>7.2.Management Functions</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#AddGeometryColumn">AddGeometryColumn</a></span><span class="refpurpose"> — Adds a geometry column to an existing table of
attributes.</span></dt><dt><span class="refentrytitle"><a href="#DropGeometryColumn">DropGeometryColumn</a></span><span class="refpurpose"> — Removes a geometry column from a spatial
table.</span></dt><dt><span class="refentrytitle"><a href="#DropGeometryTable">DropGeometryTable</a></span><span class="refpurpose"> — Drops a table and all its references in
geometry_columns.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_Full_Version">PostGIS_Full_Version</a></span><span class="refpurpose"> — Reports full postgis version and build configuration
infos.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_GEOS_Version">PostGIS_GEOS_Version</a></span><span class="refpurpose"> — Returns the version number of the GEOS
library.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_LibXML_Version">PostGIS_LibXML_Version</a></span><span class="refpurpose"> — Returns the version number of the libxml2
library.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_Lib_Build_Date">PostGIS_Lib_Build_Date</a></span><span class="refpurpose"> — Returns build date of the PostGIS library.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_Lib_Version">PostGIS_Lib_Version</a></span><span class="refpurpose"> — Returns the version number of the PostGIS
library.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_PROJ_Version">PostGIS_PROJ_Version</a></span><span class="refpurpose"> — Returns the version number of the PROJ4
library.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_Scripts_Build_Date">PostGIS_Scripts_Build_Date</a></span><span class="refpurpose"> — Returns build date of the PostGIS scripts.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_Scripts_Installed">PostGIS_Scripts_Installed</a></span><span class="refpurpose"> — Returns version of the postgis scripts installed in this
database.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_Scripts_Released">PostGIS_Scripts_Released</a></span><span class="refpurpose"> — Returns the version number of the postgis.sql script
released with the installed postgis lib.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_Uses_Stats">PostGIS_Uses_Stats</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if STATS usage has been
enabled.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_Version">PostGIS_Version</a></span><span class="refpurpose"> — Returns PostGIS version number and compile-time
options.</span></dt><dt><span class="refentrytitle"><a href="#Populate_Geometry_Columns">Populate_Geometry_Columns</a></span><span class="refpurpose"> — Ensures geometry columns have appropriate spatial constraints
and exist in the <code class="varname">geometry_columns</code> table.</span></dt><dt><span class="refentrytitle"><a href="#Probe_Geometry_Columns">Probe_Geometry_Columns</a></span><span class="refpurpose"> — Scans all tables with PostGIS geometry constraints and adds them to the <code class="varname">geometry_columns</code>
table if they are not there.</span></dt><dt><span class="refentrytitle"><a href="#UpdateGeometrySRID">UpdateGeometrySRID</a></span><span class="refpurpose"> — Updates the SRID of all features in a geometry
column, geometry_columns metadata and srid table constraint</span></dt></dl></div><div class="refentry" title="AddGeometryColumn"><a name="AddGeometryColumn"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>AddGeometryColumn — Adds a geometry column to an existing table of
attributes.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">AddGeometryColumn</b>(</code>varchar
<var class="pdparam">table_name</var>, varchar
<var class="pdparam">column_name</var>, integer
<var class="pdparam">srid</var>, varchar
<var class="pdparam">type</var>, integer
<var class="pdparam">dimension</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">AddGeometryColumn</b>(</code>varchar
<var class="pdparam">schema_name</var>, varchar
<var class="pdparam">table_name</var>, varchar
<var class="pdparam">column_name</var>, integer
<var class="pdparam">srid</var>, varchar
<var class="pdparam">type</var>, integer
<var class="pdparam">dimension</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">AddGeometryColumn</b>(</code>varchar
<var class="pdparam">catalog_name</var>, varchar
<var class="pdparam">schema_name</var>, varchar
<var class="pdparam">table_name</var>, varchar
<var class="pdparam">column_name</var>, integer
<var class="pdparam">srid</var>, varchar
<var class="pdparam">type</var>, integer
<var class="pdparam">dimension</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36149395"></a><h2>Description</h2><p>Adds a geometry column to an existing table of attributes. The
<code class="varname">schema_name</code> is the name of the table schema (unused
for pre-schema PostgreSQL installations). The <code class="varname">srid</code>
must be an integer value reference to an entry in the SPATIAL_REF_SYS
table. The <code class="varname">type</code> must be an uppercase string
corresponding to the geometry type, eg, 'POLYGON' or
'MULTILINESTRING'. An error is thrown if the schemaname doesn't exist
(or not visible in the current search_path) or the specified SRID,
geometry type, or dimension is invalid.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Views and derivatively created spatial tables will need to be registered in geometry_columns manually,
since AddGeometryColumn also adds a spatial column which is not needed when you already have a spatial column. Refer to <a class="xref" href="#Manual_Register_Spatial_Column" title="4.3.4.Manually Registering Geometry Columns in geometry_columns">Section4.3.4, “Manually Registering Geometry Columns in geometry_columns”</a>.
</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36149476"></a><h2>Examples</h2><pre class="programlisting">
-- Create a new simple PostgreSQL table
postgis=# CREATE TABLE my_schema.my_spatial_table (id serial);
-- Describing the table shows a simple table with a single "id" column.
postgis=# \d my_schema.my_spatial_table
Table "my_schema.my_spatial_table"
Column | Type | Modifiers
--------+---------+-------------------------------------------------------------------------
id | integer | not null default nextval('my_schema.my_spatial_table_id_seq'::regclass)
-- Add a spatial column to the table
postgis=# SELECT AddGeometryColumn ('my_schema','my_spatial_table','the_geom',4326,'POINT',2);
--Add a curvepolygon
SELECT AddGeometryColumn ('my_schema','my_spatial_table','the_geomcp',4326,'CURVEPOLYGON',2);
-- Describe the table again reveals the addition of a new "the_geom" column.
postgis=# \d my_schema.my_spatial_table
Column | Type | Modifiers
------------+----------+-------------------------------------------------------------------------
id | integer | not null default nextval('my_schema.my_spatial_table_id_seq'::regclass)
the_geom | geometry |
the_geomcp | geometry |
Check constraints:
"enforce_dims_the_geom" CHECK (ndims(the_geom) = 2)
"enforce_dims_the_geomcp" CHECK (ndims(the_geomcp) = 2)
"enforce_geotype_the_geom" CHECK (geometrytype(the_geom) = 'POINT'::text OR
the_geom IS NULL)
"enforce_geotype_the_geomcp" CHECK (geometrytype(the_geomcp) = 'CURVEPOLYGON
'::text OR the_geomcp IS NULL)
"enforce_srid_the_geom" CHECK (srid(the_geom) = 4326)
"enforce_srid_the_geomcp" CHECK (srid(the_geomcp) = 4326)</pre></div><div class="refsection" title="See Also"><a name="id36149440"></a><h2>See Also</h2><p><a class="xref" href="#DropGeometryColumn" title="DropGeometryColumn">DropGeometryColumn</a>, <a class="xref" href="#DropGeometryTable" title="DropGeometryTable">DropGeometryTable</a>, <a class="xref" href="#Manual_Register_Spatial_Column" title="4.3.4.Manually Registering Geometry Columns in geometry_columns">Section4.3.4, “Manually Registering Geometry Columns in geometry_columns”</a></p></div></div><div class="refentry" title="DropGeometryColumn"><div class="refentry.separator"><hr></div><a name="DropGeometryColumn"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>DropGeometryColumn — Removes a geometry column from a spatial
table.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">DropGeometryColumn</b>(</code>varchar
<var class="pdparam">table_name</var>, varchar
<var class="pdparam">column_name</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">DropGeometryColumn</b>(</code>varchar
<var class="pdparam">schema_name</var>, varchar
<var class="pdparam">table_name</var>, varchar
<var class="pdparam">column_name</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">DropGeometryColumn</b>(</code>varchar
<var class="pdparam">catalog_name</var>, varchar
<var class="pdparam">schema_name</var>, varchar
<var class="pdparam">table_name</var>, varchar
<var class="pdparam">column_name</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36149776"></a><h2>Description</h2><p>Removes a geometry column from a spatial table. Note that
schema_name will need to match the f_table_schema field of the table's
row in the geometry_columns table.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36149825"></a><h2>Examples</h2><pre class="programlisting">
SELECT DropGeometryColumn ('my_schema','my_spatial_table','the_geomcp');
----RESULT output ---
my_schema.my_spatial_table.the_geomcp effectively removed.
</pre></div><div class="refsection" title="See Also"><a name="id36149838"></a><h2>See Also</h2><p><a class="xref" href="#AddGeometryColumn" title="AddGeometryColumn">AddGeometryColumn</a>, <a class="xref" href="#DropGeometryTable" title="DropGeometryTable">DropGeometryTable</a></p></div></div><div class="refentry" title="DropGeometryTable"><div class="refentry.separator"><hr></div><a name="DropGeometryTable"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>DropGeometryTable — Drops a table and all its references in
geometry_columns.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">DropGeometryTable</b>(</code>varchar
<var class="pdparam">table_name</var><code>)</code>;</p><p><code class="funcdef">boolean <b class="fsfunc">DropGeometryTable</b>(</code>varchar
<var class="pdparam">schema_name</var>, varchar
<var class="pdparam">table_name</var><code>)</code>;</p><p><code class="funcdef">boolean <b class="fsfunc">DropGeometryTable</b>(</code>varchar
<var class="pdparam">catalog_name</var>, varchar
<var class="pdparam">schema_name</var>, varchar
<var class="pdparam">table_name</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36149962"></a><h2>Description</h2><p>Drops a table and all its references in geometry_columns. Note:
uses current_schema() on schema-aware pgsql installations if schema is
not provided.</p></div><div class="refsection" title="Examples"><a name="id36149973"></a><h2>Examples</h2><pre class="programlisting">
SELECT DropGeometryTable ('my_schema','my_spatial_table');
----RESULT output ---
my_schema.my_spatial_table dropped.
</pre></div><div class="refsection" title="See Also"><a name="id36149986"></a><h2>See Also</h2><p><a class="xref" href="#AddGeometryColumn" title="AddGeometryColumn">AddGeometryColumn</a>, <a class="xref" href="#DropGeometryColumn" title="DropGeometryColumn">DropGeometryColumn</a></p></div></div><div class="refentry" title="PostGIS_Full_Version"><div class="refentry.separator"><hr></div><a name="PostGIS_Full_Version"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_Full_Version — Reports full postgis version and build configuration
infos.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">PostGIS_Full_Version</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36150036"></a><h2>Description</h2><p>Reports full postgis version and build configuration
infos.</p></div><div class="refsection" title="Examples"><a name="id36150046"></a><h2>Examples</h2><pre class="programlisting">SELECT PostGIS_Full_Version();
postgis_full_version
----------------------------------------------------------------------------------
POSTGIS="1.3.3" GEOS="3.1.0-CAPI-1.5.0" PROJ="Rel. 4.4.9, 29 Oct 2004" USE_STATS
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36150059"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_GEOS_Version" title="PostGIS_GEOS_Version">PostGIS_GEOS_Version</a>, <a class="xref" href="#PostGIS_Lib_Version" title="PostGIS_Lib_Version">PostGIS_Lib_Version</a>, <a class="xref" href="#PostGIS_LibXML_Version" title="PostGIS_LibXML_Version">PostGIS_LibXML_Version</a>, <a class="xref" href="#PostGIS_PROJ_Version" title="PostGIS_PROJ_Version">PostGIS_PROJ_Version</a>, <a class="xref" href="#PostGIS_Version" title="PostGIS_Version">PostGIS_Version</a></p></div></div><div class="refentry" title="PostGIS_GEOS_Version"><div class="refentry.separator"><hr></div><a name="PostGIS_GEOS_Version"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_GEOS_Version — Returns the version number of the GEOS
library.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">PostGIS_GEOS_Version</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36150121"></a><h2>Description</h2><p>Returns the version number of the GEOS library, or
<code class="varname">NULL</code> if GEOS support is not enabled.</p></div><div class="refsection" title="Examples"><a name="id36150134"></a><h2>Examples</h2><pre class="programlisting">SELECT PostGIS_GEOS_Version();
postgis_geos_version
----------------------
3.1.0-CAPI-1.5.0
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36150146"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_Full_Version" title="PostGIS_Full_Version">PostGIS_Full_Version</a>, <a class="xref" href="#PostGIS_Lib_Version" title="PostGIS_Lib_Version">PostGIS_Lib_Version</a>, <a class="xref" href="#PostGIS_LibXML_Version" title="PostGIS_LibXML_Version">PostGIS_LibXML_Version</a>, <a class="xref" href="#PostGIS_PROJ_Version" title="PostGIS_PROJ_Version">PostGIS_PROJ_Version</a>, <a class="xref" href="#PostGIS_Version" title="PostGIS_Version">PostGIS_Version</a></p></div></div><div class="refentry" title="PostGIS_LibXML_Version"><div class="refentry.separator"><hr></div><a name="PostGIS_LibXML_Version"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_LibXML_Version — Returns the version number of the libxml2
library.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">PostGIS_LibXML_Version</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36150208"></a><h2>Description</h2><p>Returns the version number of the LibXML2 library.</p><p>Availability: 1.5</p></div><div class="refsection" title="Examples"><a name="id36150221"></a><h2>Examples</h2><pre class="programlisting">SELECT PostGIS_LibXML_Version();
postgis_libxml_version
----------------------
2.7.6
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36150234"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_Full_Version" title="PostGIS_Full_Version">PostGIS_Full_Version</a>, <a class="xref" href="#PostGIS_Lib_Version" title="PostGIS_Lib_Version">PostGIS_Lib_Version</a>, <a class="xref" href="#PostGIS_PROJ_Version" title="PostGIS_PROJ_Version">PostGIS_PROJ_Version</a>, <a class="xref" href="#PostGIS_GEOS_Version" title="PostGIS_GEOS_Version">PostGIS_GEOS_Version</a>, <a class="xref" href="#PostGIS_Version" title="PostGIS_Version">PostGIS_Version</a></p></div></div><div class="refentry" title="PostGIS_Lib_Build_Date"><div class="refentry.separator"><hr></div><a name="PostGIS_Lib_Build_Date"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_Lib_Build_Date — Returns build date of the PostGIS library.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">PostGIS_Lib_Build_Date</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36150295"></a><h2>Description</h2><p>Returns build date of the PostGIS library.</p></div><div class="refsection" title="Examples"><a name="id36150304"></a><h2>Examples</h2><pre class="programlisting">SELECT PostGIS_Lib_Build_Date();
postgis_lib_build_date
------------------------
2008-06-21 17:53:21
(1 row)</pre></div></div><div class="refentry" title="PostGIS_Lib_Version"><div class="refentry.separator"><hr></div><a name="PostGIS_Lib_Version"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_Lib_Version — Returns the version number of the PostGIS
library.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">PostGIS_Lib_Version</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36150351"></a><h2>Description</h2><p>Returns the version number of the PostGIS library.</p></div><div class="refsection" title="Examples"><a name="id36150361"></a><h2>Examples</h2><pre class="programlisting">SELECT PostGIS_Lib_Version();
postgis_lib_version
---------------------
1.3.3
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36150373"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_Full_Version" title="PostGIS_Full_Version">PostGIS_Full_Version</a>, <a class="xref" href="#PostGIS_GEOS_Version" title="PostGIS_GEOS_Version">PostGIS_GEOS_Version</a>, <a class="xref" href="#PostGIS_LibXML_Version" title="PostGIS_LibXML_Version">PostGIS_LibXML_Version</a>, <a class="xref" href="#PostGIS_PROJ_Version" title="PostGIS_PROJ_Version">PostGIS_PROJ_Version</a>, <a class="xref" href="#PostGIS_Version" title="PostGIS_Version">PostGIS_Version</a></p></div></div><div class="refentry" title="PostGIS_PROJ_Version"><div class="refentry.separator"><hr></div><a name="PostGIS_PROJ_Version"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_PROJ_Version — Returns the version number of the PROJ4
library.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">PostGIS_PROJ_Version</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36150435"></a><h2>Description</h2><p>Returns the version number of the PROJ4 library, or
<code class="varname">NULL</code> if PROJ4 support is not enabled.</p></div><div class="refsection" title="Examples"><a name="id36150448"></a><h2>Examples</h2><pre class="programlisting">SELECT PostGIS_PROJ_Version();
postgis_proj_version
-------------------------
Rel. 4.4.9, 29 Oct 2004
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36150461"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_Full_Version" title="PostGIS_Full_Version">PostGIS_Full_Version</a>, <a class="xref" href="#PostGIS_GEOS_Version" title="PostGIS_GEOS_Version">PostGIS_GEOS_Version</a>, <a class="xref" href="#PostGIS_Lib_Version" title="PostGIS_Lib_Version">PostGIS_Lib_Version</a>, <a class="xref" href="#PostGIS_LibXML_Version" title="PostGIS_LibXML_Version">PostGIS_LibXML_Version</a>, <a class="xref" href="#PostGIS_Version" title="PostGIS_Version">PostGIS_Version</a></p></div></div><div class="refentry" title="PostGIS_Scripts_Build_Date"><div class="refentry.separator"><hr></div><a name="PostGIS_Scripts_Build_Date"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_Scripts_Build_Date — Returns build date of the PostGIS scripts.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">PostGIS_Scripts_Build_Date</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36150522"></a><h2>Description</h2><p>Returns build date of the PostGIS scripts.</p><p>Availability: 1.0.0RC1</p></div><div class="refsection" title="Examples"><a name="id36150535"></a><h2>Examples</h2><pre class="programlisting">SELECT PostGIS_Scripts_Build_Date();
postgis_scripts_build_date
-------------------------
2007-08-18 09:09:26
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36150547"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_Full_Version" title="PostGIS_Full_Version">PostGIS_Full_Version</a>, <a class="xref" href="#PostGIS_GEOS_Version" title="PostGIS_GEOS_Version">PostGIS_GEOS_Version</a>, <a class="xref" href="#PostGIS_Lib_Version" title="PostGIS_Lib_Version">PostGIS_Lib_Version</a>, <a class="xref" href="#PostGIS_LibXML_Version" title="PostGIS_LibXML_Version">PostGIS_LibXML_Version</a>, <a class="xref" href="#PostGIS_Version" title="PostGIS_Version">PostGIS_Version</a></p></div></div><div class="refentry" title="PostGIS_Scripts_Installed"><div class="refentry.separator"><hr></div><a name="PostGIS_Scripts_Installed"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_Scripts_Installed — Returns version of the postgis scripts installed in this
database.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">PostGIS_Scripts_Installed</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36150609"></a><h2>Description</h2><p>Returns version of the postgis scripts installed in this
database.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If the output of this function doesn't match the output of
<a class="xref" href="#PostGIS_Scripts_Released" title="PostGIS_Scripts_Released">PostGIS_Scripts_Released</a>
you probably missed to properly upgrade an existing database.
See the <a class="link" href="#upgrading" title="2.7.Upgrading">Upgrading</a> section for
more info.</p></td></tr></table></div><p>Availability: 0.9.0</p></div><div class="refsection" title="Examples"><a name="id36150641"></a><h2>Examples</h2><pre class="programlisting">SELECT PostGIS_Scripts_Installed();
postgis_scripts_installed
-------------------------
1.5.0SVN
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36150653"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_Full_Version" title="PostGIS_Full_Version">PostGIS_Full_Version</a>, <a class="xref" href="#PostGIS_Scripts_Released" title="PostGIS_Scripts_Released">PostGIS_Scripts_Released</a>, <a class="xref" href="#PostGIS_Version" title="PostGIS_Version">PostGIS_Version</a></p></div></div><div class="refentry" title="PostGIS_Scripts_Released"><div class="refentry.separator"><hr></div><a name="PostGIS_Scripts_Released"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_Scripts_Released — Returns the version number of the postgis.sql script
released with the installed postgis lib.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">PostGIS_Scripts_Released</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36150712"></a><h2>Description</h2><p>Returns the version number of the postgis.sql script
released with the installed postgis lib.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Starting with version 1.1.0 this function returns the same
value of <a class="xref" href="#PostGIS_Lib_Version" title="PostGIS_Lib_Version">PostGIS_Lib_Version</a>. Kept
for backward compatibility.</p></td></tr></table></div><p>Availability: 0.9.0</p></div><div class="refsection" title="Examples"><a name="id36150738"></a><h2>Examples</h2><pre class="programlisting">SELECT PostGIS_Scripts_Released();
postgis_scripts_released
-------------------------
1.3.4SVN
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36150750"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_Full_Version" title="PostGIS_Full_Version">PostGIS_Full_Version</a>, <a class="xref" href="#PostGIS_Scripts_Installed" title="PostGIS_Scripts_Installed">PostGIS_Scripts_Installed</a>, <a class="xref" href="#PostGIS_Lib_Version" title="PostGIS_Lib_Version">PostGIS_Lib_Version</a></p></div></div><div class="refentry" title="PostGIS_Uses_Stats"><div class="refentry.separator"><hr></div><a name="PostGIS_Uses_Stats"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_Uses_Stats — Returns <code class="varname">TRUE</code> if STATS usage has been
enabled.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">PostGIS_Uses_Stats</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36150813"></a><h2>Description</h2><p>Returns <code class="varname">TRUE</code> if STATS usage has been enabled,
<code class="varname">FALSE</code> otherwise.</p></div><div class="refsection" title="Examples"><a name="id36150829"></a><h2>Examples</h2><pre class="programlisting">SELECT PostGIS_Uses_Stats();
postgis_uses_stats
--------------------
t
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36150842"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_Version" title="PostGIS_Version">PostGIS_Version</a></p></div></div><div class="refentry" title="PostGIS_Version"><div class="refentry.separator"><hr></div><a name="PostGIS_Version"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_Version — Returns PostGIS version number and compile-time
options.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">PostGIS_Version</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36150888"></a><h2>Description</h2><p>Returns PostGIS version number and compile-time options.</p></div><div class="refsection" title="Examples"><a name="id36150898"></a><h2>Examples</h2><pre class="programlisting">SELECT PostGIS_Version();
postgis_version
---------------------------------------
1.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36150911"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_Full_Version" title="PostGIS_Full_Version">PostGIS_Full_Version</a>, <a class="xref" href="#PostGIS_GEOS_Version" title="PostGIS_GEOS_Version">PostGIS_GEOS_Version</a>,<a class="xref" href="#PostGIS_Lib_Version" title="PostGIS_Lib_Version">PostGIS_Lib_Version</a>, <a class="xref" href="#PostGIS_LibXML_Version" title="PostGIS_LibXML_Version">PostGIS_LibXML_Version</a>, <a class="xref" href="#PostGIS_PROJ_Version" title="PostGIS_PROJ_Version">PostGIS_PROJ_Version</a></p></div></div><div class="refentry" title="Populate_Geometry_Columns"><div class="refentry.separator"><hr></div><a name="Populate_Geometry_Columns"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>Populate_Geometry_Columns — Ensures geometry columns have appropriate spatial constraints
and exist in the <code class="varname">geometry_columns</code> table.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">Populate_Geometry_Columns</b>(</code><code>)</code>;</p><p><code class="funcdef">int <b class="fsfunc">Populate_Geometry_Columns</b>(</code>oid <var class="pdparam">relation_oid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36151005"></a><h2>Description</h2><p>Ensures geometry columns have appropriate spatial constraints and
exist in the <code class="varname">geometry_columns</code> table. In particular,
this means that every geometry column belonging to a table has at least
three constraints:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><code class="varname">enforce_dims_the_geom</code> - ensures every
geometry has the same dimension (see <a class="xref" href="#ST_NDims" title="ST_NDims">ST_NDims</a>)</p></li><li class="listitem"><p><code class="varname">enforce_geotype_the_geom</code> - ensures every
geometry is of the same type (see <a class="xref" href="#GeometryType" title="GeometryType">GeometryType</a>)</p></li><li class="listitem"><p><code class="varname">enforce_srid_the_geom</code> - ensures every
geometry is in the same projection (see <a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a>)</p></li></ul></div><p>If a table <code class="varname">oid</code> is provided, this function
tries to determine the srid, dimension, and geometry type of all
geometry columns in the table, adding contraints as necessary. If
successful, an appropriate row is inserted into the geometry_columns
table, otherwise, the exception is caught and an error notice is raised
describing the problem.</p><p>If the <code class="varname">oid</code> of a view is provided, as with a
table oid, this function tries to determine the srid, dimension, and
type of all the geometries in the view, inserting appropriate entries
into the <code class="varname">geometry_columns</code> table, but nothing is done
to enforce contraints.</p><p>The parameterless variant is a simple wrapper for the parameterized
variant that first truncates and repopulates the geometry_columns table
for every spatial table and view in the database, adding spatial
contraints to tables where appropriate. It returns a summary of the
number of geometry columns detected in the database and the number that
were inserted into the <code class="varname">geometry_columns</code> table. The
parameterized version simply returns the number of rows inserted into
the <code class="varname">geometry_columns</code> table.</p><p>Availability: 1.4.0</p></div><div class="refsection" title="Examples"><a name="id36151105"></a><h2>Examples</h2><pre class="programlisting">SELECT Populate_Geometry_Columns('public.myspatial_table'::regclass);</pre></div><div class="refsection" title="See Also"><a name="id36151117"></a><h2>See Also</h2><p><a class="xref" href="#Probe_Geometry_Columns" title="Probe_Geometry_Columns">Probe_Geometry_Columns</a></p></div></div><div class="refentry" title="Probe_Geometry_Columns"><div class="refentry.separator"><hr></div><a name="Probe_Geometry_Columns"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>Probe_Geometry_Columns — Scans all tables with PostGIS geometry constraints and adds them to the <code class="varname">geometry_columns</code>
table if they are not there.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">Probe_Geometry_Columns</b>(</code><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36151170"></a><h2>Description</h2><p>Scans all tables with PostGIS geometry constraints and adds them to the <code class="varname">geometry_columns</code>
table if they are not there. Also give stats on number of inserts and already present or possibly obsolete.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This will usually only pick up records added by AddGeometryColumn() function. It will not scan views so views
will need to be manually added to geometry_columns table.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36151191"></a><h2>Examples</h2><pre class="programlisting">SELECT Probe_Geometry_Columns();
probe_geometry_columns
---------------------------------------
probed:6 inserted:0 conflicts:6 stale:0
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36151203"></a><h2>See Also</h2><p><a class="xref" href="#AddGeometryColumn" title="AddGeometryColumn">AddGeometryColumn</a></p></div></div><div class="refentry" title="UpdateGeometrySRID"><div class="refentry.separator"><hr></div><a name="UpdateGeometrySRID"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>UpdateGeometrySRID — Updates the SRID of all features in a geometry
column, geometry_columns metadata and srid table constraint</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">UpdateGeometrySRID</b>(</code>varchar
<var class="pdparam">table_name</var>, varchar
<var class="pdparam">column_name</var>, integer
<var class="pdparam">srid</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">UpdateGeometrySRID</b>(</code>varchar
<var class="pdparam">schema_name</var>, varchar
<var class="pdparam">table_name</var>, varchar
<var class="pdparam">column_name</var>, integer
<var class="pdparam">srid</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">UpdateGeometrySRID</b>(</code>varchar
<var class="pdparam">catalog_name</var>, varchar
<var class="pdparam">schema_name</var>, varchar
<var class="pdparam">table_name</var>, varchar
<var class="pdparam">column_name</var>, integer
<var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36151386"></a><h2>Description</h2><p>Updates the SRID of all features in a geometry column, updating
constraints and reference in geometry_columns. Note: uses
current_schema() on schema-aware pgsql installations if schema is not
provided.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="See Also"><a name="id36151423"></a><h2>See Also</h2><p><a class="xref" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a></p></div></div></div><div class="sect1" title="7.3.Geometry Constructors"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Geometry_Constructors"></a>7.3.Geometry Constructors</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#ST_BdPolyFromText">ST_BdPolyFromText</a></span><span class="refpurpose"> — Construct a Polygon given an arbitrary collection of closed
linestrings as a MultiLineString Well-Known text representation.</span></dt><dt><span class="refentrytitle"><a href="#ST_BdMPolyFromText">ST_BdMPolyFromText</a></span><span class="refpurpose"> — Construct a MultiPolygon given an arbitrary collection of
closed linestrings as a MultiLineString text
representation Well-Known text representation.</span></dt><dt><span class="refentrytitle"><a href="#ST_GeogFromText">ST_GeogFromText</a></span><span class="refpurpose"> — Return a specified geography value from Well-Known Text representation or extended (WKT). </span></dt><dt><span class="refentrytitle"><a href="#ST_GeographyFromText">ST_GeographyFromText</a></span><span class="refpurpose"> — Return a specified geography value from Well-Known Text representation or extended (WKT). </span></dt><dt><span class="refentrytitle"><a href="#ST_GeogFromWKB">ST_GeogFromWKB</a></span><span class="refpurpose"> — Creates a geography instance from a Well-Known Binary geometry
representation (WKB) or extended Well Known Binary (EWKB).</span></dt><dt><span class="refentrytitle"><a href="#ST_GeomCollFromText">ST_GeomCollFromText</a></span><span class="refpurpose"> — Makes a collection Geometry from collection WKT with the given SRID. If SRID is
not give, it defaults to -1.</span></dt><dt><span class="refentrytitle"><a href="#ST_GeomFromEWKB">ST_GeomFromEWKB</a></span><span class="refpurpose"> — Return a specified ST_Geometry value from Extended Well-Known Binary representation (EWKB).</span></dt><dt><span class="refentrytitle"><a href="#ST_GeomFromEWKT">ST_GeomFromEWKT</a></span><span class="refpurpose"> — Return a specified ST_Geometry value from Extended Well-Known Text representation (EWKT).</span></dt><dt><span class="refentrytitle"><a href="#ST_GeometryFromText">ST_GeometryFromText</a></span><span class="refpurpose"> — Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an alias name for ST_GeomFromText</span></dt><dt><span class="refentrytitle"><a href="#ST_GeomFromGML">ST_GeomFromGML</a></span><span class="refpurpose"> — Takes as input GML representation of geometry and outputs a PostGIS geometry object</span></dt><dt><span class="refentrytitle"><a href="#ST_GeomFromKML">ST_GeomFromKML</a></span><span class="refpurpose"> — Takes as input KML representation of geometry and outputs a PostGIS geometry object</span></dt><dt><span class="refentrytitle"><a href="#ST_GMLToSQL">ST_GMLToSQL</a></span><span class="refpurpose"> — Return a specified ST_Geometry value from GML representation. This is an alias name for ST_GeomFromGML</span></dt><dt><span class="refentrytitle"><a href="#ST_GeomFromText">ST_GeomFromText</a></span><span class="refpurpose"> — Return a specified ST_Geometry value from Well-Known Text representation (WKT).</span></dt><dt><span class="refentrytitle"><a href="#ST_GeomFromWKB">ST_GeomFromWKB</a></span><span class="refpurpose"> — Creates a geometry instance from a Well-Known Binary geometry
representation (WKB) and optional SRID.</span></dt><dt><span class="refentrytitle"><a href="#ST_LineFromMultiPoint">ST_LineFromMultiPoint</a></span><span class="refpurpose"> — Creates a LineString from a MultiPoint geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_LineFromText">ST_LineFromText</a></span><span class="refpurpose"> — Makes a Geometry from WKT representation with the given SRID. If SRID is
not given, it defaults to -1.</span></dt><dt><span class="refentrytitle"><a href="#ST_LineFromWKB">ST_LineFromWKB</a></span><span class="refpurpose"> — Makes a <code class="varname">LINESTRING</code> from WKB with the given SRID</span></dt><dt><span class="refentrytitle"><a href="#ST_LinestringFromWKB">ST_LinestringFromWKB</a></span><span class="refpurpose"> — Makes a geometry from WKB with the given SRID.</span></dt><dt><span class="refentrytitle"><a href="#ST_MakeBox2D">ST_MakeBox2D</a></span><span class="refpurpose"> — Creates a BOX2D defined by the given point
geometries.</span></dt><dt><span class="refentrytitle"><a href="#ST_MakeBox3D">ST_MakeBox3D</a></span><span class="refpurpose"> — Creates a BOX3D defined by the given 3d point
geometries.</span></dt><dt><span class="refentrytitle"><a href="#ST_MakeLine">ST_MakeLine</a></span><span class="refpurpose"> — Creates a Linestring from point geometries.</span></dt><dt><span class="refentrytitle"><a href="#ST_MakeEnvelope">ST_MakeEnvelope</a></span><span class="refpurpose"> — Creates a rectangular Polygon formed from the given minimums and maximums. Input
values must be in SRS specified by the SRID.</span></dt><dt><span class="refentrytitle"><a href="#ST_MakePolygon">ST_MakePolygon</a></span><span class="refpurpose"> — Creates a Polygon formed by the given shell. Input
geometries must be closed LINESTRINGS.</span></dt><dt><span class="refentrytitle"><a href="#ST_MakePoint">ST_MakePoint</a></span><span class="refpurpose"> — Creates a 2D,3DZ or 4D point geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_MakePointM">ST_MakePointM</a></span><span class="refpurpose"> — Creates a point geometry with an x y and m coordinate.</span></dt><dt><span class="refentrytitle"><a href="#ST_MLineFromText">ST_MLineFromText</a></span><span class="refpurpose"> — Return a specified ST_MultiLineString value from WKT representation.</span></dt><dt><span class="refentrytitle"><a href="#ST_MPointFromText">ST_MPointFromText</a></span><span class="refpurpose"> — Makes a Geometry from WKT with the given SRID. If SRID is
not give, it defaults to -1.</span></dt><dt><span class="refentrytitle"><a href="#ST_MPolyFromText">ST_MPolyFromText</a></span><span class="refpurpose"> — Makes a MultiPolygon Geometry from WKT with the given SRID. If SRID is
not give, it defaults to -1.</span></dt><dt><span class="refentrytitle"><a href="#ST_Point">ST_Point</a></span><span class="refpurpose"> — Returns an ST_Point with the given coordinate values. OGC alias for ST_MakePoint.</span></dt><dt><span class="refentrytitle"><a href="#ST_PointFromText">ST_PointFromText</a></span><span class="refpurpose"> — Makes a point Geometry from WKT with the given SRID. If SRID is
not given, it defaults to unknown.</span></dt><dt><span class="refentrytitle"><a href="#ST_PointFromWKB">ST_PointFromWKB</a></span><span class="refpurpose"> — Makes a geometry from WKB with the given SRID</span></dt><dt><span class="refentrytitle"><a href="#ST_Polygon">ST_Polygon</a></span><span class="refpurpose"> — Returns a polygon built from the specified linestring and SRID.</span></dt><dt><span class="refentrytitle"><a href="#ST_PolygonFromText">ST_PolygonFromText</a></span><span class="refpurpose"> — Makes a Geometry from WKT with the given SRID. If SRID is
not give, it defaults to -1.</span></dt><dt><span class="refentrytitle"><a href="#ST_WKBToSQL">ST_WKBToSQL</a></span><span class="refpurpose"> — Return a specified ST_Geometry value from Well-Known Binary representation (WKB). This is an alias name for ST_GeomFromWKB that takes no srid</span></dt><dt><span class="refentrytitle"><a href="#ST_WKTToSQL">ST_WKTToSQL</a></span><span class="refpurpose"> — Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an alias name for ST_GeomFromText</span></dt></dl></div><div class="refentry" title="ST_BdPolyFromText"><a name="ST_BdPolyFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_BdPolyFromText — Construct a Polygon given an arbitrary collection of closed
linestrings as a MultiLineString Well-Known text representation.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_BdPolyFromText</b>(</code>text <var class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36153756"></a><h2>Description</h2><p>Construct a Polygon given an arbitrary collection of closed
linestrings as a MultiLineString Well-Known text representation.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Throws an error if WKT is not a MULTILINESTRING. Throws an
error if output is a MULTIPOLYGON; use ST_BdMPolyFromText in that case, or
see ST_BuildArea() for a
postgis-specific approach.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.6.2</p><p>Availability: 1.1.0 - requires GEOS >= 2.1.0.</p></div><div class="refsection" title="Examples"><a name="id36153800"></a><h2>Examples</h2><pre class="programlisting">Forthcoming</pre></div><div class="refsection" title="See Also"><a name="id36153812"></a><h2>See Also</h2><p><a class="xref" href="#ST_BuildArea" title="ST_BuildArea">ST_BuildArea</a>, <a class="xref" href="#ST_BdMPolyFromText" title="ST_BdMPolyFromText">ST_BdMPolyFromText</a></p></div></div><div class="refentry" title="ST_BdMPolyFromText"><div class="refentry.separator"><hr></div><a name="ST_BdMPolyFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_BdMPolyFromText — Construct a MultiPolygon given an arbitrary collection of
closed linestrings as a MultiLineString text
representation Well-Known text representation.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_BdMPolyFromText</b>(</code>text <var class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36153885"></a><h2>Description</h2><p>Construct a Polygon given an arbitrary collection of closed
linestrings, polygons, MultiLineStrings as Well-Known text representation.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Throws an error if WKT is not a MULTILINESTRING. Forces
MULTIPOLYGON output even when result is really only composed by a
single POLYGON; use <a class="link" href="#ST_BdPolyFromText" title="ST_BdPolyFromText">ST_BdPolyFromText</a> if you're sure a
single POLYGON will result from operation, or see <a class="link" href="#ST_BuildArea" title="ST_BuildArea">ST_BuildArea()</a> for a postgis-specific
approach.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.6.2</p><p>Availability: 1.1.0 - requires GEOS >= 2.1.0.</p></div><div class="refsection" title="Examples"><a name="id36153943"></a><h2>Examples</h2><pre class="programlisting">Forthcoming</pre></div><div class="refsection" title="See Also"><a name="id36153955"></a><h2>See Also</h2><p><a class="xref" href="#ST_BuildArea" title="ST_BuildArea">ST_BuildArea</a>, <a class="xref" href="#ST_BdPolyFromText" title="ST_BdPolyFromText">ST_BdPolyFromText</a></p></div></div><div class="refentry" title="ST_GeogFromText"><div class="refentry.separator"><hr></div><a name="ST_GeogFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeogFromText — Return a specified geography value from Well-Known Text representation or extended (WKT). </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geography <b class="fsfunc">ST_GeogFromText</b>(</code>text <var class="pdparam">EWKT</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36154016"></a><h2>Description</h2><p>Returns a geography object from the well-known text or extended well-known representation. SRID 4326 is assumed. This
is an alias for ST_GeographyFromText</p></div><div class="refsection" title="Examples"><a name="id36154028"></a><h2>Examples</h2><pre class="programlisting">
--- converting lon lat coords to geography
ALTER TABLE sometable ADD COLUMN geog geography(POINT,4326);
UPDATE sometable SET geog = ST_GeogFromText('SRID=4326;POINT(' || lon || ' ' || lat || ')');
</pre></div><div class="refsection" title="See Also"><a name="id36154041"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a>,<a class="xref" href="#ST_GeographyFromText" title="ST_GeographyFromText">ST_GeographyFromText</a></p></div></div><div class="refentry" title="ST_GeographyFromText"><div class="refentry.separator"><hr></div><a name="ST_GeographyFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeographyFromText — Return a specified geography value from Well-Known Text representation or extended (WKT). </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geography <b class="fsfunc">ST_GeographyFromText</b>(</code>text <var class="pdparam">EWKT</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36154104"></a><h2>Description</h2><p>Returns a geography object from the well-known text representation. SRID 4326 is assumed.</p></div><div class="refsection" title="See Also"><a name="id36154117"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a></p></div></div><div class="refentry" title="ST_GeogFromWKB"><div class="refentry.separator"><hr></div><a name="ST_GeogFromWKB"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeogFromWKB — Creates a geography instance from a Well-Known Binary geometry
representation (WKB) or extended Well Known Binary (EWKB).</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geography <b class="fsfunc">ST_GeogFromWKB</b>(</code>bytea <var class="pdparam">geom</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36154173"></a><h2>Description</h2><p>The <code class="varname">ST_GeogFromWKB</code> function, takes a well-known
binary representation (WKB) of a geometry or PostGIS Extended WKB and creates an instance of the appropriate
geography type. This function plays the role of the Geometry Factory in
SQL. </p><p>If SRID is not specified, it defaults to 4326 (WGS 84 long lat).</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36154204"></a><h2>Examples</h2><pre class="programlisting">--Although bytea rep contains single \, these need to be escaped when inserting into a table
SELECT ST_AsText(
ST_GeogFromWKB(E'\\001\\002\\000\\000\\000\\002\\000\\000\\000\\037\\205\\353Q\\270~\\\\\\300\\323Mb\\020X\\231C@\\020X9\\264\\310~\\\\\\300)\\\\\\217\\302\\365\\230C@')
);
st_astext
------------------------------------------------------
LINESTRING(-113.98 39.198,-113.981 39.195)
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36154219"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeogFromText" title="ST_GeogFromText">ST_GeogFromText</a>, <a class="xref" href="#ST_AsBinary" title="ST_AsBinary">ST_AsBinary</a></p></div></div><div class="refentry" title="ST_GeomCollFromText"><div class="refentry.separator"><hr></div><a name="ST_GeomCollFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeomCollFromText — Makes a collection Geometry from collection WKT with the given SRID. If SRID is
not give, it defaults to -1.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomCollFromText</b>(</code>text <var class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomCollFromText</b>(</code>text <var class="pdparam">WKT</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36154312"></a><h2>Description</h2><p>Makes a collection Geometry from the Well-Known-Text (WKT) representation with the given SRID. If SRID is
not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance suite</p><p>Returns null if the WKT is not a GEOMETRYCOLLECTION</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you are absolutely sure all your WKT geometries are collections, don't use this function.
It is slower than ST_GeomFromText since it adds an additional validation step.
</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.6.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification.</p></div><div class="refsection" title="Examples"><a name="id36154376"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(1 2, 3 4))');
</pre></div><div class="refsection" title="See Also"><a name="id36154385"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a></p></div></div><div class="refentry" title="ST_GeomFromEWKB"><div class="refentry.separator"><hr></div><a name="ST_GeomFromEWKB"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeomFromEWKB — Return a specified ST_Geometry value from Extended Well-Known Binary representation (EWKB).</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomFromEWKB</b>(</code>bytea <var class="pdparam">EWKB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36154446"></a><h2>Description</h2><p>Constructs a PostGIS ST_Geometry object from the OGC Extended Well-Known binary (EWKT) representation.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>The EWKB format is not an OGC standard, but a PostGIS specific format that includes the spatial reference system (SRID)
identifier</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36154490"></a><h2>Examples</h2><p>line string binary rep 0f
LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932) in NAD 83 long lat (4269).</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>NOTE: Even though byte arrays are delimited with \ and may have ', we need to escape both out with \ and ''. So it does not
look exactly like its AsEWKB representation.</p></td></tr></table></div><pre class="programlisting">SELECT ST_GeomFromEWKB(E'\\001\\002\\000\\000 \\255\\020\\000\\000\\003\\000\\000\\000\\344J=
\\013B\\312Q\\300n\\303(\\010\\036!E@''\\277E''K
\\312Q\\300\\366{b\\235*!E@\\225|\\354.P\\312Q
\\300p\\231\\323e1!E@');</pre></div><div class="refsection" title="See Also"><a name="id36154513"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsBinary" title="ST_AsBinary">ST_AsBinary</a>, <a class="xref" href="#ST_AsEWKB" title="ST_AsEWKB">ST_AsEWKB</a>, <a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a></p></div></div><div class="refentry" title="ST_GeomFromEWKT"><div class="refentry.separator"><hr></div><a name="ST_GeomFromEWKT"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeomFromEWKT — Return a specified ST_Geometry value from Extended Well-Known Text representation (EWKT).</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomFromEWKT</b>(</code>text <var class="pdparam">EWKT</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36154580"></a><h2>Description</h2><p>Constructs a PostGIS ST_Geometry object from the OGC Extended Well-Known text (EWKT) representation.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>The EWKT format is not an OGC standard, but an PostGIS specific format that includes the spatial reference system (SRID)
identifier</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36154624"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_GeomFromEWKT('SRID=4269;LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)');
SELECT ST_GeomFromEWKT('SRID=4269;MULTILINESTRING((-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932))');
SELECT ST_GeomFromEWKT('SRID=4269;POINT(-71.064544 42.28787)');
SELECT ST_GeomFromEWKT('SRID=4269;POLYGON((-71.1776585052917 42.3902909739571,-71.1776820268866 42.3903701743239,
-71.1776063012595 42.3903825660754,-71.1775826583081 42.3903033653531,-71.1776585052917 42.3902909739571))');
SELECT ST_GeomFromEWKT('SRID=4269;MULTIPOLYGON(((-71.1031880899493 42.3152774590236,
-71.1031627617667 42.3152960829043,-71.102923838298 42.3149156848307,
-71.1023097974109 42.3151969047397,-71.1019285062273 42.3147384934248,
-71.102505233663 42.3144722937587,-71.10277487471 42.3141658254797,
-71.103113945163 42.3142739188902,-71.10324876416 42.31402489987,
-71.1033002961013 42.3140393340215,-71.1033488797549 42.3139495090772,
-71.103396240451 42.3138632439557,-71.1041521907712 42.3141153348029,
-71.1041411411543 42.3141545014533,-71.1041287795912 42.3142114839058,
-71.1041188134329 42.3142693656241,-71.1041112482575 42.3143272556118,
-71.1041072845732 42.3143851580048,-71.1041057218871 42.3144430686681,
-71.1041065602059 42.3145009876017,-71.1041097995362 42.3145589148055,
-71.1041166403905 42.3146168544148,-71.1041258822717 42.3146748022936,
-71.1041375307579 42.3147318674446,-71.1041492906949 42.3147711126569,
-71.1041598612795 42.314808571739,-71.1042515013869 42.3151287620809,
-71.1041173835118 42.3150739481917,-71.1040809891419 42.3151344119048,
-71.1040438678912 42.3151191367447,-71.1040194562988 42.3151832057859,
-71.1038734225584 42.3151140942995,-71.1038446938243 42.3151006300338,
-71.1038315271889 42.315094347535,-71.1037393329282 42.315054824985,
-71.1035447555574 42.3152608696313,-71.1033436658644 42.3151648370544,
-71.1032580383161 42.3152269126061,-71.103223066939 42.3152517403219,
-71.1031880899493 42.3152774590236)),
((-71.1043632495873 42.315113108546,-71.1043583974082 42.3151211109857,
-71.1043443253471 42.3150676015829,-71.1043850704575 42.3150793250568,-71.1043632495873 42.315113108546)))');
--3d circular string
SELECT ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)');
</pre></div><div class="refsection" title="See Also"><a name="id36154636"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a></p></div></div><div class="refentry" title="ST_GeometryFromText"><div class="refentry.separator"><hr></div><a name="ST_GeometryFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeometryFromText — Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an alias name for ST_GeomFromText</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_GeometryFromText</b>(</code>text <var class="pdparam">WKT</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_GeometryFromText</b>(</code>text <var class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36154734"></a><h2>Description</h2><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.40</p></div><div class="refsection" title="See Also"><a name="id36154772"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a></p></div></div><div class="refentry" title="ST_GeomFromGML"><div class="refentry.separator"><hr></div><a name="ST_GeomFromGML"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeomFromGML — Takes as input GML representation of geometry and outputs a PostGIS geometry object</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomFromGML</b>(</code>text <var class="pdparam">geomgml</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36154827"></a><h2>Description</h2><p>Constructs a PostGIS ST_Geometry object from the OGC GML representation.</p><p>ST_GeomFromGML works only for GML Geometry fragments. It throws an error if you try to use it on a whole GML document.</p><p>
OGC GML versions supported:
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>GML 3.2.1 Namespace</p></li><li class="listitem"><p>GML 3.1.1 Simple Features profile SF-2 (with GML 3.1.0 and 3.0.0 backward compatibility)</p></li><li class="listitem"><p>GML 2.1.2</p></li></ul></div><p>
OGC GML standards, cf: <a class="ulink" href="http://www.opengeospatial.org/standards/gml" target="_top">http://www.opengeospatial.org/standards/gml</a>:
</p><p>Availability: 1.5</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p>GML allow mixed dimensions (2D and 3D inside the same MultiGeometry for instance). As PostGIS geometries don't, ST_GeomFromGML convert the whole geometry to 2D if a missing Z dimension is found once.</p><p>GML support mixed SRS inside the same MultiGeometry. As PostGIS geometries don't, ST_GeomFromGML, in this case, reproject all subgeometries to the SRS root node. If no srsName attribute available for the GML root node, the function throw an error.</p><p>ST_GeomFromGML function is not pedantic about an explicit GML namespace. You could avoid to mention it explicitly for common usages. But you need it if you want to use XLink feature inside GML.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>ST_GeomFromGML function not support SQL/MM curves geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples - A single geometry with srsName"><a name="id36154915"></a><h2>Examples - A single geometry with srsName</h2><pre class="programlisting">SELECT ST_GeomFromGML('
<gml:LineString srsName="EPSG:4269">
<gml:coordinates>
-71.16028,42.258729 -71.160837,42.259112 -71.161143,42.25932
</gml:coordinates>
</gml:LineString>');
</pre></div><div class="refsection" title="Examples - XLink usage"><a name="id36154932"></a><h2>Examples - XLink usage</h2><pre class="programlisting">ST_GeomFromGML('
<gml:LineString xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
srsName="urn:ogc:def:crs:EPSG::4269">
<gml:pointProperty>
<gml:Point gml:id="p1"><gml:pos>42.258729 -71.16028</gml:pos></gml:Point>
</gml:pointProperty>
<gml:pos>42.259112 -71.160837</gml:pos>
<gml:pointProperty>
<gml:Point xlink:type="simple" xlink:href="#p1"/>
</gml:pointProperty>
</gml:LineString>'););
</pre></div><div class="refsection" title="See Also"><a name="id36154952"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsGML" title="ST_AsGML">ST_AsGML</a></p><p><a class="xref" href="#ST_GMLToSQL" title="ST_GMLToSQL">ST_GMLToSQL</a></p></div></div><div class="refentry" title="ST_GeomFromKML"><div class="refentry.separator"><hr></div><a name="ST_GeomFromKML"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeomFromKML — Takes as input KML representation of geometry and outputs a PostGIS geometry object</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomFromKML</b>(</code>text <var class="pdparam">geomkml</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36155014"></a><h2>Description</h2><p>Constructs a PostGIS ST_Geometry object from the OGC KML representation.</p><p>ST_GeomFromKML works only for KML Geometry fragments. It throws an error if you try to use it on a whole KML document.</p><p>
OGC KML versions supported:
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>KML 2.2.0 Namespace</p></li></ul></div><p>
OGC KML standards, cf: <a class="ulink" href="http://www.opengeospatial.org/standards/kml" target="_top">http://www.opengeospatial.org/standards/kml</a>:
</p><p>Availability: 1.5</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>ST_GeomFromKML function not support SQL/MM curves geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples - A single geometry with srsName"><a name="id36155072"></a><h2>Examples - A single geometry with srsName</h2><pre class="programlisting">SELECT ST_GeomFromKML('
<LineString>
<coordinates>-71.1663,42.2614
-71.1667,42.2616</coordinates>
</LineString>');
</pre></div><div class="refsection" title="See Also"><a name="id36155088"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsKML" title="ST_AsKML">ST_AsKML</a></p></div></div><div class="refentry" title="ST_GMLToSQL"><div class="refentry.separator"><hr></div><a name="ST_GMLToSQL"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GMLToSQL — Return a specified ST_Geometry value from GML representation. This is an alias name for ST_GeomFromGML</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_GMLToSQL</b>(</code>text <var class="pdparam">geomgml</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36155144"></a><h2>Description</h2><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.50 (except for curves support).</p><p>Availability: 1.5</p></div><div class="refsection" title="See Also"><a name="id36155169"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromGML" title="ST_GeomFromGML">ST_GeomFromGML</a></p><p><a class="xref" href="#ST_AsGML" title="ST_AsGML">ST_AsGML</a></p></div></div><div class="refentry" title="ST_GeomFromText"><div class="refentry.separator"><hr></div><a name="ST_GeomFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeomFromText — Return a specified ST_Geometry value from Well-Known Text representation (WKT).</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomFromText</b>(</code>text <var class="pdparam">WKT</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomFromText</b>(</code>text <var class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36155261"></a><h2>Description</h2><p>Constructs a PostGIS ST_Geometry object from the OGC Well-Known text representation.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>There are 2 variants of ST_GeomFromText function, the first takes no SRID and returns a geometry
with no defined spatial reference system. The second takes a spatial reference id as the second argument
and returns an ST_Geometry that includes this srid as part of its meta-data. The srid must be defined
in the spatial_ref_sys table.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.6.2 - option SRID is from the conformance suite.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.40</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36155329"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_GeomFromText('LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)');
SELECT ST_GeomFromText('LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)',4269);
SELECT ST_GeomFromText('MULTILINESTRING((-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932))');
SELECT ST_GeomFromText('POINT(-71.064544 42.28787)');
SELECT ST_GeomFromText('POLYGON((-71.1776585052917 42.3902909739571,-71.1776820268866 42.3903701743239,
-71.1776063012595 42.3903825660754,-71.1775826583081 42.3903033653531,-71.1776585052917 42.3902909739571))');
SELECT ST_GeomFromText('MULTIPOLYGON(((-71.1031880899493 42.3152774590236,
-71.1031627617667 42.3152960829043,-71.102923838298 42.3149156848307,
-71.1023097974109 42.3151969047397,-71.1019285062273 42.3147384934248,
-71.102505233663 42.3144722937587,-71.10277487471 42.3141658254797,
-71.103113945163 42.3142739188902,-71.10324876416 42.31402489987,
-71.1033002961013 42.3140393340215,-71.1033488797549 42.3139495090772,
-71.103396240451 42.3138632439557,-71.1041521907712 42.3141153348029,
-71.1041411411543 42.3141545014533,-71.1041287795912 42.3142114839058,
-71.1041188134329 42.3142693656241,-71.1041112482575 42.3143272556118,
-71.1041072845732 42.3143851580048,-71.1041057218871 42.3144430686681,
-71.1041065602059 42.3145009876017,-71.1041097995362 42.3145589148055,
-71.1041166403905 42.3146168544148,-71.1041258822717 42.3146748022936,
-71.1041375307579 42.3147318674446,-71.1041492906949 42.3147711126569,
-71.1041598612795 42.314808571739,-71.1042515013869 42.3151287620809,
-71.1041173835118 42.3150739481917,-71.1040809891419 42.3151344119048,
-71.1040438678912 42.3151191367447,-71.1040194562988 42.3151832057859,
-71.1038734225584 42.3151140942995,-71.1038446938243 42.3151006300338,
-71.1038315271889 42.315094347535,-71.1037393329282 42.315054824985,
-71.1035447555574 42.3152608696313,-71.1033436658644 42.3151648370544,
-71.1032580383161 42.3152269126061,-71.103223066939 42.3152517403219,
-71.1031880899493 42.3152774590236)),
((-71.1043632495873 42.315113108546,-71.1043583974082 42.3151211109857,
-71.1043443253471 42.3150676015829,-71.1043850704575 42.3150793250568,-71.1043632495873 42.315113108546)))',4326);
SELECT ST_GeomFromText('CIRCULARSTRING(220268 150415,220227 150505,220227 150406)');
</pre></div><div class="refsection" title="See Also"><a name="id36155340"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a>, <a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a></p></div></div><div class="refentry" title="ST_GeomFromWKB"><div class="refentry.separator"><hr></div><a name="ST_GeomFromWKB"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeomFromWKB — Creates a geometry instance from a Well-Known Binary geometry
representation (WKB) and optional SRID.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomFromWKB</b>(</code>bytea <var class="pdparam">geom</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomFromWKB</b>(</code>bytea <var class="pdparam">geom</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36155437"></a><h2>Description</h2><p>The <code class="varname">ST_GeomFromWKB</code> function, takes a well-known
binary representation of a geometry and a Spatial Reference System ID
(<code class="varname">SRID</code>) and creates an instance of the appropriate
geometry type. This function plays the role of the Geometry Factory in
SQL. This is an alternate name for ST_WKBToSQL.</p><p>If SRID is not specified, it defaults to -1 (Unknown).</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.7.2 - the optional SRID is from the conformance suite</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.41</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36155504"></a><h2>Examples</h2><pre class="programlisting">--Although bytea rep contains single \, these need to be escaped when inserting into a table
SELECT ST_AsEWKT(
ST_GeomFromWKB(E'\\001\\002\\000\\000\\000\\002\\000\\000\\000\\037\\205\\353Q\\270~\\\\\\300\\323Mb\\020X\\231C@\\020X9\\264\\310~\\\\\\300)\\\\\\217\\302\\365\\230C@',4326)
);
st_asewkt
------------------------------------------------------
SRID=4326;LINESTRING(-113.98 39.198,-113.981 39.195)
(1 row)
SELECT
ST_AsText(
ST_GeomFromWKB(
ST_AsEWKB('POINT(2 5)'::geometry)
)
);
st_astext
------------
POINT(2 5)
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36155524"></a><h2>See Also</h2><p><a class="xref" href="#ST_WKBToSQL" title="ST_WKBToSQL">ST_WKBToSQL</a>, <a class="xref" href="#ST_AsBinary" title="ST_AsBinary">ST_AsBinary</a>, <a class="xref" href="#ST_GeomFromEWKB" title="ST_GeomFromEWKB">ST_GeomFromEWKB</a></p></div></div><div class="refentry" title="ST_LineFromMultiPoint"><div class="refentry.separator"><hr></div><a name="ST_LineFromMultiPoint"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_LineFromMultiPoint — Creates a LineString from a MultiPoint geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_LineFromMultiPoint</b>(</code>geometry <var class="pdparam">aMultiPoint</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36155590"></a><h2>Description</h2><p>Creates a LineString from a MultiPoint geometry.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36155614"></a><h2>Examples</h2><pre class="programlisting">
--Create a 3d line string from a 3d multipoint
SELECT ST_AsEWKT(ST_LineFromMultiPoint(ST_GeomFromEWKT('MULTIPOINT(1 2 3, 4 5 6, 7 8 9)')));
--result--
LINESTRING(1 2 3,4 5 6,7 8 9)
</pre></div><div class="refsection" title="See Also"><a name="id36155631"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_Collect" title="ST_Collect">ST_Collect</a>,<a class="xref" href="#ST_MakeLine" title="ST_MakeLine">ST_MakeLine</a></p></div></div><div class="refentry" title="ST_LineFromText"><div class="refentry.separator"><hr></div><a name="ST_LineFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_LineFromText — Makes a Geometry from WKT representation with the given SRID. If SRID is
not given, it defaults to -1.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_LineFromText</b>(</code>text <var class="pdparam">WKT</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_LineFromText</b>(</code>text <var class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36155728"></a><h2>Description</h2><p>Makes a Geometry from WKT with the given SRID. If SRID is
not give, it defaults to -1. If WKT passed in is not a LINESTRING, then null is returned. </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
suite.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you know all your geometries are LINESTRINGS, its more efficient to just use ST_GeomFromText.
This just calls ST_GeomFromText and adds additional validation that it returns a linestring.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.6.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 7.2.8</p></div><div class="refsection" title="Examples"><a name="id36155788"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_LineFromText('LINESTRING(1 2, 3 4)') AS aline, ST_LineFromText('POINT(1 2)') AS null_return;
aline | null_return
------------------------------------------------
010200000002000000000000000000F ... | t
</pre></div><div class="refsection" title="See Also"><a name="id36155804"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a></p></div></div><div class="refentry" title="ST_LineFromWKB"><div class="refentry.separator"><hr></div><a name="ST_LineFromWKB"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_LineFromWKB — Makes a <code class="varname">LINESTRING</code> from WKB with the given SRID</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_LineFromWKB</b>(</code>bytea <var class="pdparam">WKB</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_LineFromWKB</b>(</code>bytea <var class="pdparam">WKB</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36155893"></a><h2>Description</h2><p>The <code class="varname">ST_LineFromWKB</code> function, takes a well-known binary
representation of geometry and a Spatial Reference System ID (<code class="varname">SRID</code>)
and creates an instance of the appropriate geometry type - in this case, a
<code class="varname">LINESTRING</code> geometry. This function plays the role of the Geometry
Factory in SQL.</p><p>If an SRID is not specified, it defaults to -1. <code class="varname">NULL</code> is
returned if the input <code class="varname">bytea</code>
does not represent a <code class="varname">LINESTRING</code>.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
suite.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you know all your geometries are <code class="varname">LINESTRING</code>s, its more
efficient to just use <a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a>. This function just
calls <a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a> and adds additional validation that
it returns a linestring.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.6.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 7.2.9</p></div><div class="refsection" title="Examples"><a name="id36155991"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_LineFromWKB(ST_AsBinary(ST_GeomFromText('LINESTRING(1 2, 3 4)'))) AS aline,
ST_LineFromWKB(ST_AsBinary(ST_GeomFromText('POINT(1 2)'))) IS NULL AS null_return;
aline | null_return
------------------------------------------------
010200000002000000000000000000F ... | t
</pre></div><div class="refsection" title="See Also"><a name="id36156008"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a>, <a class="xref" href="#ST_LinestringFromWKB" title="ST_LinestringFromWKB">ST_LinestringFromWKB</a></p></div></div><div class="refentry" title="ST_LinestringFromWKB"><div class="refentry.separator"><hr></div><a name="ST_LinestringFromWKB"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_LinestringFromWKB — Makes a geometry from WKB with the given SRID.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_LinestringFromWKB</b>(</code>bytea <var class="pdparam">WKB</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_LinestringFromWKB</b>(</code>bytea <var class="pdparam">WKB</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36156100"></a><h2>Description</h2><p>The <code class="varname">ST_LinestringFromWKB</code> function, takes a well-known binary
representation of geometry and a Spatial Reference System ID (<code class="varname">SRID</code>)
and creates an instance of the appropriate geometry type - in this case, a
<code class="varname">LINESTRING</code> geometry. This function plays the role of the Geometry
Factory in SQL.</p><p>If an SRID is not specified, it defaults to -1. <code class="varname">NULL</code> is
returned if the input <code class="varname">bytea</code> does not represent a
<code class="varname">LINESTRING</code> geometry. This an alias for <a class="xref" href="#ST_LineFromWKB" title="ST_LineFromWKB">ST_LineFromWKB</a>.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>OGC SPEC 3.2.6.2 - optional SRID is from the conformance suite.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you know all your geometries are <code class="varname">LINESTRING</code>s, it's more
efficient to just use <a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a>. This function just calls
<a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a> and adds additional validation that it returns a
<code class="varname">LINESTRING</code>.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.6.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 7.2.9</p></div><div class="refsection" title="Examples"><a name="id36156206"></a><h2>Examples</h2><pre class="programlisting">SELECT
ST_LineStringFromWKB(
ST_AsBinary(ST_GeomFromText('LINESTRING(1 2, 3 4)'))
) AS aline,
ST_LinestringFromWKB(
ST_AsBinary(ST_GeomFromText('POINT(1 2)'))
) IS NULL AS null_return;
aline | null_return
------------------------------------------------
010200000002000000000000000000F ... | t</pre></div><div class="refsection" title="See Also"><a name="id36156224"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a>, <a class="xref" href="#ST_LineFromWKB" title="ST_LineFromWKB">ST_LineFromWKB</a></p></div></div><div class="refentry" title="ST_MakeBox2D"><div class="refentry.separator"><hr></div><a name="ST_MakeBox2D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MakeBox2D — Creates a BOX2D defined by the given point
geometries.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">box2d <b class="fsfunc">ST_MakeBox2D</b>(</code>geometry <var class="pdparam">pointLowLeft</var>, geometry <var class="pdparam">pointUpRight</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36156294"></a><h2>Description</h2><p>Creates a BOX2D defined by the given point
geometries. This is useful for doing range queries</p></div><div class="refsection" title="Examples"><a name="id36156305"></a><h2>Examples</h2><pre class="programlisting">
--Return all features that fall reside or partly reside in a US national atlas coordinate bounding box
--It is assumed here that the geometries are stored with SRID = 2163 (US National atlas equal area)
SELECT feature_id, feature_name, the_geom
FROM features
WHERE the_geom && ST_SetSRID(ST_MakeBox2D(ST_Point(-989502.1875, 528439.5625),
ST_Point(-987121.375 ,529933.1875)),2163)</pre></div><div class="refsection" title="See Also"><a name="id36156324"></a><h2>See Also</h2><p><a class="xref" href="#ST_MakePoint" title="ST_MakePoint">ST_MakePoint</a>, <a class="xref" href="#ST_Point" title="ST_Point">ST_Point</a>, <a class="xref" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a>, <a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a></p></div></div><div class="refentry" title="ST_MakeBox3D"><div class="refentry.separator"><hr></div><a name="ST_MakeBox3D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MakeBox3D — Creates a BOX3D defined by the given 3d point
geometries.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">box3d <b class="fsfunc">ST_MakeBox3D</b>(</code>geometry <var class="pdparam">point3DLowLeftBottom</var>, geometry <var class="pdparam">point3DUpRightTop</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36156406"></a><h2>Description</h2><p>Creates a BOX3D defined by the given 2 3D point
geometries. </p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36156432"></a><h2>Examples</h2><pre class="programlisting">
SELECT ST_MakeBox3D(ST_MakePoint(-989502.1875, 528439.5625, 10),
ST_MakePoint(-987121.375 ,529933.1875, 10)) As abb3d
--bb3d--
--------
BOX3D(-989502.1875 528439.5625 10,-987121.375 529933.1875 10)
</pre></div><div class="refsection" title="See Also"><a name="id36156449"></a><h2>See Also</h2><p><a class="xref" href="#ST_MakePoint" title="ST_MakePoint">ST_MakePoint</a>, <a class="xref" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a>, <a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a></p></div></div><div class="refentry" title="ST_MakeLine"><div class="refentry.separator"><hr></div><a name="ST_MakeLine"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MakeLine — Creates a Linestring from point geometries.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MakeLine</b>(</code>geometry set <var class="pdparam">pointfield</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_MakeLine</b>(</code>geometry <var class="pdparam">point1</var>, geometry <var class="pdparam">point2</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_MakeLine</b>(</code>geometry[] <var class="pdparam">point_array</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36156565"></a><h2>Description</h2><p>ST_MakeLine comes in 3 forms: a spatial aggregate that takes
rows of point geometries and returns a line string, a function that takes an array of points, and a regular function that takes two point geometries. You
might want to use a subselect to order points before feeding them
to the aggregate version of this function.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p>Availability: 1.4.0 - ST_MakeLine(geomarray) was introduced. ST_MakeLine aggregate functions was enhanced to handle more points faster.</p></div><div class="refsection" title="Examples: Spatial Aggregate version"><a name="id36156596"></a><h2>Examples: Spatial Aggregate version</h2><p>This example takes a sequence of GPS points and creates one record for each
gps travel where the geometry field is a line string composed of the gps points
in the order of the travel.</p><pre class="programlisting">
SELECT gps.gps_track, ST_MakeLine(gps.the_geom) As newgeom
FROM (SELECT gps_track,gps_time, the_geom
FROM gps_points ORDER BY gps_track, gps_time) As gps
GROUP BY gps.gps_track</pre></div><div class="refsection" title="Examples: Non-Spatial Aggregate version"><a name="id36156614"></a><h2>Examples: Non-Spatial Aggregate version</h2><p>First example is a simple one off line string composed of 2 points. The second formulates
line strings from 2 points a user draws. The third is a one-off that joins 2 3d points to create a line in 3d space.</p><pre class="programlisting">
SELECT ST_AsText(ST_MakeLine(ST_MakePoint(1,2), ST_MakePoint(3,4)));
st_astext
---------------------
LINESTRING(1 2,3 4)
SELECT userpoints.id, ST_MakeLine(startpoint, endpoint) As drawn_line
FROM userpoints ;
SELECT ST_AsEWKT(ST_MakeLine(ST_MakePoint(1,2,3), ST_MakePoint(3,4,5)));
st_asewkt
-------------------------
LINESTRING(1 2 3,3 4 5)
</pre></div><div class="refsection" title="Examples: Using Array version"><a name="id36156634"></a><h2>Examples: Using Array version</h2><pre class="programlisting">
SELECT ST_MakeLine(ARRAY(SELECT ST_Centroid(the_geom) FROM visit_locations ORDER BY visit_time));
--Making a 3d line with 3 3-d points
SELECT ST_AsEWKT(ST_MakeLine(ARRAY[ST_MakePoint(1,2,3),
ST_MakePoint(3,4,5), ST_MakePoint(6,6,6)]));
st_asewkt
-------------------------
LINESTRING(1 2 3,3 4 5,6 6 6)
</pre></div><div class="refsection" title="See Also"><a name="id36156649"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a>, <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_MakePoint" title="ST_MakePoint">ST_MakePoint</a></p></div></div><div class="refentry" title="ST_MakeEnvelope"><div class="refentry.separator"><hr></div><a name="ST_MakeEnvelope"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MakeEnvelope — Creates a rectangular Polygon formed from the given minimums and maximums. Input
values must be in SRS specified by the SRID.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MakeEnvelope</b>(</code>double precision <var class="pdparam">xmin</var>, double precision <var class="pdparam">ymin</var>, double precision <var class="pdparam">xmax</var>, double precision <var class="pdparam">ymax</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36156759"></a><h2>Description</h2><p>Creates a rectangular Polygon formed from the minima and maxima. by the given shell. Input
values must be in SRS specified by the SRID.</p><p>Availability: 1.5</p></div><div class="refsection" title="Example: Building a bounding box polygon"><a name="id36156774"></a><h2>Example: Building a bounding box polygon</h2><pre class="programlisting">
SELECT ST_AsText(ST_MakeEnvelope(10, 10, 11, 11, 4326));
st_asewkt
-----------
POLYGON((10 10, 10 11, 11 11, 11 10, 10 10))
</pre></div><div class="refsection" title="See Also"><a name="id36156787"></a><h2>See Also</h2><p><a class="xref" href="#ST_MakePoint" title="ST_MakePoint">ST_MakePoint</a>, <a class="xref" href="#ST_MakeLine" title="ST_MakeLine">ST_MakeLine</a>, <a class="xref" href="#ST_MakePolygon" title="ST_MakePolygon">ST_MakePolygon</a></p></div></div><div class="refentry" title="ST_MakePolygon"><div class="refentry.separator"><hr></div><a name="ST_MakePolygon"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MakePolygon — Creates a Polygon formed by the given shell. Input
geometries must be closed LINESTRINGS.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MakePolygon</b>(</code>geometry <var class="pdparam">linestring</var><code>)</code>;</p></div><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MakePolygon</b>(</code>geometry <var class="pdparam">outerlinestring</var>, geometry[] <var class="pdparam">interiorlinestrings</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36156887"></a><h2>Description</h2><p>Creates a Polygon formed by the given shell. Input
geometries must be closed LINESTRINGS. Comes in 2 variants.</p><p>Variant 1: takes one closed linestring.</p><p>Variant 2: Creates a Polygon formed by the given shell and array of
holes. You can construct a geometry array using ST_Accum or the PostgreSQL ARRAY[] and
ARRAY() constructs. Input geometries must be closed LINESTRINGS.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function will not accept a MULTILINESTRING. Use <a class="xref" href="#ST_LineMerge" title="ST_LineMerge">ST_LineMerge</a> or <a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a> to generate line strings.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples: Single closed LINESTRING"><a name="id36156939"></a><h2>Examples: Single closed LINESTRING</h2><pre class="programlisting">
--2d line
SELECT ST_MakePolygon(ST_GeomFromText('LINESTRING(75.15 29.53,77 29,77.6 29.5, 75.15 29.53)'));
--If linestring is not closed
--you can add the start point to close it
SELECT ST_MakePolygon(ST_AddPoint(foo.open_line, ST_StartPoint(foo.open_line)))
FROM (
SELECT ST_GeomFromText('LINESTRING(75.15 29.53,77 29,77.6 29.5)') As open_line) As foo;
--3d closed line
SELECT ST_MakePolygon(ST_GeomFromText('LINESTRING(75.15 29.53 1,77 29 1,77.6 29.5 1, 75.15 29.53 1)'));
st_asewkt
-----------
POLYGON((75.15 29.53 1,77 29 1,77.6 29.5 1,75.15 29.53 1))
--measured line --
SELECT ST_MakePolygon(ST_GeomFromText('LINESTRINGM(75.15 29.53 1,77 29 1,77.6 29.5 2, 75.15 29.53 2)'));
st_asewkt
----------
POLYGONM((75.15 29.53 1,77 29 1,77.6 29.5 2,75.15 29.53 2))
</pre></div><div class="refsection" title="Examples: Outter shell with inner shells"><a name="id36156957"></a><h2>Examples: Outter shell with inner shells</h2><p>Build a donut with an ant hole</p><pre class="programlisting">
SELECT ST_MakePolygon(
ST_ExteriorRing(ST_Buffer(foo.line,10)),
ARRAY[ST_Translate(foo.line,1,1),
ST_ExteriorRing(ST_Buffer(ST_MakePoint(20,20),1)) ]
)
FROM
(SELECT ST_ExteriorRing(ST_Buffer(ST_MakePoint(10,10),10,10))
As line )
As foo;
</pre><p>Build province boundaries with holes
representing lakes in the province from a set of
province polygons/multipolygons and water line strings
this is an example of using PostGIS ST_Accum
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>The use of CASE because feeding a null array into
ST_MakePolygon results in NULL</p></td></tr></table></div><p>
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>the use of left join to guarantee we get all provinces back even if they have no lakes</p></td></tr></table></div><pre class="programlisting">
SELECT p.gid, p.province_name,
CASE WHEN
ST_Accum(w.the_geom) IS NULL THEN p.the_geom
ELSE ST_MakePolygon(ST_LineMerge(ST_Boundary(p.the_geom)), ST_Accum(w.the_geom)) END
FROM
provinces p LEFT JOIN waterlines w
ON (ST_Within(w.the_geom, p.the_geom) AND ST_IsClosed(w.the_geom))
GROUP BY p.gid, p.province_name, p.the_geom;
--Same example above but utilizing a correlated subquery
--and PostgreSQL built-in ARRAY() function that converts a row set to an array
SELECT p.gid, p.province_name, CASE WHEN
EXISTS(SELECT w.the_geom
FROM waterlines w
WHERE ST_Within(w.the_geom, p.the_geom)
AND ST_IsClosed(w.the_geom))
THEN
ST_MakePolygon(ST_LineMerge(ST_Boundary(p.the_geom)),
ARRAY(SELECT w.the_geom
FROM waterlines w
WHERE ST_Within(w.the_geom, p.the_geom)
AND ST_IsClosed(w.the_geom)))
ELSE p.the_geom END As the_geom
FROM
provinces p;
</pre></div><div class="refsection" title="See Also"><a name="id36157002"></a><h2>See Also</h2><p><a class="xref" href="#ST_Accum" title="ST_Accum">ST_Accum</a>, <a class="xref" href="#ST_AddPoint" title="ST_AddPoint">ST_AddPoint</a>, <a class="xref" href="#ST_GeometryType" title="ST_GeometryType">ST_GeometryType</a>, <a class="xref" href="#ST_IsClosed" title="ST_IsClosed">ST_IsClosed</a>, <a class="xref" href="#ST_LineMerge" title="ST_LineMerge">ST_LineMerge</a></p></div></div><div class="refentry" title="ST_MakePoint"><div class="refentry.separator"><hr></div><a name="ST_MakePoint"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MakePoint — Creates a 2D,3DZ or 4D point geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MakePoint</b>(</code>double precision <var class="pdparam">x</var>, double precision <var class="pdparam">y</var><code>)</code>;</p></div><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MakePoint</b>(</code>double precision <var class="pdparam">x</var>, double precision <var class="pdparam">y</var>, double precision <var class="pdparam">z</var><code>)</code>;</p></div><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MakePoint</b>(</code>double precision <var class="pdparam">x</var>, double precision <var class="pdparam">y</var>, double precision <var class="pdparam">z</var>, double precision <var class="pdparam">m</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36157186"></a><h2>Description</h2><p>Creates a 2D,3DZ or 4D point geometry (geometry with measure).
<code class="varname">ST_MakePoint</code> while not being OGC compliant is
generally faster and more precise than <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>
and <a class="xref" href="#ST_PointFromText" title="ST_PointFromText">ST_PointFromText</a>. It is also easier to use if
you have raw coordinates rather than WKT.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Note x is longitude and y is latitude</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Use <a class="xref" href="#ST_MakePointM" title="ST_MakePointM">ST_MakePointM</a> if you need to make a point with x,y,m.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36157242"></a><h2>Examples</h2><pre class="programlisting">--Return point with unknown SRID
SELECT ST_MakePoint(-71.1043443253471, 42.3150676015829);
--Return point marked as WGS 84 long lat
SELECT ST_SetSRID(ST_MakePoint(-71.1043443253471, 42.3150676015829),4326);
--Return a 3D point (e.g. has altitude)
SELECT ST_MakePoint(1, 2,1.5);
--Get z of point
SELECT ST_Z(ST_MakePoint(1, 2,1.5));
result
-------
1.5</pre></div><div class="refsection" title="See Also"><a name="id36157256"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_PointFromText" title="ST_PointFromText">ST_PointFromText</a>, <a class="xref" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a>, <a class="xref" href="#ST_MakePointM" title="ST_MakePointM">ST_MakePointM</a></p></div></div><div class="refentry" title="ST_MakePointM"><div class="refentry.separator"><hr></div><a name="ST_MakePointM"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MakePointM — Creates a point geometry with an x y and m coordinate.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MakePointM</b>(</code>float <var class="pdparam">x</var>, float <var class="pdparam">y</var>, float <var class="pdparam">m</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36157346"></a><h2>Description</h2><p>Creates a point with x, y and measure coordinates. </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Note x is longitude and y is latitude.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36157361"></a><h2>Examples</h2><p>We use ST_AsEWKT in these examples to show the text representation instead of ST_AsText because ST_AsText does not
support returning M.</p><pre class="programlisting">
--Return EWKT representation of point with unknown SRID
SELECT ST_AsEWKT(ST_MakePointM(-71.1043443253471, 42.3150676015829, 10));
--result
st_asewkt
-----------------------------------------------
POINTM(-71.1043443253471 42.3150676015829 10)
--Return EWKT representation of point with measure marked as WGS 84 long lat
SELECT ST_AsEWKT(ST_SetSRID(ST_MakePointM(-71.1043443253471, 42.3150676015829,10),4326));
st_asewkt
---------------------------------------------------------
SRID=4326;POINTM(-71.1043443253471 42.3150676015829 10)
--Return a 3d point (e.g. has altitude)
SELECT ST_MakePoint(1, 2,1.5);
--Get m of point
SELECT ST_M(ST_MakePointM(-71.1043443253471, 42.3150676015829,10));
result
-------
10
</pre></div><div class="refsection" title="See Also"><a name="id36157383"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_MakePoint" title="ST_MakePoint">ST_MakePoint</a>, <a class="xref" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a></p></div></div><div class="refentry" title="ST_MLineFromText"><div class="refentry.separator"><hr></div><a name="ST_MLineFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MLineFromText — Return a specified ST_MultiLineString value from WKT representation.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MLineFromText</b>(</code>text <var class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_MLineFromText</b>(</code>text <var class="pdparam">WKT</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36157480"></a><h2>Description</h2><p>Makes a Geometry from Well-Known-Text (WKT) with the given SRID. If SRID is
not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
suite</p><p>Returns null if the WKT is not a MULTILINESTRING</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you are absolutely sure all your WKT geometries are points, don't use this function.
It is slower than ST_GeomFromText since it adds an additional validation step.
</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.6.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification.SQL-MM 3: 9.4.4</p></div><div class="refsection" title="Examples"><a name="id36157538"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_MLineFromText('MULTILINESTRING((1 2, 3 4), (4 5, 6 7))');</pre></div><div class="refsection" title="See Also"><a name="id36157554"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a></p></div></div><div class="refentry" title="ST_MPointFromText"><div class="refentry.separator"><hr></div><a name="ST_MPointFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MPointFromText — Makes a Geometry from WKT with the given SRID. If SRID is
not give, it defaults to -1.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MPointFromText</b>(</code>text <var class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_MPointFromText</b>(</code>text <var class="pdparam">WKT</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36157640"></a><h2>Description</h2><p>Makes a Geometry from WKT with the given SRID. If SRID is
not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
suite</p><p>Returns null if the WKT is not a MULTIPOINT</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you are absolutely sure all your WKT geometries are points, don't use this function.
It is slower than ST_GeomFromText since it adds an additional validation step.
</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> 3.2.6.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 9.2.4</p></div><div class="refsection" title="Examples"><a name="id36157698"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_MPointFromText('MULTIPOINT(1 2, 3 4)');
SELECT ST_MPointFromText('MULTIPOINT(-70.9590 42.1180, -70.9611 42.1223)', 4326);</pre></div><div class="refsection" title="See Also"><a name="id36157714"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a></p></div></div><div class="refentry" title="ST_MPolyFromText"><div class="refentry.separator"><hr></div><a name="ST_MPolyFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MPolyFromText — Makes a MultiPolygon Geometry from WKT with the given SRID. If SRID is
not give, it defaults to -1.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MPolyFromText</b>(</code>text <var class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_MPolyFromText</b>(</code>text <var class="pdparam">WKT</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36157801"></a><h2>Description</h2><p>Makes a MultiPolygon from WKT with the given SRID. If SRID is
not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance suite</p><p>Throws an error if the WKT is not a MULTIPOLYGON</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you are absolutely sure all your WKT geometries are multipolygons, don't use this function.
It is slower than ST_GeomFromText since it adds an additional validation step.
</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.6.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 9.6.4</p></div><div class="refsection" title="Examples"><a name="id36157860"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_MPolyFromText('MULTIPOLYGON(((0 0 1,20 0 1,20 20 1,0 20 1,0 0 1),(5 5 3,5 7 3,7 7 3,7 5 3,5 5 3)))');
SELECt ST_MPolyFromText('MULTIPOLYGON(((-70.916 42.1002,-70.9468 42.0946,-70.9765 42.0872,-70.9754 42.0875,-70.9749 42.0879,-70.9752 42.0881,-70.9754 42.0891,-70.9758 42.0894,-70.9759 42.0897,-70.9759 42.0899,-70.9754 42.0902,-70.9756 42.0906,-70.9753 42.0907,-70.9753 42.0917,-70.9757 42.0924,-70.9755 42.0928,-70.9755 42.0942,-70.9751 42.0948,-70.9755 42.0953,-70.9751 42.0958,-70.9751 42.0962,-70.9759 42.0983,-70.9767 42.0987,-70.9768 42.0991,-70.9771 42.0997,-70.9771 42.1003,-70.9768 42.1005,-70.977 42.1011,-70.9766 42.1019,-70.9768 42.1026,-70.9769 42.1033,-70.9775 42.1042,-70.9773 42.1043,-70.9776 42.1043,-70.9778 42.1048,-70.9773 42.1058,-70.9774 42.1061,-70.9779 42.1065,-70.9782 42.1078,-70.9788 42.1085,-70.9798 42.1087,-70.9806 42.109,-70.9807 42.1093,-70.9806 42.1099,-70.9809 42.1109,-70.9808 42.1112,-70.9798 42.1116,-70.9792 42.1127,-70.979 42.1129,-70.9787 42.1134,-70.979 42.1139,-70.9791 42.1141,-70.9987 42.1116,-71.0022 42.1273,
-70.9408 42.1513,-70.9315 42.1165,-70.916 42.1002)))',4326);
</pre></div><div class="refsection" title="See Also"><a name="id36157875"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a></p></div></div><div class="refentry" title="ST_Point"><div class="refentry.separator"><hr></div><a name="ST_Point"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Point — Returns an ST_Point with the given coordinate values. OGC alias for ST_MakePoint.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Point</b>(</code>float <var class="pdparam">x_lon</var>, float <var class="pdparam">y_lat</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36157945"></a><h2>Description</h2><p>Returns an ST_Point with the given coordinate values. MM compliant alias for ST_MakePoint that takes just an x and y.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 6.1.2</p></div><div class="refsection" title="Examples: Geometry"><a name="id36157971"></a><h2>Examples: Geometry</h2><pre class="programlisting">SELECT ST_SetSRID(ST_Point(-71.1043443253471, 42.3150676015829),4326)</pre></div><div class="refsection" title="Examples: Geography"><a name="id36157983"></a><h2>Examples: Geography</h2><pre class="programlisting">SELECT CAST(ST_SetSRID(ST_Point(-71.1043443253471, 42.3150676015829),4326) As geography);</pre><pre class="programlisting">-- the :: is PostgreSQL short-hand for casting.
SELECT ST_SetSRID(ST_Point(-71.1043443253471, 42.3150676015829),4326)::geography;</pre><pre class="programlisting">--If your point coordinates are in a different spatial reference from WGS-84 long lat, then you need to transform before casting
-- This example we convert a point in Pennsylvania State Plane feet to WGS 84 and then geography
SELECT ST_Transform(ST_SetSRID(ST_Point(3637510, 3014852),2273),4326)::geography</pre></div>;
<div class="refsection" title="See Also"><a name="id36158013"></a><h2>See Also</h2><p><a class="xref" href="#Geography_Basics" title="4.2.1.Geography Basics">Section4.2.1, “Geography Basics”</a>, <a class="xref" href="#ST_MakePoint" title="ST_MakePoint">ST_MakePoint</a>, <a class="xref" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a>, <a class="xref" href="#ST_Transform" title="ST_Transform">ST_Transform</a></p></div></div><div class="refentry" title="ST_PointFromText"><div class="refentry.separator"><hr></div><a name="ST_PointFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_PointFromText — Makes a point Geometry from WKT with the given SRID. If SRID is
not given, it defaults to unknown.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_PointFromText</b>(</code>text <var class="pdparam">WKT</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_PointFromText</b>(</code>text <var class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36158116"></a><h2>Description</h2><p>Constructs a PostGIS ST_Geometry point object from the OGC Well-Known text representation. If SRID is
not give, it defaults to unknown (currently -1). If geometry is not a WKT point representation, returns null.
If completely invalid WKT, then throws an error.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>There are 2 variants of ST_PointFromText function, the first takes no SRID and returns a geometry
with no defined spatial reference system. The second takes a spatial reference id as the second argument
and returns an ST_Geometry that includes this srid as part of its meta-data. The srid must be defined
in the spatial_ref_sys table.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you are absolutely sure all your WKT geometries are points, don't use this function.
It is slower than ST_GeomFromText since it adds an additional validation step. If you are building points from long lat coordinates and care more about performance and accuracy than OGC compliance, use <a class="xref" href="#ST_MakePoint" title="ST_MakePoint">ST_MakePoint</a> or OGC compliant alias <a class="xref" href="#ST_Point" title="ST_Point">ST_Point</a>. </p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.6.2 - option SRID is from the conformance suite.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 6.1.8</p></div><div class="refsection" title="Examples"><a name="id36158192"></a><h2>Examples</h2><pre class="programlisting">
SELECT ST_PointFromText('POINT(-71.064544 42.28787)');
SELECT ST_PointFromText('POINT(-71.064544 42.28787)', 4326);
</pre></div><div class="refsection" title="See Also"><a name="id36158205"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_MakePoint" title="ST_MakePoint">ST_MakePoint</a>, <a class="xref" href="#ST_Point" title="ST_Point">ST_Point</a>, <a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a></p></div></div><div class="refentry" title="ST_PointFromWKB"><div class="refentry.separator"><hr></div><a name="ST_PointFromWKB"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_PointFromWKB — Makes a geometry from WKB with the given SRID</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomFromWKB</b>(</code>bytea <var class="pdparam">geom</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_GeomFromWKB</b>(</code>bytea <var class="pdparam">geom</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36158441"></a><h2>Description</h2><p>The <code class="varname">ST_PointFromWKB</code> function, takes a well-known binary
representation of geometry and a Spatial Reference System ID (<code class="varname">SRID</code>)
and creates an instance of the appropriate geometry type - in this case, a
<code class="varname">POINT</code> geometry. This function plays the role of the Geometry
Factory in SQL.</p><p>If an SRID is not specified, it defaults to -1. <code class="varname">NULL</code> is
returned if the input <code class="varname">bytea</code> does not represent a
<code class="varname">POINT</code> geometry.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.7.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 6.1.9</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36158536"></a><h2>Examples</h2><pre class="programlisting">SELECT
ST_AsText(
ST_PointFromWKB(
ST_AsEWKB('POINT(2 5)'::geometry)
)
);
st_astext
------------
POINT(2 5)
(1 row)
SELECT
ST_AsText(
ST_PointFromWKB(
ST_AsEWKB('LINESTRING(2 5, 2 6)'::geometry)
)
);
st_astext
-----------
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36158553"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a>, <a class="xref" href="#ST_LineFromWKB" title="ST_LineFromWKB">ST_LineFromWKB</a></p></div></div><div class="refentry" title="ST_Polygon"><div class="refentry.separator"><hr></div><a name="ST_Polygon"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Polygon — Returns a polygon built from the specified linestring and SRID.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Polygon</b>(</code>geometry <var class="pdparam">aLineString</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36158623"></a><h2>Description</h2><p>Returns a polygon built from the specified linestring and SRID.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>ST_Polygon is similar to first version oST_MakePolygon except it also sets the spatial ref sys (SRID) of the polygon. Will not work with MULTILINESTRINGS
so use LineMerge to merge multilines. Also does not create polygons with holes. Use ST_MakePolygon for that.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 8.3.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36158690"></a><h2>Examples</h2><pre class="programlisting">
--a 2d polygon
SELECT ST_Polygon(ST_GeomFromText('LINESTRING(75.15 29.53,77 29,77.6 29.5, 75.15 29.53)'), 4326);
--result--
POLYGON((75.15 29.53,77 29,77.6 29.5,75.15 29.53))
--a 3d polygon
SELECT ST_AsEWKT(ST_Polygon(ST_GeomFromEWKT('LINESTRING(75.15 29.53 1,77 29 1,77.6 29.5 1, 75.15 29.53 1)'), 4326));
result
------
SRID=4326;POLYGON((75.15 29.53 1,77 29 1,77.6 29.5 1,75.15 29.53 1))
</pre></div><div class="refsection" title="See Also"><a name="id36158708"></a><h2>See Also</h2><p> <a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_LineMerge" title="ST_LineMerge">ST_LineMerge</a>, <a class="xref" href="#ST_MakePolygon" title="ST_MakePolygon">ST_MakePolygon</a></p></div></div><div class="refentry" title="ST_PolygonFromText"><div class="refentry.separator"><hr></div><a name="ST_PolygonFromText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_PolygonFromText — Makes a Geometry from WKT with the given SRID. If SRID is
not give, it defaults to -1.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_PolygonFromText</b>(</code>text <var class="pdparam">WKT</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_PolygonFromText</b>(</code>text <var class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36158820"></a><h2>Description</h2><p>Makes a Geometry from WKT with the given SRID. If SRID is
not give, it defaults to -1. Returns null if WKT is not a polygon.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
suite</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you are absolutely sure all your WKT geometries are polygons, don't use this function.
It is slower than ST_GeomFromText since it adds an additional validation step. </p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.6.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 8.3.6</p></div><div class="refsection" title="Examples"><a name="id36158873"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_PolygonFromText('POLYGON((-71.1776585052917 42.3902909739571,-71.1776820268866 42.3903701743239,
-71.1776063012595 42.3903825660754,-71.1775826583081 42.3903033653531,-71.1776585052917 42.3902909739571))');
st_polygonfromtext
------------------
010300000001000000050000006...
SELECT ST_PolygonFromText('POINT(1 2)') IS NULL as point_is_notpoly;
point_is_not_poly
----------
t
</pre></div><div class="refsection" title="See Also"><a name="id36158891"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a></p></div></div><div class="refentry" title="ST_WKBToSQL"><div class="refentry.separator"><hr></div><a name="ST_WKBToSQL"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_WKBToSQL — Return a specified ST_Geometry value from Well-Known Binary representation (WKB). This is an alias name for ST_GeomFromWKB that takes no srid</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_WKBToSQL</b>(</code>bytea <var class="pdparam">WKB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36158947"></a><h2>Description</h2><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.36</p></div><div class="refsection" title="See Also"><a name="id36158969"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a></p></div></div><div class="refentry" title="ST_WKTToSQL"><div class="refentry.separator"><hr></div><a name="ST_WKTToSQL"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_WKTToSQL — Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an alias name for ST_GeomFromText</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_WKTToSQL</b>(</code>text <var class="pdparam">WKT</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36159024"></a><h2>Description</h2><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.34</p></div><div class="refsection" title="See Also"><a name="id36159046"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a></p></div></div></div><div class="sect1" title="7.4.Geometry Accessors"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Geometry_Accessors"></a>7.4.Geometry Accessors</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#GeometryType">GeometryType</a></span><span class="refpurpose"> — Returns the type of the geometry as a string. Eg:
'LINESTRING', 'POLYGON', 'MULTIPOINT', etc.</span></dt><dt><span class="refentrytitle"><a href="#ST_Boundary">ST_Boundary</a></span><span class="refpurpose"> — Returns the closure of the combinatorial boundary of this
Geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_CoordDim">ST_CoordDim</a></span><span class="refpurpose"> — <p>Return the coordinate dimension of the ST_Geometry value.</p></span></dt><dt><span class="refentrytitle"><a href="#ST_Dimension">ST_Dimension</a></span><span class="refpurpose"> — The inherent dimension of this Geometry object, which must
be less than or equal to the coordinate dimension. </span></dt><dt><span class="refentrytitle"><a href="#ST_EndPoint">ST_EndPoint</a></span><span class="refpurpose"> — Returns the last point of a <code class="varname">LINESTRING</code>
geometry as a <code class="varname">POINT</code>.</span></dt><dt><span class="refentrytitle"><a href="#ST_Envelope">ST_Envelope</a></span><span class="refpurpose"> — Returns a geometry representing the double precision (float8) bounding box of the
supplied geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_ExteriorRing">ST_ExteriorRing</a></span><span class="refpurpose"> — Returns a line string representing the exterior ring of the <code class="varname">POLYGON</code> geometry. Return
NULL if the geometry is not a polygon. Will not work with MULTIPOLYGON</span></dt><dt><span class="refentrytitle"><a href="#ST_GeometryN">ST_GeometryN</a></span><span class="refpurpose"> — Return the 1-based Nth geometry if the geometry is a
GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or MULTIPOLYGON.
Otherwise, return NULL.</span></dt><dt><span class="refentrytitle"><a href="#ST_GeometryType">ST_GeometryType</a></span><span class="refpurpose"> — Return the geometry type of the ST_Geometry value.</span></dt><dt><span class="refentrytitle"><a href="#ST_InteriorRingN">ST_InteriorRingN</a></span><span class="refpurpose"> — Return the Nth interior linestring ring of the polygon geometry.
Return NULL if the geometry is not a polygon or the given N is out
of range.</span></dt><dt><span class="refentrytitle"><a href="#ST_IsClosed">ST_IsClosed</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if the
<code class="varname">LINESTRING</code>'s start and end points are coincident.
</span></dt><dt><span class="refentrytitle"><a href="#ST_IsEmpty">ST_IsEmpty</a></span><span class="refpurpose"> — Returns true if this Geometry is an empty geometry . If
true, then this Geometry represents the empty point set - i.e.
GEOMETRYCOLLECTION(EMPTY).</span></dt><dt><span class="refentrytitle"><a href="#ST_IsRing">ST_IsRing</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if this
<code class="varname">LINESTRING</code> is both closed and simple.</span></dt><dt><span class="refentrytitle"><a href="#ST_IsSimple">ST_IsSimple</a></span><span class="refpurpose"> — Returns (TRUE) if this Geometry has no anomalous geometric
points, such as self intersection or self tangency.</span></dt><dt><span class="refentrytitle"><a href="#ST_IsValid">ST_IsValid</a></span><span class="refpurpose"> — Returns <code class="varname">true</code> if the
<code class="varname">ST_Geometry</code> is well formed.
</span></dt><dt><span class="refentrytitle"><a href="#ST_IsValidReason">ST_IsValidReason</a></span><span class="refpurpose"> — Returns text stating if a geometry is valid or not and if not valid, a reason why.</span></dt><dt><span class="refentrytitle"><a href="#ST_M">ST_M</a></span><span class="refpurpose"> — Return the M coordinate of the point, or NULL if not
available. Input must be a point.</span></dt><dt><span class="refentrytitle"><a href="#ST_NDims">ST_NDims</a></span><span class="refpurpose"> — Returns coordinate dimension of the geometry as a small int.
Values are: 2,3 or 4.</span></dt><dt><span class="refentrytitle"><a href="#ST_NPoints">ST_NPoints</a></span><span class="refpurpose"> — Return the number of points (vertexes) in a geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_NRings">ST_NRings</a></span><span class="refpurpose"> — If the geometry is a polygon or multi-polygon returns the number of rings.</span></dt><dt><span class="refentrytitle"><a href="#ST_NumGeometries">ST_NumGeometries</a></span><span class="refpurpose"> — If geometry is a GEOMETRYCOLLECTION (or MULTI*) return the
number of geometries, otherwise return NULL.</span></dt><dt><span class="refentrytitle"><a href="#ST_NumInteriorRings">ST_NumInteriorRings</a></span><span class="refpurpose"> — Return the number of interior rings of the first polygon in
the geometry. This will work with both POLYGON and MULTIPOLYGON types but only looks at the first polygon.
Return NULL if there is no polygon in the
geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_NumInteriorRing">ST_NumInteriorRing</a></span><span class="refpurpose"> — Return the number of interior rings of the first polygon in
the geometry. Synonym to ST_NumInteriorRings. </span></dt><dt><span class="refentrytitle"><a href="#ST_NumPoints">ST_NumPoints</a></span><span class="refpurpose"> — Return the number of points in an ST_LineString or
ST_CircularString value.</span></dt><dt><span class="refentrytitle"><a href="#ST_PointN">ST_PointN</a></span><span class="refpurpose"> — Return the Nth point in the first linestring or circular linestring in the
geometry. Return NULL if there is no linestring in the
geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_SRID">ST_SRID</a></span><span class="refpurpose"> — Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table.</span></dt><dt><span class="refentrytitle"><a href="#ST_StartPoint">ST_StartPoint</a></span><span class="refpurpose"> — Returns the first point of a <code class="varname">LINESTRING</code>
geometry as a <code class="varname">POINT</code>.</span></dt><dt><span class="refentrytitle"><a href="#ST_Summary">ST_Summary</a></span><span class="refpurpose"> — Returns a text summary of the contents of the
<code class="varname">ST_Geometry</code>.
</span></dt><dt><span class="refentrytitle"><a href="#ST_X">ST_X</a></span><span class="refpurpose"> — Return the X coordinate of the point, or NULL if not
available. Input must be a point.</span></dt><dt><span class="refentrytitle"><a href="#ST_Y">ST_Y</a></span><span class="refpurpose"> — Return the Y coordinate of the point, or NULL if not
available. Input must be a point.</span></dt><dt><span class="refentrytitle"><a href="#ST_Z">ST_Z</a></span><span class="refpurpose"> — Return the Z coordinate of the point, or NULL if not
available. Input must be a point.</span></dt><dt><span class="refentrytitle"><a href="#ST_Zmflag">ST_Zmflag</a></span><span class="refpurpose"> — Returns ZM (dimension semantic) flag of the geometries as a
small int. Values are: 0=2d, 1=3dm, 2=3dz, 3=4d.</span></dt></dl></div><div class="refentry" title="GeometryType"><a name="GeometryType"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>GeometryType — Returns the type of the geometry as a string. Eg:
'LINESTRING', 'POLYGON', 'MULTIPOINT', etc.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">GeometryType</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36164382"></a><h2>Description</h2><p>Returns the type of the geometry as a string. Eg:
'LINESTRING', 'POLYGON', 'MULTIPOINT', etc.</p><p>OGC SPEC s2.1.1.1 - Returns the name of the instantiable
subtype of Geometry of which this Geometry instance is a member.
The name of the instantiable subtype of Geometry is returned as a
string.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function also indicates if the geometry is measured,
by returning a string of the form 'POINTM'.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36164433"></a><h2>Examples</h2><pre class="programlisting">SELECT GeometryType(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'));
geometrytype
--------------
LINESTRING
</pre></div><div class="refsection" title="See Also"><a name="id36164449"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeometryType" title="ST_GeometryType">ST_GeometryType</a></p></div></div><div class="refentry" title="ST_Boundary"><div class="refentry.separator"><hr></div><a name="ST_Boundary"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Boundary — Returns the closure of the combinatorial boundary of this
Geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Boundary</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36164504"></a><h2>Description</h2><p>Returns the closure of the combinatorial boundary of this
Geometry. The combinatorial boundary is defined as described in
section 3.12.3.2 of the OGC SPEC. Because the result of this
function is a closure, and hence topologically closed, the
resulting boundary can be represented using representational
geometry primitives as discussed in the OGC SPEC, section
3.12.2.</p><p>Performed by the GEOS module</p><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a <code class="varname">GEOMETRYCOLLECTION</code> as an argument</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> OGC SPEC s2.1.1.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.14</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36164578"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsText(ST_Boundary(ST_GeomFromText('LINESTRING(1 1,0 0, -1 1)')));
st_astext
-----------
MULTIPOINT(1 1,-1 1)
SELECT ST_AsText(ST_Boundary(ST_GeomFromText('POLYGON((1 1,0 0, -1 1, 1 1))')));
st_astext
----------
LINESTRING(1 1,0 0,-1 1,1 1)
--Using a 3d polygon
SELECT ST_AsEWKT(ST_Boundary(ST_GeomFromEWKT('POLYGON((1 1 1,0 0 1, -1 1 1, 1 1 1))')));
st_asewkt
-----------------------------------
LINESTRING(1 1 1,0 0 1,-1 1 1,1 1 1)
--Using a 3d multilinestring
SELECT ST_AsEWKT(ST_Boundary(ST_GeomFromEWKT('MULTILINESTRING((1 1 1,0 0 0.5, -1 1 1),(1 1 0.5,0 0 0.5, -1 1 0.5, 1 1 0.5) )')));
st_asewkt
----------
MULTIPOINT(-1 1 1,1 1 0.75)
</pre></div><div class="refsection" title="See Also"><a name="id36164595"></a><h2>See Also</h2><p><a class="xref" href="#ST_ExteriorRing" title="ST_ExteriorRing">ST_ExteriorRing</a>, <a class="xref" href="#ST_MakePolygon" title="ST_MakePolygon">ST_MakePolygon</a></p></div></div><div class="refentry" title="ST_CoordDim"><div class="refentry.separator"><hr></div><a name="ST_CoordDim"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_CoordDim — <p>Return the coordinate dimension of the ST_Geometry value.</p></p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_CoordDim</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36164657"></a><h2>Description</h2><p>Return the coordinate dimension of the ST_Geometry value.</p><p>This is the MM compliant alias name for <a class="xref" href="#ST_NDims" title="ST_NDims">ST_NDims</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36164732"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_CoordDim('CIRCULARSTRING(1 2 3, 1 3 4, 5 6 7, 8 9 10, 11 12 13)');
---result--
3
SELECT ST_CoordDim(ST_Point(1,2));
--result--
2
</pre></div><div class="refsection" title="See Also"><a name="id36164748"></a><h2>See Also</h2><p><a class="xref" href="#ST_NDims" title="ST_NDims">ST_NDims</a></p></div></div><div class="refentry" title="ST_Dimension"><div class="refentry.separator"><hr></div><a name="ST_Dimension"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Dimension — The inherent dimension of this Geometry object, which must
be less than or equal to the coordinate dimension. </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_Dimension</b>(</code>geometry <var class="pdparam">g</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36164804"></a><h2>Description</h2><p>The inherent dimension of this Geometry object, which must
be less than or equal to the coordinate dimension. OGC SPEC
s2.1.1.1 - returns 0 for <code class="varname">POINT</code>, 1 for <code class="varname">LINESTRING</code>, 2 for <code class="varname">POLYGON</code>, and
the largest dimension of the components of a
<code class="varname">GEOMETRYCOLLECTION</code>.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.2</p></div><div class="refsection" title="Examples"><a name="id36164845"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_Dimension('GEOMETRYCOLLECTION(LINESTRING(1 1,0 0),POINT(0 0))');
ST_Dimension
-----------
1
</pre></div><div class="refsection" title="See Also"><a name="id36164857"></a><h2>See Also</h2><p><a class="xref" href="#ST_NDims" title="ST_NDims">ST_NDims</a></p></div></div><div class="refentry" title="ST_EndPoint"><div class="refentry.separator"><hr></div><a name="ST_EndPoint"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_EndPoint — Returns the last point of a <code class="varname">LINESTRING</code>
geometry as a <code class="varname">POINT</code>.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_EndPoint</b>(</code>geometry <var class="pdparam">g</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36164919"></a><h2>Description</h2><p>Returns the last point of a <code class="varname">LINESTRING</code> geometry
as a <code class="varname">POINT</code> or <code class="varname">NULL</code> if the input
parameter is not a <code class="varname">LINESTRING</code>.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 7.1.4</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36164973"></a><h2>Examples</h2><pre class="programlisting">postgis=# SELECT ST_AsText(ST_EndPoint('LINESTRING(1 1, 2 2, 3 3)'::geometry));
st_astext
------------
POINT(3 3)
(1 row)
postgis=# SELECT ST_EndPoint('POINT(1 1)'::geometry) IS NULL AS is_null;
is_null
----------
t
(1 row)
--3d endpoint
SELECT ST_AsEWKT(ST_EndPoint('LINESTRING(1 1 2, 1 2 3, 0 0 5)'));
st_asewkt
--------------
POINT(0 0 5)
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36164987"></a><h2>See Also</h2><p><a class="xref" href="#ST_PointN" title="ST_PointN">ST_PointN</a>, <a class="xref" href="#ST_StartPoint" title="ST_StartPoint">ST_StartPoint</a></p></div></div><div class="refentry" title="ST_Envelope"><div class="refentry.separator"><hr></div><a name="ST_Envelope"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Envelope — Returns a geometry representing the double precision (float8) bounding box of the
supplied geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Envelope</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36165050"></a><h2>Description</h2><p>Returns the float8 minimum bounding box for the supplied geometry, as a geometry.
The polygon is defined by the corner points of the bounding box
((<code class="varname">MINX</code>, <code class="varname">MINY</code>),
(<code class="varname">MINX</code>, <code class="varname">MAXY</code>),
(<code class="varname">MAXX</code>, <code class="varname">MAXY</code>),
(<code class="varname">MAXX</code>, <code class="varname">MINY</code>),
(<code class="varname">MINX</code>, <code class="varname">MINY</code>)). (PostGIS will add a
<code class="varname">ZMIN</code>/<code class="varname">ZMAX</code> coordinate as
well).</p><p>Degenerate cases (vertical lines, points) will return a geometry of
lower dimension than <code class="varname">POLYGON</code>, ie.
<code class="varname">POINT</code> or <code class="varname">LINESTRING</code>.</p><p>Availability: 1.5.0 behavior changed to output double precision instead of float4</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.15</p></div><div class="refsection" title="Examples"><a name="id36165154"></a><h2>Examples</h2><pre class="programlisting">
SELECT ST_AsText(ST_Envelope('POINT(1 3)'::geometry));
st_astext
------------
POINT(1 3)
(1 row)
SELECT ST_AsText(ST_Envelope('LINESTRING(0 0, 1 3)'::geometry));
st_astext
--------------------------------
POLYGON((0 0,0 3,1 3,1 0,0 0))
(1 row)
SELECT ST_AsText(ST_Envelope('POLYGON((0 0, 0 1, 1.0000001 1, 1.0000001 0, 0 0))'::geometry));
st_astext
--------------------------------------------------------------
POLYGON((0 0,0 1,1.00000011920929 1,1.00000011920929 0,0 0))
(1 row)
SELECT ST_AsText(ST_Envelope('POLYGON((0 0, 0 1, 1.0000000001 1, 1.0000000001 0, 0 0))'::geometry));
st_astext
--------------------------------------------------------------
POLYGON((0 0,0 1,1.00000011920929 1,1.00000011920929 0,0 0))
(1 row)
SELECT Box3D(geom), Box2D(geom), ST_AsText(ST_Envelope(geom)) As envelopewkt
FROM (SELECT 'POLYGON((0 0, 0 1000012333334.34545678, 1.0000001 1, 1.0000001 0, 0 0))'::geometry As geom) As foo;
</pre></div><div class="refsection" title="See Also"><a name="id36165176"></a><h2>See Also</h2><p><a class="xref" href="#Box2D" title="Box2D">Box2D</a>, <a class="xref" href="#Box3D" title="Box3D">Box3D</a></p></div></div><div class="refentry" title="ST_ExteriorRing"><div class="refentry.separator"><hr></div><a name="ST_ExteriorRing"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_ExteriorRing — Returns a line string representing the exterior ring of the <code class="varname">POLYGON</code> geometry. Return
NULL if the geometry is not a polygon. Will not work with MULTIPOLYGON</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_ExteriorRing</b>(</code>geometry <var class="pdparam">a_polygon</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36165242"></a><h2>Description</h2><p>Returns a line string representing the exterior ring of the <code class="varname">POLYGON</code> geometry. Return
NULL if the geometry is not a polygon.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Only works with POLYGON geometry types</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> 2.1.5.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 8.2.3, 8.3.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36165307"></a><h2>Examples</h2><pre class="programlisting">
--If you have a table of polygons
SELECT gid, ST_ExteriorRing(the_geom) AS ering
FROM sometable;
--If you have a table of MULTIPOLYGONs
--and want to return a MULTILINESTRING composed of the exterior rings of each polygon
SELECT gid, ST_Collect(ST_ExteriorRing(the_geom)) AS erings
FROM (SELECT gid, (ST_Dump(the_geom)).geom As the_geom
FROM sometable) As foo
GROUP BY gid;
--3d Example
SELECT ST_AsEWKT(
ST_ExteriorRing(
ST_GeomFromEWKT('POLYGON((0 0 1, 1 1 1, 1 2 1, 1 1 1, 0 0 1))')
)
);
st_asewkt
---------
LINESTRING(0 0 1,1 1 1,1 2 1,1 1 1,0 0 1)
</pre></div><div class="refsection" title="See Also"><a name="id36165319"></a><h2>See Also</h2><p><a class="xref" href="#ST_Boundary" title="ST_Boundary">ST_Boundary</a>, <a class="xref" href="#ST_NumInteriorRings" title="ST_NumInteriorRings">ST_NumInteriorRings</a></p></div></div><div class="refentry" title="ST_GeometryN"><div class="refentry.separator"><hr></div><a name="ST_GeometryN"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeometryN — Return the 1-based Nth geometry if the geometry is a
GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or MULTIPOLYGON.
Otherwise, return NULL.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_GeometryN</b>(</code>geometry <var class="pdparam">geomA</var>, integer <var class="pdparam">n</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36165391"></a><h2>Description</h2><p>Return the 1-based Nth geometry if the geometry is a
GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or MULTIPOLYGON.
Otherwise, return NULL.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Index is 1-based as for OGC specs since version 0.8.0.
Previous versions implemented this as 0-based instead.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you want to extract all geometries, of a geometry, ST_Dump is more efficient and will also work for singular geoms.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 9.1.5</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36165474"></a><h2>Examples</h2><pre class="programlisting">
--Extracting a subset of points from a 3d multipoint
SELECT n, ST_AsEWKT(ST_GeometryN(the_geom, n)) As geomewkt
FROM (
VALUES (ST_GeomFromEWKT('MULTIPOINT(1 2 7, 3 4 7, 5 6 7, 8 9 10)') ),
( ST_GeomFromEWKT('MULTICURVE(CIRCULARSTRING(2.5 2.5,4.5 2.5, 3.5 3.5), (10 11, 12 11))') )
)As foo(the_geom)
CROSS JOIN generate_series(1,100) n
WHERE n <= ST_NumGeometries(the_geom);
n | geomewkt
---+-----------------------------------------
1 | POINT(1 2 7)
2 | POINT(3 4 7)
3 | POINT(5 6 7)
4 | POINT(8 9 10)
1 | CIRCULARSTRING(2.5 2.5,4.5 2.5,3.5 3.5)
2 | LINESTRING(10 11,12 11)
--Extracting all geometries (useful when you want to assign an id)
SELECT gid, n, ST_GeometryN(the_geom, n)
FROM sometable CROSS JOIN generate_series(1,100) n
WHERE n <= ST_NumGeometries(the_geom);
</pre></div><div class="refsection" title="See Also"><a name="id36165489"></a><h2>See Also</h2><p><a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a>, <a class="xref" href="#ST_NumGeometries" title="ST_NumGeometries">ST_NumGeometries</a></p></div></div><div class="refentry" title="ST_GeometryType"><div class="refentry.separator"><hr></div><a name="ST_GeometryType"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeometryType — Return the geometry type of the ST_Geometry value.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">ST_GeometryType</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36165549"></a><h2>Description</h2><p>Returns the type of the geometry as a string. EG: 'ST_Linestring', 'ST_Polygon','ST_MultiPolygon' etc. This function differs from GeometryType(geometry) in the case of the string and ST in front that is returned, as well as the fact that it will not indicate whether the geometry is measured.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.4</p></div><div class="refsection" title="Examples"><a name="id36165577"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_GeometryType(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'));
--result
ST_LineString
</pre></div><div class="refsection" title="See Also"><a name="id36165590"></a><h2>See Also</h2><p><a class="xref" href="#GeometryType" title="GeometryType">GeometryType</a></p></div></div><div class="refentry" title="ST_InteriorRingN"><div class="refentry.separator"><hr></div><a name="ST_InteriorRingN"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_InteriorRingN — Return the Nth interior linestring ring of the polygon geometry.
Return NULL if the geometry is not a polygon or the given N is out
of range.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_InteriorRingN</b>(</code>geometry <var class="pdparam">a_polygon</var>, integer <var class="pdparam">n</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36165656"></a><h2>Description</h2><p>Return the Nth interior linestring ring of the polygon geometry.
Return NULL if the geometry is not a polygon or the given N is out
of range. index starts at 1.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This will not work for MULTIPOLYGONs. Use in conjunction with ST_Dump for MULTIPOLYGONS</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 8.2.6, 8.3.5</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36165723"></a><h2>Examples</h2><pre class="programlisting">
SELECT ST_AsText(ST_InteriorRingN(the_geom, 1)) As the_geom
FROM (SELECT ST_BuildArea(
ST_Collect(ST_Buffer(ST_Point(1,2), 20,3),
ST_Buffer(ST_Point(1, 2), 10,3))) As the_geom
) as foo
</pre></div><div class="refsection" title="See Also"><a name="id36165740"></a><h2>See Also</h2><p><a class="xref" href="#ST_BuildArea" title="ST_BuildArea">ST_BuildArea</a>, <a class="xref" href="#ST_Collect" title="ST_Collect">ST_Collect</a>, <a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a>, <a class="xref" href="#ST_NumInteriorRing" title="ST_NumInteriorRing">ST_NumInteriorRing</a>, <a class="xref" href="#ST_NumInteriorRings" title="ST_NumInteriorRings">ST_NumInteriorRings</a></p></div></div><div class="refentry" title="ST_IsClosed"><div class="refentry.separator"><hr></div><a name="ST_IsClosed"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_IsClosed — Returns <code class="varname">TRUE</code> if the
<code class="varname">LINESTRING</code>'s start and end points are coincident.
</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_IsClosed</b>(</code>geometry <var class="pdparam">g</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36165822"></a><h2>Description</h2><p>Returns <code class="varname">TRUE</code> if the <code class="varname">LINESTRING</code>'s
start and end points are coincident.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 7.1.5, 9.3.3</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>SQL-MM defines the result of
<code class="function">ST_IsClosed(<code class="varname">NULL</code>)</code> to be 0, while
PostGIS returns <code class="varname">NULL</code>.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36165915"></a><h2>Examples</h2><pre class="programlisting">postgis=# SELECT ST_IsClosed('LINESTRING(0 0, 1 1)'::geometry);
st_isclosed
-------------
f
(1 row)
postgis=# SELECT ST_IsClosed('LINESTRING(0 0, 0 1, 1 1, 0 0)'::geometry);
st_isclosed
-------------
t
(1 row)
postgis=# SELECT ST_IsClosed('MULTILINESTRING((0 0, 0 1, 1 1, 0 0),(0 0, 1 1))'::geometry);
st_isclosed
-------------
f
(1 row)
postgis=# SELECT ST_IsClosed('POINT(0 0)'::geometry);
st_isclosed
-------------
t
(1 row)
postgis=# SELECT ST_IsClosed('MULTIPOINT((0 0), (1 1))'::geometry);
st_isclosed
-------------
t
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36165932"></a><h2>See Also</h2><p><a class="xref" href="#ST_IsRing" title="ST_IsRing">ST_IsRing</a></p></div></div><div class="refentry" title="ST_IsEmpty"><div class="refentry.separator"><hr></div><a name="ST_IsEmpty"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_IsEmpty — Returns true if this Geometry is an empty geometry . If
true, then this Geometry represents the empty point set - i.e.
GEOMETRYCOLLECTION(EMPTY).</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_IsEmpty</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36165989"></a><h2>Description</h2><p>Returns true if this Geometry is an empty geometry . If
true, then this Geometry represents an empty geometry collection, polygon, point etc.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>SQL-MM defines the result of ST_IsEmpty(NULL) to be 0, while
PostGIS returns NULL.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.7</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36166052"></a><h2>Examples</h2><pre class="programlisting">
SELECT ST_IsEmpty('GEOMETRYCOLLECTION(EMPTY)');
st_isempty
------------
t
(1 row)
SELECT ST_IsEmpty(ST_GeomFromText('POLYGON EMPTY'));
st_isempty
------------
t
(1 row)
SELECT ST_IsEmpty(ST_GeomFromText('POLYGON((1 2, 3 4, 5 6, 1 2))'));
st_isempty
------------
f
(1 row)
SELECT ST_IsEmpty(ST_GeomFromText('POLYGON((1 2, 3 4, 5 6, 1 2))')) = false;
?column?
----------
t
(1 row)
SELECT ST_IsEmpty(ST_GeomFromText('CIRCULARSTRING EMPTY'));
st_isempty
------------
t
(1 row)
</pre></div></div><div class="refentry" title="ST_IsRing"><div class="refentry.separator"><hr></div><a name="ST_IsRing"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_IsRing — Returns <code class="varname">TRUE</code> if this
<code class="varname">LINESTRING</code> is both closed and simple.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_IsRing</b>(</code>geometry <var class="pdparam">g</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36166117"></a><h2>Description</h2><p>Returns <code class="varname">TRUE</code> if this
<code class="varname">LINESTRING</code> is both <a class="xref" href="#ST_IsClosed" title="ST_IsClosed">ST_IsClosed</a>
(<code class="function">ST_StartPoint(<em class="parameter"><code>g</code></em>)</code>
<code class="function">~=</code>
<code class="function">ST_Endpoint(<em class="parameter"><code>g</code></em>)</code>) and <a class="xref" href="#ST_IsSimple" title="ST_IsSimple">ST_IsSimple</a> (does not self intersect).</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> 2.1.5.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 7.1.6</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>SQL-MM defines the result of
<code class="function">ST_IsRing(<code class="varname">NULL</code>)</code> to be 0, while
PostGIS returns <code class="varname">NULL</code>.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36166222"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_IsRing(the_geom), ST_IsClosed(the_geom), ST_IsSimple(the_geom)
FROM (SELECT 'LINESTRING(0 0, 0 1, 1 1, 1 0, 0 0)'::geometry AS the_geom) AS foo;
st_isring | st_isclosed | st_issimple
-----------+-------------+-------------
t | t | t
(1 row)
SELECT ST_IsRing(the_geom), ST_IsClosed(the_geom), ST_IsSimple(the_geom)
FROM (SELECT 'LINESTRING(0 0, 0 1, 1 0, 1 1, 0 0)'::geometry AS the_geom) AS foo;
st_isring | st_isclosed | st_issimple
-----------+-------------+-------------
f | t | f
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36166238"></a><h2>See Also</h2><p><a class="xref" href="#ST_IsClosed" title="ST_IsClosed">ST_IsClosed</a>, <a class="xref" href="#ST_IsSimple" title="ST_IsSimple">ST_IsSimple</a>, <a class="xref" href="#ST_StartPoint" title="ST_StartPoint">ST_StartPoint</a>,
<a class="xref" href="#ST_EndPoint" title="ST_EndPoint">ST_EndPoint</a></p></div></div><div class="refentry" title="ST_IsSimple"><div class="refentry.separator"><hr></div><a name="ST_IsSimple"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_IsSimple — Returns (TRUE) if this Geometry has no anomalous geometric
points, such as self intersection or self tangency.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_IsSimple</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36166310"></a><h2>Description</h2><p>Returns true if this Geometry has no anomalous geometric
points, such as self intersection or self tangency. For more
information on the OGC's definition of geometry simplicity and validity, refer
to <a class="link" href="#OGC_Validity" title="4.3.5.Ensuring OpenGIS compliancy of geometries">"Ensuring OpenGIS compliancy of geometries"</a></p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>SQL-MM defines the result of ST_IsSimple(NULL) to be 0,
while PostGIS returns NULL.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.8</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36166381"></a><h2>Examples</h2><pre class="programlisting"> SELECT ST_IsSimple(ST_GeomFromText('POLYGON((1 2, 3 4, 5 6, 1 2))'));
st_issimple
-------------
t
(1 row)
SELECT ST_IsSimple(ST_GeomFromText('LINESTRING(1 1,2 2,2 3.5,1 3,1 2,2 1)'));
st_issimple
-------------
f
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36166395"></a><h2>See Also</h2><p><a class="xref" href="#ST_IsValid" title="ST_IsValid">ST_IsValid</a></p></div></div><div class="refentry" title="ST_IsValid"><div class="refentry.separator"><hr></div><a name="ST_IsValid"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_IsValid — Returns <code class="varname">true</code> if the
<code class="varname">ST_Geometry</code> is well formed.
</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_IsValid</b>(</code>geometry <var class="pdparam">g</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36166458"></a><h2>Description</h2><p>Test if an ST_Geometry value is well formed. For geometries that are invalid,
the PostgreSQL NOTICE will provide details of why it is not valid. For more
information on the OGC's definition of geometry simplicity and validity, refer
to <a class="link" href="#OGC_Validity" title="4.3.5.Ensuring OpenGIS compliancy of geometries">"Ensuring OpenGIS compliancy of geometries"</a></p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>SQL-MM defines the result of ST_IsValid(NULL) to be 0, while
PostGIS returns NULL.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.9</p></div><div class="refsection" title="Examples"><a name="id36166513"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_IsValid(ST_GeomFromText('LINESTRING(0 0, 1 1)')) As good_line,
ST_IsValid(ST_GeomFromText('POLYGON((0 0, 1 1, 1 2, 1 1, 0 0))')) As bad_poly
--results
NOTICE: Self-intersection at or near point 0 0
good_line | bad_poly
-----------+----------
t | f
</pre></div><div class="refsection" title="See Also"><a name="id36166527"></a><h2>See Also</h2><p><a class="xref" href="#ST_IsSimple" title="ST_IsSimple">ST_IsSimple</a>, <a class="xref" href="#ST_IsValidReason" title="ST_IsValidReason">ST_IsValidReason</a>, <a class="xref" href="#ST_Summary" title="ST_Summary">ST_Summary</a></p></div></div><div class="refentry" title="ST_IsValidReason"><div class="refentry.separator"><hr></div><a name="ST_IsValidReason"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_IsValidReason — Returns text stating if a geometry is valid or not and if not valid, a reason why.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">ST_IsValidReason</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36166595"></a><h2>Description</h2><p>Returns text stating if a geometry is valid or not an if not valid, a reason why.</p><p>Useful in combination with ST_IsValid to generate a detailed report of invalid geometries and reasons.</p><p>Availability: 1.4 - requires GEOS >= 3.1.0.</p></div><div class="refsection" title="Examples"><a name="id36166614"></a><h2>Examples</h2><pre class="programlisting">
--First 3 Rejects from a successful quintuplet experiment
SELECT gid, ST_IsValidReason(the_geom) as validity_info
FROM
(SELECT ST_MakePolygon(ST_ExteriorRing(e.buff), ST_Accum(f.line)) As the_geom, gid
FROM (SELECT ST_Buffer(ST_MakePoint(x1*10,y1), z1) As buff, x1*10 + y1*100 + z1*1000 As gid
FROM generate_series(-4,6) x1
CROSS JOIN generate_series(2,5) y1
CROSS JOIN generate_series(1,8) z1
WHERE x1 > y1*0.5 AND z1 < x1*y1) As e
INNER JOIN (SELECT ST_Translate(ST_ExteriorRing(ST_Buffer(ST_MakePoint(x1*10,y1), z1)),y1*1, z1*2) As line
FROM generate_series(-3,6) x1
CROSS JOIN generate_series(2,5) y1
CROSS JOIN generate_series(1,10) z1
WHERE x1 > y1*0.75 AND z1 < x1*y1) As f
ON (ST_Area(e.buff) > 78 AND ST_Contains(e.buff, f.line))
GROUP BY gid, e.buff) As quintuplet_experiment
WHERE ST_IsValid(the_geom) = false
ORDER BY gid
LIMIT 3;
gid | validity_info
------+--------------------------
5330 | Self-intersection [32 5]
5340 | Self-intersection [42 5]
5350 | Self-intersection [52 5]
--simple example
SELECT ST_IsValidReason('LINESTRING(220227 150406,2220227 150407,222020 150410)');
st_isvalidreason
------------------
Valid Geometry
</pre></div><div class="refsection" title="See Also"><a name="id36166629"></a><h2>See Also</h2><p><a class="xref" href="#ST_IsValid" title="ST_IsValid">ST_IsValid</a>, <a class="xref" href="#ST_Summary" title="ST_Summary">ST_Summary</a></p></div></div><div class="refentry" title="ST_M"><div class="refentry.separator"><hr></div><a name="ST_M"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_M — Return the M coordinate of the point, or NULL if not
available. Input must be a point.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_M</b>(</code>geometry <var class="pdparam">a_point</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36166689"></a><h2>Description</h2><p>Return the M coordinate of the point, or NULL if not
available. Input must be a point.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This is not (yet) part of the OGC spec, but is listed here
to complete the point coordinate extractor function list.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36166751"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_M(ST_GeomFromEWKT('POINT(1 2 3 4)'));
st_m
------
4
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36166766"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_X" title="ST_X">ST_X</a>, <a class="xref" href="#ST_Y" title="ST_Y">ST_Y</a>, <a class="xref" href="#ST_Z" title="ST_Z">ST_Z</a></p></div></div><div class="refentry" title="ST_NDims"><div class="refentry.separator"><hr></div><a name="ST_NDims"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_NDims — Returns coordinate dimension of the geometry as a small int.
Values are: 2,3 or 4.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_NDims</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36166839"></a><h2>Description</h2><p>Returns the coordinate dimension of the geometry. PostGIS supports 2 - (x,y) ,
3 - (x,y,z) or 2D with measure - x,y,m, and 4 - 3D with measure space x,y,z,m</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36166864"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_NDims(ST_GeomFromText('POINT(1 1)')) As d2point,
ST_NDims(ST_GeomFromEWKT('POINT(1 1 2)')) As d3point,
ST_NDims(ST_GeomFromEWKT('POINTM(1 1 0.5)')) As d2pointm;
d2point | d3point | d2pointm
---------+---------+----------
2 | 3 | 3
</pre></div><div class="refsection" title="See Also"><a name="id36166878"></a><h2>See Also</h2><p><a class="xref" href="#ST_CoordDim" title="ST_CoordDim">ST_CoordDim</a>, <a class="xref" href="#ST_Dimension" title="ST_Dimension">ST_Dimension</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a></p></div></div><div class="refentry" title="ST_NPoints"><div class="refentry.separator"><hr></div><a name="ST_NPoints"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_NPoints — Return the number of points (vertexes) in a geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_NPoints</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36166945"></a><h2>Description</h2><p>Return the number of points in a geometry. Works for all geometries.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36166986"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_NPoints(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'));
--result
4
--Polygon in 3D space
SELECT ST_NPoints(ST_GeomFromEWKT('LINESTRING(77.29 29.07 1,77.42 29.26 0,77.27 29.31 -1,77.29 29.07 3)'))
--result
4</pre></div><div class="refsection" title="See Also"><a name="id36167136"></a><h2>See Also</h2><p><a class="xref" href="#ST_NumPoints" title="ST_NumPoints">ST_NumPoints</a></p></div></div><div class="refentry" title="ST_NRings"><div class="refentry.separator"><hr></div><a name="ST_NRings"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_NRings — If the geometry is a polygon or multi-polygon returns the number of rings.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_NRings</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36167192"></a><h2>Description</h2><p>If the geometry is a polygon or multi-polygon returns the number of rings. Unlike NumInteriorRings, it counts
the outer rings as well.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36167228"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_NRings(the_geom) As Nrings, ST_NumInteriorRings(the_geom) As ninterrings
FROM (SELECT ST_GeomFromText('POLYGON((1 2, 3 4, 5 6, 1 2))') As the_geom) As foo;
nrings | ninterrings
--------+-------------
1 | 0
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36167245"></a><h2>See Also</h2><p><a class="xref" href="#ST_NumInteriorRings" title="ST_NumInteriorRings">ST_NumInteriorRings</a></p></div></div><div class="refentry" title="ST_NumGeometries"><div class="refentry.separator"><hr></div><a name="ST_NumGeometries"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_NumGeometries — If geometry is a GEOMETRYCOLLECTION (or MULTI*) return the
number of geometries, otherwise return NULL.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_NumGeometries</b>(</code>geometry <var class="pdparam">a_multi_or_geomcollection</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36167302"></a><h2>Description</h2><p>Returns the number of Geometries. If geometry is a GEOMETRYCOLLECTION (or MULTI*) return the
number of geometries, otherwise return NULL.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 9.1.4</p></div><div class="refsection" title="Examples"><a name="id36167328"></a><h2>Examples</h2><pre class="programlisting">
--Although ST_NumGeometries will return null when passed a single, you can wrap in ST_Multi to force 1 or more for all geoms
SELECT ST_NumGeometries(ST_Multi(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)')));
--result
1
--Geometry Collection Example - multis count as one geom in a collection
SELECT ST_NumGeometries(ST_GeomFromEWKT('GEOMETRYCOLLECTION(MULTIPOINT(-2 3 , -2 2),
LINESTRING(5 5 ,10 10),
POLYGON((-7 4.2,-7.1 5,-7.1 4.3,-7 4.2)))'));
--result
3
</pre></div><div class="refsection" title="See Also"><a name="id36167344"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeometryN" title="ST_GeometryN">ST_GeometryN</a>, <a class="xref" href="#ST_Multi" title="ST_Multi">ST_Multi</a></p></div></div><div class="refentry" title="ST_NumInteriorRings"><div class="refentry.separator"><hr></div><a name="ST_NumInteriorRings"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_NumInteriorRings — Return the number of interior rings of the first polygon in
the geometry. This will work with both POLYGON and MULTIPOLYGON types but only looks at the first polygon.
Return NULL if there is no polygon in the
geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_NumInteriorRings</b>(</code>geometry <var class="pdparam">a_polygon</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36167407"></a><h2>Description</h2><p>Return the number of interior rings of the first polygon in
the geometry. This will work with both POLYGON and MULTIPOLYGON types but only looks at the first polygon.
Return NULL if there is no polygon in the
geometry.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 8.2.5</p></div><div class="refsection" title="Examples"><a name="id36167434"></a><h2>Examples</h2><pre class="programlisting">
--If you have a regular polygon
SELECT gid, field1, field2, ST_NumInteriorRings(the_geom) AS numholes
FROM sometable;
--If you have multipolygons
--And you want to know the total number of interior rings in the MULTIPOLYGON
SELECT gid, field1, field2, SUM(ST_NumInteriorRings(the_geom)) AS numholes
FROM (SELECT gid, field1, field2, (ST_Dump(the_geom)).geom As the_geom
FROM sometable) As foo
GROUP BY gid, field1,field2;
</pre></div><div class="refsection" title="See Also"><a name="id36167450"></a><h2>See Also</h2><p><a class="xref" href="#ST_NumInteriorRing" title="ST_NumInteriorRing">ST_NumInteriorRing</a></p></div></div><div class="refentry" title="ST_NumInteriorRing"><div class="refentry.separator"><hr></div><a name="ST_NumInteriorRing"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_NumInteriorRing — Return the number of interior rings of the first polygon in
the geometry. Synonym to ST_NumInteriorRings. </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_NumInteriorRing</b>(</code>geometry <var class="pdparam">a_polygon</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36167506"></a><h2>Description</h2><p>Return the number of interior rings of the first polygon in
the geometry. Synonym to ST_NumInteriorRings. The OpenGIS specs are
ambiguous about the exact function naming, so we provide both
spellings.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 8.2.5</p></div><div class="refsection" title="See Also"><a name="id36167533"></a><h2>See Also</h2><p><a class="xref" href="#ST_NumInteriorRings" title="ST_NumInteriorRings">ST_NumInteriorRings</a></p></div></div><div class="refentry" title="ST_NumPoints"><div class="refentry.separator"><hr></div><a name="ST_NumPoints"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_NumPoints — Return the number of points in an ST_LineString or
ST_CircularString value.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_NumPoints</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36167589"></a><h2>Description</h2><p>Return the number of points in an ST_LineString or
ST_CircularString value. Prior to 1.4 only works with Linestrings as the specs state. From 1.4 forward this is an alias for ST_NPoints which returns number of vertexes for
not just line strings.
Consider using ST_NPoints instead which is multi-purpose
and works with many geometry types.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 7.2.4</p></div><div class="refsection" title="Examples"><a name="id36167633"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_NumPoints(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'));
--result
4
</pre></div><div class="refsection" title="See Also"><a name="id36167646"></a><h2>See Also</h2><p><a class="xref" href="#ST_NPoints" title="ST_NPoints">ST_NPoints</a></p></div></div><div class="refentry" title="ST_PointN"><div class="refentry.separator"><hr></div><a name="ST_PointN"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_PointN — Return the Nth point in the first linestring or circular linestring in the
geometry. Return NULL if there is no linestring in the
geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_PointN</b>(</code>geometry <var class="pdparam">a_linestring</var>, integer <var class="pdparam">n</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36167713"></a><h2>Description</h2><p>Return the Nth point in the first linestring or circular linestring in the
geometry. Return NULL if there is no linestring in the
geometry.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Index is 1-based as for OGC specs since version 0.8.0.
Previous versions implemented this as 0-based instead.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you want to get the nth point of each line string in a multilinestring, use in conjunction
with ST_Dump</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 7.2.5, 7.3.5</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36167796"></a><h2>Examples</h2><pre class="programlisting">-- Extract all POINTs from a LINESTRING
SELECT ST_AsText(
ST_PointN(
column1,
generate_series(1, ST_NPoints(column1))
))
FROM ( VALUES ('LINESTRING(0 0, 1 1, 2 2)'::geometry) ) AS foo;
st_astext
------------
POINT(0 0)
POINT(1 1)
POINT(2 2)
(3 rows)
--Example circular string
SELECT ST_AsText(ST_PointN(ST_GeomFromText('CIRCULARSTRING(1 2, 3 2, 1 2)'),2));
st_astext
----------
POINT(3 2)
</pre></div><div class="refsection" title="See Also"><a name="id36167811"></a><h2>See Also</h2><p><a class="xref" href="#ST_NPoints" title="ST_NPoints">ST_NPoints</a></p></div></div><div class="refentry" title="ST_SRID"><div class="refentry.separator"><hr></div><a name="ST_SRID"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_SRID — Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_SRID</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36167867"></a><h2>Description</h2><p>Returns the spatial reference identifier for the ST_Geometry as defined in <a class="xref" href="#spatial_ref_sys" title="4.3.1.The SPATIAL_REF_SYS Table and Spatial Reference Systems">Section4.3.1, “The SPATIAL_REF_SYS Table and Spatial Reference Systems”</a> table. </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>spatial_ref_sys
table is a table that catalogs all spatial reference systems known to PostGIS and is used for transformations from one spatial
reference system to another. So verifying you have the right spatial reference system identifier is important if you plan to ever transform your geometries.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.5</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36167936"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_SRID(ST_GeomFromText('POINT(-71.1043 42.315)',4326));
--result
4326
</pre></div><div class="refsection" title="See Also"><a name="id36167948"></a><h2>See Also</h2><p><a class="xref" href="#spatial_ref_sys" title="4.3.1.The SPATIAL_REF_SYS Table and Spatial Reference Systems">Section4.3.1, “The SPATIAL_REF_SYS Table and Spatial Reference Systems”</a>,<a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a>, <a class="xref" href="#ST_Transform" title="ST_Transform">ST_Transform</a></p></div></div><div class="refentry" title="ST_StartPoint"><div class="refentry.separator"><hr></div><a name="ST_StartPoint"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_StartPoint — Returns the first point of a <code class="varname">LINESTRING</code>
geometry as a <code class="varname">POINT</code>.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_StartPoint</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36168025"></a><h2>Description</h2><p>Returns the first point of a <code class="varname">LINESTRING</code> geometry
as a <code class="varname">POINT</code> or <code class="varname">NULL</code> if the input
parameter is not a <code class="varname">LINESTRING</code>.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 7.1.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36168079"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsText(ST_StartPoint('LINESTRING(0 1, 0 2)'::geometry));
st_astext
------------
POINT(0 1)
(1 row)
SELECT ST_StartPoint('POINT(0 1)'::geometry) IS NULL AS is_null;
is_null
----------
t
(1 row)
--3d line
SELECT ST_AsEWKT(ST_StartPoint('LINESTRING(0 1 1, 0 2 2)'::geometry));
st_asewkt
------------
POINT(0 1 1)
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36168093"></a><h2>See Also</h2><p><a class="xref" href="#ST_EndPoint" title="ST_EndPoint">ST_EndPoint</a>, <a class="xref" href="#ST_PointN" title="ST_PointN">ST_PointN</a></p></div></div><div class="refentry" title="ST_Summary"><div class="refentry.separator"><hr></div><a name="ST_Summary"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Summary — Returns a text summary of the contents of the
<code class="varname">ST_Geometry</code>.
</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">ST_Summary</b>(</code>geometry <var class="pdparam">g</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36168157"></a><h2>Description</h2><p>Returns a text summary of the contents of the geometry.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36168181"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_Summary(ST_GeomFromText('LINESTRING(0 0, 1 1)')) As good_line,
ST_Summary(ST_GeomFromText('POLYGON((0 0, 1 1, 1 2, 1 1, 0 0))')) As bad_poly
--results
good_line | bad_poly
----------------------+-------------------------
|
Line[B] with 2 points : Polygon[B] with 1 rings
: ring 0 has 5 points
:
--3d polygon
SELECT ST_Summary(ST_GeomFromEWKT('LINESTRING(0 0 1, 1 1 1)')) As good_line,
ST_Summary(ST_GeomFromEWKT('POLYGON((0 0 1, 1 1 2, 1 2 3, 1 1 1, 0 0 1))')) As poly
--results
good_line | poly
----------------------+-------------------------
|
Line[ZB] with 2 points : Polygon[ZB] with 1 rings
: ring 0 has 5 points
:
</pre></div><div class="refsection" title="See Also"><a name="id36168199"></a><h2>See Also</h2><p><a class="xref" href="#ST_IsValid" title="ST_IsValid">ST_IsValid</a>, <a class="xref" href="#ST_IsValidReason" title="ST_IsValidReason">ST_IsValidReason</a></p></div></div><div class="refentry" title="ST_X"><div class="refentry.separator"><hr></div><a name="ST_X"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_X — Return the X coordinate of the point, or NULL if not
available. Input must be a point.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_X</b>(</code>geometry <var class="pdparam">a_point</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36168260"></a><h2>Description</h2><p>Return the X coordinate of the point, or NULL if not
available. Input must be a point.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If you want to get the max min x values of any geometry look at ST_XMin, ST_XMax functions.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 6.1.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36168304"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_X(ST_GeomFromEWKT('POINT(1 2 3 4)'));
st_x
------
1
(1 row)
SELECT ST_Y(ST_Centroid(ST_GeomFromEWKT('LINESTRING(1 2 3 4, 1 1 1 1)')));
st_y
------
1.5
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36168321"></a><h2>See Also</h2><p><a class="xref" href="#ST_Centroid" title="ST_Centroid">ST_Centroid</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_M" title="ST_M">ST_M</a>, <a class="xref" href="#ST_XMax" title="ST_XMax">ST_XMax</a>, <a class="xref" href="#ST_XMin" title="ST_XMin">ST_XMin</a>, <a class="xref" href="#ST_Y" title="ST_Y">ST_Y</a>, <a class="xref" href="#ST_Z" title="ST_Z">ST_Z</a></p></div></div><div class="refentry" title="ST_Y"><div class="refentry.separator"><hr></div><a name="ST_Y"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Y — Return the Y coordinate of the point, or NULL if not
available. Input must be a point.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Y</b>(</code>geometry <var class="pdparam">a_point</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36168409"></a><h2>Description</h2><p>Return the Y coordinate of the point, or NULL if not
available. Input must be a point.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 6.1.4</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36168465"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_Y(ST_GeomFromEWKT('POINT(1 2 3 4)'));
st_y
------
2
(1 row)
SELECT ST_Y(ST_Centroid(ST_GeomFromEWKT('LINESTRING(1 2 3 4, 1 1 1 1)')));
st_y
------
1.5
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36168481"></a><h2>See Also</h2><p><a class="xref" href="#ST_Centroid" title="ST_Centroid">ST_Centroid</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_M" title="ST_M">ST_M</a>, <a class="xref" href="#ST_X" title="ST_X">ST_X</a>, <a class="xref" href="#ST_YMax" title="ST_YMax">ST_YMax</a>, <a class="xref" href="#ST_YMin" title="ST_YMin">ST_YMin</a>, <a class="xref" href="#ST_Z" title="ST_Z">ST_Z</a></p></div></div><div class="refentry" title="ST_Z"><div class="refentry.separator"><hr></div><a name="ST_Z"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Z — Return the Z coordinate of the point, or NULL if not
available. Input must be a point.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Z</b>(</code>geometry <var class="pdparam">a_point</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36168568"></a><h2>Description</h2><p>Return the Z coordinate of the point, or NULL if not
available. Input must be a point.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36168607"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_Z(ST_GeomFromEWKT('POINT(1 2 3 4)'));
st_z
------
3
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36168622"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_M" title="ST_M">ST_M</a>, <a class="xref" href="#ST_X" title="ST_X">ST_X</a>, <a class="xref" href="#ST_Y" title="ST_Y">ST_Y</a>, <a class="xref" href="#ST_ZMax" title="ST_ZMax">ST_ZMax</a>, <a class="xref" href="#ST_ZMin" title="ST_ZMin">ST_ZMin</a> </p></div></div><div class="refentry" title="ST_Zmflag"><div class="refentry.separator"><hr></div><a name="ST_Zmflag"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Zmflag — Returns ZM (dimension semantic) flag of the geometries as a
small int. Values are: 0=2d, 1=3dm, 2=3dz, 3=4d.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">smallint <b class="fsfunc">ST_Zmflag</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36168705"></a><h2>Description</h2><p>Returns ZM (dimension semantic) flag of the geometries as a
small int. Values are: 0=2d, 1=3dm, 2=3dz, 3=4d.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36168741"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_Zmflag(ST_GeomFromEWKT('LINESTRING(1 2, 3 4)'));
st_zmflag
-----------
0
SELECT ST_Zmflag(ST_GeomFromEWKT('LINESTRINGM(1 2 3, 3 4 3)'));
st_zmflag
-----------
1
SELECT ST_Zmflag(ST_GeomFromEWKT('CIRCULARSTRING(1 2 3, 3 4 3, 5 6 3)'));
st_zmflag
-----------
2
SELECT ST_Zmflag(ST_GeomFromEWKT('POINT(1 2 3 4)'));
st_zmflag
-----------
3
</pre></div><div class="refsection" title="See Also"><a name="id36168759"></a><h2>See Also</h2><p><a class="xref" href="#ST_CoordDim" title="ST_CoordDim">ST_CoordDim</a>, <a class="xref" href="#ST_NDims" title="ST_NDims">ST_NDims</a>, <a class="xref" href="#ST_Dimension" title="ST_Dimension">ST_Dimension</a></p></div></div></div><div class="sect1" title="7.5.Geometry Editors"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Geometry_Editors"></a>7.5.Geometry Editors</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#ST_AddPoint">ST_AddPoint</a></span><span class="refpurpose"> — Adds a point to a LineString before point <position>
(0-based index).</span></dt><dt><span class="refentrytitle"><a href="#ST_Affine">ST_Affine</a></span><span class="refpurpose"> — Applies a 3d affine transformation to the geometry to do things like translate, rotate, scale in one step.</span></dt><dt><span class="refentrytitle"><a href="#ST_Force_2D">ST_Force_2D</a></span><span class="refpurpose"> — Forces the geometries into a "2-dimensional mode" so that
all output representations will only have the X and Y coordinates.</span></dt><dt><span class="refentrytitle"><a href="#ST_Force_3D">ST_Force_3D</a></span><span class="refpurpose"> — Forces the geometries into XYZ mode. This is an alias for ST_Force_3DZ.</span></dt><dt><span class="refentrytitle"><a href="#ST_Force_3DZ">ST_Force_3DZ</a></span><span class="refpurpose"> — Forces the geometries into XYZ mode. This is a synonym for ST_Force_3D.</span></dt><dt><span class="refentrytitle"><a href="#ST_Force_3DM">ST_Force_3DM</a></span><span class="refpurpose"> — Forces the geometries into XYM mode.</span></dt><dt><span class="refentrytitle"><a href="#ST_Force_4D">ST_Force_4D</a></span><span class="refpurpose"> — Forces the geometries into XYZM mode. </span></dt><dt><span class="refentrytitle"><a href="#ST_Force_Collection">ST_Force_Collection</a></span><span class="refpurpose"> — Converts the geometry into a GEOMETRYCOLLECTION.</span></dt><dt><span class="refentrytitle"><a href="#ST_ForceRHR">ST_ForceRHR</a></span><span class="refpurpose"> — Forces the orientation of the vertices in a polygon to follow the
Right-Hand-Rule.</span></dt><dt><span class="refentrytitle"><a href="#ST_LineMerge">ST_LineMerge</a></span><span class="refpurpose"> — Returns a (set of) LineString(s) formed by sewing together
a MULTILINESTRING.</span></dt><dt><span class="refentrytitle"><a href="#ST_CollectionExtract">ST_CollectionExtract</a></span><span class="refpurpose"> — Given a GEOMETRYCOLLECTION, returns a MULTI* geometry consisting only of the specified type. Sub-geometries that are not
the specified type are ignored. If there are no sub-geometries of the right type, an EMPTY collection will be returned. Only
points, lines and polygons are supported. Type numbers are 1 == POINT, 2 == LINESTRING, 3 == POLYGON.</span></dt><dt><span class="refentrytitle"><a href="#ST_Multi">ST_Multi</a></span><span class="refpurpose"> — Returns the geometry as a MULTI* geometry. If the geometry
is already a MULTI*, it is returned unchanged.</span></dt><dt><span class="refentrytitle"><a href="#ST_RemovePoint">ST_RemovePoint</a></span><span class="refpurpose"> — Removes point from a linestring. Offset is 0-based.</span></dt><dt><span class="refentrytitle"><a href="#ST_Reverse">ST_Reverse</a></span><span class="refpurpose"> — Returns the geometry with vertex order reversed.</span></dt><dt><span class="refentrytitle"><a href="#ST_Rotate">ST_Rotate</a></span><span class="refpurpose"> — This is a synonym for ST_RotateZ</span></dt><dt><span class="refentrytitle"><a href="#ST_RotateX">ST_RotateX</a></span><span class="refpurpose"> — Rotate a geometry rotRadians about the X axis.</span></dt><dt><span class="refentrytitle"><a href="#ST_RotateY">ST_RotateY</a></span><span class="refpurpose"> — Rotate a geometry rotRadians about the Y axis.</span></dt><dt><span class="refentrytitle"><a href="#ST_RotateZ">ST_RotateZ</a></span><span class="refpurpose"> — Rotate a geometry rotRadians about the Z axis.</span></dt><dt><span class="refentrytitle"><a href="#ST_Scale">ST_Scale</a></span><span class="refpurpose"> — Scales the geometry to a new size by multiplying the
ordinates with the parameters. Ie: ST_Scale(geom, Xfactor, Yfactor,
Zfactor).
</span></dt><dt><span class="refentrytitle"><a href="#ST_Segmentize">ST_Segmentize</a></span><span class="refpurpose"> — Return a modified geometry having no segment longer than the
given distance. Distance computation is performed in 2d
only.</span></dt><dt><span class="refentrytitle"><a href="#ST_SetPoint">ST_SetPoint</a></span><span class="refpurpose"> — Replace point N of linestring with given point. Index is
0-based.</span></dt><dt><span class="refentrytitle"><a href="#ST_SetSRID">ST_SetSRID</a></span><span class="refpurpose"> — Sets the SRID on a geometry to a particular integer
value.</span></dt><dt><span class="refentrytitle"><a href="#ST_SnapToGrid">ST_SnapToGrid</a></span><span class="refpurpose"> — Snap all points of the input geometry to the grid defined by
its origin and cell size. Remove consecutive points falling on the
same cell, eventually returning NULL if output points are not
enough to define a geometry of the given type. Collapsed
geometries in a collection are stripped from it. Useful for reducing precision.</span></dt><dt><span class="refentrytitle"><a href="#ST_Transform">ST_Transform</a></span><span class="refpurpose"> — Returns a new geometry with its coordinates transformed to
the SRID referenced by the integer parameter.</span></dt><dt><span class="refentrytitle"><a href="#ST_Translate">ST_Translate</a></span><span class="refpurpose"> — Translates the geometry to a new location using the numeric
parameters as offsets. Ie: ST_Translate(geom, X, Y) or ST_Translate(geom, X, Y,Z).</span></dt><dt><span class="refentrytitle"><a href="#ST_TransScale">ST_TransScale</a></span><span class="refpurpose"> — Translates the geometry using the deltaX and deltaY args,
then scales it using the XFactor, YFactor args, working in 2D only.
</span></dt></dl></div><div class="refentry" title="ST_AddPoint"><a name="ST_AddPoint"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_AddPoint — Adds a point to a LineString before point <position>
(0-based index).</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_AddPoint</b>(</code>geometry <var class="pdparam">linestring</var>, geometry <var class="pdparam">point</var><code>)</code>;</p></div><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_AddPoint</b>(</code>geometry <var class="pdparam">linestring</var>, geometry <var class="pdparam">point</var>, integer <var class="pdparam">position</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36173246"></a><h2>Description</h2><p>Adds a point to a LineString before point <position>
(0-based index). Third parameter can be omitted or set to -1 for
appending.</p><p>Availability: 1.1.0</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36173275"></a><h2>Examples</h2><pre class="programlisting">
--guarantee all linestrings in a table are closed
--by adding the start point of each linestring to the end of the line string
--only for those that are not closed
UPDATE sometable
SET the_geom = ST_AddPoint(the_geom, ST_StartPoint(the_geom))
FROM sometable
WHERE ST_IsClosed(the_geom) = false;
--Adding point to a 3-d line
SELECT ST_AsEWKT(ST_AddPoint(ST_GeomFromEWKT('LINESTRING(0 0 1, 1 1 1)'), ST_MakePoint(1, 2, 3)));
--result
st_asewkt
----------
LINESTRING(0 0 1,1 1 1,1 2 3)
</pre></div><div class="refsection" title="See Also"><a name="id36173291"></a><h2>See Also</h2><p><a class="xref" href="#ST_RemovePoint" title="ST_RemovePoint">ST_RemovePoint</a>, <a class="xref" href="#ST_SetPoint" title="ST_SetPoint">ST_SetPoint</a></p></div></div><div class="refentry" title="ST_Affine"><div class="refentry.separator"><hr></div><a name="ST_Affine"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Affine — Applies a 3d affine transformation to the geometry to do things like translate, rotate, scale in one step.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Affine</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">a</var>, float <var class="pdparam">b</var>, float <var class="pdparam">c</var>, float <var class="pdparam">d</var>, float <var class="pdparam">e</var>, float <var class="pdparam">f</var>, float <var class="pdparam">g</var>, float <var class="pdparam">h</var>, float <var class="pdparam">i</var>, float <var class="pdparam">xoff</var>, float <var class="pdparam">yoff</var>, float <var class="pdparam">zoff</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_Affine</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">a</var>, float <var class="pdparam">b</var>, float <var class="pdparam">d</var>, float <var class="pdparam">e</var>, >
float <var class="pdparam">xoff</var>, float <var class="pdparam">yoff</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36173551"></a><h2>Description</h2><p>Applies a 3d affine transformation to the geometry to do things like translate, rotate, scale in one step.</p><p>
Version 1: The
call </p><pre class="programlisting">ST_Affine(geom, a, b, c, d, e, f, g, h, i, xoff, yoff, zoff) </pre><p>
represents the transformation matrix </p><pre class="programlisting">/ a b c xoff \
| d e f yoff |
| g h i zoff |
\ 0 0 0 1 /</pre><p> and the vertices are transformed as
follows: </p><pre class="programlisting">x' = a*x + b*y + c*z + xoff
y' = d*x + e*y + f*z + yoff
z' = g*x + h*y + i*z + zoff</pre><p> All of the translate / scale
functions below are expressed via such an affine
transformation.</p><p>Version 2: Applies a 2d affine transformation to the geometry. The
call </p><pre class="programlisting">ST_Affine(geom, a, b, d, e, xoff, yoff)</pre><p>
represents the transformation matrix </p><pre class="programlisting">/ a b 0 xoff \ / a b xoff \
| d e 0 yoff | rsp. | d e yoff |
| 0 0 1 0 | \ 0 0 1 /
\ 0 0 0 1 /</pre><p> and the vertices are transformed as
follows: </p><pre class="programlisting">x' = a*x + b*y + xoff
y' = d*x + e*y + yoff
z' = z </pre><p> This method is a subcase of the 3D method
above.</p><p>Availability: 1.1.2. Name changed from Affine to ST_Affine in 1.2.2</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36173642"></a><h2>Examples</h2><pre class="programlisting">
--Rotate a 3d line 180 degrees about the z axis. Note this is long-hand for doing ST_RotateZ();
SELECT ST_AsEWKT(ST_Affine(the_geom, cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), 0, 0, 0, 1, 0, 0, 0)) As using_affine,
ST_AsEWKT(ST_RotateZ(the_geom, pi())) As using_rotatez
FROM (SELECT ST_GeomFromEWKT('LINESTRING(1 2 3, 1 4 3)') As the_geom) As foo;
using_affine | using_rotatez
-----------------------------+-----------------------------
LINESTRING(-1 -2 3,-1 -4 3) | LINESTRING(-1 -2 3,-1 -4 3)
(1 row)
--Rotate a 3d line 180 degrees in both the x and z axis
SELECT ST_AsEWKT(ST_Affine(the_geom, cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), 0, 0, 0))
FROM (SELECT ST_GeomFromEWKT('LINESTRING(1 2 3, 1 4 3)') As the_geom) As foo;
st_asewkt
-------------------------------
LINESTRING(-1 -2 -3,-1 -4 -3)
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36173664"></a><h2>See Also</h2><p><a class="xref" href="#ST_Rotate" title="ST_Rotate">ST_Rotate</a>, <a class="xref" href="#ST_Scale" title="ST_Scale">ST_Scale</a>, <a class="xref" href="#ST_Translate" title="ST_Translate">ST_Translate</a>, <a class="xref" href="#ST_TransScale" title="ST_TransScale">ST_TransScale</a></p></div></div><div class="refentry" title="ST_Force_2D"><div class="refentry.separator"><hr></div><a name="ST_Force_2D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Force_2D — Forces the geometries into a "2-dimensional mode" so that
all output representations will only have the X and Y coordinates.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Force_2D</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36173738"></a><h2>Description</h2><p>Forces the geometries into a "2-dimensional mode" so that
all output representations will only have the X and Y coordinates.
This is useful for force OGC-compliant output (since OGC only
specifies 2-D geometries).</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36173762"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsEWKT(ST_Force_2D(ST_GeomFromEWKT('CIRCULARSTRING(1 1 2, 2 3 2, 4 5 2, 6 7 2, 5 6 2)')));
st_asewkt
-------------------------------------
CIRCULARSTRING(1 1,2 3,4 5,6 7,5 6)
SELECT ST_AsEWKT(ST_Force_2D('POLYGON((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))'));
st_asewkt
----------------------------------------------
POLYGON((0 0,0 5,5 0,0 0),(1 1,3 1,1 3,1 1))
</pre></div><div class="refsection" title="See Also"><a name="id36173780"></a><h2>See Also</h2><p><a class="xref" href="#ST_Force_3D" title="ST_Force_3D">ST_Force_3D</a></p></div></div><div class="refentry" title="ST_Force_3D"><div class="refentry.separator"><hr></div><a name="ST_Force_3D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Force_3D — Forces the geometries into XYZ mode. This is an alias for ST_Force_3DZ.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Force_3D</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36173836"></a><h2>Description</h2><p>Forces the geometries into XYZ mode. This is an alias for ST_Force_3DZ. If a geometry has no Z component, then a 0 Z coordinate is tacked on.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36173872"></a><h2>Examples</h2><pre class="programlisting">
--Nothing happens to an already 3D geometry
SELECT ST_AsEWKT(ST_Force_3D(ST_GeomFromEWKT('CIRCULARSTRING(1 1 2, 2 3 2, 4 5 2, 6 7 2, 5 6 2)')));
st_asewkt
-----------------------------------------------
CIRCULARSTRING(1 1 2,2 3 2,4 5 2,6 7 2,5 6 2)
SELECT ST_AsEWKT(ST_Force_3D('POLYGON((0 0,0 5,5 0,0 0),(1 1,3 1,1 3,1 1))'));
st_asewkt
--------------------------------------------------------------
POLYGON((0 0 0,0 5 0,5 0 0,0 0 0),(1 1 0,3 1 0,1 3 0,1 1 0))
</pre></div><div class="refsection" title="See Also"><a name="id36173891"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_Force_2D" title="ST_Force_2D">ST_Force_2D</a>, <a class="xref" href="#ST_Force_3DM" title="ST_Force_3DM">ST_Force_3DM</a>, <a class="xref" href="#ST_Force_3DZ" title="ST_Force_3DZ">ST_Force_3DZ</a></p></div></div><div class="refentry" title="ST_Force_3DZ"><div class="refentry.separator"><hr></div><a name="ST_Force_3DZ"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Force_3DZ — Forces the geometries into XYZ mode. This is a synonym for ST_Force_3D.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Force_3DZ</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36173963"></a><h2>Description</h2><p>Forces the geometries into XYZ mode. This is a synonym for ST_Force_3DZ. If a geometry has no Z component, then a 0 Z coordinate is tacked on.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36173999"></a><h2>Examples</h2><pre class="programlisting">
--Nothing happens to an already 3D geometry
SELECT ST_AsEWKT(ST_Force_3DZ(ST_GeomFromEWKT('CIRCULARSTRING(1 1 2, 2 3 2, 4 5 2, 6 7 2, 5 6 2)')));
st_asewkt
-----------------------------------------------
CIRCULARSTRING(1 1 2,2 3 2,4 5 2,6 7 2,5 6 2)
SELECT ST_AsEWKT(ST_Force_3DZ('POLYGON((0 0,0 5,5 0,0 0),(1 1,3 1,1 3,1 1))'));
st_asewkt
--------------------------------------------------------------
POLYGON((0 0 0,0 5 0,5 0 0,0 0 0),(1 1 0,3 1 0,1 3 0,1 1 0))
</pre></div><div class="refsection" title="See Also"><a name="id36174018"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_Force_2D" title="ST_Force_2D">ST_Force_2D</a>, <a class="xref" href="#ST_Force_3DM" title="ST_Force_3DM">ST_Force_3DM</a>, <a class="xref" href="#ST_Force_3D" title="ST_Force_3D">ST_Force_3D</a></p></div></div><div class="refentry" title="ST_Force_3DM"><div class="refentry.separator"><hr></div><a name="ST_Force_3DM"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Force_3DM — Forces the geometries into XYM mode.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Force_3DM</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36174088"></a><h2>Description</h2><p>Forces the geometries into XYM mode. If a geometry has no M component, then a 0 M coordinate is tacked on. If it has a Z component, then Z is removed</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36174110"></a><h2>Examples</h2><pre class="programlisting">
--Nothing happens to an already 3D geometry
SELECT ST_AsEWKT(ST_Force_3DM(ST_GeomFromEWKT('CIRCULARSTRING(1 1 2, 2 3 2, 4 5 2, 6 7 2, 5 6 2)')));
st_asewkt
------------------------------------------------
CIRCULARSTRINGM(1 1 0,2 3 0,4 5 0,6 7 0,5 6 0)
SELECT ST_AsEWKT(ST_Force_3DM('POLYGON((0 0 1,0 5 1,5 0 1,0 0 1),(1 1 1,3 1 1,1 3 1,1 1 1))'));
st_asewkt
---------------------------------------------------------------
POLYGONM((0 0 0,0 5 0,5 0 0,0 0 0),(1 1 0,3 1 0,1 3 0,1 1 0))
</pre></div><div class="refsection" title="See Also"><a name="id36174129"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_Force_2D" title="ST_Force_2D">ST_Force_2D</a>, <a class="xref" href="#ST_Force_3DM" title="ST_Force_3DM">ST_Force_3DM</a>, <a class="xref" href="#ST_Force_3D" title="ST_Force_3D">ST_Force_3D</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a></p></div></div><div class="refentry" title="ST_Force_4D"><div class="refentry.separator"><hr></div><a name="ST_Force_4D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Force_4D — Forces the geometries into XYZM mode. </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Force_4D</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36174204"></a><h2>Description</h2><p>Forces the geometries into XYZM mode. 0 is tacked on for missing Z and M dimensions. </p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36174240"></a><h2>Examples</h2><pre class="programlisting">
--Nothing happens to an already 3D geometry
SELECT ST_AsEWKT(ST_Force_4D(ST_GeomFromEWKT('CIRCULARSTRING(1 1 2, 2 3 2, 4 5 2, 6 7 2, 5 6 2)')));
st_asewkt
---------------------------------------------------------
CIRCULARSTRING(1 1 2 0,2 3 2 0,4 5 2 0,6 7 2 0,5 6 2 0)
SELECT ST_AsEWKT(ST_Force_4D('MULTILINESTRINGM((0 0 1,0 5 2,5 0 3,0 0 4),(1 1 1,3 1 1,1 3 1,1 1 1))'));
st_asewkt
--------------------------------------------------------------------------------------
MULTILINESTRING((0 0 0 1,0 5 0 2,5 0 0 3,0 0 0 4),(1 1 0 1,3 1 0 1,1 3 0 1,1 1 0 1))
</pre></div><div class="refsection" title="See Also"><a name="id36174260"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_Force_2D" title="ST_Force_2D">ST_Force_2D</a>, <a class="xref" href="#ST_Force_3DM" title="ST_Force_3DM">ST_Force_3DM</a>, <a class="xref" href="#ST_Force_3D" title="ST_Force_3D">ST_Force_3D</a></p></div></div><div class="refentry" title="ST_Force_Collection"><div class="refentry.separator"><hr></div><a name="ST_Force_Collection"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Force_Collection — Converts the geometry into a GEOMETRYCOLLECTION.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Force_Collection</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36174331"></a><h2>Description</h2><p>Converts the geometry into a GEOMETRYCOLLECTION. This is
useful for simplifying the WKB representation.</p><p>Availability: 1.2.2, prior to 1.3.4 this function will crash with Curves. This is fixed in 1.3.4+</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36174371"></a><h2>Examples</h2><pre class="programlisting">
SELECT ST_AsEWKT(ST_Force_Collection('POLYGON((0 0 1,0 5 1,5 0 1,0 0 1),(1 1 1,3 1 1,1 3 1,1 1 1))'));
st_asewkt
----------------------------------------------------------------------------------
GEOMETRYCOLLECTION(POLYGON((0 0 1,0 5 1,5 0 1,0 0 1),(1 1 1,3 1 1,1 3 1,1 1 1)))
SELECT ST_AsText(ST_Force_Collection('CIRCULARSTRING(220227 150406,2220227 150407,220227 150406)'));
st_astext
--------------------------------------------------------------------------------
GEOMETRYCOLLECTION(CIRCULARSTRING(220227 150406,2220227 150407,220227 150406))
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36174386"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_Force_2D" title="ST_Force_2D">ST_Force_2D</a>, <a class="xref" href="#ST_Force_3DM" title="ST_Force_3DM">ST_Force_3DM</a>, <a class="xref" href="#ST_Force_3D" title="ST_Force_3D">ST_Force_3D</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a></p></div></div><div class="refentry" title="ST_ForceRHR"><div class="refentry.separator"><hr></div><a name="ST_ForceRHR"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_ForceRHR — Forces the orientation of the vertices in a polygon to follow the
Right-Hand-Rule.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean
<b class="fsfunc">ST_ForceRHR</b>(</code>geometry <var class="pdparam">g</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36174461"></a><h2>Description</h2><p>Forces the orientation of the vertices in a polygon to follow the
Right-Hand-Rule. In GIS terminology, this means that the area that is bounded by the
polygon is to the right of the boundary. In particular, the exterior ring is
orientated in a clockwise direction and the interior rings in a counter-clockwise
direction.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36174488"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsEWKT(
ST_ForceRHR(
'POLYGON((0 0 2, 5 0 2, 0 5 2, 0 0 2),(1 1 2, 1 3 2, 3 1 2, 1 1 2))'
)
);
st_asewkt
--------------------------------------------------------------
POLYGON((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36174502"></a><h2>See Also</h2><p><a class="xref" href="#ST_BuildArea" title="ST_BuildArea">ST_BuildArea</a>,
<a class="xref" href="#ST_Polygonize" title="ST_Polygonize">ST_Polygonize</a>,
<a class="xref" href="#ST_Reverse" title="ST_Reverse">ST_Reverse</a></p></div></div><div class="refentry" title="ST_LineMerge"><div class="refentry.separator"><hr></div><a name="ST_LineMerge"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_LineMerge — Returns a (set of) LineString(s) formed by sewing together
a MULTILINESTRING.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_LineMerge</b>(</code>geometry <var class="pdparam">amultilinestring</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36174570"></a><h2>Description</h2><p>Returns a (set of) LineString(s) formed by sewing together
the constituent line work of a MULTILINESTRING. </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Only use with MULTILINESTRING/LINESTRINGs. If you feed a polygon or geometry collection into this function, it
will return an empty GEOMETRYCOLLECTION</p></td></tr></table></div><p>Availability: 1.1.0</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>requires GEOS >= 2.1.0</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36174594"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsText(ST_LineMerge(
ST_GeomFromText('MULTILINESTRING((-29 -27,-30 -29.7,-36 -31,-45 -33),(-45 -33,-46 -32))')
)
);
st_astext
--------------------------------------------------------------------------------------------------
LINESTRING(-29 -27,-30 -29.7,-36 -31,-45 -33,-46 -32)
(1 row)
--If can't be merged - original MULTILINESTRING is returned
SELECT ST_AsText(ST_LineMerge(
ST_GeomFromText('MULTILINESTRING((-29 -27,-30 -29.7,-36 -31,-45 -33),(-45.2 -33.2,-46 -32))')
)
);
st_astext
----------------
MULTILINESTRING((-45.2 -33.2,-46 -32),(-29 -27,-30 -29.7,-36 -31,-45 -33))
</pre></div><div class="refsection" title="See Also"><a name="id36174611"></a><h2>See Also</h2><p><a class="xref" href="#ST_Segmentize" title="ST_Segmentize">ST_Segmentize</a>, <a class="xref" href="#ST_Line_Substring" title="ST_Line_Substring">ST_Line_Substring</a></p></div></div><div class="refentry" title="ST_CollectionExtract"><div class="refentry.separator"><hr></div><a name="ST_CollectionExtract"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_CollectionExtract — Given a GEOMETRYCOLLECTION, returns a MULTI* geometry consisting only of the specified type. Sub-geometries that are not
the specified type are ignored. If there are no sub-geometries of the right type, an EMPTY collection will be returned. Only
points, lines and polygons are supported. Type numbers are 1 == POINT, 2 == LINESTRING, 3 == POLYGON.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_CollectionExtract</b>(</code>geometry <var class="pdparam">collection</var>, integer <var class="pdparam">type</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36174686"></a><h2>Description</h2><p>Given a GEOMETRYCOLLECTION, returns a MULTI* geometry consisting only of the specified type. Sub-geometries that are not
the specified type are ignored. If there are no sub-geometries of the right type, an EMPTY collection will be returned. Only
points, lines and polygons are supported. Type numbers are 1 == POINT, 2 == LINESTRING, 3 == POLYGON.</p><p>Availability: 1.5.0</p></div><div class="refsection" title="Examples"><a name="id36174703"></a><h2>Examples</h2><pre class="programlisting">-- Constants: 1 == POINT, 2 == LINESTRING, 3 == POLYGON
SELECT ST_AsText(ST_CollectionExtract(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0)))'),1));
st_astext
---------------
MULTIPOINT(0 0)
(1 row)
SELECT ST_AsText(ST_CollectionExtract(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(0 0, 1 1)),LINESTRING(2 2, 3 3))'),2));
st_astext
---------------
MULTILINESTRING((0 0, 1 1), (2 2, 3 3))
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36174718"></a><h2>See Also</h2><p><a class="xref" href="#ST_Multi" title="ST_Multi">ST_Multi</a></p></div></div><div class="refentry" title="ST_Multi"><div class="refentry.separator"><hr></div><a name="ST_Multi"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Multi — Returns the geometry as a MULTI* geometry. If the geometry
is already a MULTI*, it is returned unchanged.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Multi</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36174774"></a><h2>Description</h2><p>Returns the geometry as a MULTI* geometry. If the geometry
is already a MULTI*, it is returned unchanged.</p></div><div class="refsection" title="Examples"><a name="id36174785"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsText(ST_Multi(ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,
743265 2967450,743265.625 2967416,743238 2967416))')));
st_astext
--------------------------------------------------------------------------------------------------
MULTIPOLYGON(((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,
743238 2967416)))
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36174800"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a></p></div></div><div class="refentry" title="ST_RemovePoint"><div class="refentry.separator"><hr></div><a name="ST_RemovePoint"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_RemovePoint — Removes point from a linestring. Offset is 0-based.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_RemovePoint</b>(</code>geometry <var class="pdparam">linestring</var>, integer <var class="pdparam">offset</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36174865"></a><h2>Description</h2><p>Removes point from a linestring. Useful for turning a closed ring into an open line string</p><p>Availability: 1.1.0</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36174893"></a><h2>Examples</h2><pre class="programlisting">
--guarantee no LINESTRINGS are closed
--by removing the end point. The below assumes the_geom is of type LINESTRING
UPDATE sometable
SET the_geom = ST_RemovePoint(the_geom, ST_NPoints(the_geom) - 1)
FROM sometable
WHERE ST_IsClosed(the_geom) = true;
</pre></div><div class="refsection" title="See Also"><a name="id36174907"></a><h2>See Also</h2><p><a class="xref" href="#ST_AddPoint" title="ST_AddPoint">ST_AddPoint</a>, <a class="xref" href="#ST_NPoints" title="ST_NPoints">ST_NPoints</a>, <a class="xref" href="#ST_NumPoints" title="ST_NumPoints">ST_NumPoints</a></p></div></div><div class="refentry" title="ST_Reverse"><div class="refentry.separator"><hr></div><a name="ST_Reverse"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Reverse — Returns the geometry with vertex order reversed.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Reverse</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36174972"></a><h2>Description</h2><p>Can be used on any geometry and reverses the order of the vertexes.</p></div><div class="refsection" title="Examples"><a name="id36174983"></a><h2>Examples</h2><pre class="programlisting">
SELECT ST_AsText(the_geom) as line, ST_AsText(ST_Reverse(the_geom)) As reverseline
FROM
(SELECT ST_MakeLine(ST_MakePoint(1,2),
ST_MakePoint(1,10)) As the_geom) as foo;
--result
line | reverseline
---------------------+----------------------
LINESTRING(1 2,1 10) | LINESTRING(1 10,1 2)
</pre></div></div><div class="refentry" title="ST_Rotate"><div class="refentry.separator"><hr></div><a name="ST_Rotate"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Rotate — This is a synonym for ST_RotateZ</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Rotate</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">rotZRadians</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36175050"></a><h2>Description</h2><p>This is a synonym for ST_RotateZ.. Rotates geometry rotZRadians about the Z-axis.</p><p>Availability: 1.1.2. Name changed from Rotate to ST_Rotate in 1.2.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36175090"></a><h2>Examples</h2><pre class="programlisting"></pre></div><div class="refsection" title="See Also"><a name="id36175103"></a><h2>See Also</h2><p><a class="xref" href="#ST_Affine" title="ST_Affine">ST_Affine</a>, <a class="xref" href="#ST_RotateX" title="ST_RotateX">ST_RotateX</a>, <a class="xref" href="#ST_RotateY" title="ST_RotateY">ST_RotateY</a>, <a class="xref" href="#ST_RotateZ" title="ST_RotateZ">ST_RotateZ</a></p></div></div><div class="refentry" title="ST_RotateX"><div class="refentry.separator"><hr></div><a name="ST_RotateX"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_RotateX — Rotate a geometry rotRadians about the X axis.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_RotateX</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">rotRadians</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36175186"></a><h2>Description</h2><p>Rotate a geometry geomA - rotRadians about the X axis.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p><code class="code">ST_RotateX(geomA, rotRadians)</code>
is short-hand for <code class="code">ST_Affine(geomA, 1, 0, 0, 0, cos(rotRadians), -sin(rotRadians), 0, sin(rotRadians), cos(rotRadians), 0, 0, 0)</code>.</p></td></tr></table></div><p>Availability: 1.1.2. Name changed from RotateX to ST_RotateX in 1.2.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36175226"></a><h2>Examples</h2><pre class="programlisting">
--Rotate a line 90 degrees along x-axis
SELECT ST_AsEWKT(ST_RotateX(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
st_asewkt
---------------------------
LINESTRING(1 -3 2,1 -1 1)
</pre></div><div class="refsection" title="See Also"><a name="id36175242"></a><h2>See Also</h2><p><a class="xref" href="#ST_Affine" title="ST_Affine">ST_Affine</a>, <a class="xref" href="#ST_RotateY" title="ST_RotateY">ST_RotateY</a>, <a class="xref" href="#ST_RotateZ" title="ST_RotateZ">ST_RotateZ</a></p></div></div><div class="refentry" title="ST_RotateY"><div class="refentry.separator"><hr></div><a name="ST_RotateY"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_RotateY — Rotate a geometry rotRadians about the Y axis.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_RotateY</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">rotRadians</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36175317"></a><h2>Description</h2><p>Rotate a geometry geomA - rotRadians about the y axis.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p><code class="code">ST_RotateY(geomA, rotRadians)</code>
is short-hand for <code class="code">ST_Affine(geomA, cos(rotRadians), 0, sin(rotRadians), 0, 1, 0, -sin(rotRadians), 0, cos(rotRadians), 0, 0, 0)</code>.</p></td></tr></table></div><p>Availability: 1.1.2. Name changed from RotateY to ST_RotateY in 1.2.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36175356"></a><h2>Examples</h2><pre class="programlisting">
--Rotate a line 90 degrees along y-axis
SELECT ST_AsEWKT(ST_RotateY(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
st_asewkt
---------------------------
LINESTRING(3 2 -1,1 1 -1)
</pre></div><div class="refsection" title="See Also"><a name="id36175373"></a><h2>See Also</h2><p><a class="xref" href="#ST_Affine" title="ST_Affine">ST_Affine</a>, <a class="xref" href="#ST_RotateX" title="ST_RotateX">ST_RotateX</a>, <a class="xref" href="#ST_RotateZ" title="ST_RotateZ">ST_RotateZ</a>, <a class="ulink" href="/support/wiki/index.php?plpgsqlfunctions" target="_top">Rotate around Point, Create Ellipse functions</a></p></div></div><div class="refentry" title="ST_RotateZ"><div class="refentry.separator"><hr></div><a name="ST_RotateZ"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_RotateZ — Rotate a geometry rotRadians about the Z axis.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_RotateZ</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">rotRadians</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36175453"></a><h2>Description</h2><p>Rotate a geometry geomA - rotRadians about the Z axis.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p><code class="code">ST_RotateZ(geomA, rotRadians)</code>
is short-hand for <code class="code">SELECT ST_Affine(geomA, cos(rotRadians), -sin(rotRadians), 0, sin(rotRadians), cos(rotRadians), 0, 0, 0, 1, 0, 0, 0)</code>.</p></td></tr></table></div><p>Availability: 1.1.2. Name changed from RotateZ to ST_RotateZ in 1.2.2</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36175509"></a><h2>Examples</h2><pre class="programlisting">
--Rotate a line 90 degrees along z-axis
SELECT ST_AsEWKT(ST_RotateZ(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
st_asewkt
---------------------------
LINESTRING(-2 1 3,-1 1 1)
--Rotate a curved circle around z-axis
SELECT ST_AsEWKT(ST_RotateZ(the_geom, pi()/2))
FROM (SELECT ST_LineToCurve(ST_Buffer(ST_GeomFromText('POINT(234 567)'), 3)) As the_geom) As foo;
st_asewkt
----------------------------------------------------------------------------------------------------------------------------
CURVEPOLYGON(CIRCULARSTRING(-567 237,-564.87867965644 236.12132034356,-564 234,-569.12132034356 231.87867965644,-567 237))
</pre></div><div class="refsection" title="See Also"><a name="id36175529"></a><h2>See Also</h2><p><a class="xref" href="#ST_Affine" title="ST_Affine">ST_Affine</a>, <a class="xref" href="#ST_RotateX" title="ST_RotateX">ST_RotateX</a>, <a class="xref" href="#ST_RotateY" title="ST_RotateY">ST_RotateY</a>, <a class="ulink" href="/support/wiki/index.php?plpgsqlfunctions" target="_top">Rotate around Point, Create Ellipse functions</a></p></div></div><div class="refentry" title="ST_Scale"><div class="refentry.separator"><hr></div><a name="ST_Scale"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Scale — Scales the geometry to a new size by multiplying the
ordinates with the parameters. Ie: ST_Scale(geom, Xfactor, Yfactor,
Zfactor).
</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Scale</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">XFactor</var>, float <var class="pdparam">YFactor</var>, float <var class="pdparam">ZFactor</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_Scale</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">XFactor</var>, float <var class="pdparam">YFactor</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36175670"></a><h2>Description</h2><p>Scales the geometry to a new size by multiplying the
ordinates with the parameters. Ie: ST_Scale(geom, Xfactor, Yfactor,
Zfactor).</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p><code class="code">ST_Scale(geomA, XFactor, YFactor, ZFactor)</code>
is short-hand for <code class="code">ST_Affine(geomA, XFactor, 0, 0, 0, YFactor, 0, 0, 0, ZFactor, 0, 0, 0)</code>.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</p></td></tr></table></div><p>Availability: 1.1.0.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36175726"></a><h2>Examples</h2><pre class="programlisting">--Version 1: scale X, Y, Z
SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 0.75, 0.8));
st_asewkt
--------------------------------------
LINESTRING(0.5 1.5 2.4,0.5 0.75 0.8)
--Version 2: Scale X Y
SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 0.75));
st_asewkt
----------------------------------
LINESTRING(0.5 1.5 3,0.5 0.75 1)
</pre></div><div class="refsection" title="See Also"><a name="id36175880"></a><h2>See Also</h2><p><a class="xref" href="#ST_Affine" title="ST_Affine">ST_Affine</a>, <a class="xref" href="#ST_TransScale" title="ST_TransScale">ST_TransScale</a></p></div></div><div class="refentry" title="ST_Segmentize"><div class="refentry.separator"><hr></div><a name="ST_Segmentize"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Segmentize — Return a modified geometry having no segment longer than the
given distance. Distance computation is performed in 2d
only.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Segmentize</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">max_length</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36175950"></a><h2>Description</h2><p>Returns a modified geometry having no segment longer than the
given distance. Distance computation is performed in 2d
only. </p><p>Availability: 1.2.2</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This will only increase segments. It will not lengthen segments shorter than
max length</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36175970"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsText(ST_Segmentize(
ST_GeomFromText('MULTILINESTRING((-29 -27,-30 -29.7,-36 -31,-45 -33),(-45 -33,-46 -32))')
,5)
);
st_astext
--------------------------------------------------------------------------------------------------
MULTILINESTRING((-29 -27,-30 -29.7,-34.886615700134 -30.758766735029,-36 -31,
-40.8809353009198 -32.0846522890933,-45 -33),
(-45 -33,-46 -32))
(1 row)
SELECT ST_AsText(ST_Segmentize(ST_GeomFromText('POLYGON((-29 28, -30 40, -29 28))'),10));
st_astext
-----------------------
POLYGON((-29 28,-29.8304547985374 37.9654575824488,-30 40,-29.1695452014626 30.0345424175512,-29 28))
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36175987"></a><h2>See Also</h2><p><a class="xref" href="#ST_Line_Substring" title="ST_Line_Substring">ST_Line_Substring</a></p></div></div><div class="refentry" title="ST_SetPoint"><div class="refentry.separator"><hr></div><a name="ST_SetPoint"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_SetPoint — Replace point N of linestring with given point. Index is
0-based.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_SetPoint</b>(</code>geometry <var class="pdparam">linestring</var>, integer <var class="pdparam">zerobasedposition</var>, geometry <var class="pdparam">point</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36176062"></a><h2>Description</h2><p>Replace point N of linestring with given point. Index is
0-based.
This is especially useful in triggers when trying to maintain relationship of joints when one vertex moves.</p><p>Availability: 1.1.0</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36176091"></a><h2>Examples</h2><pre class="programlisting">
--Change first point in line string from -1 3 to -1 1
SELECT ST_AsText(ST_SetPoint('LINESTRING(-1 2,-1 3)', 0, 'POINT(-1 1)'));
st_astext
-----------------------
LINESTRING(-1 1,-1 3)
---Change last point in a line string (lets play with 3d linestring this time)
SELECT ST_AsEWKT(ST_SetPoint(foo.the_geom, ST_NumPoints(foo.the_geom) - 1, ST_GeomFromEWKT('POINT(-1 1 3)')))
FROM (SELECT ST_GeomFromEWKT('LINESTRING(-1 2 3,-1 3 4, 5 6 7)') As the_geom) As foo;
st_asewkt
-----------------------
LINESTRING(-1 2 3,-1 3 4,-1 1 3)
</pre></div><div class="refsection" title="See Also"><a name="id36176107"></a><h2>See Also</h2><p><a class="xref" href="#ST_AddPoint" title="ST_AddPoint">ST_AddPoint</a>,<a class="xref" href="#ST_NPoints" title="ST_NPoints">ST_NPoints</a>, <a class="xref" href="#ST_NumPoints" title="ST_NumPoints">ST_NumPoints</a>, <a class="xref" href="#ST_PointN" title="ST_PointN">ST_PointN</a>, <a class="xref" href="#ST_RemovePoint" title="ST_RemovePoint">ST_RemovePoint</a></p></div></div><div class="refentry" title="ST_SetSRID"><div class="refentry.separator"><hr></div><a name="ST_SetSRID"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_SetSRID — Sets the SRID on a geometry to a particular integer
value.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_SetSRID</b>(</code>geometry
<var class="pdparam">geom</var>, integer
<var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36176192"></a><h2>Description</h2><p>Sets the SRID on a geometry to a particular integer value.
Useful in constructing bounding boxes for queries.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function does not transform the geometry coordinates in any way -
it simply sets the meta data defining the spatial reference system the geometry is assumed to be in.
Use <a class="xref" href="#ST_Transform" title="ST_Transform">ST_Transform</a> if you want to transform the
geometry into a new projection.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36176244"></a><h2>Examples</h2><p>-- Mark a point as WGS 84 long lat --</p><pre class="programlisting">SELECT ST_SetSRID(ST_Point(-123.365556, 48.428611),4326) As wgs84long_lat;
-- the ewkt representation (wrap with ST_AsEWKT) -
SRID=4326;POINT(-123.365556 48.428611)
</pre><p>-- Mark a point as WGS 84 long lat and then transform to web mercator (Spherical Mercator) --</p><pre class="programlisting">SELECT ST_Transform(ST_SetSRID(ST_Point(-123.365556, 48.428611),4326),3785) As spere_merc;
-- the ewkt representation (wrap with ST_AsEWKT) -
SRID=3785;POINT(-13732990.8753491 6178458.96425423)
</pre></div><div class="refsection" title="See Also"><a name="id36176272"></a><h2>See Also</h2><p><a class="xref" href="#spatial_ref_sys" title="4.3.1.The SPATIAL_REF_SYS Table and Spatial Reference Systems">Section4.3.1, “The SPATIAL_REF_SYS Table and Spatial Reference Systems”</a>, <a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_Point" title="ST_Point">ST_Point</a>, <a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a>,<a class="xref" href="#ST_Transform" title="ST_Transform">ST_Transform</a>, <a class="xref" href="#UpdateGeometrySRID" title="UpdateGeometrySRID">UpdateGeometrySRID</a></p></div></div><div class="refentry" title="ST_SnapToGrid"><div class="refentry.separator"><hr></div><a name="ST_SnapToGrid"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_SnapToGrid — Snap all points of the input geometry to the grid defined by
its origin and cell size. Remove consecutive points falling on the
same cell, eventually returning NULL if output points are not
enough to define a geometry of the given type. Collapsed
geometries in a collection are stripped from it. Useful for reducing precision.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_SnapToGrid</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">originX</var>, float <var class="pdparam">originY</var>, float <var class="pdparam">sizeX</var>, float <var class="pdparam">sizeY</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_SnapToGrid</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">sizeX</var>, float <var class="pdparam">sizeY</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_SnapToGrid</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">size</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_SnapToGrid</b>(</code>geometry <var class="pdparam">geomA</var>, geometry <var class="pdparam">pointOrigin</var>, float <var class="pdparam">sizeX</var>, float <var class="pdparam">sizeY</var>, float <var class="pdparam">sizeZ</var>, float <var class="pdparam">sizeM</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36176534"></a><h2>Description</h2><p>Variant 1,2,3: Snap all points of the input geometry to the grid defined by
its origin and cell size. Remove consecutive points falling on the
same cell, eventually returning NULL if output points are not
enough to define a geometry of the given type. Collapsed
geometries in a collection are stripped from it.
</p><p>Variant 4: Introduced 1.1.0 - Snap all points of the input geometry to the grid defined by
its origin (the second argument, must be a point) and cell sizes.
Specify 0 as size for any dimension you don't want to snap to a
grid.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>The returned geometry might loose its simplicity (see
<a class="xref" href="#ST_IsSimple" title="ST_IsSimple">ST_IsSimple</a>).</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Before release 1.1.0 this function always returned a 2d
geometry. Starting at 1.1.0 the returned geometry will have same
dimensionality as the input one with higher dimension values
untouched. Use the version taking a second geometry argument to
define all grid dimensions.</p></td></tr></table></div><p>Availability: 1.0.0RC1</p><p>Availability: 1.1.0 - Z and M support</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36176594"></a><h2>Examples</h2><pre class="programlisting">
--Snap your geometries to a precision grid of 10^-3
UPDATE mytable
SET the_geom = ST_SnapToGrid(the_geom, 0.001);
SELECT ST_AsText(ST_SnapToGrid(
ST_GeomFromText('LINESTRING(1.1115678 2.123, 4.111111 3.2374897, 4.11112 3.23748667)'),
0.001)
);
st_astext
-------------------------------------
LINESTRING(1.112 2.123,4.111 3.237)
--Snap a 4d geometry
SELECT ST_AsEWKT(ST_SnapToGrid(
ST_GeomFromEWKT('LINESTRING(-1.1115678 2.123 2.3456 1.11111,
4.111111 3.2374897 3.1234 1.1111, -1.11111112 2.123 2.3456 1.1111112)'),
ST_GeomFromEWKT('POINT(1.12 2.22 3.2 4.4444)'),
0.1, 0.1, 0.1, 0.01) );
st_asewkt
------------------------------------------------------------------------------
LINESTRING(-1.08 2.12 2.3 1.1144,4.12 3.22 3.1 1.1144,-1.08 2.12 2.3 1.1144)
--With a 4d geometry - the ST_SnapToGrid(geom,size) only touches x and y coords but keeps m and z the same
SELECT ST_AsEWKT(ST_SnapToGrid(ST_GeomFromEWKT('LINESTRING(-1.1115678 2.123 3 2.3456,
4.111111 3.2374897 3.1234 1.1111)'),
0.01) );
st_asewkt
---------------------------------------------------------
LINESTRING(-1.11 2.12 3 2.3456,4.11 3.24 3.1234 1.1111)
</pre></div><div class="refsection" title="See Also"><a name="id36176609"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a>, <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_Simplify" title="ST_Simplify">ST_Simplify</a></p></div></div><div class="refentry" title="ST_Transform"><div class="refentry.separator"><hr></div><a name="ST_Transform"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Transform — Returns a new geometry with its coordinates transformed to
the SRID referenced by the integer parameter.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Transform</b>(</code>geometry <var class="pdparam">g1</var>, integer <var class="pdparam">srid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36176695"></a><h2>Description</h2><p>Returns a new geometry with its coordinates transformed to
spatial reference system referenced by the SRID integer parameter. The destination SRID
must exist in the <code class="varname">SPATIAL_REF_SYS</code> table.</p><p>ST_Transform is often confused with ST_SetSRID(). ST_Transform actually changes the coordinates
of a geometry from one spatial reference system to another, while ST_SetSRID() simply changes the SRID identifier of
the geometry</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Requires PostGIS be compiled with Proj support. Use <a class="xref" href="#PostGIS_Full_Version" title="PostGIS_Full_Version">PostGIS_Full_Version</a> to confirm you have proj support compiled in.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If using more than one transformation, it is useful to have a functional index on the commonly used
transformations to take advantage of index usage.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.6</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36176783"></a><h2>Examples</h2><p>Change Mass state plane US feet geometry to WGS 84 long lat</p><pre class="programlisting">
SELECT ST_AsText(ST_Transform(ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,
743265 2967450,743265.625 2967416,743238 2967416))',2249),4326)) As wgs_geom;
wgs_geom
---------------------------
POLYGON((-71.1776848522251 42.3902896512902,-71.1776843766326 42.3903829478009,
-71.1775844305465 42.3903826677917,-71.1775825927231 42.3902893647987,-71.177684
8522251 42.3902896512902));
(1 row)
--3D Circular String example
SELECT ST_AsEWKT(ST_Transform(ST_GeomFromEWKT('SRID=2249;CIRCULARSTRING(743238 2967416 1,743238 2967450 2,743265 2967450 3,743265.625 2967416 3,743238 2967416 4)'),4326));
st_asewkt
--------------------------------------------------------------------------------------
SRID=4326;CIRCULARSTRING(-71.1776848522251 42.3902896512902 1,-71.1776843766326 42.3903829478009 2,
-71.1775844305465 42.3903826677917 3,
-71.1775825927231 42.3902893647987 3,-71.1776848522251 42.3902896512902 4)
</pre><p>Example of creating a partial functional index. For tables where you are not sure all the geometries
will be filled in, its best to use a partial index that leaves out null geometries which will both conserve space and make your index smaller and more efficient.</p><pre class="programlisting">
CREATE INDEX idx_the_geom_26986_parcels
ON parcels
USING gist
(ST_Transform(the_geom, 26986))
WHERE the_geom IS NOT NULL;
</pre></div><div class="refsection" title="Configuring transformation behaviour"><a name="id36176818"></a><h2>Configuring transformation behaviour</h2><p>Sometimes coordinate transformation involving a grid-shift can fail, for example if PROJ.4 has not been built with grid-shift files or the coordinate does not lie within the range for which the grid shift is defined. By default, PostGIS will throw an error if a grid shift file is not present, but this behaviour can be configured on a per-SRID basis by altering the proj4text value within the spatial_ref_sys table.</p><p>For example, the proj4text parameter +datum=NAD87 is a shorthand form for the following +nadgrids parameter:</p><pre class="programlisting">+nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat</pre><p>The @ prefix means no error is reported if the files are not present, but if the end of the list is reached with no file having been appropriate (ie. found and overlapping) then an error is issued.</p><p>If, conversely, you wanted to ensure that at least the standard files were present, but that if all files were scanned without a hit a null transformation is applied you could use:</p><pre class="programlisting">+nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat,null</pre><p>The null grid shift file is a valid grid shift file covering the whole world and applying no shift. So for a complete example, if you wanted to alter PostGIS so that transformations to SRID 4267 that didn't lie within the correct range did not throw an ERROR, you would use the following:</p><pre class="programlisting">UPDATE spatial_ref_sys SET proj4text = '+proj=longlat +ellps=clrk66 +nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat,null +no_defs' WHERE srid = 4267;</pre></div><div class="refsection" title="See Also"><a name="id36176872"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_Full_Version" title="PostGIS_Full_Version">PostGIS_Full_Version</a>, <a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a>, <a class="xref" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a>, <a class="xref" href="#UpdateGeometrySRID" title="UpdateGeometrySRID">UpdateGeometrySRID</a></p></div></div><div class="refentry" title="ST_Translate"><div class="refentry.separator"><hr></div><a name="ST_Translate"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Translate — Translates the geometry to a new location using the numeric
parameters as offsets. Ie: ST_Translate(geom, X, Y) or ST_Translate(geom, X, Y,Z).</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Translate</b>(</code>geometry <var class="pdparam">g1</var>, float <var class="pdparam">deltax</var>, float <var class="pdparam">deltay</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_Translate</b>(</code>geometry <var class="pdparam">g1</var>, float <var class="pdparam">deltax</var>, float <var class="pdparam">deltay</var>, float <var class="pdparam">deltaz</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36177012"></a><h2>Description</h2><p>Returns a new geometry whose coordinates are translated delta x,delta y,delta z units. Units are
based on the units defined in spatial reference (SRID) for this geometry.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</p></td></tr></table></div><p>Availability: 1.2.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36177058"></a><h2>Examples</h2><p>Move a point 1 degree longitude</p><pre class="programlisting">
SELECT ST_AsText(ST_Translate(ST_GeomFromText('POINT(-71.01 42.37)',4326),1,0)) As wgs_transgeomtxt;
wgs_transgeomtxt
---------------------
POINT(-70.01 42.37)
</pre><p>Move a linestring 1 degree longitude and 1/2 degree latitude</p><pre class="programlisting">SELECT ST_AsText(ST_Translate(ST_GeomFromText('LINESTRING(-71.01 42.37,-71.11 42.38)',4326),1,0.5)) As wgs_transgeomtxt;
wgs_transgeomtxt
---------------------------------------
LINESTRING(-70.01 42.87,-70.11 42.88)
</pre><p>Move a 3d point</p><pre class="programlisting">SELECT ST_AsEWKT(ST_Translate(CAST('POINT(0 0 0)' As geometry), 5, 12,3));
st_asewkt
---------
POINT(5 12 3)
</pre><p>Move a curve and a point</p><pre class="programlisting">SELECT ST_AsText(ST_Translate(ST_Collect('CURVEPOLYGON(CIRCULARSTRING(4 3,3.12 0.878,1 0,-1.121 5.1213,6 7, 8 9,4 3))','POINT(1 3)'),1,2));
st_astext
------------------------------------------------------------------------------------------------------------
GEOMETRYCOLLECTION(CURVEPOLYGON(CIRCULARSTRING(5 5,4.12 2.878,2 2,-0.121 7.1213,7 9,9 11,5 5)),POINT(2 5))
</pre></div><div class="refsection" title="See Also"><a name="id36177110"></a><h2>See Also</h2><p><a class="xref" href="#ST_Affine" title="ST_Affine">ST_Affine</a>, <a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a>, <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a></p></div></div><div class="refentry" title="ST_TransScale"><div class="refentry.separator"><hr></div><a name="ST_TransScale"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_TransScale — Translates the geometry using the deltaX and deltaY args,
then scales it using the XFactor, YFactor args, working in 2D only.
</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_TransScale</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">deltaX</var>, float <var class="pdparam">deltaY</var>, float <var class="pdparam">XFactor</var>, float <var class="pdparam">YFactor</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36177215"></a><h2>Description</h2><p>Translates the geometry using the deltaX and deltaY args,
then scales it using the XFactor, YFactor args, working in 2D only.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p><code class="code">ST_TransScale(geomA, deltaX, deltaY, XFactor, YFactor)</code>
is short-hand for <code class="code">ST_Affine(geomA, XFactor, 0, 0, 0, YFactor, 0,
0, 0, 1, deltaX*XFactor, deltaY*YFactor, 0)</code>.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</p></td></tr></table></div><p>Availability: 1.1.0.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36177271"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsEWKT(ST_TransScale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 1, 1, 2));
st_asewkt
-----------------------------
LINESTRING(1.5 6 3,1.5 4 1)
--Buffer a point to get an approximation of a circle, convert to curve and then translate 1,2 and scale it 3,4
SELECT ST_AsText(ST_Transscale(ST_LineToCurve(ST_Buffer('POINT(234 567)', 3)),1,2,3,4));
st_astext
------------------------------------------------------------------------------------------------------------------------------
CURVEPOLYGON(CIRCULARSTRING(714 2276,711.363961030679 2267.51471862576,705 2264,698.636038969321 2284.48528137424,714 2276))
</pre></div><div class="refsection" title="See Also"><a name="id36177291"></a><h2>See Also</h2><p><a class="xref" href="#ST_Affine" title="ST_Affine">ST_Affine</a>, <a class="xref" href="#ST_Translate" title="ST_Translate">ST_Translate</a></p></div></div></div><div class="sect1" title="7.6.Geometry Outputs"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Geometry_Outputs"></a>7.6.Geometry Outputs</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#ST_AsBinary">ST_AsBinary</a></span><span class="refpurpose"> — Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.</span></dt><dt><span class="refentrytitle"><a href="#ST_AsEWKB">ST_AsEWKB</a></span><span class="refpurpose"> — Return the Well-Known Binary (WKB) representation of the geometry with SRID meta data.</span></dt><dt><span class="refentrytitle"><a href="#ST_AsEWKT">ST_AsEWKT</a></span><span class="refpurpose"> — Return the Well-Known Text (WKT) representation of the geometry with SRID meta data.</span></dt><dt><span class="refentrytitle"><a href="#ST_AsGeoJSON">ST_AsGeoJSON</a></span><span class="refpurpose"> — Return the geometry as a GeoJSON element.</span></dt><dt><span class="refentrytitle"><a href="#ST_AsGML">ST_AsGML</a></span><span class="refpurpose"> — Return the geometry as a GML version 2 or 3 element.</span></dt><dt><span class="refentrytitle"><a href="#ST_AsHEXEWKB">ST_AsHEXEWKB</a></span><span class="refpurpose"> — Returns a Geometry in HEXEWKB format (as text) using either
little-endian (NDR) or big-endian (XDR) encoding.</span></dt><dt><span class="refentrytitle"><a href="#ST_AsKML">ST_AsKML</a></span><span class="refpurpose"> — Return the geometry as a KML element. Several variants. Default version=2, default precision=15</span></dt><dt><span class="refentrytitle"><a href="#ST_AsSVG">ST_AsSVG</a></span><span class="refpurpose"> — Returns a Geometry in SVG path data given a geometry or geography object.</span></dt><dt><span class="refentrytitle"><a href="#ST_GeoHash">ST_GeoHash</a></span><span class="refpurpose"> — Return a GeoHash representation (geohash.org) of the geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_AsText">ST_AsText</a></span><span class="refpurpose"> — Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.</span></dt></dl></div><div class="refentry" title="ST_AsBinary"><a name="ST_AsBinary"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_AsBinary — Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">bytea <b class="fsfunc">ST_AsBinary</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">bytea <b class="fsfunc">ST_AsBinary</b>(</code>geography <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">bytea <b class="fsfunc">ST_AsBinary</b>(</code>geometry <var class="pdparam">g1</var>, text <var class="pdparam">NDR_or_XDR</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36181480"></a><h2>Description</h2><p>Returns the Well-Known Binary representation of the geometry. There are 2 variants of the function. The first
variant takes no endian encoding paramater and defaults to little endian. The second variant takes a second argument
denoting the encoding - using little-endian ('NDR') or big-endian ('XDR') encoding.</p><p>This is useful in binary cursors to pull data out of the
database without converting it to a string representation.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>The WKB spec does not include the SRID. To get the OGC WKB with SRID format use ST_AsEWKB</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>ST_AsBinary is the reverse of <a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a> for geometry. Use <a class="xref" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a> to convert to a postgis geometry from ST_AsBinary representation.</p></td></tr></table></div><p>Availability: 1.5.0 geography support was introduced.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.37</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36181569"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsBinary(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
st_asbinary
--------------------------------
\001\003\000\000\000\001\000\000\000\005
\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000
\000\000\000\360?\000\000\000\000\000\000
\360?\000\000\000\000\000\000\360?\000\000
\000\000\000\000\360?\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000
(1 row)</pre><pre class="programlisting">SELECT ST_AsBinary(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326), 'XDR');
st_asbinary
--------------------------------
\000\000\000\000\003\000\000\000\001\000\000\000\005\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
\000?\360\000\000\000\000\000\000?\360\000\000\000\000\000\000?\360\000\000
\000\000\000\000?\360\000\000\000\000\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36181598"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKB" title="ST_AsEWKB">ST_AsEWKB</a>, <a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a>, <a class="xref" href="#ST_GeomFromEWKB" title="ST_GeomFromEWKB">ST_GeomFromEWKB</a></p></div></div><div class="refentry" title="ST_AsEWKB"><div class="refentry.separator"><hr></div><a name="ST_AsEWKB"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_AsEWKB — Return the Well-Known Binary (WKB) representation of the geometry with SRID meta data.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">bytea <b class="fsfunc">ST_AsEWKB</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">bytea <b class="fsfunc">ST_AsEWKB</b>(</code>geometry <var class="pdparam">g1</var>, text <var class="pdparam">NDR_or_XDR</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36181697"></a><h2>Description</h2><p>Returns the Well-Known Binary representation of the geometry with SRID metadata. There are 2 variants of the function. The first
variant takes no endian encoding paramater and defaults to little endian. The second variant takes a second argument
denoting the encoding - using little-endian ('NDR') or big-endian ('XDR') encoding.</p><p>This is useful in binary cursors to pull data out of the
database without converting it to a string representation.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>The WKB spec does not include the SRID. To get the OGC WKB format use ST_AsBinary</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>ST_AsEWKB is the reverse of ST_GeomFromEWKB. Use ST_GeomFromEWKB to convert to a postgis geometry from ST_AsEWKB representation.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36181754"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
st_asewkb
--------------------------------
\001\003\000\000 \346\020\000\000\001\000
\000\000\005\000\000\000\000
\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000
\000\000\360?\000\000\000\000\000\000\360?
\000\000\000\000\000\000\360?\000\000\000\000\000
\000\360?\000\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000\000\000\000
(1 row)</pre><pre class="programlisting">
SELECT ST_AsEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326), 'XDR');
st_asewkb
--------------------------------
\000 \000\000\003\000\000\020\346\000\000\000\001\000\000\000\005\000\000\000\000\
000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000?
\360\000\000\000\000\000\000?\360\000\000\000\000\000\000?\360\000\000\000\000
\000\000?\360\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000\000\000\000
</pre></div><div class="refsection" title="See Also"><a name="id36181783"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsBinary" title="ST_AsBinary">ST_AsBinary</a>, <a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a></p></div></div><div class="refentry" title="ST_AsEWKT"><div class="refentry.separator"><hr></div><a name="ST_AsEWKT"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_AsEWKT — Return the Well-Known Text (WKT) representation of the geometry with SRID meta data.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">ST_AsEWKT</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36181858"></a><h2>Description</h2><p>Returns the Well-Known Text representation of the geometry prefixed with the SRID.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>The WKT spec does not include the SRID. To get the OGC WKT format use ST_AsText</p></td></tr></table></div><p><img src="images/warning.png">
WKT format does not maintain precision so to prevent floating truncation, use ST_AsBinary or ST_AsEWKB format for transport.
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>ST_AsEWKT is the reverse of <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>. Use <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a> to convert to a postgis geometry from ST_AsEWKT representation.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36181926"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsEWKT('0103000020E61000000100000005000000000000
000000000000000000000000000000000000000000000000000000
F03F000000000000F03F000000000000F03F000000000000F03
F000000000000000000000000000000000000000000000000'::geometry);
st_asewkt
--------------------------------
SRID=4326;POLYGON((0 0,0 1,1 1,1 0,0 0))
(1 row)
SELECT ST_AsEWKT('0108000080030000000000000060E30A4100000000785C0241000000000000F03F0000000018
E20A4100000000485F024100000000000000400000000018
E20A4100000000305C02410000000000000840')
--st_asewkt---
CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)
</pre></div><div class="refsection" title="See Also"><a name="id36181946"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsBinary" title="ST_AsBinary">ST_AsBinary</a><a class="xref" href="#ST_AsEWKB" title="ST_AsEWKB">ST_AsEWKB</a><a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a></p></div></div><div class="refentry" title="ST_AsGeoJSON"><div class="refentry.separator"><hr></div><a name="ST_AsGeoJSON"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_AsGeoJSON — Return the geometry as a GeoJSON element.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>geography <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>geometry <var class="pdparam">g1</var>, integer <var class="pdparam">max_decimal_digits</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>geography <var class="pdparam">g1</var>, integer <var class="pdparam">max_decimal_digits</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>geometry <var class="pdparam">g1</var>, integer <var class="pdparam">max_decimal_digits</var>, integer <var class="pdparam">options</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>geography <var class="pdparam">g1</var>, integer <var class="pdparam">max_decimal_digits</var>, integer <var class="pdparam">options</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>integer <var class="pdparam">gj_version</var>, geometry <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>integer <var class="pdparam">gj_version</var>, geography <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>integer <var class="pdparam">gj_version</var>, geometry <var class="pdparam">g1</var>, integer <var class="pdparam">max_decimal_digits</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>integer <var class="pdparam">gj_version</var>, geography <var class="pdparam">g1</var>, integer <var class="pdparam">max_decimal_digits</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>integer <var class="pdparam">gj_version</var>, geometry <var class="pdparam">g1</var>, integer <var class="pdparam">max_decimal_digits</var>, integer <var class="pdparam">options</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGeoJSON</b>(</code>integer <var class="pdparam">gj_version</var>, geography <var class="pdparam">g1</var>, integer <var class="pdparam">max_decimal_digits</var>, integer <var class="pdparam">options</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36182415"></a><h2>Description</h2><p>Return the geometry as a Geometry Javascript Object Notation (GeoJSON) element. (Cf <a class="ulink" href="http://geojson.org/geojson-spec.html" target="_top">GeoJSON
specifications 1.0</a>). 2D and 3D Geometries are both
supported. GeoJSON only support SFS 1.1 geometry type (no curve
support for example).</p><p>The gj_version parameter is the major version of the GeoJSON spec. If specified, must be 1.</p><p>The third argument may be used to reduce the maximum number
of decimal places used in output (defaults to 15).</p><p>The last 'options' argument could be used to add Bbox or Crs
in GeoJSON output:
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>0: means no option (default value)</p></li><li class="listitem"><p>1: GeoJSON Bbox</p></li><li class="listitem"><p>2: GeoJSON Short CRS (e.g EPSG:4326)</p></li><li class="listitem"><p>4: GeoJSON Long CRS (e.g urn:ogc:def:crs:EPSG::4326)</p></li></ul></div><p>
</p><p>Version 1: ST_AsGeoJSON(geom) / precision=15 version=1 options=0</p><p>Version 2: ST_AsGeoJSON(geom, precision) / version=1 options=0</p><p>Version 3: ST_AsGeoJSON(geom, precision, options) / version=1</p><p>Version 4: ST_AsGeoJSON(version, geom) / precision=15 options=0</p><p>Version 5: ST_AsGeoJSON(version, geom, precision) /options=0</p><p>Version 6: ST_AsGeoJSON(version, geom, precision,options)</p><p>Availability: 1.3.4</p><p>Availability: 1.5.0 geography support was introduced.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36182518"></a><h2>Examples</h2><p>GeoJSON format is generally more efficient than other formats for use in ajax mapping.
One popular javascript client that supports this is Open Layers.
Example of its use is <a class="ulink" href="http://openlayers.org/dev/examples/vector-formats.html" target="_top">OpenLayers GeoJSON Example</a>
</p><pre class="programlisting">SELECT ST_AsGeoJSON(the_geom) from fe_edges limit 1;
st_asgeojson
-----------------------------------------------------------------------------------------------------------
{"type":"MultiLineString","coordinates":[[[-89.734634999999997,31.492072000000000],
[-89.734955999999997,31.492237999999997]]]}
(1 row)
--3d point
SELECT ST_AsGeoJSON('LINESTRING(1 2 3, 4 5 6)');
st_asgeojson
-----------------------------------------------------------------------------------------
{"type":"LineString","coordinates":[[1,2,3],[4,5,6]]}
</pre></div></div><div class="refentry" title="ST_AsGML"><div class="refentry.separator"><hr></div><a name="ST_AsGML"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_AsGML — Return the geometry as a GML version 2 or 3 element.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">ST_AsGML</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGML</b>(</code>geography <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGML</b>(</code>geometry <var class="pdparam">g1</var>, integer <var class="pdparam">precision</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGML</b>(</code>geography <var class="pdparam">g1</var>, integer <var class="pdparam">precision</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGML</b>(</code>integer <var class="pdparam">version</var>, geometry <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGML</b>(</code>integer <var class="pdparam">version</var>, geography <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGML</b>(</code>integer <var class="pdparam">version</var>, geometry <var class="pdparam">g1</var>, integer <var class="pdparam">precision</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGML</b>(</code>integer <var class="pdparam">version</var>, geography <var class="pdparam">g1</var>, integer <var class="pdparam">precision</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGML</b>(</code>integer <var class="pdparam">version</var>, geometry <var class="pdparam">g1</var>, integer <var class="pdparam">precision</var>, integer <var class="pdparam">options</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsGML</b>(</code>integer <var class="pdparam">version</var>, geography <var class="pdparam">g1</var>, integer <var class="pdparam">precision</var>, integer <var class="pdparam">options</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36182908"></a><h2>Description</h2><p>Return the geometry as a Geography Markup Language (GML) element. The version parameter,
if specified, may be either 2 or 3. If no version parameter is
specified then the default is assumed to be 2. The third argument
may be used to reduce the maximum number of decimal places
used in output (defaults to 15).</p><p>GML 2 refer to 2.1.2 version, GML 3 to 3.1.1 version</p><p>The last 'options' argument is a bitfield. It could be used to define CRS output type
in GML output, and to declare data as lat/lon:
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>0: GML Short CRS (e.g EPSG:4326), default value</p></li><li class="listitem"><p>1: GML Long CRS (e.g urn:ogc:def:crs:EPSG::4326)</p></li><li class="listitem"><p>16: Declare that datas are lat/lon (e.g srid=4326). Default is to assume that data are planars. This option is usefull for GML 3.1.1 output only, related to axis order.</p></li></ul></div><p>
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Availability: 1.3.2</p><p>Availability: 1.5.0 geography support was introduced.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36182982"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsGML(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
st_asgml
--------
<gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,0 0,1 1,1 1,0 0,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>
</pre><pre class="programlisting">SELECT ST_AsGML(3, ST_GeomFromText('POINT(5.234234233242 6.34534534534)',4326), 5, 17);
st_asgml
--------
<gml:Point srsName="urn:ogc:def:crs:EPSG::4326"><gml:pos>6.34535 5.23423</gml:pos></gml:Point>
</pre></div><div class="refsection" title="See Also"><a name="id36183006"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromGML" title="ST_GeomFromGML">ST_GeomFromGML</a></p></div></div><div class="refentry" title="ST_AsHEXEWKB"><div class="refentry.separator"><hr></div><a name="ST_AsHEXEWKB"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_AsHEXEWKB — Returns a Geometry in HEXEWKB format (as text) using either
little-endian (NDR) or big-endian (XDR) encoding.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">ST_AsHEXEWKB</b>(</code>geometry <var class="pdparam">g1</var>, text <var class="pdparam">NDRorXDR</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsHEXEWKB</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36183096"></a><h2>Description</h2><p>Returns a Geometry in HEXEWKB format (as text) using either
little-endian (NDR) or big-endian (XDR) encoding. If no encoding is specified, then NDR is used.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Availability: 1.2.2</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36183139"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsHEXEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
which gives same answer as
SELECT ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326)::text;
st_ashexewkb
--------
0103000020E6100000010000000500
00000000000000000000000000000000
00000000000000000000000000000000F03F
000000000000F03F000000000000F03F000000000000F03
F000000000000000000000000000000000000000000000000</pre></div></div><div class="refentry" title="ST_AsKML"><div class="refentry.separator"><hr></div><a name="ST_AsKML"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_AsKML — Return the geometry as a KML element. Several variants. Default version=2, default precision=15</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">ST_AsKML</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsKML</b>(</code>geography <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsKML</b>(</code>geometry <var class="pdparam">g1</var>, integer <var class="pdparam">precision</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsKML</b>(</code>geography <var class="pdparam">g1</var>, integer <var class="pdparam">precision</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsKML</b>(</code>integer <var class="pdparam">version</var>, geometry <var class="pdparam">geom1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsKML</b>(</code>integer <var class="pdparam">version</var>, geography <var class="pdparam">geom1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsKML</b>(</code>integer <var class="pdparam">version</var>, geometry <var class="pdparam">geom1</var>, integer <var class="pdparam">precision</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsKML</b>(</code>integer <var class="pdparam">version</var>, geography <var class="pdparam">geom1</var>, integer <var class="pdparam">precision</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36183418"></a><h2>Description</h2><p>Return the geometry as a Keyhole Markup Language (KML) element. There are several variants of this function.
maximum number of decimal places used in
output (defaults to 15) and version default to 2.</p><p>Version 1: ST_AsKML(geom) / version=2 precision=15</p><p>Version 2: ST_AsKML(geom, max_sig_digits) / version=2 </p><p>Version 3: ST_AsKML(version, geom) / precision=15 </p><p>Version 4: ST_AsKML(version, geom, precision) </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Requires PostGIS be compiled with Proj support. Use <a class="xref" href="#PostGIS_Full_Version" title="PostGIS_Full_Version">PostGIS_Full_Version</a> to confirm you have proj support compiled in.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Availability: 1.2.2 - later variants that include version param came in 1.3.2</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>AsKML output will not work with geometries that do not have an SRID</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36183485"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsKML(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
st_askml
--------
<Polygon><outerBoundaryIs><LinearRing><coordinates>0,0 0,1 1,1 1,0 0,0</coordinates></LinearRing></outerBoundaryIs></Polygon>
--3d linestring
SELECT ST_AsKML('SRID=4326;LINESTRING(1 2 3, 4 5 6)');
<LineString><coordinates>1,2,3 4,5,6</coordinates></LineString>
</pre></div><div class="refsection" title="See Also"><a name="id36183503"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsSVG" title="ST_AsSVG">ST_AsSVG</a>, <a class="xref" href="#ST_AsGML" title="ST_AsGML">ST_AsGML</a></p></div></div><div class="refentry" title="ST_AsSVG"><div class="refentry.separator"><hr></div><a name="ST_AsSVG"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_AsSVG — Returns a Geometry in SVG path data given a geometry or geography object.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">ST_AsSVG</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsSVG</b>(</code>geography <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsSVG</b>(</code>geometry <var class="pdparam">g1</var>, integer <var class="pdparam">rel</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsSVG</b>(</code>geography <var class="pdparam">g1</var>, integer <var class="pdparam">rel</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsSVG</b>(</code>geometry <var class="pdparam">g1</var>, integer <var class="pdparam">rel</var>, integer <var class="pdparam">maxdecimaldigits</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsSVG</b>(</code>geography <var class="pdparam">g1</var>, integer <var class="pdparam">rel</var>, integer <var class="pdparam">maxdecimaldigits</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36183724"></a><h2>Description</h2><p>Return the geometry as Scalar Vector Graphics (SVG) path data. Use 1 as second
argument to have the path data implemented in terms of relative
moves, the default (or 0) uses absolute moves. Third argument may
be used to reduce the maximum number of decimal digits used in
output (defaults to 15). Point geometries will be rendered as
cx/cy when 'rel' arg is 0, x/y when 'rel' is 1. Multipoint
geometries are delimited by commas (","), GeometryCollection
geometries are delimited by semicolons (";").</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Availability: 1.2.2 . Availability: 1.4.0 Changed in PostGIS 1.4.0 to include L command in absolute path to conform to <a class="ulink" href="http://www.w3.org/TR/SVG/paths.html#PathDataBNF" target="_top">http://www.w3.org/TR/SVG/paths.html#PathDataBNF</a></p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36183751"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsSVG(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
st_assvg
--------
M 0 0 L 0 -1 1 -1 1 0 Z</pre></div></div><div class="refentry" title="ST_GeoHash"><div class="refentry.separator"><hr></div><a name="ST_GeoHash"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_GeoHash — Return a GeoHash representation (geohash.org) of the geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">ST_GeoHash</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_GeoHash</b>(</code>geometry <var class="pdparam">g1</var>, integer <var class="pdparam">precision</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36183837"></a><h2>Description</h2><p>Return a GeoHash representation (geohash.org) of the geometry. A GeoHash encodes a point into a text form that is sortable and searchable based on prefixing. A shorter GeoHash is a less precise representation of a point. It can also be thought of as a box, that contains the actual point.</p><p>The one-parameter variant of ST_GeoHash returns a GeoHash based on the input geometry type. Points return a GeoHash with 20 characters of precision (about enough to hold the full double precision of the input). Other types return a GeoHash with a variable amount of precision, based on the size of the feature. Larger features are represented with less precision, smaller features with more precision. The idea is that the box implied by the GeoHash will always contain the input feature.</p><p>The two-parameter variant of ST_GeoHash returns a GeoHash with a requested precision. For non-points, the starting point of the calculation is the center of the bounding box of the geometry.</p><p>Availability: 1.4.0</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>ST_GeoHash will not work with geometries that are not in geographic (lon/lat) coordinates.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36183884"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_GeoHash(ST_SetSRID(ST_MakePoint(-126,48),4326));
st_geohash
----------------------
c0w3hf1s70w3hf1s70w3
SELECT ST_GeoHash(ST_SetSRID(ST_MakePoint(-126,48),4326),5);
st_geohash
------------
c0w3h
</pre></div><div class="refsection" title="See Also"><a name="id36183894"></a><h2>See Also</h2><p></p></div></div><div class="refentry" title="ST_AsText"><div class="refentry.separator"><hr></div><a name="ST_AsText"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_AsText — Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">ST_AsText</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_AsText</b>(</code>geography <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36183971"></a><h2>Description</h2><p>Returns the Well-Known Text representation of the geometry/geography.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>The WKT spec does not include the SRID. To get the SRID as part of the data, use the non-standard
PostGIS <a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a></p></td></tr></table></div><p><img src="images/warning.png">
WKT format does not maintain precision so to prevent floating truncation, use ST_AsBinary or ST_AsEWKB format for transport.
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>ST_AsText is the reverse of <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>. Use <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a> to convert to a postgis geometry from ST_AsText representation.</p></td></tr></table></div><p>Availability: 1.5 - support for geography was introduced.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.25</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36184066"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsText('01030000000100000005000000000000000000
000000000000000000000000000000000000000000000000
F03F000000000000F03F000000000000F03F000000000000F03
F000000000000000000000000000000000000000000000000');
st_astext
--------------------------------
POLYGON((0 0,0 1,1 1,1 0,0 0))
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36184083"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsBinary" title="ST_AsBinary">ST_AsBinary</a>, <a class="xref" href="#ST_AsEWKB" title="ST_AsEWKB">ST_AsEWKB</a>, <a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a></p></div></div></div><div class="sect1" title="7.7.Operators"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Operators"></a>7.7.Operators</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#ST_Geometry_Overlap">&&</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box overlaps B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_Overleft">&<</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box overlaps or is to the left of B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_Overbelow">&<|</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box overlaps or is below B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_Overright">&></a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A' bounding box overlaps or is to the right of B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_Left"><<</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box is strictly to the left of B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_Below"><<|</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box is strictly below B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_EQ">=</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box is the same as B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_Right">>></a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box is strictly to the right of B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_Contained">@</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box is contained by B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_Overabove">|&></a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box overlaps or is above B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_Above">|>></a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box is strictly above B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_Contain">~</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box contains B's.</span></dt><dt><span class="refentrytitle"><a href="#ST_Geometry_Same">~=</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if A's bounding box is the same as B's.</span></dt></dl></div><div class="refentry" title="&&"><a name="ST_Geometry_Overlap"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>&& — Returns <code class="varname">TRUE</code> if A's bounding box overlaps B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">&&</b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p><p><code class="funcdef">boolean <b class="fsfunc">&&</b>(</code>
geography
<var class="pdparam">A</var>
,
geography
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36187144"></a><h2>Description</h2><p>The <code class="varname">&&</code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry A overlaps the bounding box of geometry B.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div><p>Availability: 1.5.0 support for geography was introduced.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36187182"></a><h2>Examples</h2><pre class="programlisting">SELECT tbl1.column1, tbl2.column1, tbl1.column2 && tbl2.column2 AS overlaps
FROM ( VALUES
(1, 'LINESTRING(0 0, 3 3)'::geometry),
(2, 'LINESTRING(0 1, 0 5)'::geometry)) AS tbl1,
( VALUES
(3, 'LINESTRING(1 2, 4 6)'::geometry)) AS tbl2;
column1 | column1 | overlaps
---------+---------+----------
1 | 3 | t
2 | 3 | f
(2 rows)</pre></div><div class="refsection" title="See Also"><a name="id36187203"></a><h2>See Also</h2><p>
<a class="xref" href="#ST_Geometry_Overabove" title="|&>">|&></a>,
<a class="xref" href="#ST_Geometry_Overright" title="&>">&></a>,
<a class="xref" href="#ST_Geometry_Overbelow" title="&<|">&<|</a>,
<a class="xref" href="#ST_Geometry_Overleft" title="&<">&<</a>,
<a class="xref" href="#ST_Geometry_Contain" title="~">~</a>,
<a class="xref" href="#ST_Geometry_Contained" title="@">@</a></p></div></div><div class="refentry" title="&<"><div class="refentry.separator"><hr></div><a name="ST_Geometry_Overleft"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>&< — Returns <code class="varname">TRUE</code> if A's bounding box overlaps or is to the left of B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">&<</b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36187313"></a><h2>Description</h2><p>The <code class="varname">&<</code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry A
overlaps or is to the left of the bounding box of geometry B, or more accurately, overlaps or is NOT to the right
of the bounding box of geometry B.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36187336"></a><h2>Examples</h2><pre class="programlisting">SELECT tbl1.column1, tbl2.column1, tbl1.column2 &< tbl2.column2 AS overleft
FROM
( VALUES
(1, 'LINESTRING(1 2, 4 6)'::geometry)) AS tbl1,
( VALUES
(2, 'LINESTRING(0 0, 3 3)'::geometry),
(3, 'LINESTRING(0 1, 0 5)'::geometry),
(4, 'LINESTRING(6 0, 6 1)'::geometry)) AS tbl2;
column1 | column1 | overleft
---------+---------+----------
1 | 2 | f
1 | 3 | f
1 | 4 | t
(3 rows)</pre></div><div class="refsection" title="See Also"><a name="id36187356"></a><h2>See Also</h2><p>
<a class="xref" href="#ST_Geometry_Overlap" title="&&">&&</a>,
<a class="xref" href="#ST_Geometry_Overabove" title="|&>">|&></a>,
<a class="xref" href="#ST_Geometry_Overright" title="&>">&></a>,
<a class="xref" href="#ST_Geometry_Overbelow" title="&<|">&<|</a></p></div></div><div class="refentry" title="&<|"><div class="refentry.separator"><hr></div><a name="ST_Geometry_Overbelow"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>&<| — Returns <code class="varname">TRUE</code> if A's bounding box overlaps or is below B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">&<|</b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36187450"></a><h2>Description</h2><p>The <code class="varname">&<|</code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry A
overlaps or is below of the bounding box of geometry B, or more accurately, overlaps or is NOT above the bounding
box of geometry B.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36187485"></a><h2>Examples</h2><pre class="programlisting">SELECT tbl1.column1, tbl2.column1, tbl1.column2 &<| tbl2.column2 AS overbelow
FROM
( VALUES
(1, 'LINESTRING(6 0, 6 4)'::geometry)) AS tbl1,
( VALUES
(2, 'LINESTRING(0 0, 3 3)'::geometry),
(3, 'LINESTRING(0 1, 0 5)'::geometry),
(4, 'LINESTRING(1 2, 4 6)'::geometry)) AS tbl2;
column1 | column1 | overbelow
---------+---------+-----------
1 | 2 | f
1 | 3 | t
1 | 4 | t
(3 rows)</pre></div><div class="refsection" title="See Also"><a name="id36187505"></a><h2>See Also</h2><p>
<a class="xref" href="#ST_Geometry_Overlap" title="&&">&&</a>,
<a class="xref" href="#ST_Geometry_Overabove" title="|&>">|&></a>,
<a class="xref" href="#ST_Geometry_Overright" title="&>">&></a>,
<a class="xref" href="#ST_Geometry_Overleft" title="&<">&<</a></p></div></div><div class="refentry" title="&>"><div class="refentry.separator"><hr></div><a name="ST_Geometry_Overright"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>&> — Returns <code class="varname">TRUE</code> if A' bounding box overlaps or is to the right of B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">&></b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36187598"></a><h2>Description</h2><p>The <code class="varname">&></code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry A
overlaps or is to the right of the bounding box of geometry B, or more accurately, overlaps or is NOT to the left
of the bounding box of geometry B.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36187622"></a><h2>Examples</h2><pre class="programlisting">SELECT tbl1.column1, tbl2.column1, tbl1.column2 &> tbl2.column2 AS overright
FROM
( VALUES
(1, 'LINESTRING(1 2, 4 6)'::geometry)) AS tbl1,
( VALUES
(2, 'LINESTRING(0 0, 3 3)'::geometry),
(3, 'LINESTRING(0 1, 0 5)'::geometry),
(4, 'LINESTRING(6 0, 6 1)'::geometry)) AS tbl2;
column1 | column1 | overright
---------+---------+-----------
1 | 2 | t
1 | 3 | t
1 | 4 | f
(3 rows)</pre></div><div class="refsection" title="See Also"><a name="id36187642"></a><h2>See Also</h2><p>
<a class="xref" href="#ST_Geometry_Overlap" title="&&">&&</a>,
<a class="xref" href="#ST_Geometry_Overabove" title="|&>">|&></a>,
<a class="xref" href="#ST_Geometry_Overbelow" title="&<|">&<|</a>,
<a class="xref" href="#ST_Geometry_Overleft" title="&<">&<</a></p></div></div><div class="refentry" title="<<"><div class="refentry.separator"><hr></div><a name="ST_Geometry_Left"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p><< — Returns <code class="varname">TRUE</code> if A's bounding box is strictly to the left of B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc"><<</b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36187736"></a><h2>Description</h2><p>The <code class="varname"><<</code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry A
is strictly to the left of the bounding box of geometry B.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36187758"></a><h2>Examples</h2><pre class="programlisting">SELECT tbl1.column1, tbl2.column1, tbl1.column2 << tbl2.column2 AS left
FROM
( VALUES
(1, 'LINESTRING (1 2, 1 5)'::geometry)) AS tbl1,
( VALUES
(2, 'LINESTRING (0 0, 4 3)'::geometry),
(3, 'LINESTRING (6 0, 6 5)'::geometry),
(4, 'LINESTRING (2 2, 5 6)'::geometry)) AS tbl2;
column1 | column1 | left
---------+---------+------
1 | 2 | f
1 | 3 | t
1 | 4 | t
(3 rows)</pre></div><div class="refsection" title="See Also"><a name="id36187778"></a><h2>See Also</h2><p><a class="xref" href="#ST_Geometry_Right" title=">>">>></a>, <a class="xref" href="#ST_Geometry_Above" title="|>>">|>></a>, <a class="xref" href="#ST_Geometry_Below" title="<<|"><<|</a></p></div></div><div class="refentry" title="<<|"><div class="refentry.separator"><hr></div><a name="ST_Geometry_Below"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p><<| — Returns <code class="varname">TRUE</code> if A's bounding box is strictly below B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc"><<|</b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36187868"></a><h2>Description</h2><p>The <code class="varname"><<|</code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry A
is strictly below the bounding box of geometry B.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36187890"></a><h2>Examples</h2><pre class="programlisting">SELECT tbl1.column1, tbl2.column1, tbl1.column2 <<| tbl2.column2 AS below
FROM
( VALUES
(1, 'LINESTRING (0 0, 4 3)'::geometry)) AS tbl1,
( VALUES
(2, 'LINESTRING (1 4, 1 7)'::geometry),
(3, 'LINESTRING (6 1, 6 5)'::geometry),
(4, 'LINESTRING (2 3, 5 6)'::geometry)) AS tbl2;
column1 | column1 | below
---------+---------+-------
1 | 2 | t
1 | 3 | f
1 | 4 | f
(3 rows)</pre></div><div class="refsection" title="See Also"><a name="id36187910"></a><h2>See Also</h2><p><a class="xref" href="#ST_Geometry_Left" title="<<"><<</a>, <a class="xref" href="#ST_Geometry_Right" title=">>">>></a>, <a class="xref" href="#ST_Geometry_Above" title="|>>">|>></a></p></div></div><div class="refentry" title="="><div class="refentry.separator"><hr></div><a name="ST_Geometry_EQ"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>= — Returns <code class="varname">TRUE</code> if A's bounding box is the same as B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">=</b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p><p><code class="funcdef">boolean <b class="fsfunc">=</b>(</code>
geography
<var class="pdparam">A</var>
,
geography
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36188032"></a><h2>Description</h2><p>The <code class="varname">=</code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry/geography A
is the same as the bounding box of geometry/geography B. PostgreSQL uses the =, <, and > operators defined for geometries to
perform internal orderings and comparison of geometries (ie. in a GROUP BY or ORDER BY clause).</p><div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This is cause for a lot of confusion. When you compare geometryA =
geometryB it will return true even when the geometries are clearly
different IF their bounding boxes are the same. To check for true
equality use <a class="xref" href="#ST_OrderingEquals" title="ST_OrderingEquals">ST_OrderingEquals</a> or <a class="xref" href="#ST_Equals" title="ST_Equals">ST_Equals</a></p></td></tr></table></div><div class="caution" title="Caution" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Caution"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will NOT make use of any indexes that may be available on the
geometries.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36188091"></a><h2>Examples</h2><pre class="programlisting">SELECT 'LINESTRING(0 0, 0 1, 1 0)'::geometry = 'LINESTRING(1 1, 0 0)'::geometry;
?column?
----------
t
(1 row)
SELECT ST_AsText(column1)
FROM ( VALUES
('LINESTRING(0 0, 1 1)'::geometry),
('LINESTRING(1 1, 0 0)'::geometry)) AS foo;
st_astext
---------------------
LINESTRING(0 0,1 1)
LINESTRING(1 1,0 0)
(2 rows)
-- Note: the GROUP BY uses the "=" to compare for geometry equivalency.
SELECT ST_AsText(column1)
FROM ( VALUES
('LINESTRING(0 0, 1 1)'::geometry),
('LINESTRING(1 1, 0 0)'::geometry)) AS foo
GROUP BY column1;
st_astext
---------------------
LINESTRING(0 0,1 1)
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36188107"></a><h2>See Also</h2><p><a class="xref" href="#ST_Equals" title="ST_Equals">ST_Equals</a>, <a class="xref" href="#ST_OrderingEquals" title="ST_OrderingEquals">ST_OrderingEquals</a>, <a class="xref" href="#ST_Geometry_Same" title="~=">~=</a>
</p></div></div><div class="refentry" title=">>"><div class="refentry.separator"><hr></div><a name="ST_Geometry_Right"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>>> — Returns <code class="varname">TRUE</code> if A's bounding box is strictly to the right of B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">>></b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36188200"></a><h2>Description</h2><p>The <code class="varname">>></code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry A
is strictly to the right of the bounding box of geometry B.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36188223"></a><h2>Examples</h2><pre class="programlisting">SELECT tbl1.column1, tbl2.column1, tbl1.column2 >> tbl2.column2 AS right
FROM
( VALUES
(1, 'LINESTRING (2 3, 5 6)'::geometry)) AS tbl1,
( VALUES
(2, 'LINESTRING (1 4, 1 7)'::geometry),
(3, 'LINESTRING (6 1, 6 5)'::geometry),
(4, 'LINESTRING (0 0, 4 3)'::geometry)) AS tbl2;
column1 | column1 | right
---------+---------+-------
1 | 2 | t
1 | 3 | f
1 | 4 | f
(3 rows)</pre></div><div class="refsection" title="See Also"><a name="id36188242"></a><h2>See Also</h2><p><a class="xref" href="#ST_Geometry_Left" title="<<"><<</a>, <a class="xref" href="#ST_Geometry_Above" title="|>>">|>></a>, <a class="xref" href="#ST_Geometry_Below" title="<<|"><<|</a></p></div></div><div class="refentry" title="@"><div class="refentry.separator"><hr></div><a name="ST_Geometry_Contained"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>@ — Returns <code class="varname">TRUE</code> if A's bounding box is contained by B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">@</b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36188329"></a><h2>Description</h2><p>The <code class="varname">@</code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry A is completely
contained by the bounding box of geometry B.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36188354"></a><h2>Examples</h2><pre class="programlisting">SELECT tbl1.column1, tbl2.column1, tbl1.column2 @ tbl2.column2 AS contained
FROM
( VALUES
(1, 'LINESTRING (1 1, 3 3)'::geometry)) AS tbl1,
( VALUES
(2, 'LINESTRING (0 0, 4 4)'::geometry),
(3, 'LINESTRING (2 2, 4 4)'::geometry),
(4, 'LINESTRING (1 1, 3 3)'::geometry)) AS tbl2;
column1 | column1 | contained
---------+---------+-----------
1 | 2 | t
1 | 3 | f
1 | 4 | t
(3 rows)</pre></div><div class="refsection" title="See Also"><a name="id36188369"></a><h2>See Also</h2><p><a class="xref" href="#ST_Geometry_Contain" title="~">~</a>, <a class="xref" href="#ST_Geometry_Overlap" title="&&">&&</a></p></div></div><div class="refentry" title="|&>"><div class="refentry.separator"><hr></div><a name="ST_Geometry_Overabove"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>|&> — Returns <code class="varname">TRUE</code> if A's bounding box overlaps or is above B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">|&></b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36188451"></a><h2>Description</h2><p>The <code class="varname">|&></code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry A
overlaps or is above the bounding box of geometry B, or more accurately, overlaps or is NOT below
the bounding box of geometry B.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36188474"></a><h2>Examples</h2><pre class="programlisting">SELECT tbl1.column1, tbl2.column1, tbl1.column2 |&> tbl2.column2 AS overabove
FROM
( VALUES
(1, 'LINESTRING(6 0, 6 4)'::geometry)) AS tbl1,
( VALUES
(2, 'LINESTRING(0 0, 3 3)'::geometry),
(3, 'LINESTRING(0 1, 0 5)'::geometry),
(4, 'LINESTRING(1 2, 4 6)'::geometry)) AS tbl2;
column1 | column1 | overabove
---------+---------+-----------
1 | 2 | t
1 | 3 | f
1 | 4 | f
(3 rows)</pre></div><div class="refsection" title="See Also"><a name="id36188494"></a><h2>See Also</h2><p>
<a class="xref" href="#ST_Geometry_Overlap" title="&&">&&</a>,
<a class="xref" href="#ST_Geometry_Overright" title="&>">&></a>,
<a class="xref" href="#ST_Geometry_Overbelow" title="&<|">&<|</a>,
<a class="xref" href="#ST_Geometry_Overleft" title="&<">&<</a></p></div></div><div class="refentry" title="|>>"><div class="refentry.separator"><hr></div><a name="ST_Geometry_Above"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>|>> — Returns <code class="varname">TRUE</code> if A's bounding box is strictly above B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">|>></b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36188587"></a><h2>Description</h2><p>The <code class="varname">|>></code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry A
is strictly to the right of the bounding box of geometry B.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36188610"></a><h2>Examples</h2><pre class="programlisting">SELECT tbl1.column1, tbl2.column1, tbl1.column2 |>> tbl2.column2 AS above
FROM
( VALUES
(1, 'LINESTRING (1 4, 1 7)'::geometry)) AS tbl1,
( VALUES
(2, 'LINESTRING (0 0, 4 2)'::geometry),
(3, 'LINESTRING (6 1, 6 5)'::geometry),
(4, 'LINESTRING (2 3, 5 6)'::geometry)) AS tbl2;
column1 | column1 | above
---------+---------+-------
1 | 2 | t
1 | 3 | f
1 | 4 | f
(3 rows)</pre></div><div class="refsection" title="See Also"><a name="id36188630"></a><h2>See Also</h2><p><a class="xref" href="#ST_Geometry_Left" title="<<"><<</a>, <a class="xref" href="#ST_Geometry_Right" title=">>">>></a>, <a class="xref" href="#ST_Geometry_Below" title="<<|"><<|</a></p></div></div><div class="refentry" title="~"><div class="refentry.separator"><hr></div><a name="ST_Geometry_Contain"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>~ — Returns <code class="varname">TRUE</code> if A's bounding box contains B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">~</b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36188717"></a><h2>Description</h2><p>The <code class="varname">~</code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry A completely
contains the bounding box of geometry B.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36188740"></a><h2>Examples</h2><pre class="programlisting">SELECT tbl1.column1, tbl2.column1, tbl1.column2 ~ tbl2.column2 AS contains
FROM
( VALUES
(1, 'LINESTRING (0 0, 3 3)'::geometry)) AS tbl1,
( VALUES
(2, 'LINESTRING (0 0, 4 4)'::geometry),
(3, 'LINESTRING (1 1, 2 2)'::geometry),
(4, 'LINESTRING (0 0, 3 3)'::geometry)) AS tbl2;
column1 | column1 | contains
---------+---------+----------
1 | 2 | f
1 | 3 | t
1 | 4 | t
(3 rows)</pre></div><div class="refsection" title="See Also"><a name="id36188755"></a><h2>See Also</h2><p><a class="xref" href="#ST_Geometry_Contained" title="@">@</a>, <a class="xref" href="#ST_Geometry_Overlap" title="&&">&&</a></p></div></div><div class="refentry" title="~="><div class="refentry.separator"><hr></div><a name="ST_Geometry_Same"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>~= — Returns <code class="varname">TRUE</code> if A's bounding box is the same as B's.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">~=</b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36188837"></a><h2>Description</h2><p>The <code class="varname">~=</code> operator returns <code class="varname">TRUE</code> if the bounding box of geometry/geography A
is the same as the bounding box of geometry/geography B.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operand will make use of any indexes that may be available on the
geometries.</p></td></tr></table></div><p>Availability: 1.5.0 changed behavior</p></div><div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This operator has changed behavior in PostGIS 1.5
from testing for actual geometric equality to only
checking for bounding box equality. To complicate things
it also depends on if you have done a hard or soft upgrade
which behavior your database has. To find out which behavior
your database has you can run the query below.
To check for true equality use <a class="xref" href="#ST_OrderingEquals" title="ST_OrderingEquals">ST_OrderingEquals</a> or <a class="xref" href="#ST_Equals" title="ST_Equals">ST_Equals</a> and to check for bounding box equality <a class="xref" href="#ST_Geometry_EQ" title="=">=</a>;
operator is a safer option.</p></td></tr></table></div><div class="refsection" title="Examples"><a name="id36188888"></a><h2>Examples</h2><pre class="programlisting">
select 'LINESTRING(0 0, 1 1)'::geometry ~= 'LINESTRING(0 1, 1 0)'::geometry as equality;
equality |
-----------------+
t |
</pre><p>The above can be used to test if you have the new or old behavior of ~= operator.</p></div><div class="refsection" title="See Also"><a name="id36188905"></a><h2>See Also</h2><p><a class="xref" href="#ST_Equals" title="ST_Equals">ST_Equals</a>, <a class="xref" href="#ST_OrderingEquals" title="ST_OrderingEquals">ST_OrderingEquals</a>, <a class="xref" href="#ST_Geometry_EQ" title="=">=</a></p></div></div></div><div class="sect1" title="7.8.Spatial Relationships and Measurements"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Spatial_Relationships_Measurements"></a>7.8.Spatial Relationships and Measurements</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#ST_Area">ST_Area</a></span><span class="refpurpose"> — Returns the area of the surface if it is a polygon or
multi-polygon. For "geometry" type area is in SRID units. For "geography" area is in square meters.</span></dt><dt><span class="refentrytitle"><a href="#ST_Azimuth">ST_Azimuth</a></span><span class="refpurpose"> — Returns the angle in radians from the horizontal of the vector defined by pointA and pointB</span></dt><dt><span class="refentrytitle"><a href="#ST_Centroid">ST_Centroid</a></span><span class="refpurpose"> — Returns the geometric center of a geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_ClosestPoint">ST_ClosestPoint</a></span><span class="refpurpose"> — Returns the 2-dimensional point on g1 that is closest to g2. This is the first point of
the shortest line.</span></dt><dt><span class="refentrytitle"><a href="#ST_Contains">ST_Contains</a></span><span class="refpurpose"> — Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A. </span></dt><dt><span class="refentrytitle"><a href="#ST_ContainsProperly">ST_ContainsProperly</a></span><span class="refpurpose"> — Returns true if B intersects the interior of A but not the boundary (or exterior). A does not contain properly itself, but does contain itself.</span></dt><dt><span class="refentrytitle"><a href="#ST_Covers">ST_Covers</a></span><span class="refpurpose"> — Returns 1 (TRUE) if no point in Geometry B is outside
Geometry A. For geography: if geography point B is not outside Polygon Geography A</span></dt><dt><span class="refentrytitle"><a href="#ST_CoveredBy">ST_CoveredBy</a></span><span class="refpurpose"> — Returns 1 (TRUE) if no point in Geometry/Geography A is outside
Geometry/Geography B</span></dt><dt><span class="refentrytitle"><a href="#ST_Crosses">ST_Crosses</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if the supplied geometries have some, but not all,
interior points in common.</span></dt><dt><span class="refentrytitle"><a href="#ST_LineCrossingDirection">ST_LineCrossingDirection</a></span><span class="refpurpose"> — Given 2 linestrings, returns a number between -3 and 3 denoting what kind of crossing behavior. 0 is no crossing.</span></dt><dt><span class="refentrytitle"><a href="#ST_Disjoint">ST_Disjoint</a></span><span class="refpurpose"> — Returns TRUE if the Geometries do not "spatially
intersect" - if they do not share any space together.
</span></dt><dt><span class="refentrytitle"><a href="#ST_Distance">ST_Distance</a></span><span class="refpurpose"> — For geometry type Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in
projected units. For geography type defaults to return spheroidal minimum distance between two geographies in meters.</span></dt><dt><span class="refentrytitle"><a href="#ST_HausdorffDistance">ST_HausdorffDistance</a></span><span class="refpurpose"> — Returns the Hausdorff distance between two geometries. Basically a measure of how similar or dissimilar 2 geometries are. Units are in the units of the spatial
reference system of the geometries.</span></dt><dt><span class="refentrytitle"><a href="#ST_MaxDistance">ST_MaxDistance</a></span><span class="refpurpose"> — Returns the 2-dimensional largest distance between two geometries in
projected units.</span></dt><dt><span class="refentrytitle"><a href="#ST_Distance_Sphere">ST_Distance_Sphere</a></span><span class="refpurpose"> — Returns minimum distance in meters between two lon/lat
geometries. Uses a spherical earth and radius of 6370986 meters.
Faster than <a class="xref" href="#ST_Distance_Spheroid" title="ST_Distance_Spheroid">ST_Distance_Spheroid</a>, but less
accurate. PostGIS versions prior to 1.5 only implemented for points.</span></dt><dt><span class="refentrytitle"><a href="#ST_Distance_Spheroid">ST_Distance_Spheroid</a></span><span class="refpurpose"> — Returns the minimum distance between two lon/lat geometries given a
particular spheroid.
PostGIS versions prior to 1.5 only support points.</span></dt><dt><span class="refentrytitle"><a href="#ST_DFullyWithin">ST_DFullyWithin</a></span><span class="refpurpose"> — Returns true if all of the geometries are within the specified
distance of one another</span></dt><dt><span class="refentrytitle"><a href="#ST_DWithin">ST_DWithin</a></span><span class="refpurpose"> — Returns true if the geometries are within the specified
distance of one another. For geometry units are in those of spatial reference and For geography units are in meters and measurement is
defaulted to use_spheroid=true (measure around spheroid), for faster check, use_spheroid=false to measure along sphere.</span></dt><dt><span class="refentrytitle"><a href="#ST_Equals">ST_Equals</a></span><span class="refpurpose"> — Returns true if the given geometries represent the same geometry. Directionality
is ignored.</span></dt><dt><span class="refentrytitle"><a href="#ST_HasArc">ST_HasArc</a></span><span class="refpurpose"> — Returns true if a geometry or geometry collection contains a circular string</span></dt><dt><span class="refentrytitle"><a href="#ST_Intersects">ST_Intersects</a></span><span class="refpurpose"> — Returns TRUE if the Geometries/Geography "spatially
intersect" - (share any portion of space) and FALSE if they don't (they are Disjoint).
For geography -- tolerance is 0.00001 meters (so any points that close are considered to intersect)
</span></dt><dt><span class="refentrytitle"><a href="#ST_Length">ST_Length</a></span><span class="refpurpose"> — Returns the 2d length of the geometry if it is a linestring or multilinestring. geometry are in units of spatial reference and geography are in meters (default spheroid)</span></dt><dt><span class="refentrytitle"><a href="#ST_Length2D">ST_Length2D</a></span><span class="refpurpose"> — Returns the 2-dimensional length of the geometry if it is a
linestring or multi-linestring. This is an alias for <code class="varname">ST_Length</code></span></dt><dt><span class="refentrytitle"><a href="#ST_Length3D">ST_Length3D</a></span><span class="refpurpose"> — Returns the 3-dimensional or 2-dimensional length of the geometry if it is a
linestring or multi-linestring. </span></dt><dt><span class="refentrytitle"><a href="#ST_Length_Spheroid">ST_Length_Spheroid</a></span><span class="refpurpose"> — Calculates the 2D or 3D length of a linestring/multilinestring on an ellipsoid. This
is useful if the coordinates of the geometry are in
longitude/latitude and a length is desired without reprojection.</span></dt><dt><span class="refentrytitle"><a href="#ST_Length2D_Spheroid">ST_Length2D_Spheroid</a></span><span class="refpurpose"> — Calculates the 2D length of a linestring/multilinestring on an ellipsoid. This
is useful if the coordinates of the geometry are in
longitude/latitude and a length is desired without reprojection. </span></dt><dt><span class="refentrytitle"><a href="#ST_Length3D_Spheroid">ST_Length3D_Spheroid</a></span><span class="refpurpose"> — Calculates the length of a geometry on an ellipsoid,
taking the elevation into account. This is just an alias for ST_Length_Spheroid. </span></dt><dt><span class="refentrytitle"><a href="#ST_LongestLine">ST_LongestLine</a></span><span class="refpurpose"> — Returns the 2-dimensional longest line points of two geometries.
The function will only return the first longest line if more than one, that the function finds.
The line returned will always start in g1 and end in g2.
The length of the line this function returns will always be the same as st_maxdistance returns for g1 and g2.</span></dt><dt><span class="refentrytitle"><a href="#ST_OrderingEquals">ST_OrderingEquals</a></span><span class="refpurpose"> — Returns true if the given geometries represent the same geometry
and points are in the same directional order.</span></dt><dt><span class="refentrytitle"><a href="#ST_Overlaps">ST_Overlaps</a></span><span class="refpurpose"> — Returns TRUE if the Geometries share space, are of the same dimension, but are not completely contained by each other.</span></dt><dt><span class="refentrytitle"><a href="#ST_Perimeter">ST_Perimeter</a></span><span class="refpurpose"> — Return the length measurement of the boundary of an ST_Surface
or ST_MultiSurface value. (Polygon, Multipolygon)</span></dt><dt><span class="refentrytitle"><a href="#ST_Perimeter2D">ST_Perimeter2D</a></span><span class="refpurpose"> — Returns the 2-dimensional perimeter of the geometry, if it
is a polygon or multi-polygon. This is currently an alias for ST_Perimeter.</span></dt><dt><span class="refentrytitle"><a href="#ST_Perimeter3D">ST_Perimeter3D</a></span><span class="refpurpose"> — Returns the 3-dimensional perimeter of the geometry, if it
is a polygon or multi-polygon.</span></dt><dt><span class="refentrytitle"><a href="#ST_PointOnSurface">ST_PointOnSurface</a></span><span class="refpurpose"> — Returns a <code class="varname">POINT</code> guaranteed to lie on the surface.</span></dt><dt><span class="refentrytitle"><a href="#ST_Relate">ST_Relate</a></span><span class="refpurpose"> — Returns true if this Geometry is spatially related to
anotherGeometry, by testing for intersections between the
Interior, Boundary and Exterior of the two geometries as specified
by the values in the intersectionMatrixPattern. If no intersectionMatrixPattern
is passed in, then returns the maximum intersectionMatrixPattern that relates the 2 geometries.</span></dt><dt><span class="refentrytitle"><a href="#ST_ShortestLine">ST_ShortestLine</a></span><span class="refpurpose"> — Returns the 2-dimensional shortest line between two geometries</span></dt><dt><span class="refentrytitle"><a href="#ST_Touches">ST_Touches</a></span><span class="refpurpose"> — Returns <code class="varname">TRUE</code> if the geometries have at least one point in common,
but their interiors do not intersect.</span></dt><dt><span class="refentrytitle"><a href="#ST_Within">ST_Within</a></span><span class="refpurpose"> — Returns true if the geometry A is completely inside geometry B</span></dt></dl></div><div class="refentry" title="ST_Area"><a name="ST_Area"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Area — Returns the area of the surface if it is a polygon or
multi-polygon. For "geometry" type area is in SRID units. For "geography" area is in square meters.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Area</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">float <b class="fsfunc">ST_Area</b>(</code>geography <var class="pdparam">g1</var><code>)</code>;</p><p><code class="funcdef">float <b class="fsfunc">ST_Area</b>(</code>geography <var class="pdparam">g1</var>, boolean <var class="pdparam">use_spheroid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36190881"></a><h2>Description</h2><p>Returns the area of the geometry if it is a polygon or
multi-polygon. Return the area measurement of an ST_Surface or
ST_MultiSurface value. For geometry Area is in the units of the srid. For geography area is in square meters and defaults to measuring about the spheroid of the geography (currently only WGS84).
To measure around the faster but less accurate sphere -- ST_Area(geog,false).
</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 8.1.2, 9.5.3</p></div><div class="refsection" title="Examples"><a name="id36190926"></a><h2>Examples</h2><p>Return area in square feet for a plot of Massachusetts land and multiply by conversion to get square meters.
Note this is in square feet because 2249 is
Mass State Plane Feet </p><pre class="programlisting">
SELECT ST_Area(the_geom) As sqft, ST_Area(the_geom)*POWER(0.3048,2) As sqm
FROM (SELECT
ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,
743265 2967450,743265.625 2967416,743238 2967416))',2249) ) As foo(the_geom);
sqft | sqm
---------+-------------
928.625 | 86.27208552
</pre><p>Return area square feet and transform to Massachusetts state plane meters (26986) to get square meters.
Note this is in square feet because 2249 is
Mass State Plane Feet and transformed area is in square meters since 26986 is state plane mass meters </p><pre class="programlisting">
SELECT ST_Area(the_geom) As sqft, ST_Area(ST_Transform(the_geom,26986)) As sqm
FROM (SELECT
ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,
743265 2967450,743265.625 2967416,743238 2967416))',2249) ) As foo(the_geom);
sqft | sqm
---------+------------------
928.625 | 86.2724304199219
</pre><p>Return area square feet and square meters using Geography data type. Note that we transform to our geometry to geography
(before you can do that make sure your geometry is in WGS 84 long lat 4326). Geography always measures in meters.
This is just for demonstration to compare. Normally your table will be stored in geography data type already.</p><pre class="programlisting">
SELECT ST_Area(the_geog)/POWER(0.3048,2) As sqft_spheroid, ST_Area(the_geog,false)/POWER(0.3048,2) As sqft_sphere, ST_Area(the_geog) As sqm_spheroid
FROM (SELECT
geography(
ST_Transform(
ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))',
2249
) ,4326
)
)
) As foo(the_geog);
sqft_spheroid | sqft_sphere | sqm_spheroid
-----------------+------------------+------------------
928.684405217197 | 927.186481558724 | 86.2776044452694
--if your data is in geography already
SELECT ST_Area(the_geog)/POWER(0.3048,2) As sqft, ST_Area(the_geog) As sqm
FROM somegeogtable;
</pre></div><div class="refsection" title="See Also"><a name="id36190975"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_GeographyFromText" title="ST_GeographyFromText">ST_GeographyFromText</a>, <a class="xref" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a>,<a class="xref" href="#ST_Transform" title="ST_Transform">ST_Transform</a></p></div></div><div class="refentry" title="ST_Azimuth"><div class="refentry.separator"><hr></div><a name="ST_Azimuth"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Azimuth — Returns the angle in radians from the horizontal of the vector defined by pointA and pointB</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Azimuth</b>(</code>geometry <var class="pdparam">pointA</var>, geometry <var class="pdparam">pointB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36191054"></a><h2>Description</h2><p>Returns the azimuth of the segment defined by the given
Point geometries, or NULL if the two points are coincident. Return
value is in radians.</p><p>The Azimuth is mathematical concept defined as the angle, in this case measured in radian, between a reference plane
and a point</p><p>Availability: 1.1.0</p><p>Azimuth is especially useful in conjunction with ST_Translate for shifting an object along its perpendicular axis. See
upgis_lineshift <a class="ulink" href="http://postgis.refractions.net/support/wiki/index.php?plpgsqlfunctions" target="_top">Plpgsqlfunctions PostGIS wiki section</a> for example of this.</p></div><div class="refsection" title="Examples"><a name="id36191084"></a><h2>Examples</h2><p>--Azimuth in degrees </p><pre class="programlisting">
SELECT ST_Azimuth(ST_MakePoint(1,2), ST_MakePoint(3,4))/(2*pi())*360 as degAz,
ST_Azimuth(ST_MakePoint(3,4), ST_MakePoint(1,2))/(2*pi())*360 As degAzrev
degaz degazrev
------ ---------
45 225
</pre></div><div class="refsection" title="See Also"><a name="id36191101"></a><h2>See Also</h2><p><a class="xref" href="#ST_MakePoint" title="ST_MakePoint">ST_MakePoint</a>, <a class="xref" href="#ST_Translate" title="ST_Translate">ST_Translate</a></p></div></div><div class="refentry" title="ST_Centroid"><div class="refentry.separator"><hr></div><a name="ST_Centroid"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Centroid — Returns the geometric center of a geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Centroid</b>(</code>geometry
<var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36191161"></a><h2>Description</h2><p>Computes the geometric center of a geometry, or equivalently,
the center of mass of the geometry as a <code class="varname">POINT</code>. For
[<code class="varname">MULTI</code>]<code class="varname">POINT</code>s, this is computed
as the arithmetric mean of the input coordinates. For
[<code class="varname">MULTI</code>]<code class="varname">LINESTRING</code>s, this is
computed as the weighted length of each line segment. For
[<code class="varname">MULTI</code>]<code class="varname">POLYGON</code>s, "weight" is
thought in terms of area. If an empty geometry is supplied, an empty
<code class="varname">GEOMETRYCOLLECTION</code> is returned. If
<code class="varname">NULL</code> is supplied, <code class="varname">NULL</code> is
returned.</p><p>The centroid is equal to the centroid of the set of component
Geometries of highest dimension (since the lower-dimension geometries
contribute zero "weight" to the centroid).</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Computation will be more accurate if performed by the GEOS
module (enabled at compile time).</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 8.1.4, 9.5.5</p></div><div class="refsection" title="Examples"><a name="id36191250"></a><h2>Examples</h2><p>In each of the following illustrations, the blue dot represents
the centroid of the source geometry.</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_centroid01.png"><div class="caption"><p>Centroid of a
<code class="varname">MULTIPOINT</code></p></div></div></div></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_centroid02.png"><div class="caption"><p>Centroid of a
<code class="varname">LINESTRING</code></p></div></div></div></td></tr><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_centroid03.png"><div class="caption"><p>Centroid of a
<code class="varname">POLYGON</code></p></div></div></div></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_centroid04.png"><div class="caption"><p>Centroid of a
<code class="varname">GEOMETRYCOLLECTION</code></p></div></div></div></td></tr></tbody></table></div><pre class="programlisting">SELECT ST_AsText(ST_Centroid('MULTIPOINT ( -1 0, -1 2, -1 3, -1 4, -1 7, 0 1, 0 3, 1 1, 2 0, 6 0, 7 8, 9 8, 10 6 )'));
st_astext
------------------------------------------
POINT(2.30769230769231 3.30769230769231)
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36191387"></a><h2>See Also</h2><p><a class="xref" href="#ST_PointOnSurface" title="ST_PointOnSurface">ST_PointOnSurface</a></p></div></div><div class="refentry" title="ST_ClosestPoint"><div class="refentry.separator"><hr></div><a name="ST_ClosestPoint"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_ClosestPoint — Returns the 2-dimensional point on g1 that is closest to g2. This is the first point of
the shortest line.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_ClosestPoint</b>(</code>geometry
<var class="pdparam">g1</var>, geometry
<var class="pdparam">g2</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36191454"></a><h2>Description</h2><p>Returns the 2-dimensional point on g1 that is closest to g2. This is the first point of
the shortest line.
</p><p>Availability: 1.5.0</p></div><div class="refsection" title="Examples"><a name="id36191468"></a><h2>Examples</h2><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_closestpoint01.png"><div class="caption"><p>Closest between point and linestring is the point itself, but closest
point between a linestring and point is the point on line string that is closest.</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_AsText(ST_ClosestPoint(pt,line)) AS cp_pt_line,
ST_AsText(ST_ClosestPoint(line,pt)) As cp_line_pt
FROM (SELECT 'POINT(100 100)'::geometry As pt,
'LINESTRING (20 80, 98 190, 110 180, 50 75 )'::geometry As line
) As foo;
cp_pt_line | cp_line_pt
----------------+------------------------------------------
POINT(100 100) | POINT(73.0769230769231 115.384615384615)
</pre><p>
</p></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_closestpoint02.png"><div class="caption"><p>closest point on polygon A to polygon B</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_AsText(
ST_ClosestPoint(
ST_GeomFromText('POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))'),
ST_Buffer(ST_GeomFromText('POINT(110 170)'), 20)
)
) As ptwkt;
ptwkt
------------------------------------------
POINT(140.752120669087 125.695053378061)
</pre><p>
</p></td></tr></tbody></table></div></div><div class="refsection" title="See Also"><a name="id36191554"></a><h2>See Also</h2><p><a class="xref" href="#ST_Distance" title="ST_Distance">ST_Distance</a>, <a class="xref" href="#ST_LongestLine" title="ST_LongestLine">ST_LongestLine</a>, <a class="xref" href="#ST_ShortestLine" title="ST_ShortestLine">ST_ShortestLine</a>, <a class="xref" href="#ST_MaxDistance" title="ST_MaxDistance">ST_MaxDistance</a></p></div></div><div class="refentry" title="ST_Contains"><div class="refentry.separator"><hr></div><a name="ST_Contains"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Contains — Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A. </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_Contains</b>(</code>geometry
<var class="pdparam">geomA</var>, geometry
<var class="pdparam">geomB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36191639"></a><h2>Description</h2><p>Geometry A contains Geometry B if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A.
An important subtlety of this definition is that A does not contain its boundary, but A does contain itself. Contrast that to <a class="xref" href="#ST_ContainsProperly" title="ST_ContainsProperly">ST_ContainsProperly</a> where geometry
A does not Contain Properly itself.</p><p>Returns TRUE if geometry B is completely inside geometry A. For this function to make
sense, the source geometries must both be of the same coordinate projection,
having the same SRID. ST_Contains is the inverse of ST_Within. So ST_Contains(A,B) implies ST_Within(B,A) except in the case of
invalid geometries where the result is always false regardless or not defined.</p><p>Performed by the GEOS module</p><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a <code class="varname">GEOMETRYCOLLECTION</code> as an argument</p></td></tr></table></div><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not use this function with invalid geometries. You will get unexpected results.</p></td></tr></table></div><p>This function call will automatically include a bounding box
comparison that will make use of any indexes that are available on
the geometries. To avoid index use, use the function
_ST_Contains.</p><p>NOTE: this is the "allowable" version that returns a
boolean, not an integer.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.2 // s2.1.13.3
- same as within(geometry B, geometry A)</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.31</p><p>There are certain subtleties to ST_Contains and ST_Within that are not intuitively obvious.
For details check out <a class="ulink" href="http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html" target="_top">Subtleties of OGC Covers, Contains, Within</a></p></div><div class="refsection" title="Examples"><a name="id36191736"></a><h2>Examples</h2><p>The <code class="function">ST_Contains</code> predicate returns <code class="varname">TRUE</code> in all the following illustrations.</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_contains01.png"><div class="caption"><p><code class="varname">LINESTRING</code> / <code class="varname">MULTIPOINT</code></p></div></div></div></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_contains02.png"><div class="caption"><p><code class="varname">POLYGON</code> / <code class="varname">POINT</code></p></div></div></div></td></tr><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_contains03.png"><div class="caption"><p><code class="varname">POLYGON</code> / <code class="varname">LINESTRING</code></p></div></div></div></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_contains04.png"><div class="caption"><p><code class="varname">POLYGON</code> / <code class="varname">POLYGON</code></p></div></div></div></td></tr></tbody></table></div><p>The <code class="function">ST_Contains</code> predicate returns <code class="varname">FALSE</code> in all the following illustrations.</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_contains05.png"><div class="caption"><p><code class="varname">POLYGON</code> / <code class="varname">MULTIPOINT</code></p></div></div></div></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_contains06.png"><div class="caption"><p><code class="varname">POLYGON</code> / <code class="varname">LINESTRING</code></p></div></div></div></td></tr></tbody></table></div><pre class="programlisting">
-- A circle within a circle
SELECT ST_Contains(smallc, bigc) As smallcontainsbig,
ST_Contains(bigc,smallc) As bigcontainssmall,
ST_Contains(bigc, ST_Union(smallc, bigc)) as bigcontainsunion,
ST_Equals(bigc, ST_Union(smallc, bigc)) as bigisunion,
ST_Covers(bigc, ST_ExteriorRing(bigc)) As bigcoversexterior,
ST_Contains(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior
FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
-- Result
smallcontainsbig | bigcontainssmall | bigcontainsunion | bigisunion | bigcoversexterior | bigcontainsexterior
------------------+------------------+------------------+------------+-------------------+---------------------
f | t | t | t | t | f
-- Example demonstrating difference between contains and contains properly
SELECT ST_GeometryType(geomA) As geomtype, ST_Contains(geomA,geomA) AS acontainsa, ST_ContainsProperly(geomA, geomA) AS acontainspropa,
ST_Contains(geomA, ST_Boundary(geomA)) As acontainsba, ST_ContainsProperly(geomA, ST_Boundary(geomA)) As acontainspropba
FROM (VALUES ( ST_Buffer(ST_Point(1,1), 5,1) ),
( ST_MakeLine(ST_Point(1,1), ST_Point(-1,-1) ) ),
( ST_Point(1,1) )
) As foo(geomA);
geomtype | acontainsa | acontainspropa | acontainsba | acontainspropba
--------------+------------+----------------+-------------+-----------------
ST_Polygon | t | f | f | f
ST_LineString | t | f | f | f
ST_Point | t | t | f | f
</pre></div><div class="refsection" title="See Also"><a name="id36191967"></a><h2>See Also</h2><p><a class="xref" href="#ST_Boundary" title="ST_Boundary">ST_Boundary</a>, <a class="xref" href="#ST_ContainsProperly" title="ST_ContainsProperly">ST_ContainsProperly</a>, <a class="xref" href="#ST_Covers" title="ST_Covers">ST_Covers</a>,<a class="xref" href="#ST_CoveredBy" title="ST_CoveredBy">ST_CoveredBy</a>, <a class="xref" href="#ST_Equals" title="ST_Equals">ST_Equals</a>,<a class="xref" href="#ST_Within" title="ST_Within">ST_Within</a></p></div></div><div class="refentry" title="ST_ContainsProperly"><div class="refentry.separator"><hr></div><a name="ST_ContainsProperly"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_ContainsProperly — Returns true if B intersects the interior of A but not the boundary (or exterior). A does not contain properly itself, but does contain itself.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_ContainsProperly</b>(</code>geometry
<var class="pdparam">geomA</var>, geometry
<var class="pdparam">geomB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36192061"></a><h2>Description</h2><p>Returns true if B intersects the interior of A but not the boundary (or exterior).</p><p>A does not contain properly itself, but does contain itself.</p><p>Every point of the other geometry is a point of this geometry's interior. The DE-9IM Intersection Matrix for the two geometries matches
[T**FF*FF*] used in <a class="xref" href="#ST_Relate" title="ST_Relate">ST_Relate</a></p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>From JTS docs slightly reworded: The advantage to using this predicate over <a class="xref" href="#ST_Contains" title="ST_Contains">ST_Contains</a> and <a class="xref" href="#ST_Intersects" title="ST_Intersects">ST_Intersects</a> is that it can be computed
efficiently, with no need to compute topology at individual points.</p><p>
An example use case for this predicate is computing the intersections
of a set of geometries with a large polygonal geometry.
Since intersection is a fairly slow operation, it can be more efficient
to use containsProperly to filter out test geometries which lie
wholly inside the area. In these cases the intersection is
known a priori to be exactly the original test geometry.
</p></td></tr></table></div><p>Availability: 1.4.0 - requires GEOS >= 3.1.0.</p><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a <code class="varname">GEOMETRYCOLLECTION</code> as an argument</p></td></tr></table></div><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not use this function with invalid geometries. You will get unexpected results.</p></td></tr></table></div><p>This function call will automatically include a bounding box
comparison that will make use of any indexes that are available on
the geometries. To avoid index use, use the function
_ST_ContainsProperly.</p></div><div class="refsection" title="Examples"><a name="id36192136"></a><h2>Examples</h2><pre class="programlisting">
--a circle within a circle
SELECT ST_ContainsProperly(smallc, bigc) As smallcontainspropbig,
ST_ContainsProperly(bigc,smallc) As bigcontainspropsmall,
ST_ContainsProperly(bigc, ST_Union(smallc, bigc)) as bigcontainspropunion,
ST_Equals(bigc, ST_Union(smallc, bigc)) as bigisunion,
ST_Covers(bigc, ST_ExteriorRing(bigc)) As bigcoversexterior,
ST_ContainsProperly(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior
FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
--Result
smallcontainspropbig | bigcontainspropsmall | bigcontainspropunion | bigisunion | bigcoversexterior | bigcontainsexterior
------------------+------------------+------------------+------------+-------------------+---------------------
f | t | f | t | t | f
--example demonstrating difference between contains and contains properly
SELECT ST_GeometryType(geomA) As geomtype, ST_Contains(geomA,geomA) AS acontainsa, ST_ContainsProperly(geomA, geomA) AS acontainspropa,
ST_Contains(geomA, ST_Boundary(geomA)) As acontainsba, ST_ContainsProperly(geomA, ST_Boundary(geomA)) As acontainspropba
FROM (VALUES ( ST_Buffer(ST_Point(1,1), 5,1) ),
( ST_MakeLine(ST_Point(1,1), ST_Point(-1,-1) ) ),
( ST_Point(1,1) )
) As foo(geomA);
geomtype | acontainsa | acontainspropa | acontainsba | acontainspropba
--------------+------------+----------------+-------------+-----------------
ST_Polygon | t | f | f | f
ST_LineString | t | f | f | f
ST_Point | t | t | f | f
</pre></div><div class="refsection" title="See Also"><a name="id36192148"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeometryType" title="ST_GeometryType">ST_GeometryType</a>, <a class="xref" href="#ST_Boundary" title="ST_Boundary">ST_Boundary</a>, <a class="xref" href="#ST_Contains" title="ST_Contains">ST_Contains</a>, <a class="xref" href="#ST_Covers" title="ST_Covers">ST_Covers</a>,<a class="xref" href="#ST_CoveredBy" title="ST_CoveredBy">ST_CoveredBy</a>, <a class="xref" href="#ST_Equals" title="ST_Equals">ST_Equals</a>,<a class="xref" href="#ST_Relate" title="ST_Relate">ST_Relate</a>,<a class="xref" href="#ST_Within" title="ST_Within">ST_Within</a></p></div></div><div class="refentry" title="ST_Covers"><div class="refentry.separator"><hr></div><a name="ST_Covers"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Covers — Returns 1 (TRUE) if no point in Geometry B is outside
Geometry A. For geography: if geography point B is not outside Polygon Geography A</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_Covers</b>(</code>geometry
<var class="pdparam">geomA</var>, geometry
<var class="pdparam">geomB</var><code>)</code>;</p><p><code class="funcdef">boolean <b class="fsfunc">ST_Covers</b>(</code>geography
<var class="pdparam">geogpolyA</var>, geography
<var class="pdparam">geogpointB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36192278"></a><h2>Description</h2><p>Returns 1 (TRUE) if no point in Geometry/Geography B is outside
Geometry/Geography A</p><p>Performed by the GEOS module</p><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a <code class="varname">GEOMETRYCOLLECTION</code> as an argument</p></td></tr></table></div><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>For geography only Polygon covers point is supported.</p></td></tr></table></div><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not use this function with invalid geometries. You will get unexpected results.</p></td></tr></table></div><p>This function call will automatically include a bounding box
comparison that will make use of any indexes that are available on
the geometries. To avoid index use, use the function
_ST_Covers.</p><p>Availability: 1.2.2 - requires GEOS >= 3.0</p><p>Availability: 1.5 - support for geography was introduced. </p><p>NOTE: this is the "allowable" version that returns a
boolean, not an integer.</p><p>Not an OGC standard, but Oracle has it too.</p><p>There are certain subtleties to ST_Contains and ST_Within that are not intuitively obvious.
For details check out <a class="ulink" href="http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html" target="_top">Subtleties of OGC Covers, Contains, Within</a></p></div><div class="refsection" title="Examples"><a name="id36192346"></a><h2>Examples</h2><p> Geometry example </p><pre class="programlisting">
--a circle covering a circle
SELECT ST_Covers(smallc,smallc) As smallinsmall,
ST_Covers(smallc, bigc) As smallcoversbig,
ST_Covers(bigc, ST_ExteriorRing(bigc)) As bigcoversexterior,
ST_Contains(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior
FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
--Result
smallinsmall | smallcoversbig | bigcoversexterior | bigcontainsexterior
--------------+----------------+-------------------+---------------------
t | f | t | f
(1 row) </pre><p>Geeography Example</p><pre class="programlisting">
-- a point with a 300 meter buffer compared to a point, a point and its 10 meter buffer
SELECT ST_Covers(geog_poly, geog_pt) As poly_covers_pt,
ST_Covers(ST_Buffer(geog_pt,10), geog_pt) As buff_10m_covers_cent
FROM (SELECT ST_Buffer(ST_GeogFromText('SRID=4326;POINT(-99.327 31.4821)'), 300) As geog_poly,
ST_GeogFromText('SRID=4326;POINT(-99.33 31.483)') As geog_pt ) As foo;
poly_covers_pt | buff_10m_covers_cent
----------------+------------------
f | t
</pre></div><div class="refsection" title="See Also"><a name="id36192379"></a><h2>See Also</h2><p><a class="xref" href="#ST_Contains" title="ST_Contains">ST_Contains</a>, <a class="xref" href="#ST_CoveredBy" title="ST_CoveredBy">ST_CoveredBy</a>, <a class="xref" href="#ST_Within" title="ST_Within">ST_Within</a></p></div></div><div class="refentry" title="ST_CoveredBy"><div class="refentry.separator"><hr></div><a name="ST_CoveredBy"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_CoveredBy — Returns 1 (TRUE) if no point in Geometry/Geography A is outside
Geometry/Geography B</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_CoveredBy</b>(</code>geometry
<var class="pdparam">geomA</var>, geometry
<var class="pdparam">geomB</var><code>)</code>;</p><p><code class="funcdef">boolean <b class="fsfunc">ST_CoveredBy</b>(</code>geography
<var class="pdparam">geogA</var>, geography
<var class="pdparam">geogB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36192485"></a><h2>Description</h2><p>Returns 1 (TRUE) if no point in Geometry/Geography A is outside
Geometry/Geography B</p><p>Performed by the GEOS module</p><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a <code class="varname">GEOMETRYCOLLECTION</code> as an argument</p></td></tr></table></div><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not use this function with invalid geometries. You will get unexpected results.</p></td></tr></table></div><p>Availability: 1.2.2 - requires GEOS >= 3.0</p><p>This function call will automatically include a bounding box
comparison that will make use of any indexes that are available on
the geometries. To avoid index use, use the function
_ST_CoveredBy.</p><p>NOTE: this is the "allowable" version that returns a
boolean, not an integer.</p><p>Not an OGC standard, but Oracle has it too.</p><p>There are certain subtleties to ST_Contains and ST_Within that are not intuitively obvious.
For details check out <a class="ulink" href="http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html" target="_top">Subtleties of OGC Covers, Contains, Within</a></p></div><div class="refsection" title="Examples"><a name="id36192542"></a><h2>Examples</h2><pre class="programlisting">
--a circle coveredby a circle
SELECT ST_CoveredBy(smallc,smallc) As smallinsmall,
ST_CoveredBy(smallc, bigc) As smallcoveredbybig,
ST_CoveredBy(ST_ExteriorRing(bigc), bigc) As exteriorcoveredbybig,
ST_Within(ST_ExteriorRing(bigc),bigc) As exeriorwithinbig
FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
--Result
smallinsmall | smallcoveredbybig | exteriorcoveredbybig | exeriorwithinbig
--------------+-------------------+----------------------+------------------
t | t | t | f
(1 row) </pre></div><div class="refsection" title="See Also"><a name="id36192559"></a><h2>See Also</h2><p><a class="xref" href="#ST_Contains" title="ST_Contains">ST_Contains</a>, <a class="xref" href="#ST_Covers" title="ST_Covers">ST_Covers</a>, <a class="xref" href="#ST_ExteriorRing" title="ST_ExteriorRing">ST_ExteriorRing</a>, <a class="xref" href="#ST_Within" title="ST_Within">ST_Within</a></p></div></div><div class="refentry" title="ST_Crosses"><div class="refentry.separator"><hr></div><a name="ST_Crosses"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Crosses — Returns <code class="varname">TRUE</code> if the supplied geometries have some, but not all,
interior points in common.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_Crosses</b>(</code>geometry <var class="pdparam">g1</var>, geometry <var class="pdparam">g2</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36192641"></a><h2>Description</h2><p><code class="function">ST_Crosses</code> takes two geometry objects and
returns <code class="varname">TRUE</code> if their intersection "spatially cross", that is, the
geometries have some, but not all interior points in common. The
intersection of the interiors of the geometries must not be the empty
set and must have a dimensionality less than the the maximum dimension
of the two input geometries. Additionally, the intersection of the two
geometries must not equal either of the source geometries. Otherwise, it
returns <code class="varname">FALSE</code>.</p><p>In mathematical terms, this is expressed as:</p><p class="remark"><em><span class="remark">TODO: Insert appropriate MathML markup here or use a gif.
Simple HTML markup does not work well in both IE and Firefox.</span></em></p><div class="informalfigure"><div class="mediaobject"><img src="images/st_crosses-math.gif"></div></div><p>The DE-9IM Intersection Matrix for the two geometries is:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><span class="markup">T*T******</span> (for Point/Line, Point/Area, and
Line/Area situations)</p></li><li class="listitem"><p><span class="markup">T*****T**</span> (for Line/Point, Area/Point, and
Area/Line situations)</p></li><li class="listitem"><p><span class="markup">0********</span> (for Line/Line situations)</p></li></ul></div><p>For any other combination of dimensions this predicate returns
false.</p><p>The OpenGIS Simple Features Specification defines this predicate
only for Point/Line, Point/Area, Line/Line, and Line/Area situations.
JTS / GEOS extends the definition to apply to Line/Point, Area/Point and
Area/Line situations as well. This makes the relation
symmetric.</p><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a <code class="varname">GEOMETRYCOLLECTION</code> as an argument</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function call will automatically include a bounding box
comparison that will make use of any indexes that are available on the
geometries.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.13.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.29</p></div><div class="refsection" title="Examples"><a name="id36192784"></a><h2>Examples</h2><p>The following illustrations all return <code class="varname">TRUE</code>.</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_crosses01.png"><div class="caption"><p><code class="varname">MULTIPOINT</code> / <code class="varname">LINESTRING</code></p></div></div></div></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_crosses02.png"><div class="caption"><p><code class="varname">MULTIPOINT</code> / <code class="varname">POLYGON</code></p></div></div></div></td></tr><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_crosses03.png"><div class="caption"><p><code class="varname">LINESTRING</code> / <code class="varname">POLYGON</code></p></div></div></div></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_crosses04.png"><div class="caption"><p><code class="varname">LINESTRING</code> / <code class="varname">LINESTRING</code></p></div></div></div></td></tr></tbody></table></div><p>Consider a situation where a user has two tables: a table of roads
and a table of highways.</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><p> </p><div class="informalexample"><pre class="programlisting">CREATE TABLE roads (
id serial NOT NULL,
the_geom geometry,
CONSTRAINT roads_pkey PRIMARY KEY (road_id)
);</pre></div><p> </p></td><td><p> </p><div class="informalexample"><pre class="programlisting">CREATE TABLE highways (
id serial NOT NULL,
the_gem geometry,
CONSTRAINT roads_pkey PRIMARY KEY (road_id)
);</pre></div><p> </p></td></tr></tbody></table></div><p>To determine a list of roads that cross a highway, use a query
similiar to:</p><div class="informalexample"><pre class="programlisting">SELECT roads.id
FROM roads, highways
WHERE ST_Crosses(roads.the_geom, highways.the_geom);</pre></div></div></div><div class="refentry" title="ST_LineCrossingDirection"><div class="refentry.separator"><hr></div><a name="ST_LineCrossingDirection"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_LineCrossingDirection — Given 2 linestrings, returns a number between -3 and 3 denoting what kind of crossing behavior. 0 is no crossing.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_LineCrossingDirection</b>(</code>geometry <var class="pdparam">linestringA</var>, geometry <var class="pdparam">linestringB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36193037"></a><h2>Description</h2><p>Given 2 linestrings, returns a number between -3 and 3 denoting what kind of crossing behavior. 0 is no crossing. This is only supported for <code class="varname">LINESTRING</code></p><p>Definition of integer constants is as follows:
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p> 0: LINE NO CROSS</p></li><li class="listitem"><p>-1: LINE CROSS LEFT</p></li><li class="listitem"><p> 1: LINE CROSS RIGHT</p></li><li class="listitem"><p>-2: LINE MULTICROSS END LEFT</p></li><li class="listitem"><p> 2: LINE MULTICROSS END RIGHT</p></li><li class="listitem"><p>-3: LINE MULTICROSS END SAME FIRST LEFT</p></li><li class="listitem"><p> 3: LINE MULTICROSS END SAME FIRST RIGHT</p></li></ul></div><p>
</p><p>Availability: 1.4</p></div><div class="refsection" title="Examples"><a name="id36193111"></a><h2>Examples</h2><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_linecrossingdirection01.png"><div class="caption"><p>Line 1 (green), Line 2 ball is start point,
triangle are end points. Query below. </p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
FROM (
SELECT
ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
ST_GeomFromText('LINESTRING(171 154,20 140,71 74,161 53)') As line2
) As foo;
l1_cross_l2 | l2_cross_l1
-------------+-------------
3 | -3
</pre><p>
</p>
</td><td>
<div class="informalfigure"><div class="mediaobject"><img src="images/st_linecrossingdirection02.png"><div class="caption"><p>Line 1 (green), Line 2 (blue) ball is start point,
triangle are end points. Query below.</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
FROM (
SELECT
ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
ST_GeomFromText('LINESTRING (171 154, 20 140, 71 74, 2.99 90.16)') As line2
) As foo;
l1_cross_l2 | l2_cross_l1
-------------+-------------
2 | -2
</pre><p>
</p>
</td></tr><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_linecrossingdirection03.png"><div class="caption"><p>Line 1 (green), Line 2 (blue) ball is start point,
triangle are end points. Query below. </p></div></div></div><p>
</p><pre class="programlisting">
SELECT
ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
FROM (
SELECT
ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
ST_GeomFromText('LINESTRING (20 140, 71 74, 161 53)') As line2
) As foo;
l1_cross_l2 | l2_cross_l1
-------------+-------------
-1 | 1
</pre><p>
</p>
</td><td>
<div class="informalfigure"><div class="mediaobject"><img src="images/st_linecrossingdirection04.png"><div class="caption"><p>Line 1 (green), Line 2 (blue) ball is start point,
triangle are end points. Query below.</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
FROM (SELECT
ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
ST_GeomFromText('LINESTRING(2.99 90.16,71 74,20 140,171 154)') As line2
) As foo;
l1_cross_l2 | l2_cross_l1
-------------+-------------
-2 | 2
</pre><p>
</p>
</td></tr></tbody></table></div><pre class="programlisting">
SELECT s1.gid, s2.gid, ST_LineCrossingDirection(s1.the_geom, s2.the_geom)
FROM streets s1 CROSS JOIN streets s2 ON (s1.gid != s2.gid AND s1.the_geom && s2.the_geom )
WHERE ST_CrossingDirection(s1.the_geom, s2.the_geom) > 0;
</pre></div><div class="refsection" title="See Also"><a name="id36193421"></a><h2>See Also</h2><p><a class="xref" href="#ST_Crosses" title="ST_Crosses">ST_Crosses</a></p></div></div><div class="refentry" title="ST_Disjoint"><div class="refentry.separator"><hr></div><a name="ST_Disjoint"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Disjoint — Returns TRUE if the Geometries do not "spatially
intersect" - if they do not share any space together.
</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_Disjoint</b>(</code>
geometry
<var class="pdparam">A</var>
,
geometry
<var class="pdparam">B</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36193491"></a><h2>Description</h2><p>Overlaps, Touches, Within all imply geometries are not spatially disjoint. If any of the aforementioned
returns true, then the geometries are not spatially disjoint.
Disjoint implies false for spatial intersection.</p><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a <code class="varname">GEOMETRYCOLLECTION</code> as an argument</p></td></tr></table></div><p>Performed by the GEOS module</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function call does not use indexes</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>NOTE: this is the "allowable" version that returns a
boolean, not an integer.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.2 //s2.1.13.3
- a.Relate(b, 'FF*FF****')</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.26</p></div><div class="refsection" title="Examples"><a name="id36193563"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_Disjoint('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry);
st_disjoint
---------------
t
(1 row)
SELECT ST_Disjoint('POINT(0 0)'::geometry, 'LINESTRING ( 0 0, 0 2 )'::geometry);
st_disjoint
---------------
f
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36193577"></a><h2>See Also</h2><p><a class="xref" href="#ST_Intersects" title="ST_Intersects">ST_Intersects</a>ST_Intersects</p></div></div><div class="refentry" title="ST_Distance"><div class="refentry.separator"><hr></div><a name="ST_Distance"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Distance — For geometry type Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in
projected units. For geography type defaults to return spheroidal minimum distance between two geographies in meters.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Distance</b>(</code>geometry
<var class="pdparam">g1</var>, geometry
<var class="pdparam">g2</var><code>)</code>;</p><p><code class="funcdef">float <b class="fsfunc">ST_Distance</b>(</code>geography
<var class="pdparam">gg1</var>, geography
<var class="pdparam">gg2</var><code>)</code>;</p><p><code class="funcdef">float <b class="fsfunc">ST_Distance</b>(</code>geography
<var class="pdparam">gg1</var>, geography
<var class="pdparam">gg2</var>, boolean
<var class="pdparam">use_spheroid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36193715"></a><h2>Description</h2><p>For geometry type returns the 2-dimensional minimum cartesian distance between two geometries in
projected units (spatial ref units). For geography type defaults to return the minimum distance around WGS 84 spheroid between two geographies in meters. Pass in
false to return answer in sphere instead of spheroid.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.23</p><p>Availability: 1.5.0 geography support was introduced in 1.5. Speed improvements for planar to better handle large or many vertex geometries</p></div><div class="refsection" title="Examples"><a name="id36193764"></a><h2>Examples</h2><pre class="programlisting">
--Geometry example - units in planar degrees 4326 is WGS 84 long lat unit=degrees
SELECT ST_Distance(
ST_GeomFromText('POINT(-72.1235 42.3521)',4326),
ST_GeomFromText('LINESTRING(-72.1260 42.45, -72.123 42.1546)', 4326)
);
st_distance
-----------------
0.00150567726382282
-- Geometry example - units in meters (SRID: 26986 Massachusetts state plane meters) (most accurate for Massachusetts)
SELECT ST_Distance(
ST_Transform(ST_GeomFromText('POINT(-72.1235 42.3521)',4326),26986),
ST_Transform(ST_GeomFromText('LINESTRING(-72.1260 42.45, -72.123 42.1546)', 4326),26986)
);
st_distance
-----------------
123.797937878454
-- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (least accurate)
SELECT ST_Distance(
ST_Transform(ST_GeomFromText('POINT(-72.1235 42.3521)',4326),2163),
ST_Transform(ST_GeomFromText('LINESTRING(-72.1260 42.45, -72.123 42.1546)', 4326),2163)
);
st_distance
------------------
126.664256056812
-- Geography example -- same but note units in meters - use sphere for slightly faster less accurate
SELECT ST_Distance(gg1, gg2) As spheroid_dist, ST_Distance(gg1, gg2, false) As sphere_dist
FROM (SELECT
ST_GeographyFromText('SRID=4326;POINT(-72.1235 42.3521)') As gg1,
ST_GeographyFromText('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)') As gg2
) As foo ;
spheroid_dist | sphere_dist
------------------+------------------
123.802076746848 | 123.475736916397
</pre></div><div class="refsection" title="See Also"><a name="id36193775"></a><h2>See Also</h2><p><a class="xref" href="#ST_DWithin" title="ST_DWithin">ST_DWithin</a>, <a class="xref" href="#ST_Distance_Sphere" title="ST_Distance_Sphere">ST_Distance_Sphere</a>, <a class="xref" href="#ST_Distance_Spheroid" title="ST_Distance_Spheroid">ST_Distance_Spheroid</a>, <a class="xref" href="#ST_MaxDistance" title="ST_MaxDistance">ST_MaxDistance</a>, <a class="xref" href="#ST_Transform" title="ST_Transform">ST_Transform</a></p></div></div><div class="refentry" title="ST_HausdorffDistance"><div class="refentry.separator"><hr></div><a name="ST_HausdorffDistance"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_HausdorffDistance — Returns the Hausdorff distance between two geometries. Basically a measure of how similar or dissimilar 2 geometries are. Units are in the units of the spatial
reference system of the geometries.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_HausdorffDistance</b>(</code>geometry
<var class="pdparam">g1</var>, geometry
<var class="pdparam">g2</var><code>)</code>;</p><p><code class="funcdef">float <b class="fsfunc">ST_HausdorffDistance</b>(</code>geometry
<var class="pdparam">g1</var>, geometry
<var class="pdparam">g2</var>, float
<var class="pdparam">densifyFrac</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36193906"></a><h2>Description</h2><p>Implements algorithm for computing a distance metric which can be thought of as the "Discrete Hausdorff Distance".
This is the Hausdorff distance restricted to discrete points for one of the geometries. <a class="ulink" href="http://en.wikipedia.org/wiki/Hausdorff_distance" target="_top">Wikipedia article on Hausdorff distance</a>
<a class="ulink" href="http://lin-ear-th-inking.blogspot.com/2009/01/computing-geometric-similarity.html" target="_top">Martin Davis note on how Hausdorff Distance calculation was used to prove correctness of the CascadePolygonUnion approach.</a></p><p>
When densifyFrac is specified, this function performs a segment densification before computing the discrete hausdorff distance. The densifyFrac parameter sets the fraction by which to densify each segment. Each segment will be split into a number of equal-length subsegments, whose fraction of the total length is closest to the given fraction.
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>
The current implementation supports only vertices as the discrete locations. This could be extended to allow an arbitrary density of points to be used.
</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>
This algorithm is NOT equivalent to the standard Hausdorff distance. However, it computes an approximation that is correct for a large subset of useful cases.
One important part of this subset is Linestrings that are roughly parallel to each other, and roughly equal in length. This is a useful metric for line matching.
</p></td></tr></table></div><p>Availability: 1.5.0 - requires GEOS >= 3.2.0</p></div><div class="refsection" title="Examples"><a name="id36193956"></a><h2>Examples</h2><pre class="programlisting">postgis=# SELECT st_HausdorffDistance(
'LINESTRING (0 0, 2 0)'::geometry,
'MULTIPOINT (0 1, 1 0, 2 1)'::geometry);
st_hausdorffdistance
----------------------
1
(1 row)
</pre><pre class="programlisting">postgis=# SELECT st_hausdorffdistance('LINESTRING (130 0, 0 0, 0 150)'::geometry, 'LINESTRING (10 10, 10 150, 130 10)'::geometry, 0.5);
st_hausdorffdistance
----------------------
70
(1 row)
</pre></div></div><div class="refentry" title="ST_MaxDistance"><div class="refentry.separator"><hr></div><a name="ST_MaxDistance"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MaxDistance — Returns the 2-dimensional largest distance between two geometries in
projected units.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_MaxDistance</b>(</code>geometry <var class="pdparam">g1</var>, geometry <var class="pdparam">g2</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36194029"></a><h2>Description</h2><p>Some useful description here.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Returns the 2-dimensional maximum distance between two linestrings in
projected units. If g1 and g2 is the same geometry the function will return the distance between
the two vertices most far from each other in that geometry.</p></td></tr></table></div><p>Availability: 1.5.0</p></div><div class="refsection" title="Examples"><a name="id36194054"></a><h2>Examples</h2><pre class="programlisting">postgis=# SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry);
st_maxdistance
-----------------
2
(1 row)
postgis=# SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 2, 2 2 )'::geometry);
st_maxdistance
------------------
2.82842712474619
(1 row)</pre></div><div class="refsection" title="See Also"><a name="id36194072"></a><h2>See Also</h2><p><a class="xref" href="#ST_Distance" title="ST_Distance">ST_Distance</a>, <a class="xref" href="#ST_LongestLine" title="ST_LongestLine">ST_LongestLine</a></p></div></div><div class="refentry" title="ST_Distance_Sphere"><div class="refentry.separator"><hr></div><a name="ST_Distance_Sphere"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Distance_Sphere — Returns minimum distance in meters between two lon/lat
geometries. Uses a spherical earth and radius of 6370986 meters.
Faster than <a class="xref" href="#ST_Distance_Spheroid" title="ST_Distance_Spheroid">ST_Distance_Spheroid</a>, but less
accurate. PostGIS versions prior to 1.5 only implemented for points.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Distance_Sphere</b>(</code>geometry <var class="pdparam">geomlonlatA</var>, geometry <var class="pdparam">geomlonlatB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36194150"></a><h2>Description</h2><p>Returns minimum distance in meters between two lon/lat
points. Uses a spherical earth and radius of 6370986 meters.
Faster than <a class="xref" href="#ST_Distance_Spheroid" title="ST_Distance_Spheroid">ST_Distance_Spheroid</a>, but less
accurate. PostGIS Versions prior to 1.5 only implemented for points.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function currently does not look at the SRID of a geometry and will always assume its in WGS 84 long lat. Prior versions of this function only support points.</p></td></tr></table></div><p>Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points.</p></div><div class="refsection" title="Examples"><a name="id36194179"></a><h2>Examples</h2><pre class="programlisting">SELECT round(CAST(ST_Distance_Sphere(ST_Centroid(the_geom), ST_GeomFromText('POINT(-118 38)',4326)) As numeric),2) As dist_meters,
round(CAST(ST_Distance(ST_Transform(ST_Centroid(the_geom),32611),
ST_Transform(ST_GeomFromText('POINT(-118 38)', 4326),32611)) As numeric),2) As dist_utm11_meters,
round(CAST(ST_Distance(ST_Centroid(the_geom), ST_GeomFromText('POINT(-118 38)', 4326)) As numeric),5) As dist_degrees,
round(CAST(ST_Distance(ST_Transform(the_geom,32611),
ST_Transform(ST_GeomFromText('POINT(-118 38)', 4326),32611)) As numeric),2) As min_dist_line_point_meters
FROM
(SELECT ST_GeomFromText('LINESTRING(-118.584 38.374,-118.583 38.5)', 4326) As the_geom) as foo;
dist_meters | dist_utm11_meters | dist_degrees | min_dist_line_point_meters
-------------+-------------------+--------------+----------------------------
70424.47 | 70438.00 | 0.72900 | 65871.18
</pre></div><div class="refsection" title="See Also"><a name="id36194202"></a><h2>See Also</h2><p><a class="xref" href="#ST_Distance" title="ST_Distance">ST_Distance</a>, <a class="xref" href="#ST_Distance_Spheroid" title="ST_Distance_Spheroid">ST_Distance_Spheroid</a></p></div></div><div class="refentry" title="ST_Distance_Spheroid"><div class="refentry.separator"><hr></div><a name="ST_Distance_Spheroid"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Distance_Spheroid — Returns the minimum distance between two lon/lat geometries given a
particular spheroid.
PostGIS versions prior to 1.5 only support points.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Distance_Spheroid</b>(</code>geometry <var class="pdparam">geomlonlatA</var>, geometry <var class="pdparam">geomlonlatB</var>, spheroid <var class="pdparam">measurement_spheroid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36194283"></a><h2>Description</h2><p>Returns minimum distance in meters between two lon/lat
geometries given a particular spheroid. See the explanation of spheroids given for
<a class="xref" href="#ST_Length_Spheroid" title="ST_Length_Spheroid">ST_Length_Spheroid</a>. PostGIS version prior to 1.5 only support points.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function currently does not look at the SRID of a geometry and will always assume its represented in the coordinates of the passed in spheroid. Prior versions of this function only support points.</p></td></tr></table></div><p>Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points.</p></div><div class="refsection" title="Examples"><a name="id36194313"></a><h2>Examples</h2><pre class="programlisting">SELECT round(CAST(
ST_Distance_Spheroid(ST_Centroid(the_geom), ST_GeomFromText('POINT(-118 38)',4326), 'SPHEROID["WGS 84",6378137,298.257223563]')
As numeric),2) As dist_meters_spheroid,
round(CAST(ST_Distance_Sphere(ST_Centroid(the_geom), ST_GeomFromText('POINT(-118 38)',4326)) As numeric),2) As dist_meters_sphere,
round(CAST(ST_Distance(ST_Transform(ST_Centroid(the_geom),32611),
ST_Transform(ST_GeomFromText('POINT(-118 38)', 4326),32611)) As numeric),2) As dist_utm11_meters
FROM
(SELECT ST_GeomFromText('LINESTRING(-118.584 38.374,-118.583 38.5)', 4326) As the_geom) as foo;
dist_meters_spheroid | dist_meters_sphere | dist_utm11_meters
----------------------+--------------------+-------------------
70454.92 | 70424.47 | 70438.00
</pre></div><div class="refsection" title="See Also"><a name="id36194328"></a><h2>See Also</h2><p><a class="xref" href="#ST_Distance" title="ST_Distance">ST_Distance</a>, <a class="xref" href="#ST_Distance_Sphere" title="ST_Distance_Sphere">ST_Distance_Sphere</a></p></div></div><div class="refentry" title="ST_DFullyWithin"><div class="refentry.separator"><hr></div><a name="ST_DFullyWithin"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_DFullyWithin — Returns true if all of the geometries are within the specified
distance of one another</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_DFullyWithin</b>(</code>geometry
<var class="pdparam">g1</var>, geometry
<var class="pdparam">g2</var>, double precision
<var class="pdparam">distance</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36194408"></a><h2>Description</h2><p>Returns true if the geometries is fully within the specified distance
of one another. The distance is specified in units defined by the
spatial reference system of the geometries. For this function to make
sense, the source geometries must both be of the same coordinate projection,
having the same SRID.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function call will automatically include a bounding box
comparison that will make use of any indexes that are available on
the geometries.</p></td></tr></table></div><p>Availability: 1.5.0</p></div><div class="refsection" title="Examples"><a name="id36194431"></a><h2>Examples</h2><pre class="programlisting">postgis=# SELECT ST_DFullyWithin(geom_a, geom_b, 10) as DFullyWithin10, ST_DWithin(geom_a, geom_b, 10) as DWithin10, ST_DFullyWithin(geom_a, geom_b, 20) as DFullyWithin20 from
(select ST_GeomFromText('POINT(1 1)') as geom_a,ST_GeomFromText('LINESTRING(1 5, 2 7, 1 9, 14 12)') as geom_b) t1;
-----------------
DFullyWithin10 | DWithin10 | DFullyWithin20 |
---------------+----------+---------------+
f | t | t | </pre></div><div class="refsection" title="See Also"><a name="id36194447"></a><h2>See Also</h2><p><a class="xref" href="#ST_MaxDistance" title="ST_MaxDistance">ST_MaxDistance</a>, <a class="xref" href="#ST_DWithin" title="ST_DWithin">ST_DWithin</a></p></div></div><div class="refentry" title="ST_DWithin"><div class="refentry.separator"><hr></div><a name="ST_DWithin"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_DWithin — Returns true if the geometries are within the specified
distance of one another. For geometry units are in those of spatial reference and For geography units are in meters and measurement is
defaulted to use_spheroid=true (measure around spheroid), for faster check, use_spheroid=false to measure along sphere.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_DWithin</b>(</code>geometry
<var class="pdparam">g1</var>, geometry
<var class="pdparam">g2</var>, double precision
<var class="pdparam">distance_of_srid</var><code>)</code>;</p><p><code class="funcdef">boolean <b class="fsfunc">ST_DWithin</b>(</code>geography
<var class="pdparam">gg1</var>, geography
<var class="pdparam">gg2</var>, double precision
<var class="pdparam">distance_meters</var><code>)</code>;</p><p><code class="funcdef">boolean <b class="fsfunc">ST_DWithin</b>(</code>geography
<var class="pdparam">gg1</var>, geography
<var class="pdparam">gg2</var>, double precision
<var class="pdparam">distance_meters</var>, boolean
<var class="pdparam">use_spheroid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36194619"></a><h2>Description</h2><p>Returns true if the geometries are within the specified distance
of one another.</p><p>For Geometries: The distance is specified in units defined by the
spatial reference system of the geometries. For this function to make
sense, the source geometries must both be of the same coorindate projection,
having the same SRID.</p><p>For geography units are in meters and measurement is
defaulted to use_spheroid=true (measure around WGS 84 spheroid), for faster check, use_spheroid=false to measure along sphere.
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function call will automatically include a bounding box
comparison that will make use of any indexes that are available on
the geometries.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Prior to 1.3, ST_Expand was commonly used in conjunction with && and ST_Distance to
achieve the same effect and in pre-1.3.4 this function was basically short-hand for that construct.
From 1.3.4, ST_DWithin uses a more short-circuit distance function which should make it more efficient
than prior versions for larger buffer regions.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p>Availability: 1.5.0 support for geography was introduced</p></div><div class="refsection" title="Examples"><a name="id36194681"></a><h2>Examples</h2><pre class="programlisting">
--Find the nearest hospital to each school
--that is within 3000 units of the school.
-- We do an ST_DWithin search to utilize indexes to limit our search list
-- that the non-indexable ST_Distance needs to process
--If the units of the spatial reference is meters then units would be meters
SELECT DISTINCT ON (s.gid) s.gid, s.school_name, s.the_geom, h.hospital_name
FROM schools s
LEFT JOIN hospitals h ON ST_DWithin(s.the_geom, h.the_geom, 3000)
ORDER BY s.gid, ST_Distance(s.the_geom, h.the_geom);
--The schools with no close hospitals
--Find all schools with no hospital within 3000 units
--away from the school. Units is in units of spatial ref (e.g. meters, feet, degrees)
SELECT s.gid, s.school_name
FROM schools s
LEFT JOIN hospitals h ON ST_DWithin(s.the_geom, h.the_geom, 3000)
WHERE h.gid IS NULL;
</pre></div><div class="refsection" title="See Also"><a name="id36194699"></a><h2>See Also</h2><p><a class="xref" href="#ST_Distance" title="ST_Distance">ST_Distance</a>, <a class="xref" href="#ST_Expand" title="ST_Expand">ST_Expand</a></p></div></div><div class="refentry" title="ST_Equals"><div class="refentry.separator"><hr></div><a name="ST_Equals"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Equals — Returns true if the given geometries represent the same geometry. Directionality
is ignored.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_Equals</b>(</code>geometry <var class="pdparam">A</var>, geometry <var class="pdparam">B</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36194771"></a><h2>Description</h2><p>Returns TRUE if the given Geometries are "spatially
equal". Use this for a 'better' answer than '='.
Note by spatially equal we mean ST_Within(A,B) = true and ST_Within(B,A) = true and
also mean ordering of points can be different but
represent the same geometry structure. To verify the order of points is consistent, use
ST_OrderingEquals (it must be noted ST_OrderingEquals is a little more stringent than simply verifying order of
points are the same).</p><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function will return false if either geometry is invalid even if they are binary equal.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.24</p></div><div class="refsection" title="Examples"><a name="id36194824"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_Equals(ST_GeomFromText('LINESTRING(0 0, 10 10)'),
ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)'));
st_equals
-----------
t
(1 row)
SELECT ST_Equals(ST_Reverse(ST_GeomFromText('LINESTRING(0 0, 10 10)')),
ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)'));
st_equals
-----------
t
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36194839"></a><h2>See Also</h2><p><a class="xref" href="#ST_IsValid" title="ST_IsValid">ST_IsValid</a>, <a class="xref" href="#ST_OrderingEquals" title="ST_OrderingEquals">ST_OrderingEquals</a>, <a class="xref" href="#ST_Reverse" title="ST_Reverse">ST_Reverse</a>, <a class="xref" href="#ST_Within" title="ST_Within">ST_Within</a></p></div></div><div class="refentry" title="ST_HasArc"><div class="refentry.separator"><hr></div><a name="ST_HasArc"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_HasArc — Returns true if a geometry or geometry collection contains a circular string</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_HasArc</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36194910"></a><h2>Description</h2><p>Returns true if a geometry or geometry collection contains a circular string</p><p>Availability: 1.2.3?</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36194949"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_HasArc(ST_Collect('LINESTRING(1 2, 3 4, 5 6)', 'CIRCULARSTRING(1 1, 2 3, 4 5, 6 7, 5 6)'));
st_hasarc
--------
t
</pre></div><div class="refsection" title="See Also"><a name="id36194965"></a><h2>See Also</h2><p><a class="xref" href="#ST_CurveToLine" title="ST_CurveToLine">ST_CurveToLine</a>,<a class="xref" href="#ST_LineToCurve" title="ST_LineToCurve">ST_LineToCurve</a></p></div></div><div class="refentry" title="ST_Intersects"><div class="refentry.separator"><hr></div><a name="ST_Intersects"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Intersects — Returns TRUE if the Geometries/Geography "spatially
intersect" - (share any portion of space) and FALSE if they don't (they are Disjoint).
For geography -- tolerance is 0.00001 meters (so any points that close are considered to intersect)
</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_Intersects</b>(</code>
geometry
<var class="pdparam">geomA</var>
,
geometry
<var class="pdparam">geomB</var>
<code>)</code>;</p><p><code class="funcdef">boolean <b class="fsfunc">ST_Intersects</b>(</code>
geography
<var class="pdparam">geogA</var>
,
geography
<var class="pdparam">geogB</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36195077"></a><h2>Description</h2><p>Overlaps, Touches, Within all imply spatial intersection. If any of the aforementioned
returns true, then the geometries also spatially intersect.
Disjoint implies false for spatial intersection.</p><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a <code class="varname">GEOMETRYCOLLECTION</code> as an argument for geometry version. The geography
version supports GEOMETRYCOLLECTION since its a thin wrapper around distance implementation.</p></td></tr></table></div><p>Performed by the GEOS module (for geometry), geography is native</p><p>Availability: 1.5 support for geography was introduced.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function call will automatically include a bounding box
comparison that will make use of any indexes that are available on the
geometries.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>For geography, this function has a distance tolerance of about 0.00001 meters and uses the sphere rather
than spheroid calculation.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>NOTE: this is the "allowable" version that returns a
boolean, not an integer.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.2 //s2.1.13.3
- ST_Intersects(g1, g2 ) --> Not (ST_Disjoint(g1, g2 ))
</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.27</p></div><div class="refsection" title="Geometry Examples"><a name="id36195164"></a><h2>Geometry Examples</h2><pre class="programlisting">SELECT ST_Intersects('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry);
st_intersects
---------------
f
(1 row)
SELECT ST_Intersects('POINT(0 0)'::geometry, 'LINESTRING ( 0 0, 0 2 )'::geometry);
st_intersects
---------------
t
(1 row)
</pre></div><div class="refsection" title="Geography Examples"><a name="id36195178"></a><h2>Geography Examples</h2><pre class="programlisting">SELECT ST_Intersects(
ST_GeographyFromText('SRID=4326;LINESTRING(-43.23456 72.4567,-43.23456 72.4568)'),
ST_GeographyFromText('SRID=4326;POINT(-43.23456 72.4567772)')
);
st_intersects
---------------
t
</pre></div><div class="refsection" title="See Also"><a name="id36195192"></a><h2>See Also</h2><p><a class="xref" href="#ST_Disjoint" title="ST_Disjoint">ST_Disjoint</a></p></div></div><div class="refentry" title="ST_Length"><div class="refentry.separator"><hr></div><a name="ST_Length"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Length — Returns the 2d length of the geometry if it is a linestring or multilinestring. geometry are in units of spatial reference and geography are in meters (default spheroid)</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Length</b>(</code>geometry <var class="pdparam">a_2dlinestring</var><code>)</code>;</p><p><code class="funcdef">float <b class="fsfunc">ST_Length</b>(</code>geography <var class="pdparam">gg</var><code>)</code>;</p><p><code class="funcdef">float <b class="fsfunc">ST_Length</b>(</code>geography <var class="pdparam">gg</var>, boolean <var class="pdparam">use_spheroid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36195295"></a><h2>Description</h2><p>For geometry: Returns the cartesian 2D length of the geometry if it is a linestring, multilinestring, ST_Curve, ST_MultiCurve. 0 is returned for
areal geometries. For areal geometries use ST_Perimeter. Geometry: Measurements are in the units of the
spatial reference system of the geometry. Geography: Units are in meters and also acts as a Perimeter function for areal geogs.</p><p>Currently for geometry this is an alias for ST_Length2D, but this may change to support higher dimensions.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Currently applying this to a MULTI/POLYGON of type geography will give you the perimeter of the POLYGON/MULTIPOLYGON. This is not the
case with the geometry implementation.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>For geography measurement defaults spheroid measurement. To use the faster less accurate sphere use ST_Length(gg,false);</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.5.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 7.1.2, 9.3.4</p><p>Availability: 1.5.0 geography support was introduced in 1.5.</p></div><div class="refsection" title="Geometry Examples"><a name="id36195360"></a><h2>Geometry Examples</h2><p>Return length in feet for line string. Note this is in feet because 2249 is
Mass State Plane Feet</p><pre class="programlisting">
SELECT ST_Length(ST_GeomFromText('LINESTRING(743238 2967416,743238 2967450,743265 2967450,
743265.625 2967416,743238 2967416)',2249));
st_length
---------
122.630744000095
--Transforming WGS 84 linestring to Massachusetts state plane meters
SELECT ST_Length(
ST_Transform(
ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45, -72.1240 42.45666, -72.123 42.1546)'),
26986
)
);
st_length
---------
34309.4563576191
</pre></div><div class="refsection" title="Geography Examples"><a name="id36195379"></a><h2>Geography Examples</h2><p>Return length of WGS 84 geography line</p><pre class="programlisting">
-- default calculation is using a sphere rather than spheroid
SELECT ST_Length(the_geog) As length_spheroid, ST_Length(the_geog,false) As length_sphere
FROM (SELECT ST_GeographyFromText(
'SRID=4326;LINESTRING(-72.1260 42.45, -72.1240 42.45666, -72.123 42.1546)') As the_geog)
As foo;
length_spheroid | length_sphere
------------------+------------------
34310.5703627305 | 34346.2060960742
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36195398"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeographyFromText" title="ST_GeographyFromText">ST_GeographyFromText</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_Length_Spheroid" title="ST_Length_Spheroid">ST_Length_Spheroid</a>, <a class="xref" href="#ST_Perimeter" title="ST_Perimeter">ST_Perimeter</a>, <a class="xref" href="#ST_Transform" title="ST_Transform">ST_Transform</a></p></div></div><div class="refentry" title="ST_Length2D"><div class="refentry.separator"><hr></div><a name="ST_Length2D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Length2D — Returns the 2-dimensional length of the geometry if it is a
linestring or multi-linestring. This is an alias for <code class="varname">ST_Length</code></p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Length2D</b>(</code>geometry <var class="pdparam">a_2dlinestring</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36195478"></a><h2>Description</h2><p>Returns the 2-dimensional length of the geometry if it is a
linestring or multi-linestring. This is an alias for <code class="varname">ST_Length</code></p></div><div class="refsection" title="See Also"><a name="id36195494"></a><h2>See Also</h2><p><a class="xref" href="#ST_Length" title="ST_Length">ST_Length</a>, <a class="xref" href="#ST_Length3D" title="ST_Length3D">ST_Length3D</a></p></div></div><div class="refentry" title="ST_Length3D"><div class="refentry.separator"><hr></div><a name="ST_Length3D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Length3D — Returns the 3-dimensional or 2-dimensional length of the geometry if it is a
linestring or multi-linestring. </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Length3D</b>(</code>geometry <var class="pdparam">a_3dlinestring</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36195556"></a><h2>Description</h2><p>Returns the 3-dimensional or 2-dimensional length of the geometry if it is a
linestring or multi-linestring. For 2-d lines it will just return the 2-d length (same as ST_Length and ST_Length2D)</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36195582"></a><h2>Examples</h2><p>Return length in feet for a 3D cable. Note this is in feet because 2249 is
Mass State Plane Feet</p><pre class="programlisting">
SELECT ST_Length3D(ST_GeomFromText('LINESTRING(743238 2967416 1,743238 2967450 1,743265 2967450 3,
743265.625 2967416 3,743238 2967416 3)',2249));
st_length3d
-----------
122.704716741457
</pre></div><div class="refsection" title="See Also"><a name="id36195602"></a><h2>See Also</h2><p><a class="xref" href="#ST_Length" title="ST_Length">ST_Length</a>, <a class="xref" href="#ST_Length2D" title="ST_Length2D">ST_Length2D</a></p></div></div><div class="refentry" title="ST_Length_Spheroid"><div class="refentry.separator"><hr></div><a name="ST_Length_Spheroid"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Length_Spheroid — Calculates the 2D or 3D length of a linestring/multilinestring on an ellipsoid. This
is useful if the coordinates of the geometry are in
longitude/latitude and a length is desired without reprojection.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Length_Spheroid</b>(</code>geometry <var class="pdparam">a_linestring</var>, spheroid <var class="pdparam">a_spheroid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36195674"></a><h2>Description</h2><p>Calculates the length of a geometry on an ellipsoid. This
is useful if the coordinates of the geometry are in
longitude/latitude and a length is desired without reprojection.
The ellipsoid is a separate database type and can be constructed
as follows:</p><div class="literallayout"><p>SPHEROID[<NAME>,<SEMI-MAJOR<br>
AXIS>,<INVERSEFLATTENING>]</p></div><div class="literallayout"><p>SPHEROID["GRS_1980",6378137,298.257222101]</p></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Will return 0 for anything that is not a MULTILINESTRING or LINESTRING</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36195720"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_Length_Spheroid( geometry_column,
'SPHEROID["GRS_1980",6378137,298.257222101]' )
FROM geometry_table;
SELECT ST_Length_Spheroid( the_geom, sph_m ) As tot_len,
ST_Length_Spheroid(ST_GeometryN(the_geom,1), sph_m) As len_line1,
ST_Length_Spheroid(ST_GeometryN(the_geom,2), sph_m) As len_line2
FROM (SELECT ST_GeomFromText('MULTILINESTRING((-118.584 38.374,-118.583 38.5),
(-71.05957 42.3589 , -71.061 43))') As the_geom,
CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo;
tot_len | len_line1 | len_line2
------------------+------------------+------------------
85204.5207562955 | 13986.8725229309 | 71217.6482333646
--3D
SELECT ST_Length_Spheroid( the_geom, sph_m ) As tot_len,
ST_Length_Spheroid(ST_GeometryN(the_geom,1), sph_m) As len_line1,
ST_Length_Spheroid(ST_GeometryN(the_geom,2), sph_m) As len_line2
FROM (SELECT ST_GeomFromEWKT('MULTILINESTRING((-118.584 38.374 20,-118.583 38.5 30),
(-71.05957 42.3589 75, -71.061 43 90))') As the_geom,
CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo;
tot_len | len_line1 | len_line2
------------------+-----------------+------------------
85204.5259107402 | 13986.876097711 | 71217.6498130292
</pre></div><div class="refsection" title="See Also"><a name="id36195735"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeometryN" title="ST_GeometryN">ST_GeometryN</a>, <a class="xref" href="#ST_Length" title="ST_Length">ST_Length</a>, <a class="xref" href="#ST_Length3D_Spheroid" title="ST_Length3D_Spheroid">ST_Length3D_Spheroid</a></p></div></div><div class="refentry" title="ST_Length2D_Spheroid"><div class="refentry.separator"><hr></div><a name="ST_Length2D_Spheroid"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Length2D_Spheroid — Calculates the 2D length of a linestring/multilinestring on an ellipsoid. This
is useful if the coordinates of the geometry are in
longitude/latitude and a length is desired without reprojection. </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Length2D_Spheroid</b>(</code>geometry <var class="pdparam">a_linestring</var>, spheroid <var class="pdparam">a_spheroid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36195813"></a><h2>Description</h2><p>Calculates the 2D length of a geometry on an ellipsoid. This
is useful if the coordinates of the geometry are in
longitude/latitude and a length is desired without reprojection.
The ellipsoid is a separate database type and can be constructed
as follows:</p><div class="literallayout"><p>SPHEROID[<NAME>,<SEMI-MAJOR<br>
AXIS>,<INVERSEFLATTENING>]</p></div><div class="literallayout"><p>SPHEROID["GRS_1980",6378137,298.257222101]</p></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Will return 0 for anything that is not a MULTILINESTRING or LINESTRING</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This is much like <a class="xref" href="#ST_Length_Spheroid" title="ST_Length_Spheroid">ST_Length_Spheroid</a> and <a class="xref" href="#ST_Length3D_Spheroid" title="ST_Length3D_Spheroid">ST_Length3D_Spheroid</a> except it will throw away the Z coordinate in calculations.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36195862"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_Length2D_Spheroid( geometry_column,
'SPHEROID["GRS_1980",6378137,298.257222101]' )
FROM geometry_table;
SELECT ST_Length2D_Spheroid( the_geom, sph_m ) As tot_len,
ST_Length2D_Spheroid(ST_GeometryN(the_geom,1), sph_m) As len_line1,
ST_Length2D_Spheroid(ST_GeometryN(the_geom,2), sph_m) As len_line2
FROM (SELECT ST_GeomFromText('MULTILINESTRING((-118.584 38.374,-118.583 38.5),
(-71.05957 42.3589 , -71.061 43))') As the_geom,
CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo;
tot_len | len_line1 | len_line2
------------------+------------------+------------------
85204.5207562955 | 13986.8725229309 | 71217.6482333646
--3D Observe same answer
SELECT ST_Length2D_Spheroid( the_geom, sph_m ) As tot_len,
ST_Length2D_Spheroid(ST_GeometryN(the_geom,1), sph_m) As len_line1,
ST_Length2D_Spheroid(ST_GeometryN(the_geom,2), sph_m) As len_line2
FROM (SELECT ST_GeomFromEWKT('MULTILINESTRING((-118.584 38.374 20,-118.583 38.5 30),
(-71.05957 42.3589 75, -71.061 43 90))') As the_geom,
CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo;
tot_len | len_line1 | len_line2
------------------+------------------+------------------
85204.5207562955 | 13986.8725229309 | 71217.6482333646
</pre></div><div class="refsection" title="See Also"><a name="id36195877"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeometryN" title="ST_GeometryN">ST_GeometryN</a>, <a class="xref" href="#ST_Length_Spheroid" title="ST_Length_Spheroid">ST_Length_Spheroid</a>, <a class="xref" href="#ST_Length3D_Spheroid" title="ST_Length3D_Spheroid">ST_Length3D_Spheroid</a></p></div></div><div class="refentry" title="ST_Length3D_Spheroid"><div class="refentry.separator"><hr></div><a name="ST_Length3D_Spheroid"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Length3D_Spheroid — Calculates the length of a geometry on an ellipsoid,
taking the elevation into account. This is just an alias for ST_Length_Spheroid. </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Length3D_Spheroid</b>(</code>geometry <var class="pdparam">a_linestring</var>, spheroid <var class="pdparam">a_spheroid</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36195953"></a><h2>Description</h2><p>Calculates the length of a geometry on an ellipsoid,
taking the elevation into account. This is just an alias
for ST_Length_Spheroid. </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Will return 0 for anything that is not a MULTILINESTRING or LINESTRING</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This functionis just an alias for ST_Length_Spheroid. </p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36195987"></a><h2>Examples</h2><pre class="programlisting">See ST_Length_Spheroid</pre></div><div class="refsection" title="See Also"><a name="id36196002"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeometryN" title="ST_GeometryN">ST_GeometryN</a>, <a class="xref" href="#ST_Length" title="ST_Length">ST_Length</a>, <a class="xref" href="#ST_Length_Spheroid" title="ST_Length_Spheroid">ST_Length_Spheroid</a></p></div></div><div class="refentry" title="ST_LongestLine"><div class="refentry.separator"><hr></div><a name="ST_LongestLine"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_LongestLine — Returns the 2-dimensional longest line points of two geometries.
The function will only return the first longest line if more than one, that the function finds.
The line returned will always start in g1 and end in g2.
The length of the line this function returns will always be the same as st_maxdistance returns for g1 and g2.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_LongestLine</b>(</code>geometry
<var class="pdparam">g1</var>, geometry
<var class="pdparam">g2</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36196080"></a><h2>Description</h2><p>Returns the 2-dimensional longest line between the points of two geometries.
</p><p>Availability: 1.5.0</p></div><div class="refsection" title="Examples"><a name="id36196094"></a><h2>Examples</h2><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_longestline01.png"><div class="caption"><p>Longest line between point and line</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_AsText(
ST_LongestLine('POINT(100 100)'::geometry,
'LINESTRING (20 80, 98 190, 110 180, 50 75 )'::geometry)
) As lline;
lline
-----------------
LINESTRING(100 100,98 190)
</pre><p>
</p></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_longestline02.png"><div class="caption"><p>longest line between polygon and polygon</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_AsText(
ST_LongestLine(
ST_GeomFromText('POLYGON((175 150, 20 40,
50 60, 125 100, 175 150))'),
ST_Buffer(ST_GeomFromText('POINT(110 170)'), 20)
)
) As llinewkt;
lline
-----------------
LINESTRING(20 40,121.111404660392 186.629392246051)
</pre><p>
</p></td></tr></tbody></table></div><div class="informaltable"><table border="1"><colgroup><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_longestline03.png"><div class="caption"><p>longest straight distance to travel from one part of an elegant city to the other
Note the max distance = to the length of the line.</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_AsText(ST_LongestLine(c.the_geom, c.the_geom)) As llinewkt,
ST_MaxDistance(c.the_geom,c.the_geom) As max_dist,
ST_Length(ST_LongestLine(c.the_geom, c.the_geom)) As lenll
FROM (SELECT ST_BuildArea(ST_Collect(the_geom)) As the_geom
FROM (SELECT ST_Translate(ST_SnapToGrid(ST_Buffer(ST_Point(50 ,generate_series(50,190, 50)
),40, 'quad_segs=2'),1), x, 0) As the_geom
FROM generate_series(1,100,50) As x) AS foo
) As c;
llinewkt | max_dist | lenll
---------------------------+------------------+------------------
LINESTRING(23 22,129 178) | 188.605408193933 | 188.605408193933
</pre><p>
</p></td></tr></tbody></table></div></div><div class="refsection" title="See Also"><a name="id36196227"></a><h2>See Also</h2><p><a class="xref" href="#ST_MaxDistance" title="ST_MaxDistance">ST_MaxDistance</a>, <a class="xref" href="#ST_ShortestLine" title="ST_ShortestLine">ST_ShortestLine</a>, <a class="xref" href="#ST_LongestLine" title="ST_LongestLine">ST_LongestLine</a></p></div></div><div class="refentry" title="ST_OrderingEquals"><div class="refentry.separator"><hr></div><a name="ST_OrderingEquals"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_OrderingEquals — Returns true if the given geometries represent the same geometry
and points are in the same directional order.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_OrderingEquals</b>(</code>geometry <var class="pdparam">A</var>, geometry <var class="pdparam">B</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36196302"></a><h2>Description</h2><p>ST_OrderingEquals compares two geometries and t (TRUE) if the
geometries are equal and the coordinates are in the same order;
otherwise it returns f (FALSE).</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function is implemented as per the ArcSDE SQL
specification rather than SQL-MM.
http://edndoc.esri.com/arcsde/9.1/sql_api/sqlapi3.htm#ST_OrderingEquals</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.43</p></div><div class="refsection" title="Examples"><a name="id36196337"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_OrderingEquals(ST_GeomFromText('LINESTRING(0 0, 10 10)'),
ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)'));
st_orderingequals
-----------
f
(1 row)
SELECT ST_OrderingEquals(ST_GeomFromText('LINESTRING(0 0, 10 10)'),
ST_GeomFromText('LINESTRING(0 0, 0 0, 10 10)'));
st_orderingequals
-----------
t
(1 row)
SELECT ST_OrderingEquals(ST_Reverse(ST_GeomFromText('LINESTRING(0 0, 10 10)')),
ST_GeomFromText('LINESTRING(0 0, 0 0, 10 10)'));
st_orderingequals
-----------
f
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36196353"></a><h2>See Also</h2><p><a class="xref" href="#ST_Equals" title="ST_Equals">ST_Equals</a>, <a class="xref" href="#ST_Reverse" title="ST_Reverse">ST_Reverse</a></p></div></div><div class="refentry" title="ST_Overlaps"><div class="refentry.separator"><hr></div><a name="ST_Overlaps"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Overlaps — Returns TRUE if the Geometries share space, are of the same dimension, but are not completely contained by each other.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_Overlaps</b>(</code>geometry <var class="pdparam">A</var>, geometry <var class="pdparam">B</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36196423"></a><h2>Description</h2><p>Returns TRUE if the Geometries "spatially
overlap". By that we mean they intersect, but one does not completely contain another. </p><p>Performed by the GEOS module</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a GeometryCollection as an argument</p></td></tr></table></div><p>This function call will automatically include a bounding box
comparison that will make use of any indexes that are available on
the geometries. To avoid index use, use the function
_ST_Overlaps.</p><p>NOTE: this is the "allowable" version that returns a
boolean, not an integer.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.2 // s2.1.13.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.32</p></div><div class="refsection" title="Examples"><a name="id36196484"></a><h2>Examples</h2><pre class="programlisting">--a point on a line is contained by the line and is of a lower dimension, and therefore does not overlap the line
nor crosses
SELECT ST_Overlaps(a,b) As a_overlap_b,
ST_Crosses(a,b) As a_crosses_b,
ST_Intersects(a, b) As a_intersects_b, ST_Contains(b,a) As b_contains_a
FROM (SELECT ST_GeomFromText('POINT(1 0.5)') As a, ST_GeomFromText('LINESTRING(1 0, 1 1, 3 5)') As b)
As foo
a_overlap_b | a_crosses_b | a_intersects_b | b_contains_a
------------+-------------+----------------+--------------
f | f | t | t
--a line that is partly contained by circle, but not fully is defined as intersecting and crossing,
-- but since of different dimension it does not overlap
SELECT ST_Overlaps(a,b) As a_overlap_b, ST_Crosses(a,b) As a_crosses_b,
ST_Intersects(a, b) As a_intersects_b,
ST_Contains(a,b) As a_contains_b
FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 0.5)'), 3) As a, ST_GeomFromText('LINESTRING(1 0, 1 1, 3 5)') As b)
As foo;
a_overlap_b | a_crosses_b | a_intersects_b | a_contains_b
-------------+-------------+----------------+--------------
f | t | t | f
-- a 2-dimensional bent hot dog (aka puffered line string) that intersects a circle,
-- but is not fully contained by the circle is defined as overlapping since they are of the same dimension,
-- but it does not cross, because the intersection of the 2 is of the same dimension
-- as the maximum dimension of the 2
SELECT ST_Overlaps(a,b) As a_overlap_b, ST_Crosses(a,b) As a_crosses_b, ST_Intersects(a, b) As a_intersects_b,
ST_Contains(b,a) As b_contains_a,
ST_Dimension(a) As dim_a, ST_Dimension(b) as dim_b, ST_Dimension(ST_Intersection(a,b)) As dima_intersection_b
FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 0.5)'), 3) As a,
ST_Buffer(ST_GeomFromText('LINESTRING(1 0, 1 1, 3 5)'),0.5) As b)
As foo;
a_overlap_b | a_crosses_b | a_intersects_b | b_contains_a | dim_a | dim_b | dima_intersection_b
-------------+-------------+----------------+--------------+-------+-------+---------------------
t | f | t | f | 2 | 2 | 2
</pre></div><div class="refsection" title="See Also"><a name="id36196496"></a><h2>See Also</h2><p><a class="xref" href="#ST_Contains" title="ST_Contains">ST_Contains</a>, <a class="xref" href="#ST_Crosses" title="ST_Crosses">ST_Crosses</a>, <a class="xref" href="#ST_Dimension" title="ST_Dimension">ST_Dimension</a>, <a class="xref" href="#ST_Intersects" title="ST_Intersects">ST_Intersects</a></p></div></div><div class="refentry" title="ST_Perimeter"><div class="refentry.separator"><hr></div><a name="ST_Perimeter"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Perimeter — Return the length measurement of the boundary of an ST_Surface
or ST_MultiSurface value. (Polygon, Multipolygon)</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Perimeter</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36196566"></a><h2>Description</h2><p>Returns the 2D perimeter of the geometry if it is a ST_Surface, ST_MultiSurface (Polygon, Multipolygon). 0 is returned for
non-areal geometries. For linestrings use ST_Length. Measurements are in the units of the
spatial reference system of the geometry.</p><p>Currently this is an alias for ST_Perimeter2D, but this may change to support higher dimensions.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.5.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 8.1.3, 9.5.4</p></div><div class="refsection" title="Examples"><a name="id36196615"></a><h2>Examples</h2><p>Return perimeter in feet for polygon and multipolygon. Note this is in feet because 2249 is
Mass State Plane Feet</p><pre class="programlisting">
SELECT ST_Perimeter(ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,743265 2967450,
743265.625 2967416,743238 2967416))', 2249));
st_perimeter
---------
122.630744000095
(1 row)
SELECT ST_Perimeter(ST_GeomFromText('MULTIPOLYGON(((763104.471273676 2949418.44119003,
763104.477769673 2949418.42538203,
763104.189609677 2949418.22343004,763104.471273676 2949418.44119003)),
((763104.471273676 2949418.44119003,763095.804579742 2949436.33850239,
763086.132105649 2949451.46730207,763078.452329651 2949462.11549407,
763075.354136904 2949466.17407812,763064.362142565 2949477.64291974,
763059.953961626 2949481.28983009,762994.637609571 2949532.04103014,
762990.568508415 2949535.06640477,762986.710889563 2949539.61421415,
763117.237897679 2949709.50493431,763235.236617789 2949617.95619822,
763287.718121842 2949562.20592617,763111.553321674 2949423.91664605,
763104.471273676 2949418.44119003)))', 2249));
st_perimeter
---------
845.227713366825
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36196639"></a><h2>See Also</h2><p><a class="xref" href="#ST_Length" title="ST_Length">ST_Length</a></p></div></div><div class="refentry" title="ST_Perimeter2D"><div class="refentry.separator"><hr></div><a name="ST_Perimeter2D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Perimeter2D — Returns the 2-dimensional perimeter of the geometry, if it
is a polygon or multi-polygon. This is currently an alias for ST_Perimeter.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Perimeter2D</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36196695"></a><h2>Description</h2><p>Returns the 2-dimensional perimeter of the geometry, if it
is a polygon or multi-polygon. </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p> This is currently an alias for ST_Perimeter. In future versions ST_Perimeter may return the highest dimension perimeter for a geometry. This is still under consideration</p></td></tr></table></div></div><div class="refsection" title="See Also"><a name="id36196720"></a><h2>See Also</h2><p><a class="xref" href="#ST_Perimeter" title="ST_Perimeter">ST_Perimeter</a></p></div></div><div class="refentry" title="ST_Perimeter3D"><div class="refentry.separator"><hr></div><a name="ST_Perimeter3D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Perimeter3D — Returns the 3-dimensional perimeter of the geometry, if it
is a polygon or multi-polygon.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Perimeter3D</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36196775"></a><h2>Description</h2><p>Returns the 3-dimensional perimeter of the geometry, if it
is a polygon or multi-polygon. If the geometry is 2-dimensional, then the 2-dimensional perimeter is returned. </p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36196800"></a><h2>Examples</h2><p>Perimeter of a slightly elevated polygon in the air in Massachusetts state plane feet</p><pre class="programlisting">SELECT ST_Perimeter3D(the_geom), ST_Perimeter2d(the_geom), ST_Perimeter(the_geom) FROM
(SELECT ST_GeomFromEWKT('SRID=2249;POLYGON((743238 2967416 2,743238 2967450 1,
743265.625 2967416 1,743238 2967416 2))') As the_geom) As foo;
st_perimeter3d | st_perimeter2d | st_perimeter
------------------+------------------+------------------
105.465793597674 | 105.432997272188 | 105.432997272188
</pre></div><div class="refsection" title="See Also"><a name="id36196822"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_Perimeter" title="ST_Perimeter">ST_Perimeter</a>, <a class="xref" href="#ST_Perimeter2D" title="ST_Perimeter2D">ST_Perimeter2D</a></p></div></div><div class="refentry" title="ST_PointOnSurface"><div class="refentry.separator"><hr></div><a name="ST_PointOnSurface"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_PointOnSurface — Returns a <code class="varname">POINT</code> guaranteed to lie on the surface.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_PointOnSurface</b>(</code>geometry
<var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36196892"></a><h2>Description</h2><p>Returns a <code class="varname">POINT</code> guaranteed to intersect a surface.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s3.2.14.2 // s3.2.18.2</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 8.1.5, 9.5.6.
According to the specs, ST_PointOnSurface works for surface geometries (POLYGONs, MULTIPOLYGONS, CURVED POLYGONS). So PostGIS seems to be extending what
the spec allows here. Most databases Oracle,DB II, ESRI SDE seem to only support this function for surfaces. SQL Server 2008 like PostGIS supports for all common geometries.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36196955"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsText(ST_PointOnSurface('POINT(0 5)'::geometry));
st_astext
------------
POINT(0 5)
(1 row)
SELECT ST_AsText(ST_PointOnSurface('LINESTRING(0 5, 0 10)'::geometry));
st_astext
------------
POINT(0 5)
(1 row)
SELECT ST_AsText(ST_PointOnSurface('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'::geometry));
st_astext
----------------
POINT(2.5 2.5)
(1 row)
SELECT ST_AsEWKT(ST_PointOnSurface(ST_GeomFromEWKT('LINESTRING(0 5 1, 0 0 1, 0 10 2)')));
st_asewkt
----------------
POINT(0 0 1)
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36196971"></a><h2>See Also</h2><p><a class="xref" href="#ST_Centroid" title="ST_Centroid">ST_Centroid</a>, <a class="xref" href="#ST_Point_Inside_Circle" title="ST_Point_Inside_Circle">ST_Point_Inside_Circle</a></p></div></div><div class="refentry" title="ST_Relate"><div class="refentry.separator"><hr></div><a name="ST_Relate"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Relate — Returns true if this Geometry is spatially related to
anotherGeometry, by testing for intersections between the
Interior, Boundary and Exterior of the two geometries as specified
by the values in the intersectionMatrixPattern. If no intersectionMatrixPattern
is passed in, then returns the maximum intersectionMatrixPattern that relates the 2 geometries.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_Relate</b>(</code>geometry <var class="pdparam">geomA</var>, geometry <var class="pdparam">geomB</var>, text <var class="pdparam">intersectionMatrixPattern</var><code>)</code>;</p><p><code class="funcdef">text <b class="fsfunc">ST_Relate</b>(</code>geometry <var class="pdparam">geomA</var>, geometry <var class="pdparam">geomB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36197085"></a><h2>Description</h2><p>Version 1: Takes geomA, geomB, intersectionMatrix and Returns 1 (TRUE) if this Geometry is spatially related to
anotherGeometry, by testing for intersections between the
Interior, Boundary and Exterior of the two geometries as specified
by the values in the <a class="ulink" href="http://docs.codehaus.org/display/GEOTDOC/Point+Set+Theory+and+the+DE-9IM+Matrix#PointSetTheoryandtheDE-9IMMatrix-9IntersectionMatrix" target="_top">intersectionMatrixPattern</a>.</p><p>This is especially useful for testing compound checks of intersection, crosses, etc in one step.</p><p>Do not call with a GeometryCollection as an argument</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This is the "allowable" version that returns a
boolean, not an integer. This is defined in OGC spec</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This DOES NOT automagically include an index call. The reason for that
is some relationships are anti e.g. Disjoint. If you are
using a relationship pattern that requires intersection, then include the &&
index call.</p></td></tr></table></div><p>Version 2: Takes geomA and geomB and returns the <a class="xref" href="#DE-9IM" title="4.3.6.Dimensionally Extended 9 Intersection Model (DE-9IM)">Section4.3.6, “Dimensionally Extended 9 Intersection Model (DE-9IM)”</a></p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a GeometryCollection as an argument</p></td></tr></table></div><p>not in OGC spec, but implied. see s2.1.13.2</p><p>Both Performed by the GEOS module</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.2 // s2.1.13.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.25</p></div><div class="refsection" title="Examples"><a name="id36197178"></a><h2>Examples</h2><pre class="programlisting">
--Find all compounds that intersect and not touch a poly (interior intersects)
SELECT l.* , b.name As poly_name
FROM polys As b
INNER JOIN compounds As l
ON (p.the_geom && b.the_geom
AND ST_Relate(l.the_geom, b.the_geom,'T********'));
SELECT ST_Relate(ST_GeometryFromText('POINT(1 2)'), ST_Buffer(ST_GeometryFromText('POINT(1 2)'),2));
st_relate
-----------
0FFFFF212
SELECT ST_Relate(ST_GeometryFromText('LINESTRING(1 2, 3 4)'), ST_GeometryFromText('LINESTRING(5 6, 7 8)'));
st_relate
-----------
FF1FF0102
SELECT ST_Relate(ST_GeometryFromText('POINT(1 2)'), ST_Buffer(ST_GeometryFromText('POINT(1 2)'),2), '0FFFFF212');
st_relate
-----------
t
SELECT ST_Relate(ST_GeometryFromText('POINT(1 2)'), ST_Buffer(ST_GeometryFromText('POINT(1 2)'),2), '*FF*FF212');
st_relate
-----------
t
</pre></div><div class="refsection" title="See Also"><a name="id36197194"></a><h2>See Also</h2><p><a class="xref" href="#ST_Crosses" title="ST_Crosses">ST_Crosses</a>, <a class="xref" href="#DE-9IM" title="4.3.6.Dimensionally Extended 9 Intersection Model (DE-9IM)">Section4.3.6, “Dimensionally Extended 9 Intersection Model (DE-9IM)”</a>, <a class="xref" href="#ST_Disjoint" title="ST_Disjoint">ST_Disjoint</a>, <a class="xref" href="#ST_Intersects" title="ST_Intersects">ST_Intersects</a>, <a class="xref" href="#ST_Touches" title="ST_Touches">ST_Touches</a></p></div></div><div class="refentry" title="ST_ShortestLine"><div class="refentry.separator"><hr></div><a name="ST_ShortestLine"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_ShortestLine — Returns the 2-dimensional shortest line between two geometries</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_ShortestLine</b>(</code>geometry
<var class="pdparam">g1</var>, geometry
<var class="pdparam">g2</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36197277"></a><h2>Description</h2><p>Returns the 2-dimensional shortest line between two geometries. The function will
only return the first shortest line if more than one, that the function finds.
If g1 and g2 intersects in just one point the function will return a line with both start
and end in that intersection-point.
If g1 and g2 are intersecting with more than one point the function will return a line with start
and end in the same point but it can be any of the intersecting points.
The line returned will always start in g1 and end in g2.
The length of the line this function returns will always be the same as st_distance returns for g1 and g2.
</p><p>Availability: 1.5.0</p></div><div class="refsection" title="Examples"><a name="id36197296"></a><h2>Examples</h2><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_shortestline01.png"><div class="caption"><p>Shortest line between point and linestring</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_AsText(
ST_ShortestLine('POINT(100 100)'::geometry,
'LINESTRING (20 80, 98 190, 110 180, 50 75 )'::geometry)
) As sline;
sline
-----------------
LINESTRING(100 100,73.0769230769231 115.384615384615)
</pre><p>
</p></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_shortestline02.png"><div class="caption"><p>shortest line between polygon and polygon</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_AsText(
ST_ShortestLine(
ST_GeomFromText('POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))'),
ST_Buffer(ST_GeomFromText('POINT(110 170)'), 20)
)
) As slinewkt;
LINESTRING(140.752120669087 125.695053378061,121.111404660392 153.370607753949)
</pre><p>
</p></td></tr></tbody></table></div></div><div class="refsection" title="See Also"><a name="id36197379"></a><h2>See Also</h2><p><a class="xref" href="#ST_ClosestPoint" title="ST_ClosestPoint">ST_ClosestPoint</a>, <a class="xref" href="#ST_Distance" title="ST_Distance">ST_Distance</a>, <a class="xref" href="#ST_LongestLine" title="ST_LongestLine">ST_LongestLine</a>, <a class="xref" href="#ST_ShortestLine" title="ST_ShortestLine">ST_ShortestLine</a>, <a class="xref" href="#ST_MaxDistance" title="ST_MaxDistance">ST_MaxDistance</a></p></div></div><div class="refentry" title="ST_Touches"><div class="refentry.separator"><hr></div><a name="ST_Touches"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Touches — Returns <code class="varname">TRUE</code> if the geometries have at least one point in common,
but their interiors do not intersect.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_Touches</b>(</code>geometry
<var class="pdparam">g1</var>, geometry
<var class="pdparam">g2</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36197469"></a><h2>Description</h2><p>Returns <code class="varname">TRUE</code> if the only points in common between
<em class="parameter"><code>g1</code></em> and <em class="parameter"><code>g2</code></em> lie in the union of the
boundaries of <em class="parameter"><code>g1</code></em> and <em class="parameter"><code>g2</code></em>.
The <code class="function">ST_Touches</code> relation applies
to all Area/Area, Line/Line, Line/Area, Point/Area and Point/Line pairs of relationships,
but <span class="emphasis"><em>not</em></span> to the Point/Point pair.</p><p>In mathematical terms, this predicate is expressed as:</p><p class="remark"><em><span class="remark">TODO: Insert appropriate MathML markup here or use a gif.
Simple HTML markup does not work well in both IE and Firefox.</span></em></p><div class="informalfigure"><div class="mediaobject"><img src="images/st_touches-math.gif"></div></div><p>The allowable DE-9IM Intersection Matrices for the two geometries are:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><span class="markup">FT*******</span></p></li><li class="listitem"><p><span class="markup">F**T*****</span></p></li><li class="listitem"><p><span class="markup">F***T****</span></p></li></ul></div><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a <code class="varname">GEOMETRYCOLLECTION</code> as an argument</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function call will automatically include a bounding box
comparison that will make use of any indexes that are available on
the geometries. To avoid using an index, use <code class="function">_ST_Touches</code> instead.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.2 // s2.1.13.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.28</p></div><div class="refsection" title="Examples"><a name="id36197624"></a><h2>Examples</h2><p>The <code class="function">ST_Touches</code> predicate returns <code class="varname">TRUE</code> in all the following illustrations.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_touches01.png"><div class="caption"><p><code class="varname">POLYGON</code> / <code class="varname">POLYGON</code></p></div></div></div></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_touches02.png"><div class="caption"><p><code class="varname">POLYGON</code> / <code class="varname">POLYGON</code></p></div></div></div></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_touches03.png"><div class="caption"><p><code class="varname">POLYGON</code> / <code class="varname">LINESTRING</code></p></div></div></div></td></tr><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_touches04.png"><div class="caption"><p><code class="varname">LINESTRING</code> / <code class="varname">LINESTRING</code></p></div></div></div></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_touches05.png"><div class="caption"><p><code class="varname">LINESTRING</code> / <code class="varname">LINESTRING</code></p></div></div></div></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_touches06.png"><div class="caption"><p><code class="varname">POLYGON</code> / <code class="varname">POINT</code></p></div></div></div></td></tr></tbody></table></div><pre class="programlisting">SELECT ST_Touches('LINESTRING(0 0, 1 1, 0 2)'::geometry, 'POINT(1 1)'::geometry);
st_touches
------------
f
(1 row)
SELECT ST_Touches('LINESTRING(0 0, 1 1, 0 2)'::geometry, 'POINT(0 2)'::geometry);
st_touches
------------
t
(1 row)</pre></div></div><div class="refentry" title="ST_Within"><div class="refentry.separator"><hr></div><a name="ST_Within"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Within — Returns true if the geometry A is completely inside geometry B</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_Within</b>(</code>geometry
<var class="pdparam">A</var>, geometry
<var class="pdparam">B</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36197882"></a><h2>Description</h2><p>Returns TRUE if geometry A is completely inside geometry B. For this function to make
sense, the source geometries must both be of the same coordinate projection,
having the same SRID. It is a given that if ST_Within(A,B) is true and ST_Within(B,A) is true, then
the two geometries are considered spatially equal.</p><p>Performed by the GEOS module</p><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a <code class="varname">GEOMETRYCOLLECTION</code> as an argument</p></td></tr></table></div><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not use this function with invalid geometries. You will get unexpected results.</p></td></tr></table></div><p>This function call will automatically include a bounding box
comparison that will make use of any indexes that are available on
the geometries. To avoid index use, use the function
_ST_Within.</p><p>NOTE: this is the "allowable" version that returns a
boolean, not an integer.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.2 // s2.1.13.3
- a.Relate(b, 'T*F**F***')
</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.30</p></div><div class="refsection" title="Examples"><a name="id36197957"></a><h2>Examples</h2><pre class="programlisting">
--a circle within a circle
SELECT ST_Within(smallc,smallc) As smallinsmall,
ST_Within(smallc, bigc) As smallinbig,
ST_Within(bigc,smallc) As biginsmall,
ST_Within(ST_Union(smallc, bigc), bigc) as unioninbig,
ST_Within(bigc, ST_Union(smallc, bigc)) as biginunion,
ST_Equals(bigc, ST_Union(smallc, bigc)) as bigisunion
FROM
(
SELECT ST_Buffer(ST_GeomFromText('POINT(50 50)'), 20) As smallc,
ST_Buffer(ST_GeomFromText('POINT(50 50)'), 40) As bigc) As foo;
--Result
smallinsmall | smallinbig | biginsmall | unioninbig | biginunion | bigisunion
--------------+------------+------------+------------+------------+------------
t | t | f | t | t | t
(1 row)
</pre><p><span class="inlinemediaobject"><img src="images/st_within01.png"></span> </p></div><div class="refsection" title="See Also"><a name="id36197988"></a><h2>See Also</h2><p><a class="xref" href="#ST_Contains" title="ST_Contains">ST_Contains</a>, <a class="xref" href="#ST_Equals" title="ST_Equals">ST_Equals</a>,<a class="xref" href="#ST_IsValid" title="ST_IsValid">ST_IsValid</a></p></div></div></div><div class="sect1" title="7.9.Geometry Processing Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Geometry_Processing"></a>7.9.Geometry Processing Functions</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#ST_Buffer">ST_Buffer</a></span><span class="refpurpose"> — (T) For geometry: Returns a geometry that represents all points whose distance
from this Geometry is less than or equal to distance. Calculations
are in the Spatial Reference System of this Geometry. For geography: Uses a planar transform wrapper. Introduced in 1.5 support for
different end cap and mitre settings to control shape. buffer_style options: quad_segs=#,endcap=round|flat|square,join=round|mitre|bevel,mitre_limit=#.#
</span></dt><dt><span class="refentrytitle"><a href="#ST_BuildArea">ST_BuildArea</a></span><span class="refpurpose"> — Creates an areal geometry formed by the constituent linework
of given geometry</span></dt><dt><span class="refentrytitle"><a href="#ST_Collect">ST_Collect</a></span><span class="refpurpose"> — Return a specified ST_Geometry value from a collection of other geometries.</span></dt><dt><span class="refentrytitle"><a href="#ST_ConvexHull">ST_ConvexHull</a></span><span class="refpurpose"> — The convex hull of a geometry represents the minimum convex
geometry that encloses all geometries within the set.</span></dt><dt><span class="refentrytitle"><a href="#ST_CurveToLine">ST_CurveToLine</a></span><span class="refpurpose"> — Converts a CIRCULARSTRING/CURVEDPOLYGON to a LINESTRING/POLYGON</span></dt><dt><span class="refentrytitle"><a href="#ST_Difference">ST_Difference</a></span><span class="refpurpose"> — Returns a geometry that represents that part of geometry A
that does not intersect with geometry B.</span></dt><dt><span class="refentrytitle"><a href="#ST_Dump">ST_Dump</a></span><span class="refpurpose"> — Returns a set of geometry_dump (geom,path) rows, that make up a geometry g1.</span></dt><dt><span class="refentrytitle"><a href="#ST_DumpPoints">ST_DumpPoints</a></span><span class="refpurpose"> — Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_DumpRings">ST_DumpRings</a></span><span class="refpurpose"> — Returns a set of <code class="varname">geometry_dump</code> rows, representing
the exterior and interior rings of a polygon.</span></dt><dt><span class="refentrytitle"><a href="#ST_Intersection">ST_Intersection</a></span><span class="refpurpose"> — (T) Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation
does a transform to geometry to do the intersection and then transform back to WGS84.
</span></dt><dt><span class="refentrytitle"><a href="#ST_LineToCurve">ST_LineToCurve</a></span><span class="refpurpose"> — Converts a LINESTRING/POLYGON to a CIRCULARSTRING, CURVED POLYGON</span></dt><dt><span class="refentrytitle"><a href="#ST_MemUnion">ST_MemUnion</a></span><span class="refpurpose"> — Same as ST_Union, only memory-friendly (uses less memory
and more processor time).</span></dt><dt><span class="refentrytitle"><a href="#ST_MinimumBoundingCircle">ST_MinimumBoundingCircle</a></span><span class="refpurpose"> — Returns the smallest circle polygon that can fully contain a geometry. Default
uses 48 segments per quarter circle.</span></dt><dt><span class="refentrytitle"><a href="#ST_Polygonize">ST_Polygonize</a></span><span class="refpurpose"> — Aggregate. Creates a GeometryCollection containing possible
polygons formed from the constituent linework of a set of
geometries.</span></dt><dt><span class="refentrytitle"><a href="#ST_Shift_Longitude">ST_Shift_Longitude</a></span><span class="refpurpose"> — Reads every point/vertex in every component of every feature
in a geometry, and if the longitude coordinate is <0, adds 360
to it. The result would be a 0-360 version of the data to be
plotted in a 180 centric map</span></dt><dt><span class="refentrytitle"><a href="#ST_Simplify">ST_Simplify</a></span><span class="refpurpose"> — Returns a "simplified" version of the given geometry using
the Douglas-Peucker algorithm.</span></dt><dt><span class="refentrytitle"><a href="#ST_SimplifyPreserveTopology">ST_SimplifyPreserveTopology</a></span><span class="refpurpose"> — Returns a "simplified" version of the given geometry using
the Douglas-Peucker algorithm. Will avoid creating derived
geometries (polygons in particular) that are invalid.</span></dt><dt><span class="refentrytitle"><a href="#ST_SymDifference">ST_SymDifference</a></span><span class="refpurpose"> — Returns a geometry that represents the portions of A and B
that do not intersect. It is called a symmetric difference because
ST_SymDifference(A,B) = ST_SymDifference(B,A).</span></dt><dt><span class="refentrytitle"><a href="#ST_Union">ST_Union</a></span><span class="refpurpose"> — Returns a geometry that represents the point set union of
the Geometries.</span></dt></dl></div><div class="refentry" title="ST_Buffer"><a name="ST_Buffer"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Buffer — (T) For geometry: Returns a geometry that represents all points whose distance
from this Geometry is less than or equal to distance. Calculations
are in the Spatial Reference System of this Geometry. For geography: Uses a planar transform wrapper. Introduced in 1.5 support for
different end cap and mitre settings to control shape. buffer_style options: quad_segs=#,endcap=round|flat|square,join=round|mitre|bevel,mitre_limit=#.#
</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Buffer</b>(</code>geometry <var class="pdparam">g1</var>, float <var class="pdparam">radius_of_buffer</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_Buffer</b>(</code>geometry <var class="pdparam">g1</var>, float <var class="pdparam">radius_of_buffer</var>, integer <var class="pdparam">num_seg_quarter_circle</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_Buffer</b>(</code>geometry <var class="pdparam">g1</var>, float <var class="pdparam">radius_of_buffer</var>, text <var class="pdparam">buffer_style_parameters</var><code>)</code>;</p><p><code class="funcdef">geography <b class="fsfunc">ST_Buffer</b>(</code>geography <var class="pdparam">g1</var>, float <var class="pdparam">radius_of_buffer_in_meters</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36205540"></a><h2>Description</h2><p>Returns a geometry/geography that represents all points whose distance
from this Geometry/geography is less than or equal to distance. </p><p>Geometry: Calculations
are in the Spatial Reference System of the geometry. Introduced in 1.5 support for
different end cap and mitre settings to control shape.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Geography: For geography this is really a thin wrapper around the geometry implementation. It first determines the best SRID that
fits the bounding box of the geography object (favoring UTM, Lambert Azimuthal Equal Area (LAEA) north/south pole, and falling back on mercator in worst case scenario) and then buffers in that planar spatial ref and retransforms back to WGS84 geography.</p></td></tr></table></div><p><img src="images/warning.png">
For geography this may not behave as expected if object is sufficiently large that it falls between two UTM zones or crosses the dateline</p><p>Availability: 1.5 - ST_Buffer was enhanced to support different endcaps and join types. These are useful for example to convert road linestrings
into polygon roads with flat or square edges instead of rounded edges. Thin wrapper for geography was added. - requires GEOS >= 3.2 to take advantage of advanced geometry functionality.
</p><p>
The optional third parameter (currently only applies to geometry) can either specify number of segments used to approximate a quarter circle (integer case, defaults to 8) or a list of blank-separated key=value pairs (string case) to tweak operations as follows:
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
'quad_segs=#' : number of segments used to approximate a quarter circle (defaults to 8).
</li><li class="listitem">
'endcap=round|flat|square' : endcap style (defaults to "round", needs GEOS-3.2 or higher for a different value). 'butt' is also accepted as a synonym for 'flat'.
</li><li class="listitem">
'join=round|mitre|bevel' : join style (defaults to "round", needs GEOS-3.2 or higher for a different value). 'miter' is also accepted as a synonym for 'mitre'.
</li><li class="listitem">
'mitre_limit=#.#' : mitre ratio limit (only affects mitred join style). 'miter_limit' is also accepted as a synonym for 'mitre_limit'.
</li></ul></div><p>
</p><p>Units of radius are measured in units of the spatial reference system.</p><p>The inputs can be POINTS, MULTIPOINTS, LINESTRINGS, MULTILINESTRINGS, POLYGONS, MULTIPOLYGONS, and GeometryCollections.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This function ignores the third dimension (z) and will always give a 2-d buffer even when presented with a 3d-geometry.</p></td></tr></table></div><p>Performed by the GEOS module.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.17</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>People often make the mistake of using this function to try to do radius searches. Creating a
buffer to to a radius search is slow and pointless. Use <a class="xref" href="#ST_DWithin" title="ST_DWithin">ST_DWithin</a> instead.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36205665"></a><h2>Examples</h2><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_buffer01.png"><div class="caption"><p>quad_segs=8 (default)</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_Buffer(
ST_GeomFromText('POINT(100 90)'),
50, 'quad_segs=8');
</pre><p>
</p></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_buffer02.png"><div class="caption"><p>quad_segs=2 (lame)</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_Buffer(
ST_GeomFromText('POINT(100 90)'),
50, 'quad_segs=2');
</pre><p>
</p></td></tr><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_buffer03.png"><div class="caption"><p>endcap=round join=round (default)</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_Buffer(
ST_GeomFromText(
'LINESTRING(50 50,150 150,150 50)'
), 10, 'endcap=round join=round');
</pre><p>
</p></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_buffer04.png"><div class="caption"><p>endcap=square</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_Buffer(
ST_GeomFromText(
'LINESTRING(50 50,150 150,150 50)'
), 10, 'endcap=square join=round');
</pre><p>
</p></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_buffer05.png"><div class="caption"><p>endcap=flat</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_Buffer(
ST_GeomFromText(
'LINESTRING(50 50,150 150,150 50)'
), 10, 'endcap=flat join=round');
</pre><p>
</p></td></tr><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_buffer07.png"><div class="caption"><p>join=bevel</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_Buffer(
ST_GeomFromText(
'LINESTRING(50 50,150 150,150 50)'
), 10, 'join=bevel');
</pre><p>
</p></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_buffer06.png"><div class="caption"><p>join=mitre mitre_limit=5.0 (default mitre limit)</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_Buffer(
ST_GeomFromText(
'LINESTRING(50 50,150 150,150 50)'
), 10, 'join=mitre mitre_limit=5.0');
</pre><p>
</p></td><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_buffer08.png"><div class="caption"><p>join=mitre mitre_limit=1</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_Buffer(
ST_GeomFromText(
'LINESTRING(50 50,150 150,150 50)'
), 10, 'join=mitre mitre_limit=1.0');
</pre><p>
</p></td></tr></tbody></table></div><pre class="programlisting">--A buffered point approximates a circle
-- A buffered point forcing approximation of (see diagram)
-- 2 points per circle is poly with 8 sides (see diagram)
SELECT ST_NPoints(ST_Buffer(ST_GeomFromText('POINT(100 90)'), 50)) As promisingcircle_pcount,
ST_NPoints(ST_Buffer(ST_GeomFromText('POINT(100 90)'), 50, 2)) As lamecircle_pcount;
promisingcircle_pcount | lamecircle_pcount
------------------------+-------------------
33 | 9
--A lighter but lamer circle
-- only 2 points per quarter circle is an octagon
--Below is a 100 meter octagon
-- Note coordinates are in NAD 83 long lat which we transform
to Mass state plane meter and then buffer to get measurements in meters;
SELECT ST_AsText(ST_Buffer(
ST_Transform(
ST_SetSRID(ST_MakePoint(-71.063526, 42.35785),4269), 26986)
,100,2)) As octagon;
----------------------
POLYGON((236057.59057465 900908.759918696,236028.301252769 900838.049240578,235
957.59057465 900808.759918696,235886.879896532 900838.049240578,235857.59057465
900908.759918696,235886.879896532 900979.470596815,235957.59057465 901008.759918
696,236028.301252769 900979.470596815,236057.59057465 900908.759918696))
--Buffer is often also used as a poor man's polygon fixer or a sometimes speedier unioner
--Sometimes able to fix invalid polygons - using below
-- using below on anything but a polygon will result in empty geometry
-- and for geometry collections kill anything in the collection that is not a polygon
--Poor man's bad poly fixer
SELECT ST_IsValid(foo.invalidpoly) as isvalid, ST_IsValid(ST_Buffer(foo.invalidpoly,0.0)) as bufferisvalid,
ST_AsText(ST_Buffer(foo.invalidpoly,0.0)) As newpolytextrep
FROM (SELECT ST_GeomFromText('POLYGON((-1 2, 3 4, 5 6, -1 2, 5 6, -1 2))') as invalidpoly) As foo
NOTICE: Self-intersection at or near point -1 2
isvalid | bufferisvalid | newpolytextrep
---------+---------------+------------------------------
f | t | POLYGON((-1 2,5 6,3 4,-1 2))
--Poor man's polygon unioner
SELECT ST_AsText(the_geom) as textorig, ST_AsText(ST_Buffer(foo.the_geom,0.0)) As textbuffer
FROM (SELECT ST_Collect('POLYGON((-1 2, 3 4, 5 6, -1 2))', 'POLYGON((-1 2, 2 3, 5 6, -1 2))') As the_geom) as foo;
textorig | textbuffer
-----------------------------------------------------------+--------------------
MULTIPOLYGON(((-1 2,3 4,5 6,-1 2)),((-1 2,2 3,5 6,-1 2))) | POLYGON((-1 2,5 6,3 4,2 3,-1 2))
</pre></div><div class="refsection" title="See Also"><a name="id36205938"></a><h2>See Also</h2><p><a class="xref" href="#ST_Collect" title="ST_Collect">ST_Collect</a>, <a class="xref" href="#ST_DWithin" title="ST_DWithin">ST_DWithin</a>, <a class="xref" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a>, <a class="xref" href="#ST_Transform" title="ST_Transform">ST_Transform</a>, <a class="xref" href="#ST_Union" title="ST_Union">ST_Union</a></p></div></div><div class="refentry" title="ST_BuildArea"><div class="refentry.separator"><hr></div><a name="ST_BuildArea"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_BuildArea — Creates an areal geometry formed by the constituent linework
of given geometry</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_BuildArea</b>(</code>geometry <var class="pdparam">A</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36206014"></a><h2>Description</h2><p>Creates an areal geometry formed by the constituent linework
of given geometry. The return type can be a Polygon or
MultiPolygon, depending on input. If the input lineworks do not
form polygons NULL is returned. The inputs can be LINESTRINGS, MULTILINESTRINGS, POLYGONS, MULTIPOLYGONS, and GeometryCollections.
</p><p>This function will assume all inner geometries represent holes</p><p>Availability: 1.1.0 - requires GEOS >= 2.1.0.</p></div><div class="refsection" title="Examples"><a name="id36206034"></a><h2>Examples</h2><div class="informaltable"><table border="1"><colgroup><col></colgroup><tbody><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_buildarea01.png"><div class="caption"><p>This will create a donut</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_BuildArea(ST_Collect(smallc,bigc))
FROM (SELECT
ST_Buffer(
ST_GeomFromText('POINT(100 90)'), 25) As smallc,
ST_Buffer(ST_GeomFromText('POINT(100 90)'), 50) As bigc) As foo;
</pre><p>
</p></td></tr><tr><td><div class="informalfigure"><div class="mediaobject"><img src="images/st_buildarea02.png"><div class="caption"><p>This will create a gaping hole inside the circle with prongs sticking out</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_BuildArea(ST_Collect(line,circle))
FROM (SELECT
ST_Buffer(
ST_MakeLine(ST_MakePoint(10, 10),ST_MakePoint(190, 190)),
5) As line,
ST_Buffer(ST_GeomFromText('POINT(100 90)'), 50) As circle) As foo;
--this creates the same gaping hole
--but using linestrings instead of polygons
SELECT ST_BuildArea(
ST_Collect(ST_ExteriorRing(line),ST_ExteriorRing(circle))
)
FROM (SELECT ST_Buffer(
ST_MakeLine(ST_MakePoint(10, 10),ST_MakePoint(190, 190))
,5) As line,
ST_Buffer(ST_GeomFromText('POINT(100 90)'), 50) As circle) As foo;
</pre><p>
</p></td></tr></tbody></table></div></div><div class="refsection" title="See Also"><a name="id36206123"></a><h2>See Also</h2><p>
<a class="xref" href="#ST_BdPolyFromText" title="ST_BdPolyFromText">ST_BdPolyFromText</a>,
<a class="xref" href="#ST_BdMPolyFromText" title="ST_BdMPolyFromText">ST_BdMPolyFromText</a>wrappers to
this function with standard OGC interface</p></div></div><div class="refentry" title="ST_Collect"><div class="refentry.separator"><hr></div><a name="ST_Collect"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Collect — Return a specified ST_Geometry value from a collection of other geometries.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Collect</b>(</code>geometry set <var class="pdparam">g1field</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_Collect</b>(</code>geometry <var class="pdparam">g1</var>, geometry <var class="pdparam">g2</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_Collect</b>(</code>geometry[] <var class="pdparam">g1_array</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36206238"></a><h2>Description</h2><p> Output type can be a MULTI* or a
GEOMETRYCOLLECTION. Comes in 2 variants. Variant 1 collects 2 geometries. Variant 2 is an aggregate function that takes a set of geometries and collects
them into a single ST_Geometry.</p><p>Aggregate version: This function returns a GEOMETRYCOLLECTION or a MULTI object
from a set of geometries. The ST_Collect() function is an "aggregate"
function in the terminology of PostgreSQL. That means that it
operates on rows of data, in the same way the SUM() and AVG()
functions do. For example, "SELECT ST_Collect(GEOM) FROM GEOMTABLE
GROUP BY ATTRCOLUMN" will return a separate GEOMETRYCOLLECTION for
each distinct value of ATTRCOLUMN.</p><p>Non-Aggregate version: This function returns a geometry being a collection of two
input geometries. Output type can be a MULTI* or a
GEOMETRYCOLLECTION.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>ST_Collect and ST_Union are often interchangeable.
ST_Collect is in general orders of magnitude faster than ST_Union
because it does not try to dissolve boundaries or validate that a constructed MultiPolgon doesn't
have overlapping regions. It merely rolls up
single geometries into MULTI and MULTI or mixed geometry types
into Geometry Collections. Unfortunately geometry collections are
not well-supported by GIS tools. To prevent ST_Collect from
returning a Geometry Collection when collecting MULTI geometries,
one can use the below trick that utilizes <a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a> to expand the
MULTIs out to singles and then regroup them.</p></td></tr></table></div><p>Availability: 1.4.0 - ST_Collect(geomarray) was introduced. ST_Collect was enhanced to handle more geometries faster.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves This method supports Circular Strings
and Curves, but will never return a MULTICURVE or MULTI as one
would expect and PostGIS does not currently support those.</p></div><div class="refsection" title="Examples"><a name="id36206308"></a><h2>Examples</h2><p>Aggregate example</p><pre class="programlisting">Thread ref: http://postgis.refractions.net/pipermail/postgis-users/2008-June/020331.html
SELECT stusps,
ST_Multi(ST_Collect(f.the_geom)) as singlegeom
FROM (SELECT stusps, (ST_Dump(the_geom)).geom As the_geom
FROM
somestatetable ) As f
GROUP BY stusps</pre><p>Non-Aggregate example</p><pre class="programlisting">Thread ref: http://postgis.refractions.net/pipermail/postgis-users/2008-June/020331.html
SELECT ST_AsText(ST_Collect(ST_GeomFromText('POINT(1 2)'),
ST_GeomFromText('POINT(-2 3)') ));
st_astext
----------
MULTIPOINT(1 2,-2 3)
--Collect 2 d points
SELECT ST_AsText(ST_Collect(ST_GeomFromText('POINT(1 2)'),
ST_GeomFromText('POINT(1 2)') ) );
st_astext
----------
MULTIPOINT(1 2,1 2)
--Collect 3d points
SELECT ST_AsEWKT(ST_Collect(ST_GeomFromEWKT('POINT(1 2 3)'),
ST_GeomFromEWKT('POINT(1 2 4)') ) );
st_asewkt
-------------------------
MULTIPOINT(1 2 3,1 2 4)
--Example with curves
SELECT ST_AsText(ST_Collect(ST_GeomFromText('CIRCULARSTRING(220268 150415,220227 150505,220227 150406)'),
ST_GeomFromText('CIRCULARSTRING(220227 150406,2220227 150407,220227 150406)')));
st_astext
------------------------------------------------------------------------------------
GEOMETRYCOLLECTION(CIRCULARSTRING(220268 150415,220227 150505,220227 150406),
CIRCULARSTRING(220227 150406,2220227 150407,220227 150406))
--New ST_Collect array construct
SELECT ST_Collect(ARRAY(SELECT the_geom FROM sometable));
SELECT ST_AsText(ST_Collect(ARRAY[ST_GeomFromText('LINESTRING(1 2, 3 4)'),
ST_GeomFromText('LINESTRING(3 4, 4 5)')])) As wktcollect;
--wkt collect --
MULTILINESTRING((1 2,3 4),(3 4,4 5))
</pre></div><div class="refsection" title="See Also"><a name="id36206334"></a><h2>See Also</h2><p><a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a>, <a class="xref" href="#ST_Union" title="ST_Union">ST_Union</a></p></div></div><div class="refentry" title="ST_ConvexHull"><div class="refentry.separator"><hr></div><a name="ST_ConvexHull"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_ConvexHull — The convex hull of a geometry represents the minimum convex
geometry that encloses all geometries within the set.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_ConvexHull</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36206395"></a><h2>Description</h2><p>The convex hull of a geometry represents the minimum convex
geometry that encloses all geometries within the set.</p><p>One can think of the convex hull as the geometry you get by wrapping an elastic
band around a set of geometries. This is different from a concave hull (not currently supported)
which is analogous to shrink-wrapping your geometries.</p><p>It is usually used with MULTI and Geometry Collections.
Although it is not an aggregate - you can use it in conjunction
with ST_Collect to get the convex hull of a set of points.
ST_ConvexHull(ST_Collect(somepointfield)).</p><p>It is often used to
determine an affected area based on a set of point
observations.</p><p>Performed by the GEOS module</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.16</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36206470"></a><h2>Examples</h2><pre class="programlisting">
--Get estimate of infected area based on point observations
SELECT d.disease_type,
ST_ConvexHull(ST_Collect(d.the_geom)) As the_geom
FROM disease_obs As d
GROUP BY d.disease_type;
</pre><p>
</p><div class="informalfigure"><div class="mediaobject"><img src="images/st_convexhull01.png"><div class="caption"><p>Convex Hull of a MultiLinestring and a MultiPoint seen together with the MultiLinestring and MultiPoint</p></div></div></div><p>
</p><pre class="programlisting">
SELECT ST_AsText(ST_ConvexHull(
ST_Collect(
ST_GeomFromText('MULTILINESTRING((100 190,10 8),(150 10, 20 30))'),
ST_GeomFromText('MULTIPOINT(50 5, 150 30, 50 10, 10 10)')
)) );
---st_astext--
POLYGON((50 5,10 8,10 10,100 190,150 30,150 10,50 5))
</pre><p>
</p></div><div class="refsection" title="See Also"><a name="id36206515"></a><h2>See Also</h2><p><a class="xref" href="#ST_Collect" title="ST_Collect">ST_Collect</a>, <a class="xref" href="#ST_MinimumBoundingCircle" title="ST_MinimumBoundingCircle">ST_MinimumBoundingCircle</a></p></div></div><div class="refentry" title="ST_CurveToLine"><div class="refentry.separator"><hr></div><a name="ST_CurveToLine"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_CurveToLine — Converts a CIRCULARSTRING/CURVEDPOLYGON to a LINESTRING/POLYGON</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_CurveToLine</b>(</code>geometry <var class="pdparam">curveGeom</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_CurveToLine</b>(</code>geometry <var class="pdparam">curveGeom</var>, integer <var class="pdparam">segments_per_qtr_circle</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36206608"></a><h2>Description</h2><p>Converst a CIRCULAR STRING to regular LINESTRING or CURVEPOLYGON to POLYGON. Useful for outputting to devices that can't support CIRCULARSTRING geometry types</p><p>Converts a given geometry to a linear geometry.
Each curved geometry or segment is converted into a linear approximation using the default value of 32 segments per quarter circle</p><p>Availability: 1.2.2?</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 7.1.7</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36206684"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsText(ST_CurveToLine(ST_GeomFromText('CIRCULARSTRING(220268 150415,220227 150505,220227 150406)')));
--Result --
LINESTRING(220268 150415,220269.95064912 150416.539364228,220271.823415575 150418.17258804,220273.613787707 150419.895736857,
220275.317452352 150421.704659462,220276.930305234 150423.594998003,220278.448460847 150425.562198489,
220279.868261823 150427.60152176,220281.186287736 150429.708054909,220282.399363347 150431.876723113,
220283.50456625 150434.10230186,220284.499233914 150436.379429536,220285.380970099 150438.702620341,220286.147650624 150441.066277505,
220286.797428488 150443.464706771,220287.328738321 150445.892130112,220287.740300149 150448.342699654,
220288.031122486 150450.810511759,220288.200504713 150453.289621251,220288.248038775 150455.77405574,
220288.173610157 150458.257830005,220287.977398166 150460.734960415,220287.659875492 150463.199479347,
220287.221807076 150465.64544956,220286.664248262 150468.066978495,220285.988542259 150470.458232479,220285.196316903 150472.81345077,
220284.289480732 150475.126959442,220283.270218395 150477.39318505,220282.140985384 150479.606668057,
220280.90450212 150481.762075989,220279.5637474 150483.85421628,220278.12195122 150485.87804878,
220276.582586992 150487.828697901,220274.949363179 150489.701464356,220273.226214362 150491.491836488,
220271.417291757 150493.195501133,220269.526953216 150494.808354014,220267.559752731 150496.326509628,
220265.520429459 150497.746310603,220263.41389631 150499.064336517,220261.245228106 150500.277412127,
220259.019649359 150501.38261503,220256.742521683 150502.377282695,220254.419330878 150503.259018879,
220252.055673714 150504.025699404,220249.657244448 150504.675477269,220247.229821107 150505.206787101,
220244.779251566 150505.61834893,220242.311439461 150505.909171266,220239.832329968 150506.078553494,
220237.347895479 150506.126087555,220234.864121215 150506.051658938,220232.386990804 150505.855446946,
220229.922471872 150505.537924272,220227.47650166 150505.099855856,220225.054972724 150504.542297043,
220222.663718741 150503.86659104,220220.308500449 150503.074365683,
220217.994991777 150502.167529512,220215.72876617 150501.148267175,
220213.515283163 150500.019034164,220211.35987523 150498.7825509,
220209.267734939 150497.441796181,220207.243902439 150496,
220205.293253319 150494.460635772,220203.420486864 150492.82741196,220201.630114732 150491.104263143,
220199.926450087 150489.295340538,220198.313597205 150487.405001997,220196.795441592 150485.437801511,
220195.375640616 150483.39847824,220194.057614703 150481.291945091,220192.844539092 150479.123276887,220191.739336189 150476.89769814,
220190.744668525 150474.620570464,220189.86293234 150472.297379659,220189.096251815 150469.933722495,
220188.446473951 150467.535293229,220187.915164118 150465.107869888,220187.50360229 150462.657300346,
220187.212779953 150460.189488241,220187.043397726 150457.710378749,220186.995863664 150455.22594426,
220187.070292282 150452.742169995,220187.266504273 150450.265039585,220187.584026947 150447.800520653,
220188.022095363 150445.35455044,220188.579654177 150442.933021505,220189.25536018 150440.541767521,
220190.047585536 150438.18654923,220190.954421707 150435.873040558,220191.973684044 150433.60681495,
220193.102917055 150431.393331943,220194.339400319 150429.237924011,220195.680155039 150427.14578372,220197.12195122 150425.12195122,
220198.661315447 150423.171302099,220200.29453926 150421.298535644,220202.017688077 150419.508163512,220203.826610682 150417.804498867,
220205.716949223 150416.191645986,220207.684149708 150414.673490372,220209.72347298 150413.253689397,220211.830006129 150411.935663483,
220213.998674333 150410.722587873,220216.22425308 150409.61738497,220218.501380756 150408.622717305,220220.824571561 150407.740981121,
220223.188228725 150406.974300596,220225.586657991 150406.324522731,220227 150406)
--3d example
SELECT ST_AsEWKT(ST_CurveToLine(ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)')));
Output
------
LINESTRING(220268 150415 1,220269.95064912 150416.539364228 1.0181172856673,
220271.823415575 150418.17258804 1.03623457133459,220273.613787707 150419.895736857 1.05435185700189,....AD INFINITUM ....
220225.586657991 150406.324522731 1.32611114201132,220227 150406 3)
--use only 2 segments to approximate quarter circle
SELECT ST_AsText(ST_CurveToLine(ST_GeomFromText('CIRCULARSTRING(220268 150415,220227 150505,220227 150406)'),2));
st_astext
------------------------------
LINESTRING(220268 150415,220287.740300149 150448.342699654,220278.12195122 150485.87804878,
220244.779251566 150505.61834893,220207.243902439 150496,220187.50360229 150462.657300346,
220197.12195122 150425.12195122,220227 150406)
</pre></div><div class="refsection" title="See Also"><a name="id36206699"></a><h2>See Also</h2><p><a class="xref" href="#ST_LineToCurve" title="ST_LineToCurve">ST_LineToCurve</a></p></div></div><div class="refentry" title="ST_Difference"><div class="refentry.separator"><hr></div><a name="ST_Difference"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Difference — Returns a geometry that represents that part of geometry A
that does not intersect with geometry B.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Difference</b>(</code>geometry <var class="pdparam">geomA</var>, geometry <var class="pdparam">geomB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36206764"></a><h2>Description</h2><p>Returns a geometry that represents that part of geometry A
that does not intersect with geometry B. One can think of this as GeometryA - ST_Intersection(A,B). If A is completely contained in B
then an empty geometry collection is returned.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Note - order matters. B - A will always return a portion of B</p></td></tr></table></div><p>Performed by the GEOS module</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a GeometryCollection as an argument</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.20</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index. However it seems to only consider x y when
doing the difference and tacks back on the Z-Index</p></div><div class="refsection" title="Examples"><a name="id36206838"></a><h2>Examples</h2><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td>
<p>
</p><div class="informalfigure"><div class="mediaobject"><img src="images/st_symdifference01.png"><div class="caption"><p>The original linestrings shown together. </p></div></div></div><p>
</p>
</td><td>
<div class="informalfigure"><div class="mediaobject"><img src="images/st_difference01.png"><div class="caption"><p>The difference of the two linestrings</p></div></div></div><p>
</p>
</td></tr></tbody></table></div><pre class="programlisting">
--Safe for 2d. This is same geometries as what is shown for st_symdifference
SELECT ST_AsText(
ST_Difference(
ST_GeomFromText('LINESTRING(50 100, 50 200)'),
ST_GeomFromText('LINESTRING(50 50, 50 150)')
)
);
st_astext
---------
LINESTRING(50 150,50 200)
</pre><pre class="programlisting">
--When used in 3d doesn't quite do the right thing
SELECT ST_AsEWKT(ST_Difference(ST_GeomFromEWKT('MULTIPOINT(-118.58 38.38 5,-118.60 38.329 6,-118.614 38.281 7)'), ST_GeomFromEWKT('POINT(-118.614 38.281 5)')));
st_asewkt
---------
MULTIPOINT(-118.6 38.329 6,-118.58 38.38 5)
</pre></div><div class="refsection" title="See Also"><a name="id36206930"></a><h2>See Also</h2><p><a class="xref" href="#ST_SymDifference" title="ST_SymDifference">ST_SymDifference</a></p></div></div><div class="refentry" title="ST_Dump"><div class="refentry.separator"><hr></div><a name="ST_Dump"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Dump — Returns a set of geometry_dump (geom,path) rows, that make up a geometry g1.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry_dump[]<b class="fsfunc">ST_Dump</b>(</code>geometry <var class="pdparam">g1</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36206986"></a><h2>Description</h2><p>This is a set-returning function (SRF). It returns a set of
geometry_dump rows, formed by a geometry (geom) and an array of
integers (path). When the input geometry is a simple type
(POINT,LINESTRING,POLYGON) a single record will be returned with
an empty path array and the input geometry as geom. When the input
geometry is a collection or multi it will return a record for each
of the collection components, and the path will express the
position of the component inside the collection.</p><p>ST_Dump is useful for expanding geometries. It is the
reverse of a GROUP BY in that it creates new rows. For example it
can be use to expand MULTIPOLYGONS into POLYGONS.</p><p>Availability: PostGIS 1.0.0RC1. Requires PostgreSQL 7.3 or higher.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36207039"></a><h2>Examples</h2><pre class="programlisting">SELECT sometable.field1, sometable.field1,
(ST_Dump(sometable.the_geom)).geom AS the_geom
FROM sometable;
--Break a compound curve into its constituent linestrings and circularstrings
SELECT ST_AsEWKT(a.geom), ST_HasArc(a.geom)
FROM ( SELECT (ST_Dump(p_geom)).geom AS geom
FROM (SELECT ST_GeomFromEWKT('COMPOUNDCURVE(CIRCULARSTRING(0 0, 1 1, 1 0),(1 0, 0 1))') AS p_geom) AS b
) AS a;
st_asewkt | st_hasarc
-----------------------------+----------
CIRCULARSTRING(0 0,1 1,1 0) | t
LINESTRING(1 0,0 1) | f
(2 rows)</pre></div><div class="refsection" title="See Also"><a name="id36207056"></a><h2>See Also</h2><p><a class="xref" href="#geometry_dump" title="geometry_dump">geometry_dump</a>, <a class="xref" href="#PostGIS_Geometry_DumpFunctions" title="8.4.PostGIS Geometry Dump Functions">Section8.4, “PostGIS Geometry Dump Functions”</a>, <a class="xref" href="#ST_Collect" title="ST_Collect">ST_Collect</a>, <a class="xref" href="#ST_Collect" title="ST_Collect">ST_Collect</a>, <a class="xref" href="#ST_GeometryN" title="ST_GeometryN">ST_GeometryN</a></p></div></div><div class="refentry" title="ST_DumpPoints"><div class="refentry.separator"><hr></div><a name="ST_DumpPoints"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_DumpPoints — Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry_dump[]<b class="fsfunc">ST_DumpPoints</b>(</code>geometry <var class="pdparam">geom</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36207132"></a><h2>Description</h2><p>This set-returning function (SRF) returns a set of <code class="varname">geometry_dump</code> rows formed
by a geometry (<code class="varname">geom</code>) and an array of integers (<code class="varname">path</code>).</p><p>The <em class="parameter"><code>geom</code></em> component of <code class="varname">geometry_dump</code> are
all the <code class="varname">POINT</code>s that make up the supplied geometry</p><p>The <em class="parameter"><code>path</code></em> component of <code class="varname">geometry_dump</code> (an <code class="varname">integer[]</code>)
is an index reference enumerating the <code class="varname">POINT</code>s of the supplied geometry.
For example, if a <code class="varname">LINESTRING</code> is supplied, a path of <code class="varname">{i}</code> is
returned where <code class="varname">i</code> is the <code class="varname">nth</code> coordinate in the <code class="varname">LINESTRING</code>.
If a <code class="varname">POLYGON</code> is supplied, a path of <code class="varname">{i,j}</code> is returned where
<code class="varname">i</code> is the outer ring followed by the inner rings and <code class="varname">j</code>
enumerates the <code class="varname">POINT</code>s.
</p><p>Availability: 1.5.0</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36207254"></a><h2>Examples</h2><div class="informalfigure"><div class="mediaobject"><img src="images/st_dumppoints01.png"></div></div><pre class="programlisting">SELECT path, ST_AsText(geom)
FROM (
SELECT (ST_DumpPoints(g.geom)).*
FROM
(SELECT
'GEOMETRYCOLLECTION(
POINT ( 0 1 ),
LINESTRING ( 0 3, 3 4 ),
POLYGON (( 2 0, 2 3, 0 2, 2 0 )),
POLYGON (( 3 0, 3 3, 6 3, 6 0, 3 0 ),
( 5 1, 4 2, 5 2, 5 1 )),
MULTIPOLYGON (
(( 0 5, 0 8, 4 8, 4 5, 0 5 ),
( 1 6, 3 6, 2 7, 1 6 )),
(( 5 4, 5 8, 6 7, 5 4 ))
)
)'::geometry AS geom
) AS g
) j;
path | st_astext
-----------+------------
{1,1} | POINT(0 1)
{2,1} | POINT(0 3)
{2,2} | POINT(3 4)
{3,1,1} | POINT(2 0)
{3,1,2} | POINT(2 3)
{3,1,3} | POINT(0 2)
{3,1,4} | POINT(2 0)
{4,1,1} | POINT(3 0)
{4,1,2} | POINT(3 3)
{4,1,3} | POINT(6 3)
{4,1,4} | POINT(6 0)
{4,1,5} | POINT(3 0)
{4,2,1} | POINT(5 1)
{4,2,2} | POINT(4 2)
{4,2,3} | POINT(5 2)
{4,2,4} | POINT(5 1)
{5,1,1,1} | POINT(0 5)
{5,1,1,2} | POINT(0 8)
{5,1,1,3} | POINT(4 8)
{5,1,1,4} | POINT(4 5)
{5,1,1,5} | POINT(0 5)
{5,1,2,1} | POINT(1 6)
{5,1,2,2} | POINT(3 6)
{5,1,2,3} | POINT(2 7)
{5,1,2,4} | POINT(1 6)
{5,2,1,1} | POINT(5 4)
{5,2,1,2} | POINT(5 8)
{5,2,1,3} | POINT(6 7)
{5,2,1,4} | POINT(5 4)
(29 rows)</pre></div><div class="refsection" title="See Also"><a name="id36207282"></a><h2>See Also</h2><p><a class="xref" href="#geometry_dump" title="geometry_dump">geometry_dump</a>, <a class="xref" href="#PostGIS_Geometry_DumpFunctions" title="8.4.PostGIS Geometry Dump Functions">Section8.4, “PostGIS Geometry Dump Functions”</a>, <a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a>, <a class="xref" href="#ST_DumpRings" title="ST_DumpRings">ST_DumpRings</a></p></div></div><div class="refentry" title="ST_DumpRings"><div class="refentry.separator"><hr></div><a name="ST_DumpRings"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_DumpRings — Returns a set of <code class="varname">geometry_dump</code> rows, representing
the exterior and interior rings of a polygon.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry_dump[] <b class="fsfunc">ST_DumpRings</b>(</code>geometry <var class="pdparam">a_polygon</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36207357"></a><h2>Description</h2><p>This is a set-returning function (SRF). It returns a set of
<code class="varname">geometry_dump</code> rows, defined as an <code class="varname">integer[]</code>
and a <code class="varname">geometry</code>, aliased "path" and "geom" respectively.
The "path" field holds the polygon ring index containing a single integer: 0 for the shell, >0 for holes.
The "geom" field contains the corresponding ring as a polygon.</p><p>Availability: PostGIS 1.1.3. Requires PostgreSQL 7.3 or higher.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This only works for POLYGON geometries. It will not work for MULTIPOLYGONS</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36207402"></a><h2>Examples</h2><pre class="programlisting">SELECT sometable.field1, sometable.field1,
(ST_DumpRings(sometable.the_geom)).geom As the_geom
FROM sometableOfpolys;
SELECT ST_AsEWKT(geom) As the_geom, path
FROM ST_DumpRings(
ST_GeomFromEWKT('POLYGON((-8149064 5133092 1,-8149064 5132986 1,-8148996 5132839 1,-8148972 5132767 1,-8148958 5132508 1,-8148941 5132466 1,-8148924 5132394 1,
-8148903 5132210 1,-8148930 5131967 1,-8148992 5131978 1,-8149237 5132093 1,-8149404 5132211 1,-8149647 5132310 1,-8149757 5132394 1,
-8150305 5132788 1,-8149064 5133092 1),
(-8149362 5132394 1,-8149446 5132501 1,-8149548 5132597 1,-8149695 5132675 1,-8149362 5132394 1))')
) as foo;
path | the_geom
----------------------------------------------------------------------------------------------------------------
{0} | POLYGON((-8149064 5133092 1,-8149064 5132986 1,-8148996 5132839 1,-8148972 5132767 1,-8148958 5132508 1,
| -8148941 5132466 1,-8148924 5132394 1,
| -8148903 5132210 1,-8148930 5131967 1,
| -8148992 5131978 1,-8149237 5132093 1,
| -8149404 5132211 1,-8149647 5132310 1,-8149757 5132394 1,-8150305 5132788 1,-8149064 5133092 1))
{1} | POLYGON((-8149362 5132394 1,-8149446 5132501 1,
| -8149548 5132597 1,-8149695 5132675 1,-8149362 5132394 1))</pre></div><div class="refsection" title="See Also"><a name="id36207417"></a><h2>See Also</h2><p><a class="xref" href="#geometry_dump" title="geometry_dump">geometry_dump</a>, <a class="xref" href="#PostGIS_Geometry_DumpFunctions" title="8.4.PostGIS Geometry Dump Functions">Section8.4, “PostGIS Geometry Dump Functions”</a>, <a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a>, <a class="xref" href="#ST_ExteriorRing" title="ST_ExteriorRing">ST_ExteriorRing</a>, <a class="xref" href="#ST_InteriorRingN" title="ST_InteriorRingN">ST_InteriorRingN</a></p></div></div><div class="refentry" title="ST_Intersection"><div class="refentry.separator"><hr></div><a name="ST_Intersection"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Intersection — (T) Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation
does a transform to geometry to do the intersection and then transform back to WGS84.
</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Intersection</b>(</code>
geometry
<var class="pdparam">geomA</var>
,
geometry
<var class="pdparam">geomB</var>
<code>)</code>;</p><p><code class="funcdef">geography <b class="fsfunc">ST_Intersection</b>(</code>
geography
<var class="pdparam">geogA</var>
,
geography
<var class="pdparam">geogB</var>
<code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36207543"></a><h2>Description</h2><p>Returns a geometry that represents the point set
intersection of the Geometries.</p><p>In other words - that portion of geometry A and geometry B
that is shared between the two geometries.</p><p>If the geometries do not share any space (are disjoint), then an empty geometry collection
is returned.</p><p>ST_Intersection in conjunction with ST_Intersects is very useful for clipping geometries such as in bounding box, buffer, region
queries where you only want to return that portion of a geometry that sits in a country or region of interest.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Geography: For geography this is really a thin wrapper around the geometry implementation. It first determines the best SRID that
fits the bounding box of the 2 geography objects (if geography objects are within one half zone UTM but not same UTM will pick one of those) (favoring UTM or Lambert Azimuthal Equal Area (LAEA) north/south pole, and falling back on mercator in worst case scenario) and then intersection in that best fit planar spatial ref and retransforms back to WGS84 geography.</p></td></tr></table></div><div class="important" title="Important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a <code class="varname">GEOMETRYCOLLECTION</code> as an argument</p></td></tr></table></div><p>Performed by the GEOS module</p><p>Availability: 1.5 support for geography data type was introduced.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.18</p></div><div class="refsection" title="Examples"><a name="id36207626"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsText(ST_Intersection('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry));
st_astext
---------------
GEOMETRYCOLLECTION EMPTY
(1 row)
SELECT ST_AsText(ST_Intersection('POINT(0 0)'::geometry, 'LINESTRING ( 0 0, 0 2 )'::geometry));
st_astext
---------------
POINT(0 0)
(1 row)
---Clip all lines (trails) by country (here we assume country geom are POLYGON or MULTIPOLYGONS)
-- NOTE: we are only keeping intersections that result in a LINESTRING or MULTILINESTRING because we don't
-- care about trails that just share a point
-- the dump is needed to expand a geometry collection into individual single MULT* parts
-- the below is fairly generic and will work for polys, etc. by just changing the where clause
SELECT clipped.gid, clipped.f_name, clipped_geom
FROM (SELECT trails.gid, trails.f_name, (ST_Dump(ST_Intersection(country.the_geom, trails.the_geom))).geom As clipped_geom
FROM country
INNER JOIN trails
ON ST_Intersects(country.the_geom, trails.the_geom)) As clipped
WHERE ST_Dimension(clipped.clipped_geom) = 1 ;
--For polys e.g. polygon landmarks, you can also use the sometimes faster hack that buffering anything by 0.0
-- except a polygon results in an empty geometry collection
--(so a geometry collection containing polys, lines and points)
-- buffered by 0.0 would only leave the polygons and dissolve the collection shell
SELECT poly.gid, ST_Multi(ST_Buffer(
ST_Intersection(country.the_geom, poly.the_geom),
0.0)
) As clipped_geom
FROM country
INNER JOIN poly
ON ST_Intersects(country.the_geom, poly.the_geom)
WHERE Not ST_IsEmpty(ST_Buffer(ST_Intersection(country.the_geom, poly.the_geom),0.0));
</pre></div><div class="refsection" title="See Also"><a name="id36207638"></a><h2>See Also</h2><p><a class="xref" href="#ST_Difference" title="ST_Difference">ST_Difference</a>, <a class="xref" href="#ST_Dimension" title="ST_Dimension">ST_Dimension</a>, <a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a>, <a class="xref" href="#ST_SymDifference" title="ST_SymDifference">ST_SymDifference</a>, <a class="xref" href="#ST_Intersects" title="ST_Intersects">ST_Intersects</a>, <a class="xref" href="#ST_Multi" title="ST_Multi">ST_Multi</a></p></div></div><div class="refentry" title="ST_LineToCurve"><div class="refentry.separator"><hr></div><a name="ST_LineToCurve"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_LineToCurve — Converts a LINESTRING/POLYGON to a CIRCULARSTRING, CURVED POLYGON</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_LineToCurve</b>(</code>geometry <var class="pdparam">geomANoncircular</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36207719"></a><h2>Description</h2><p>Converts plain LINESTRING/POLYGONS to CIRCULAR STRINGs and Curved Polygons. Note much fewer points are needed to describe the curved equivalent.</p><p>Availability: 1.2.2?</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36207759"></a><h2>Examples</h2><pre class="programlisting">
SELECT ST_AsText(ST_LineToCurve(foo.the_geom)) As curvedastext,ST_AsText(foo.the_geom) As non_curvedastext
FROM (SELECT ST_Buffer('POINT(1 3)'::geometry, 3) As the_geom) As foo;
curvedatext non_curvedastext
------------------------------------------------------------------| -----------------------------------------------------------------
CURVEPOLYGON(CIRCULARSTRING(4 3,3.12132034355964 0.878679656440359, | POLYGON((4 3,3.94235584120969 2.41472903395162,3.77163859753386 1.85194970290473
1 0,-1.12132034355965 5.12132034355963,4 3)) | ,3.49440883690764 1.33328930094119,3.12132034355964 0.878679656440359,
| 2.66671069905881 0.505591163092366,2.14805029709527 0.228361402466141,
| 1.58527096604839 0.0576441587903094,1 0,
| 0.414729033951621 0.0576441587903077,-0.148050297095264 0.228361402466137,
| -0.666710699058802 0.505591163092361,-1.12132034355964 0.878679656440353,
| -1.49440883690763 1.33328930094119,-1.77163859753386 1.85194970290472
| --ETC-- ,3.94235584120969 3.58527096604839,4 3))
--3D example
SELECT ST_AsEWKT(ST_LineToCurve(ST_GeomFromEWKT('LINESTRING(1 2 3, 3 4 8, 5 6 4, 7 8 4, 9 10 4)')));
st_asewkt
------------------------------------
CIRCULARSTRING(1 2 3,5 6 4,9 10 4)
</pre></div><div class="refsection" title="See Also"><a name="id36207774"></a><h2>See Also</h2><p><a class="xref" href="#ST_CurveToLine" title="ST_CurveToLine">ST_CurveToLine</a></p></div></div><div class="refentry" title="ST_MemUnion"><div class="refentry.separator"><hr></div><a name="ST_MemUnion"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MemUnion — Same as ST_Union, only memory-friendly (uses less memory
and more processor time).</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MemUnion</b>(</code>geometry set <var class="pdparam">geomfield</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36207830"></a><h2>Description</h2><p>Some useful description here.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Same as ST_Union, only memory-friendly (uses less memory
and more processor time). This aggregate function works by unioning the geometries one at a time to previous result as opposed to
ST_Union aggregate which first creates an array and then unions</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36207866"></a><h2>Examples</h2><pre class="programlisting">See ST_Union</pre></div><div class="refsection" title="See Also"><a name="id36207881"></a><h2>See Also</h2><p><a class="xref" href="#ST_Union" title="ST_Union">ST_Union</a></p></div></div><div class="refentry" title="ST_MinimumBoundingCircle"><div class="refentry.separator"><hr></div><a name="ST_MinimumBoundingCircle"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_MinimumBoundingCircle — Returns the smallest circle polygon that can fully contain a geometry. Default
uses 48 segments per quarter circle.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_MinimumBoundingCircle</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_MinimumBoundingCircle</b>(</code>geometry <var class="pdparam">geomA</var>, integer <var class="pdparam">num_segs_per_qt_circ</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36207967"></a><h2>Description</h2><p>Returns the smallest circle polygon that can fully contain a geometry. </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>The circle is approximated by a polygon with a default of 48 segments per quarter circle. This number can be increased with little performance penalty to obtain a more accurate result.</p></td></tr></table></div><p>It is often used with MULTI and Geometry Collections.
Although it is not an aggregate - you can use it in conjunction
with ST_Collect to get the minimum bounding cirlce of a set of geometries.
ST_MinimumBoundingCircle(ST_Collect(somepointfield)).</p><p>The ratio of the area of a polygon divided by the area of its Minimum Bounding Circle is often referred to as the Roeck test.</p><p>Availability: 1.4.0 - requires GEOS</p></div><div class="refsection" title="Examples"><a name="id36207996"></a><h2>Examples</h2><pre class="programlisting">SELECT d.disease_type,
ST_MinimumBoundingCircle(ST_Collect(d.the_geom)) As the_geom
FROM disease_obs As d
GROUP BY d.disease_type;
</pre><div class="informalfigure"><div class="mediaobject"><img src="images/st_minimumboundingcircle01.png"><div class="caption"><p>Minimum bounding circle of a point and linestring. Using 8 segs to approximate a quarter circle</p></div></div></div><pre class="programlisting">
SELECT ST_AsText(ST_MinimumBoundingCircle(
ST_Collect(
ST_GeomFromEWKT('LINESTRING(55 75,125 150)'),
ST_Point(20, 80)), 8
)) As wktmbc;
wktmbc
-----------
POLYGON((135.59714732062 115,134.384753327498 102.690357210921,130.79416296937 90.8537670908995,124.963360620072 79.9451031602111,117.116420743937 70.3835792560632,107.554896839789 62.5366393799277,96.6462329091006 56.70583703063,84.8096427890789 53.115246672502,72.5000000000001 51.9028526793802,60.1903572109213 53.1152466725019,48.3537670908996 56.7058370306299,37.4451031602112 62.5366393799276,27.8835792560632 70.383579256063,20.0366393799278 79.9451031602109,14.20583703063 90.8537670908993,10.615246672502 102.690357210921,9.40285267938019 115,10.6152466725019 127.309642789079,14.2058370306299 139.1462329091,20.0366393799275 150.054896839789,27.883579256063 159.616420743937,
37.4451031602108 167.463360620072,48.3537670908992 173.29416296937,60.190357210921 176.884753327498,
72.4999999999998 178.09714732062,84.8096427890786 176.884753327498,96.6462329091003 173.29416296937,107.554896839789 167.463360620072,
117.116420743937 159.616420743937,124.963360620072 150.054896839789,130.79416296937 139.146232909101,134.384753327498 127.309642789079,135.59714732062 115))
</pre></div><div class="refsection" title="See Also"><a name="id36208035"></a><h2>See Also</h2><p><a class="xref" href="#ST_Collect" title="ST_Collect">ST_Collect</a>, <a class="xref" href="#ST_ConvexHull" title="ST_ConvexHull">ST_ConvexHull</a></p></div></div><div class="refentry" title="ST_Polygonize"><div class="refentry.separator"><hr></div><a name="ST_Polygonize"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Polygonize — Aggregate. Creates a GeometryCollection containing possible
polygons formed from the constituent linework of a set of
geometries.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Polygonize</b>(</code>geometry set <var class="pdparam">geomfield</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_Polygonize</b>(</code>geometry[] <var class="pdparam">geom_array</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36208118"></a><h2>Description</h2><p>Creates a GeometryCollection containing possible
polygons formed from the constituent linework of a set of
geometries.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Geometry Collections are often difficult to deal with with third party tools, so use ST_Polygonize in conjunction with <a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a> to dump the polygons
out into individual polygons.</p></td></tr></table></div><p>Availability: 1.0.0RC1 - requires GEOS >= 2.1.0.</p></div><div class="refsection" title="Examples: Polygonizing single linestrings"><a name="id36208146"></a><h2>Examples: Polygonizing single linestrings</h2><pre class="programlisting">
SELECT ST_AsEWKT(ST_Polygonize(the_geom_4269)) As geomtextrep
FROM (SELECT the_geom_4269 FROM ma.suffolk_edges ORDER BY tlid LIMIT 45) As foo;
geomtextrep
-------------------------------------
SRID=4269;GEOMETRYCOLLECTION(POLYGON((-71.040878 42.285678,-71.040943 42.2856,-71.04096 42.285752,-71.040878 42.285678)),
POLYGON((-71.17166 42.353675,-71.172026 42.354044,-71.17239 42.354358,-71.171794 42.354971,-71.170511 42.354855,
-71.17112 42.354238,-71.17166 42.353675)))
(1 row)
--Use ST_Dump to dump out the polygonize geoms into individual polygons
SELECT ST_AsEWKT((ST_Dump(foofoo.polycoll)).geom) As geomtextrep
FROM (SELECT ST_Polygonize(the_geom_4269) As polycoll
FROM (SELECT the_geom_4269 FROM ma.suffolk_edges
ORDER BY tlid LIMIT 45) As foo) As foofoo;
geomtextrep
------------------------
SRID=4269;POLYGON((-71.040878 42.285678,-71.040943 42.2856,-71.04096 42.285752,
-71.040878 42.285678))
SRID=4269;POLYGON((-71.17166 42.353675,-71.172026 42.354044,-71.17239 42.354358
,-71.171794 42.354971,-71.170511 42.354855,-71.17112 42.354238,-71.17166 42.353675))
(2 rows)
</pre></div><div class="refsection" title="See Also"><a name="id36208158"></a><h2>See Also</h2><p><a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a></p></div></div><div class="refentry" title="ST_Shift_Longitude"><div class="refentry.separator"><hr></div><a name="ST_Shift_Longitude"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Shift_Longitude — Reads every point/vertex in every component of every feature
in a geometry, and if the longitude coordinate is <0, adds 360
to it. The result would be a 0-360 version of the data to be
plotted in a 180 centric map</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Shift_Longitude</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36208216"></a><h2>Description</h2><p>Reads every point/vertex in every component of every feature
in a geometry, and if the longitude coordinate is <0, adds 360
to it. The result would be a 0-360 version of the data to be
plotted in a 180 centric map</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>This is only useful for data in long lat e.g. 4326 (WGS 84 long lat)</p></td></tr></table></div><p><img src="images/warning.png">
Pre-1.3.4 bug prevented this from working for MULTIPOINT. 1.3.4+ works with MULTIPOINT as well.
</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36208253"></a><h2>Examples</h2><pre class="programlisting">--3d points
SELECT ST_AsEWKT(ST_Shift_Longitude(ST_GeomFromEWKT('SRID=4326;POINT(-118.58 38.38 10)'))) As geomA,
ST_AsEWKT(ST_Shift_Longitude(ST_GeomFromEWKT('SRID=4326;POINT(241.42 38.38 10)'))) As geomb
geomA geomB
---------- -----------
SRID=4326;POINT(241.42 38.38 10) SRID=4326;POINT(-118.58 38.38 10)
--regular line string
SELECT ST_AsText(ST_Shift_Longitude(ST_GeomFromText('LINESTRING(-118.58 38.38, -118.20 38.45)')))
st_astext
----------
LINESTRING(241.42 38.38,241.8 38.45)
</pre></div><div class="refsection" title="See Also"><a name="id36208272"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a></p></div></div><div class="refentry" title="ST_Simplify"><div class="refentry.separator"><hr></div><a name="ST_Simplify"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Simplify — Returns a "simplified" version of the given geometry using
the Douglas-Peucker algorithm.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Simplify</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">tolerance</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36208348"></a><h2>Description</h2><p>Returns a "simplified" version of the given geometry using
the Douglas-Peucker algorithm. Will actually do something only with
(multi)lines and (multi)polygons but you can safely call it with
any kind of geometry. Since simplification occurs on a
object-by-object basis you can also feed a GeometryCollection to
this function.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Note that returned geometry might loose its
simplicity (see <a class="xref" href="#ST_IsSimple" title="ST_IsSimple">ST_IsSimple</a>)</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Note topology may not be preserved and may result in invalid geometries. Use (see <a class="xref" href="#ST_SimplifyPreserveTopology" title="ST_SimplifyPreserveTopology">ST_SimplifyPreserveTopology</a>) to preserve topology.</p></td></tr></table></div><p>Performed by the GEOS module.</p><p>Availability: 1.2.2</p></div><div class="refsection" title="Examples"><a name="id36208389"></a><h2>Examples</h2><p>A circle simplified too much becomes a triangle, medium an octagon, </p><pre class="programlisting">
SELECT ST_Npoints(the_geom) As np_before, ST_NPoints(ST_Simplify(the_geom,0.1)) As np01_notbadcircle, ST_NPoints(ST_Simplify(the_geom,0.5)) As np05_notquitecircle,
ST_NPoints(ST_Simplify(the_geom,1)) As np1_octagon, ST_NPoints(ST_Simplify(the_geom,10)) As np10_triangle,
(ST_Simplify(the_geom,100) is null) As np100_geometrygoesaway
FROM (SELECT ST_Buffer('POINT(1 3)', 10,12) As the_geom) As foo;
-result
np_before | np01_notbadcircle | np05_notquitecircle | np1_octagon | np10_triangle | np100_geometrygoesaway
-----------+-------------------+---------------------+-------------+---------------+------------------------
49 | 33 | 17 | 9 | 4 | t
</pre></div><div class="refsection" title="See Also"><a name="id36208411"></a><h2>See Also</h2><p><a class="xref" href="#ST_IsSimple" title="ST_IsSimple">ST_IsSimple</a>, <a class="xref" href="#ST_SimplifyPreserveTopology" title="ST_SimplifyPreserveTopology">ST_SimplifyPreserveTopology</a></p></div></div><div class="refentry" title="ST_SimplifyPreserveTopology"><div class="refentry.separator"><hr></div><a name="ST_SimplifyPreserveTopology"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_SimplifyPreserveTopology — Returns a "simplified" version of the given geometry using
the Douglas-Peucker algorithm. Will avoid creating derived
geometries (polygons in particular) that are invalid.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_SimplifyPreserveTopology</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">tolerance</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36208483"></a><h2>Description</h2><p>Returns a "simplified" version of the given geometry using
the Douglas-Peucker algorithm. Will avoid creating derived
geometries (polygons in particular) that are invalid. Will actually do something only with
(multi)lines and (multi)polygons but you can safely call it with
any kind of geometry. Since simplification occurs on a
object-by-object basis you can also feed a GeometryCollection to
this function.</p><p>Performed by the GEOS module.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Requires GEOS 3.0.0+</p></td></tr></table></div><p>Availability: 1.3.3</p></div><div class="refsection" title="Examples"><a name="id36208508"></a><h2>Examples</h2><p>Same example as Simplify, but we see Preserve Topology prevents oversimplification. The circle can at most become a square.</p><pre class="programlisting">
SELECT ST_Npoints(the_geom) As np_before, ST_NPoints(ST_SimplifyPreserveTopology(the_geom,0.1)) As np01_notbadcircle, ST_NPoints(ST_SimplifyPreserveTopology(the_geom,0.5)) As np05_notquitecircle,
ST_NPoints(ST_SimplifyPreserveTopology(the_geom,1)) As np1_octagon, ST_NPoints(ST_SimplifyPreserveTopology(the_geom,10)) As np10_square,
ST_NPoints(ST_SimplifyPreserveTopology(the_geom,100)) As np100_stillsquare
FROM (SELECT ST_Buffer('POINT(1 3)', 10,12) As the_geom) As foo;
--result--
np_before | np01_notbadcircle | np05_notquitecircle | np1_octagon | np10_square | np100_stillsquare
-----------+-------------------+---------------------+-------------+---------------+-------------------
49 | 33 | 17 | 9 | 5 | 5
</pre></div><div class="refsection" title="See Also"><a name="id36208530"></a><h2>See Also</h2><p><a class="xref" href="#ST_Simplify" title="ST_Simplify">ST_Simplify</a></p></div></div><div class="refentry" title="ST_SymDifference"><div class="refentry.separator"><hr></div><a name="ST_SymDifference"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_SymDifference — Returns a geometry that represents the portions of A and B
that do not intersect. It is called a symmetric difference because
ST_SymDifference(A,B) = ST_SymDifference(B,A).</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_SymDifference</b>(</code>geometry <var class="pdparam">geomA</var>, geometry <var class="pdparam">geomB</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36208597"></a><h2>Description</h2><p>Returns a geometry that represents the portions of A and B
that do not intersect. It is called a symmetric difference because
ST_SymDifference(A,B) = ST_SymDifference(B,A). One can think of this as ST_Union(geomA,geomB) - ST_Intersection(A,B).
</p><p>Performed by the GEOS module</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Do not call with a GeometryCollection as an argument</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.3</p><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.21</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index. However it seems to only consider x y when
doing the difference and tacks back on the Z-Index</p></div><div class="refsection" title="Examples"><a name="id36208666"></a><h2>Examples</h2><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td>
<p>
</p><div class="informalfigure"><div class="mediaobject"><img src="images/st_symdifference01.png"><div class="caption"><p>The original linestrings shown together</p></div></div></div><p>
</p>
</td><td>
<div class="informalfigure"><div class="mediaobject"><img src="images/st_symdifference02.png"><div class="caption"><p>The symmetric difference of the two linestrings</p></div></div></div><p>
</p>
</td></tr></tbody></table></div><pre class="programlisting">
--Safe for 2d - symmetric difference of 2 linestrings
SELECT ST_AsText(
ST_SymDifference(
ST_GeomFromText('LINESTRING(50 100, 50 200)'),
ST_GeomFromText('LINESTRING(50 50, 50 150)')
)
);
st_astext
---------
MULTILINESTRING((50 150,50 200),(50 50,50 100))
</pre><pre class="programlisting">
--When used in 3d doesn't quite do the right thing
SELECT ST_AsEWKT(ST_SymDifference(ST_GeomFromEWKT('LINESTRING(1 2 1, 1 4 2)'),
ST_GeomFromEWKT('LINESTRING(1 1 3, 1 3 4)')))
st_astext
------------
MULTILINESTRING((1 3 2.75,1 4 2),(1 1 3,1 2 2.25))
</pre></div><div class="refsection" title="See Also"><a name="id36208758"></a><h2>See Also</h2><p><a class="xref" href="#ST_Difference" title="ST_Difference">ST_Difference</a>, <a class="xref" href="#ST_Intersection" title="ST_Intersection">ST_Intersection</a>, <a class="xref" href="#ST_Union" title="ST_Union">ST_Union</a></p></div></div><div class="refentry" title="ST_Union"><div class="refentry.separator"><hr></div><a name="ST_Union"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Union — Returns a geometry that represents the point set union of
the Geometries.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Union</b>(</code>geometry set <var class="pdparam">g1field</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_Union</b>(</code>geometry <var class="pdparam">g1</var>, geometry <var class="pdparam">g2</var><code>)</code>;</p><p><code class="funcdef">geometry <b class="fsfunc">ST_Union</b>(</code>geometry[] <var class="pdparam">g1_array</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36208874"></a><h2>Description</h2><p> Output type can be a MULTI* , single geometry, or Geometry Collection. Comes in 2 variants. Variant 1 unions 2 geometries resulting in a new geomety with no intersecting regions.
Variant 2 is an aggregate function that takes a set of geometries and unions
them into a single ST_Geometry resulting in no intersecting regions.</p><p>Aggregate version: This function returns a MULTI geometry or NON-MULTI geometry
from a set of geometries. The ST_Union() function is an "aggregate"
function in the terminology of PostgreSQL. That means that it
operates on rows of data, in the same way the SUM() and AVG()
functions do.</p><p>Non-Aggregate version: This function returns a geometry being a union of two
input geometries. Output type can be a MULTI* ,NON-MULTI or
GEOMETRYCOLLECTION.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>ST_Collect and ST_Union are often interchangeable.
ST_Union is in general orders of magnitude slower than ST_Collect
because it tries to dissolve boundaries and reorder geometries to ensure that a constructed Multi* doesn't
have intersecting regions.</p></td></tr></table></div><p>Performed by the GEOS module.</p><p>NOTE: this function was formerly called GeomUnion(), which
was renamed from "Union" because UNION is an SQL reserved
word.</p><p>Availability: 1.4.0 - ST_Union was enhanced. ST_Union(geomarray) was introduced and also faster aggregate collection in PostgreSQL. If you are using GEOS 3.1.0+
ST_Union will use the faster Cascaded Union algorithm described in
<a class="ulink" href="http://blog.cleverelephant.ca/2009/01/must-faster-unions-in-postgis-14.html" target="_top">http://blog.cleverelephant.ca/2009/01/must-faster-unions-in-postgis-14.html</a></p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method implements the <a class="ulink" href="http://www.opengeospatial.org/standards/sfs" target="_top">OpenGIS Simple Features
Implementation Specification for SQL 1.1.</a> s2.1.1.3</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Aggregate version is not explicitly defined in OGC SPEC.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span> This method implements the SQL/MM specification. SQL-MM 3: 5.1.19
the z-index (elevation) when polygons are involved.</p></div><div class="refsection" title="Examples"><a name="id36208959"></a><h2>Examples</h2><p>Aggregate example</p><pre class="programlisting">
SELECT stusps,
ST_Multi(ST_Union(f.the_geom)) as singlegeom
FROM sometable As f
GROUP BY stusps
</pre><p>Non-Aggregate example</p><pre class="programlisting">
SELECT ST_AsText(ST_Union(ST_GeomFromText('POINT(1 2)'),
ST_GeomFromText('POINT(-2 3)') ) )
st_astext
----------
MULTIPOINT(-2 3,1 2)
SELECT ST_AsText(ST_Union(ST_GeomFromText('POINT(1 2)'),
ST_GeomFromText('POINT(1 2)') ) );
st_astext
----------
POINT(1 2)
--3d example - sort of supports 3d (and with mixed dimensions!)
SELECT ST_AsEWKT(st_union(the_geom))
FROM
(SELECT ST_GeomFromEWKT('POLYGON((-7 4.2,-7.1 4.2,-7.1 4.3,
-7 4.2))') as the_geom
UNION ALL
SELECT ST_GeomFromEWKT('POINT(5 5 5)') as the_geom
UNION ALL
SELECT ST_GeomFromEWKT('POINT(-2 3 1)') as the_geom
UNION ALL
SELECT ST_GeomFromEWKT('LINESTRING(5 5 5, 10 10 10)') as the_geom ) as foo;
st_asewkt
---------
GEOMETRYCOLLECTION(POINT(-2 3 1),LINESTRING(5 5 5,10 10 10),POLYGON((-7 4.2 5,-7.1 4.2 5,-7.1 4.3 5,-7 4.2 5)));
--3d example not mixing dimensions
SELECT ST_AsEWKT(st_union(the_geom))
FROM
(SELECT ST_GeomFromEWKT('POLYGON((-7 4.2 2,-7.1 4.2 3,-7.1 4.3 2,
-7 4.2 2))') as the_geom
UNION ALL
SELECT ST_GeomFromEWKT('POINT(5 5 5)') as the_geom
UNION ALL
SELECT ST_GeomFromEWKT('POINT(-2 3 1)') as the_geom
UNION ALL
SELECT ST_GeomFromEWKT('LINESTRING(5 5 5, 10 10 10)') as the_geom ) as foo;
st_asewkt
---------
GEOMETRYCOLLECTION(POINT(-2 3 1),LINESTRING(5 5 5,10 10 10),POLYGON((-7 4.2 2,-7.1 4.2 3,-7.1 4.3 2,-7 4.2 2)))
--Examples using new Array construct
SELECT ST_Union(ARRAY(SELECT the_geom FROM sometable));
SELECT ST_AsText(ST_Union(ARRAY[ST_GeomFromText('LINESTRING(1 2, 3 4)'),
ST_GeomFromText('LINESTRING(3 4, 4 5)')])) As wktunion;
--wktunion---
MULTILINESTRING((3 4,4 5),(1 2,3 4))
</pre></div><div class="refsection" title="See Also"><a name="id36208984"></a><h2>See Also</h2><p><a class="xref" href="#ST_Collect" title="ST_Collect">ST_Collect</a></p></div></div></div><div class="sect1" title="7.10.Linear Referencing"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Linear_Referencing"></a>7.10.Linear Referencing</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#ST_Line_Interpolate_Point">ST_Line_Interpolate_Point</a></span><span class="refpurpose"> — Returns a point interpolated along a line. Second argument is a float8 between 0 and 1
representing fraction of total length of linestring the point has to be located.</span></dt><dt><span class="refentrytitle"><a href="#ST_Line_Locate_Point">ST_Line_Locate_Point</a></span><span class="refpurpose"> — Returns a float between 0 and 1 representing the location of
the closest point on LineString to the given Point, as a fraction
of total 2d line length.</span></dt><dt><span class="refentrytitle"><a href="#ST_Line_Substring">ST_Line_Substring</a></span><span class="refpurpose"> — Return a linestring being a substring of the input one
starting and ending at the given fractions of total 2d length.
Second and third arguments are float8 values between 0 and
1.</span></dt><dt><span class="refentrytitle"><a href="#ST_Locate_Along_Measure">ST_Locate_Along_Measure</a></span><span class="refpurpose"> — Return a derived geometry collection value with elements
that match the specified measure. Polygonal elements are not
supported.</span></dt><dt><span class="refentrytitle"><a href="#ST_Locate_Between_Measures">ST_Locate_Between_Measures</a></span><span class="refpurpose"> — Return a derived geometry collection value with elements
that match the specified range of measures inclusively. Polygonal
elements are not supported.</span></dt><dt><span class="refentrytitle"><a href="#ST_LocateBetweenElevations">ST_LocateBetweenElevations</a></span><span class="refpurpose"> — Return a derived geometry (collection) value with elements
that intersect the specified range of elevations inclusively. Only 3D, 4D LINESTRINGS and MULTILINESTRINGS
are supported.</span></dt><dt><span class="refentrytitle"><a href="#ST_AddMeasure">ST_AddMeasure</a></span><span class="refpurpose"> — Return a derived geometry with measure elements linearly interpolated between the start and end points. If the geometry has no measure dimension, one is added. If the geometry has a measure dimension, it is over-written with new values. Only LINESTRINGS and MULTILINESTRINGS are supported.</span></dt></dl></div><div class="refentry" title="ST_Line_Interpolate_Point"><a name="ST_Line_Interpolate_Point"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Line_Interpolate_Point — Returns a point interpolated along a line. Second argument is a float8 between 0 and 1
representing fraction of total length of linestring the point has to be located.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Line_Interpolate_Point</b>(</code>geometry <var class="pdparam">a_linestring</var>, float <var class="pdparam">a_fraction</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36212889"></a><h2>Description</h2><p>Returns a point interpolated along a line. First argument
must be a LINESTRING. Second argument is a float8 between 0 and 1
representing fraction of total linestring length the point has to be located.</p><p>See <a class="xref" href="#ST_Line_Locate_Point" title="ST_Line_Locate_Point">ST_Line_Locate_Point</a> for
computing the line location nearest to a Point.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Since release 1.1.1 this function also interpolates M and
Z values (when present), while prior releases set them to
0.0.</p></td></tr></table></div><p>Availability: 0.8.2, Z and M supported added in 1.1.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36212936"></a><h2>Examples</h2><div class="informalfigure"><div class="mediaobject"><img src="images/st_line_interpolate_point01.png"><div class="caption"><p>A linestring with the interpolated point at 20% position (0.20) </p></div></div></div><pre class="programlisting">--Return point 20% along 2d line
SELECT ST_AsEWKT(ST_Line_Interpolate_Point(the_line, 0.20))
FROM (SELECT ST_GeomFromEWKT('LINESTRING(25 50, 100 125, 150 190)') as the_line) As foo;
st_asewkt
----------------
POINT(51.5974135047432 76.5974135047432)
</pre><pre class="programlisting">
--Return point mid-way of 3d line
SELECT ST_AsEWKT(ST_Line_Interpolate_Point(the_line, 0.5))
FROM (SELECT ST_GeomFromEWKT('LINESTRING(1 2 3, 4 5 6, 6 7 8)') as the_line) As foo;
st_asewkt
--------------------
POINT(3.5 4.5 5.5)
--find closest point on a line to a point or other geometry
SELECT ST_AsText(ST_Line_Interpolate_Point(foo.the_line, ST_Line_Locate_Point(foo.the_line, ST_GeomFromText('POINT(4 3)'))))
FROM (SELECT ST_GeomFromText('LINESTRING(1 2, 4 5, 6 7)') As the_line) As foo;
st_astext
----------------
POINT(3 4)
</pre></div><div class="refsection" title="See Also"><a name="id36212984"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsText" title="ST_AsText">ST_AsText</a>,<a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>,<a class="xref" href="#ST_Length" title="ST_Length">ST_Length</a>, <a class="xref" href="#ST_Line_Locate_Point" title="ST_Line_Locate_Point">ST_Line_Locate_Point</a></p></div></div><div class="refentry" title="ST_Line_Locate_Point"><div class="refentry.separator"><hr></div><a name="ST_Line_Locate_Point"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Line_Locate_Point — Returns a float between 0 and 1 representing the location of
the closest point on LineString to the given Point, as a fraction
of total 2d line length.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_Line_Locate_Point</b>(</code>geometry <var class="pdparam">a_linestring</var>, geometry <var class="pdparam">a_point</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36213065"></a><h2>Description</h2><p>Returns a float between 0 and 1 representing the location of
the closest point on LineString to the given Point, as a fraction
of total <a class="link" href="#ST_Length2D" title="ST_Length2D">2d line</a> length.</p><p>You can use the returned location to extract a Point (<a class="xref" href="#ST_Line_Interpolate_Point" title="ST_Line_Interpolate_Point">ST_Line_Interpolate_Point</a>) or
a substring (<a class="xref" href="#ST_Line_Substring" title="ST_Line_Substring">ST_Line_Substring</a>).</p><p>This is useful for approximating numbers of addresses</p><p>Availability: 1.1.0</p><p>Availability: 1.5.1 - support for MULTILINESTRINGS was introduced.</p></div><div class="refsection" title="Examples"><a name="id36213109"></a><h2>Examples</h2><pre class="programlisting">
--Rough approximation of finding the street number of a point along the street
--Note the whole foo thing is just to generate dummy data that looks
--like house centroids and street
--We use ST_DWithin to exclude
--houses too far away from the street to be considered on the street
SELECT ST_AsText(house_loc) As as_text_house_loc,
startstreet_num +
CAST( (endstreet_num - startstreet_num)
* ST_Line_Locate_Point(street_line, house_loc) As integer) As street_num
FROM
(SELECT ST_GeomFromText('LINESTRING(1 2, 3 4)') As street_line,
ST_MakePoint(x*1.01,y*1.03) As house_loc, 10 As startstreet_num,
20 As endstreet_num
FROM generate_series(1,3) x CROSS JOIN generate_series(2,4) As y)
As foo
WHERE ST_DWithin(street_line, house_loc, 0.2);
as_text_house_loc | street_num
-------------------+------------
POINT(1.01 2.06) | 10
POINT(2.02 3.09) | 15
POINT(3.03 4.12) | 20
--find closest point on a line to a point or other geometry
SELECT ST_AsText(ST_Line_Interpolate_Point(foo.the_line, ST_Line_Locate_Point(foo.the_line, ST_GeomFromText('POINT(4 3)'))))
FROM (SELECT ST_GeomFromText('LINESTRING(1 2, 4 5, 6 7)') As the_line) As foo;
st_astext
----------------
POINT(3 4)
</pre></div><div class="refsection" title="See Also"><a name="id36213124"></a><h2>See Also</h2><p><a class="xref" href="#ST_DWithin" title="ST_DWithin">ST_DWithin</a>, <a class="xref" href="#ST_Length2D" title="ST_Length2D">ST_Length2D</a>, <a class="xref" href="#ST_Line_Interpolate_Point" title="ST_Line_Interpolate_Point">ST_Line_Interpolate_Point</a>, <a class="xref" href="#ST_Line_Substring" title="ST_Line_Substring">ST_Line_Substring</a></p></div></div><div class="refentry" title="ST_Line_Substring"><div class="refentry.separator"><hr></div><a name="ST_Line_Substring"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Line_Substring — Return a linestring being a substring of the input one
starting and ending at the given fractions of total 2d length.
Second and third arguments are float8 values between 0 and
1.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Line_Substring</b>(</code>geometry <var class="pdparam">a_linestring</var>, float <var class="pdparam">startfraction</var>, float <var class="pdparam">endfraction</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36213215"></a><h2>Description</h2><p>Return a linestring being a substring of the input one
starting and ending at the given fractions of total 2d length.
Second and third arguments are float8 values between 0 and
1. This only works with LINESTRINGs.
To use with contiguous MULTILINESTRINGs use in conjunction with ST_LineMerge.</p><p>If 'start' and 'end' have the same value this is equivalent
to <a class="xref" href="#ST_Line_Interpolate_Point" title="ST_Line_Interpolate_Point">ST_Line_Interpolate_Point</a>.</p><p>See <a class="xref" href="#ST_Line_Locate_Point" title="ST_Line_Locate_Point">ST_Line_Locate_Point</a> for
computing the line location nearest to a Point.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Since release 1.1.1 this function also interpolates M and
Z values (when present), while prior releases set them to
unspecified values.</p></td></tr></table></div><p>Availability: 1.1.0 , Z and M supported added in 1.1.1</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36213271"></a><h2>Examples</h2><div class="informalfigure"><div class="mediaobject"><img src="images/st_line_substring01.png"><div class="caption"><p>A linestring seen with 1/3 midrange overlaid (0.333, 0.666) </p></div></div></div><pre class="programlisting">
--Return the approximate 1/3 mid-range part of a linestring
SELECT ST_AsText(ST_Line_SubString(ST_GeomFromText('LINESTRING(25 50, 100 125, 150 190)'), 0.333, 0.666));
st_astext
------------------------------------------------------------------------------------------------
LINESTRING(69.2846934853974 94.2846934853974,100 125,111.700356260683 140.210463138888)
--The below example simulates a while loop in
--SQL using PostgreSQL generate_series() to cut all
--linestrings in a table to 100 unit segments
-- of which no segment is longer than 100 units
-- units are measured in the SRID units of measurement
-- It also assumes all geometries are LINESTRING or contiguous MULTILINESTRING
--and no geometry is longer than 100 units*10000
--for better performance you can reduce the 10000
--to match max number of segments you expect
SELECT field1, field2, ST_Line_Substring(the_geom, 100.00*n/length,
CASE
WHEN 100.00*(n+1) < length THEN 100.00*(n+1)/length
ELSE 1
END) As the_geom
FROM
(SELECT sometable.field1, sometable.field2,
ST_LineMerge(sometable.the_geom) AS the_geom,
ST_Length(sometable.the_geom) As length
FROM sometable
) AS t
CROSS JOIN generate_series(0,10000) AS n
WHERE n*100.00/length < 1;
</pre></div><div class="refsection" title="See Also"><a name="id36213306"></a><h2>See Also</h2><p><a class="xref" href="#ST_Length" title="ST_Length">ST_Length</a>, <a class="xref" href="#ST_Line_Interpolate_Point" title="ST_Line_Interpolate_Point">ST_Line_Interpolate_Point</a>, <a class="xref" href="#ST_LineMerge" title="ST_LineMerge">ST_LineMerge</a></p></div></div><div class="refentry" title="ST_Locate_Along_Measure"><div class="refentry.separator"><hr></div><a name="ST_Locate_Along_Measure"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Locate_Along_Measure — Return a derived geometry collection value with elements
that match the specified measure. Polygonal elements are not
supported.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Locate_Along_Measure</b>(</code>geometry <var class="pdparam">ageom_with_measure</var>, float <var class="pdparam">a_measure</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36213383"></a><h2>Description</h2><p>Return a derived geometry collection value with elements
that match the specified measure. Polygonal elements are not
supported.</p><p>Semantic is specified by: ISO/IEC CD 13249-3:200x(E) - Text
for Continuation CD Editing Meeting</p><p>Availability: 1.1.0</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Use this function only for geometries with an M component</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports M coordinates.</p></div><div class="refsection" title="Examples"><a name="id36213426"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsEWKT(the_geom)
FROM
(SELECT ST_Locate_Along_Measure(
ST_GeomFromEWKT('MULTILINESTRINGM((1 2 3, 3 4 2, 9 4 3),
(1 2 3, 5 4 5))'),3) As the_geom) As foo;
st_asewkt
-----------------------------------------------------------
GEOMETRYCOLLECTIONM(MULTIPOINT(1 2 3,9 4 3),POINT(1 2 3))
--Geometry collections are difficult animals so dump them
--to make them more digestable
SELECT ST_AsEWKT((ST_Dump(the_geom)).geom)
FROM
(SELECT ST_Locate_Along_Measure(
ST_GeomFromEWKT('MULTILINESTRINGM((1 2 3, 3 4 2, 9 4 3),
(1 2 3, 5 4 5))'),3) As the_geom) As foo;
st_asewkt
---------------
POINTM(1 2 3)
POINTM(9 4 3)
POINTM(1 2 3)
</pre></div><div class="refsection" title="See Also"><a name="id36213440"></a><h2>See Also</h2><p><a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a>, <a class="xref" href="#ST_Locate_Between_Measures" title="ST_Locate_Between_Measures">ST_Locate_Between_Measures</a></p></div></div><div class="refentry" title="ST_Locate_Between_Measures"><div class="refentry.separator"><hr></div><a name="ST_Locate_Between_Measures"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Locate_Between_Measures — Return a derived geometry collection value with elements
that match the specified range of measures inclusively. Polygonal
elements are not supported.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Locate_Between_Measures</b>(</code>geometry <var class="pdparam">geomA</var>, float <var class="pdparam">measure_start</var>, float <var class="pdparam">measure_end</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36213522"></a><h2>Description</h2><p>Return a derived geometry collection value with elements
that match the specified range of measures inclusively. Polygonal
elements are not supported.</p><p>Semantic is specified by: ISO/IEC CD 13249-3:200x(E) - Text
for Continuation CD Editing Meeting</p><p>Availability: 1.1.0</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports M coordinates.</p></div><div class="refsection" title="Examples"><a name="id36213554"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsEWKT(the_geom)
FROM
(SELECT ST_Locate_Between_Measures(
ST_GeomFromEWKT('MULTILINESTRINGM((1 2 3, 3 4 2, 9 4 3),
(1 2 3, 5 4 5))'),1.5, 3) As the_geom) As foo;
st_asewkt
-----------------------------------------------------------------
GEOMETRYCOLLECTIONM(LINESTRING(1 2 3,3 4 2,9 4 3),POINT(1 2 3))
--Geometry collections are difficult animals so dump them
--to make them more digestable
SELECT ST_AsEWKT((ST_Dump(the_geom)).geom)
FROM
(SELECT ST_Locate_Between_Measures(
ST_GeomFromEWKT('MULTILINESTRINGM((1 2 3, 3 4 2, 9 4 3),
(1 2 3, 5 4 5))'),1.5, 3) As the_geom) As foo;
st_asewkt
--------------------------------
LINESTRINGM(1 2 3,3 4 2,9 4 3)
POINTM(1 2 3)</pre></div><div class="refsection" title="See Also"><a name="id36213575"></a><h2>See Also</h2><p><a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a>, <a class="xref" href="#ST_Locate_Along_Measure" title="ST_Locate_Along_Measure">ST_Locate_Along_Measure</a></p></div></div><div class="refentry" title="ST_LocateBetweenElevations"><div class="refentry.separator"><hr></div><a name="ST_LocateBetweenElevations"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_LocateBetweenElevations — Return a derived geometry (collection) value with elements
that intersect the specified range of elevations inclusively. Only 3D, 4D LINESTRINGS and MULTILINESTRINGS
are supported.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_LocateBetweenElevations</b>(</code>geometry <var class="pdparam">geom_mline</var>, float <var class="pdparam">elevation_start</var>, float <var class="pdparam">elevation_end</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36213657"></a><h2>Description</h2><p>Return a derived geometry (collection) value with elements
that intersect the specified range of elevations inclusively. Only 3D, 3DM LINESTRINGS and MULTILINESTRINGS
are supported.</p><p>Availability: 1.4.0</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36213686"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsEWKT(ST_LocateBetweenElevations(
ST_GeomFromEWKT('LINESTRING(1 2 3, 4 5 6)'),2,4)) As ewelev;
ewelev
----------------------------------------------------------------
MULTILINESTRING((1 2 3,2 3 4))
SELECT ST_AsEWKT(ST_LocateBetweenElevations(
ST_GeomFromEWKT('LINESTRING(1 2 6, 4 5 -1, 7 8 9)'),6,9)) As ewelev;
ewelev
----------------------------------------------------------------
GEOMETRYCOLLECTION(POINT(1 2 6),LINESTRING(6.1 7.1 6,7 8 9))
--Geometry collections are difficult animals so dump them
--to make them more digestable
SELECT ST_AsEWKT((ST_Dump(the_geom)).geom)
FROM
(SELECT ST_LocateBetweenElevations(
ST_GeomFromEWKT('LINESTRING(1 2 6, 4 5 -1, 7 8 9)'),6,9) As the_geom) As foo;
st_asewkt
--------------------------------
POINT(1 2 6)
LINESTRING(6.1 7.1 6,7 8 9)
</pre></div><div class="refsection" title="See Also"><a name="id36213708"></a><h2>See Also</h2><p><a class="xref" href="#ST_Dump" title="ST_Dump">ST_Dump</a></p></div></div><div class="refentry" title="ST_AddMeasure"><div class="refentry.separator"><hr></div><a name="ST_AddMeasure"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_AddMeasure — Return a derived geometry with measure elements linearly interpolated between the start and end points. If the geometry has no measure dimension, one is added. If the geometry has a measure dimension, it is over-written with new values. Only LINESTRINGS and MULTILINESTRINGS are supported.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_AddMeasure</b>(</code>geometry <var class="pdparam">geom_mline</var>, float <var class="pdparam">measure_start</var>, float <var class="pdparam">measure_end</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36213785"></a><h2>Description</h2><p>Return a derived geometry with measure elements linearly interpolated between the start and end points. If the geometry has no measure dimension, one is added. If the geometry has a measure dimension, it is over-written with new values. Only LINESTRINGS and MULTILINESTRINGS are supported.</p><p>Availability: 1.5.0</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p></div><div class="refsection" title="Examples"><a name="id36213814"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_AsEWKT(ST_AddMeasure(
ST_GeomFromEWKT('LINESTRING(1 0, 2 0, 4 0)'),1,4)) As ewelev;
ewelev
--------------------------------
LINESTRINGM(1 0 1,2 0 2,4 0 4)
SELECT ST_AsEWKT(ST_AddMeasure(
ST_GeomFromEWKT('LINESTRING(1 0 4, 2 0 4, 4 0 4)'),10,40)) As ewelev;
ewelev
----------------------------------------
LINESTRING(1 0 4 10,2 0 4 20,4 0 4 40)
SELECT ST_AsEWKT(ST_AddMeasure(
ST_GeomFromEWKT('LINESTRINGM(1 0 4, 2 0 4, 4 0 4)'),10,40)) As ewelev;
ewelev
----------------------------------------
LINESTRINGM(1 0 10,2 0 20,4 0 40)
SELECT ST_AsEWKT(ST_AddMeasure(
ST_GeomFromEWKT('MULTILINESTRINGM((1 0 4, 2 0 4, 4 0 4),(1 0 4, 2 0 4, 4 0 4))'),10,70)) As ewelev;
ewelev
-----------------------------------------------------------------
MULTILINESTRINGM((1 0 10,2 0 20,4 0 40),(1 0 40,2 0 50,4 0 70))
</pre></div></div></div><div class="sect1" title="7.11.Long Transactions Support"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Long_Transactions_Support"></a>7.11.Long Transactions Support</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#AddAuth">AddAuth</a></span><span class="refpurpose"> — Add an authorization token to be used in current transaction.</span></dt><dt><span class="refentrytitle"><a href="#CheckAuth">CheckAuth</a></span><span class="refpurpose"> — Creates trigger on a table to prevent/allow updates and deletes of rows based on authorization token.</span></dt><dt><span class="refentrytitle"><a href="#DisableLongTransactions">DisableLongTransactions</a></span><span class="refpurpose"> — Disable long transaction support. This function removes the
long transaction support metadata tables, and drops all triggers
attached to lock-checked tables.</span></dt><dt><span class="refentrytitle"><a href="#EnableLongTransactions">EnableLongTransactions</a></span><span class="refpurpose"> — Enable long transaction support. This function creates the
required metadata tables, needs to be called once before using the
other functions in this section. Calling it twice is
harmless.</span></dt><dt><span class="refentrytitle"><a href="#LockRow">LockRow</a></span><span class="refpurpose"> — Set lock/authorization for specific row in table</span></dt><dt><span class="refentrytitle"><a href="#UnlockRows">UnlockRows</a></span><span class="refpurpose"> — Remove all locks held by specified authorization id. Returns
the number of locks released.</span></dt></dl></div><p>This module and associated pl/pgsql functions have been
implemented to provide long locking support required by <a class="ulink" href="http://portal.opengeospatial.org/files/index.php?artifact_id=7176" target="_top">Web Feature Service</a> specification.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Users must use <a class="ulink" href="http://www.postgresql.org/docs/8.3/static/transaction-iso.html" target="_top">serializable
transaction level</a> otherwise locking mechanism would
break.</p></td></tr></table></div><div class="refentry" title="AddAuth"><a name="AddAuth"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>AddAuth — Add an authorization token to be used in current transaction.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">AddAuth</b>(</code>text <var class="pdparam">auth_token</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36214928"></a><h2>Description</h2><p>Add an authorization token to be used in current transaction.</p><p>Creates/adds to a temp table called temp_lock_have_table the current transaction identifier
and authorization token key.</p><p>Availability: 1.1.3</p></div><div class="refsection" title="Examples"><a name="id36214946"></a><h2>Examples</h2><pre class="programlisting">
SELECT LockRow('towns', '353', 'priscilla');
BEGIN TRANSACTION;
SELECT AddAuth('joey');
UPDATE towns SET the_geom = ST_Translate(the_geom,2,2) WHERE gid = 353;
COMMIT;
---Error--
ERROR: UPDATE where "gid" = '353' requires authorization 'priscilla'
</pre></div><div class="refsection" title="See Also"><a name="id36214963"></a><h2>See Also</h2><p><a class="xref" href="#LockRow" title="LockRow">LockRow</a></p></div></div><div class="refentry" title="CheckAuth"><div class="refentry.separator"><hr></div><a name="CheckAuth"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>CheckAuth — Creates trigger on a table to prevent/allow updates and deletes of rows based on authorization token.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">CheckAuth</b>(</code>text <var class="pdparam">a_schema_name</var>, text <var class="pdparam">a_table_name</var>, text <var class="pdparam">a_key_column_name</var><code>)</code>;</p><p><code class="funcdef">integer <b class="fsfunc">CheckAuth</b>(</code>text <var class="pdparam">a_table_name</var>, text <var class="pdparam">a_key_column_name</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36215070"></a><h2>Description</h2><p>Creates trigger on a table to prevent/allow updates and deletes of rows based on authorization token. Identify rows using <rowid_col> column.</p><p>If a_schema_name is not passed in, then searches for table in current schema.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>If an authorization trigger already exists on this table function errors.</p><p>If Transaction support is not enabled, function throws an exception.</p></td></tr></table></div><p>Availability: 1.1.3</p></div><div class="refsection" title="Examples"><a name="id36215099"></a><h2>Examples</h2><pre class="programlisting">
SELECT CheckAuth('public', 'towns', 'gid');
result
------
0
</pre></div><div class="refsection" title="See Also"><a name="id36215114"></a><h2>See Also</h2><p><a class="xref" href="#EnableLongTransactions" title="EnableLongTransactions">EnableLongTransactions</a></p></div></div><div class="refentry" title="DisableLongTransactions"><div class="refentry.separator"><hr></div><a name="DisableLongTransactions"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>DisableLongTransactions — Disable long transaction support. This function removes the
long transaction support metadata tables, and drops all triggers
attached to lock-checked tables.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">DisableLongTransactions</b>(</code></p></div></div><div class="refsection" title="Description"><a name="id36215162"></a><h2>Description</h2><p>Disable long transaction support. This function removes the
long transaction support metadata tables, and drops all triggers
attached to lock-checked tables.</p><p>Drops meta table called <code class="varname">authorization_table</code> and a view called <code class="varname">authorized_tables</code>
and all triggers called <code class="varname">checkauthtrigger</code></p><p>Availability: 1.1.3</p></div><div class="refsection" title="Examples"><a name="id36215190"></a><h2>Examples</h2><pre class="programlisting">SELECT DisableLongTransactions();
--result--
Long transactions support disabled
</pre></div><div class="refsection" title="See Also"><a name="id36215206"></a><h2>See Also</h2><p><a class="xref" href="#EnableLongTransactions" title="EnableLongTransactions">EnableLongTransactions</a></p></div></div><div class="refentry" title="EnableLongTransactions"><div class="refentry.separator"><hr></div><a name="EnableLongTransactions"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>EnableLongTransactions — Enable long transaction support. This function creates the
required metadata tables, needs to be called once before using the
other functions in this section. Calling it twice is
harmless.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">text <b class="fsfunc">EnableLongTransactions</b>(</code></p></div></div><div class="refsection" title="Description"><a name="id36215254"></a><h2>Description</h2><p>Enable long transaction support. This function creates the
required metadata tables, needs to be called once before using the
other functions in this section. Calling it twice is
harmless.</p><p>Creates a meta table called <code class="varname">authorization_table</code> and a view called <code class="varname">authorized_tables</code></p><p>Availability: 1.1.3</p></div><div class="refsection" title="Examples"><a name="id36215278"></a><h2>Examples</h2><pre class="programlisting">SELECT EnableLongTransactions();
--result--
Long transactions support enabled
</pre></div><div class="refsection" title="See Also"><a name="id36215294"></a><h2>See Also</h2><p><a class="xref" href="#DisableLongTransactions" title="DisableLongTransactions">DisableLongTransactions</a></p></div></div><div class="refentry" title="LockRow"><div class="refentry.separator"><hr></div><a name="LockRow"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>LockRow — Set lock/authorization for specific row in table</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">LockRow</b>(</code>text <var class="pdparam">a_schema_name</var>, text <var class="pdparam">a_table_name</var>, text <var class="pdparam">a_row_key</var>, text <var class="pdparam">an_auth_token</var>, timestamp <var class="pdparam">expire_dt</var><code>)</code>;</p><p><code class="funcdef">integer <b class="fsfunc">LockRow</b>(</code>text <var class="pdparam">a_table_name</var>, text <var class="pdparam">a_row_key</var>, text <var class="pdparam">an_auth_token</var>, timestamp <var class="pdparam">expire_dt</var><code>)</code>;</p><p><code class="funcdef">integer <b class="fsfunc">LockRow</b>(</code>text <var class="pdparam">a_table_name</var>, text <var class="pdparam">a_row_key</var>, text <var class="pdparam">an_auth_token</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36215478"></a><h2>Description</h2><p>Set lock/authorization for specific row in table
<authid> is a text value, <expires> is a timestamp
defaulting to now()+1hour. Returns 1 if lock has been assigned, 0
otherwise (already locked by other auth)</p><p>Availability: 1.1.3</p></div><div class="refsection" title="Examples"><a name="id36215497"></a><h2>Examples</h2><pre class="programlisting">SELECT LockRow('public', 'towns', '2', 'joey');
LockRow
-------
1
--Joey has already locked the record and Priscilla is out of luck
SELECT LockRow('public', 'towns', '2', 'priscilla');
LockRow
-------
0
</pre></div><div class="refsection" title="See Also"><a name="id36215513"></a><h2>See Also</h2><p><a class="xref" href="#UnlockRows" title="UnlockRows">UnlockRows</a></p></div></div><div class="refentry" title="UnlockRows"><div class="refentry.separator"><hr></div><a name="UnlockRows"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>UnlockRows — Remove all locks held by specified authorization id. Returns
the number of locks released.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">UnlockRows</b>(</code>text <var class="pdparam">auth_token</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36215568"></a><h2>Description</h2><p>Remove all locks held by specified authorization id. Returns
the number of locks released.</p><p>Availability: 1.1.3</p></div><div class="refsection" title="Examples"><a name="id36215582"></a><h2>Examples</h2><pre class="programlisting">
SELECT LockRow('towns', '353', 'priscilla');
SELECT LockRow('towns', '2', 'priscilla');
SELECT UnLockRows('priscilla');
UnLockRows
------------
2
</pre></div><div class="refsection" title="See Also"><a name="id36215599"></a><h2>See Also</h2><p><a class="xref" href="#LockRow" title="LockRow">LockRow</a></p></div></div></div><div class="sect1" title="7.12.Miscellaneous Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Miscellaneous_Functions"></a>7.12.Miscellaneous Functions</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#ST_Accum">ST_Accum</a></span><span class="refpurpose"> — Aggregate. Constructs an array of geometries.</span></dt><dt><span class="refentrytitle"><a href="#Box2D">Box2D</a></span><span class="refpurpose"> — Returns a BOX2D representing the maximum extents of the geometry.</span></dt><dt><span class="refentrytitle"><a href="#Box3D">Box3D</a></span><span class="refpurpose"> — Returns a BOX3D representing the maximum extents of the geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_Estimated_Extent">ST_Estimated_Extent</a></span><span class="refpurpose"> — Return the 'estimated' extent of the given spatial table.
The estimated is taken from the geometry column's statistics. The
current schema will be used if not specified.</span></dt><dt><span class="refentrytitle"><a href="#ST_Expand">ST_Expand</a></span><span class="refpurpose"> — Returns bounding box expanded in all directions from the bounding box of the input geometry. Uses double-precision</span></dt><dt><span class="refentrytitle"><a href="#ST_Extent">ST_Extent</a></span><span class="refpurpose"> — an aggregate function that returns the bounding box that bounds rows of geometries.</span></dt><dt><span class="refentrytitle"><a href="#ST_Extent3D">ST_Extent3D</a></span><span class="refpurpose"> — an aggregate function that returns the box3D bounding box that bounds rows of geometries.</span></dt><dt><span class="refentrytitle"><a href="#Find_SRID">Find_SRID</a></span><span class="refpurpose"> — The syntax is find_srid(<db/schema>, <table>,
<column>) and the function returns the integer SRID of the
specified column by searching through the GEOMETRY_COLUMNS table.</span></dt><dt><span class="refentrytitle"><a href="#ST_Mem_Size">ST_Mem_Size</a></span><span class="refpurpose"> — Returns the amount of space (in bytes) the geometry takes.</span></dt><dt><span class="refentrytitle"><a href="#ST_Point_Inside_Circle">ST_Point_Inside_Circle</a></span><span class="refpurpose"> — Is the point geometry insert circle defined by center_x, center_y , radius</span></dt><dt><span class="refentrytitle"><a href="#ST_XMax">ST_XMax</a></span><span class="refpurpose"> — Returns X maxima of a bounding box 2d or 3d or a geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_XMin">ST_XMin</a></span><span class="refpurpose"> — Returns X minima of a bounding box 2d or 3d or a geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_YMax">ST_YMax</a></span><span class="refpurpose"> — Returns Y maxima of a bounding box 2d or 3d or a geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_YMin">ST_YMin</a></span><span class="refpurpose"> — Returns Y minima of a bounding box 2d or 3d or a geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_ZMax">ST_ZMax</a></span><span class="refpurpose"> — Returns Z minima of a bounding box 2d or 3d or a geometry.</span></dt><dt><span class="refentrytitle"><a href="#ST_ZMin">ST_ZMin</a></span><span class="refpurpose"> — Returns Z minima of a bounding box 2d or 3d or a geometry.</span></dt></dl></div><div class="refentry" title="ST_Accum"><a name="ST_Accum"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Accum — Aggregate. Constructs an array of geometries.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry[] <b class="fsfunc">ST_Accum</b>(</code>geometry set <var class="pdparam">geomfield</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36216436"></a><h2>Description</h2><p>Aggregate. Constructs an array of geometries.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36216472"></a><h2>Examples</h2><pre class="programlisting">SELECT (ST_Accum(the_geom)) As all_em, ST_AsText((ST_Accum(the_geom))[1]) As grabone,
(ST_Accum(the_geom))[2:4] as grab_rest
FROM (SELECT ST_MakePoint(a*CAST(random()*10 As integer), a*CAST(random()*10 As integer), a*CAST(random()*10 As integer)) As the_geom
FROM generate_series(1,4) a) As foo;
all_em|grabone | grab_rest
-------------------------------------------------------------------------------+
{0101000080000000000000144000000000000024400000000000001040:
0101000080000000000
00018400000000000002C400000000000003040:
0101000080000000000000354000000000000038400000000000001840:
010100008000000000000040400000000000003C400000000000003040} |
POINT(5 10) | {010100008000000000000018400000000000002C400000000000003040:
0101000080000000000000354000000000000038400000000000001840:
010100008000000000000040400000000000003C400000000000003040}
(1 row)
</pre></div><div class="refsection" title="See Also"><a name="id36216494"></a><h2>See Also</h2><p><a class="xref" href="#ST_Collect" title="ST_Collect">ST_Collect</a></p></div></div><div class="refentry" title="Box2D"><div class="refentry.separator"><hr></div><a name="Box2D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>Box2D — Returns a BOX2D representing the maximum extents of the geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">box2d <b class="fsfunc">Box2D</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36216549"></a><h2>Description</h2><p>Returns a BOX2D representing the maximum extents of the geometry.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36216571"></a><h2>Examples</h2><pre class="programlisting">SELECT Box2D(ST_GeomFromText('LINESTRING(1 2, 3 4, 5 6)'));
box2d
---------
BOX(1 2,5 6)
SELECT Box2D(ST_GeomFromText('CIRCULARSTRING(220268 150415,220227 150505,220227 150406)'));
box2d
--------
BOX(220186.984375 150406,220288.25 150506.140625)
</pre></div><div class="refsection" title="See Also"><a name="id36216588"></a><h2>See Also</h2><p><a class="xref" href="#Box3D" title="Box3D">Box3D</a>, <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a></p></div></div><div class="refentry" title="Box3D"><div class="refentry.separator"><hr></div><a name="Box3D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>Box3D — Returns a BOX3D representing the maximum extents of the geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">box3d <b class="fsfunc">Box3D</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36216648"></a><h2>Description</h2><p>Returns a BOX3D representing the maximum extents of the geometry.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36216684"></a><h2>Examples</h2><pre class="programlisting">SELECT Box3D(ST_GeomFromEWKT('LINESTRING(1 2 3, 3 4 5, 5 6 5)'));
Box3d
---------
BOX3D(1 2 3,5 6 5)
SELECT Box3D(ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 1,220227 150406 1)'));
Box3d
--------
BOX3D(220227 150406 1,220268 150415 1)
</pre></div><div class="refsection" title="See Also"><a name="id36216701"></a><h2>See Also</h2><p><a class="xref" href="#Box2D" title="Box2D">Box2D</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a></p></div></div><div class="refentry" title="ST_Estimated_Extent"><div class="refentry.separator"><hr></div><a name="ST_Estimated_Extent"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Estimated_Extent — Return the 'estimated' extent of the given spatial table.
The estimated is taken from the geometry column's statistics. The
current schema will be used if not specified.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">box2d <b class="fsfunc">ST_Estimated_Extent</b>(</code>text <var class="pdparam">schema_name</var>, text <var class="pdparam">table_name</var>, text <var class="pdparam">geocolumn_name</var><code>)</code>;</p><p><code class="funcdef">box2d <b class="fsfunc">ST_Estimated_Extent</b>(</code>text <var class="pdparam">table_name</var>, text <var class="pdparam">geocolumn_name</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36216813"></a><h2>Description</h2><p>Return the 'estimated' extent of the given spatial table.
The estimated is taken from the geometry column's statistics. The
current schema will be used if not specified.</p><p>For PostgreSQL>=8.0.0 statistics are gathered by VACUUM
ANALYZE and resulting extent will be about 95% of the real
one.</p><p>For PostgreSQL<8.0.0 statistics are gathered by
update_geometry_stats() and resulting extent will be exact.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36216847"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_Estimated_extent('ny', 'edges', 'the_geom');
--result--
BOX(-8877653 4912316,-8010225.5 5589284)
SELECT ST_Estimated_Extent('feature_poly', 'the_geom');
--result--
BOX(-124.659652709961 24.6830825805664,-67.7798080444336 49.0012092590332)
</pre></div><div class="refsection" title="See Also"><a name="id36216864"></a><h2>See Also</h2><p><a class="xref" href="#ST_Extent" title="ST_Extent">ST_Extent</a></p></div></div><div class="refentry" title="ST_Expand"><div class="refentry.separator"><hr></div><a name="ST_Expand"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Expand — Returns bounding box expanded in all directions from the bounding box of the input geometry. Uses double-precision</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">ST_Expand</b>(</code>geometry <var class="pdparam">g1</var>, float <var class="pdparam">units_to_expand</var><code>)</code>;</p><p><code class="funcdef">box2d <b class="fsfunc">ST_Expand</b>(</code>box2d <var class="pdparam">g1</var>, float <var class="pdparam">units_to_expand</var><code>)</code>;</p><p><code class="funcdef">box3d <b class="fsfunc">ST_Expand</b>(</code>box3d <var class="pdparam">g1</var>, float <var class="pdparam">units_to_expand</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36216990"></a><h2>Description</h2><p>This function returns a bounding box expanded in all
directions from the bounding box of the input geometry, by an
amount specified in the second argument. Uses double-precision. Very useful for
distance() queries, or bounding box queries to add an index filter to the query.</p><p>There are 3 variants of this. The one that takes a geometry will return a POLYGON geometry representation
of the bounding box and is the most commonly used variant.</p><p>ST_Expand is similar in concept to ST_Buffer except while buffer expands the geometry in all directions,
ST_Expand expands the bounding box an x,y,z unit amount.</p><p>Units are in the units of the spatial reference system in use denoted by the SRID</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Pre 1.3, ST_Expand was used in conjunction with distance to do indexable queries. Something of the form
<code class="code">the_geom && ST_Expand('POINT(10 20)', 10) AND ST_Distance(the_geom, 'POINT(10 20)') < 10</code>
Post 1.2, this was replaced with the easier ST_DWithin construct.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Bounding boxes of all geometries are currently 2-d even if they are 3-dimensional geometries.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Availability: 1.5.0 behavior changed to output double precision instead of float4 coordinates.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36217043"></a><h2>Examples</h2><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Examples below use US National Atlas Equal Area (SRID=2163) which is a meter projection</p></td></tr></table></div><pre class="programlisting">
--10 meter expanded box around bbox of a linestring
SELECT CAST(ST_Expand(ST_GeomFromText('LINESTRING(2312980 110676,2312923 110701,2312892 110714)', 2163),10) As box2d);
st_expand
------------------------------------
BOX(2312882 110666,2312990 110724)
--10 meter expanded 3d box of a 3d box
SELECT ST_Expand(CAST('BOX3D(778783 2951741 1,794875 2970042.61545891 10)' As box3d),10)
st_expand
-----------------------------------------------------
BOX3D(778773 2951731 -9,794885 2970052.61545891 20)
--10 meter geometry astext rep of a expand box around a point geometry
SELECT ST_AsEWKT(ST_Expand(ST_GeomFromEWKT('SRID=2163;POINT(2312980 110676)'),10));
st_asewkt
-------------------------------------------------------------------------------------------------
SRID=2163;POLYGON((2312970 110666,2312970 110686,2312990 110686,2312990 110666,2312970 110666))
</pre></div><div class="refsection" title="See Also"><a name="id36217071"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_Buffer" title="ST_Buffer">ST_Buffer</a>, <a class="xref" href="#ST_DWithin" title="ST_DWithin">ST_DWithin</a>, <a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>,<a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a></p></div></div><div class="refentry" title="ST_Extent"><div class="refentry.separator"><hr></div><a name="ST_Extent"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Extent — an aggregate function that returns the bounding box that bounds rows of geometries.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">box3d_extent <b class="fsfunc">ST_Extent</b>(</code>geometry set <var class="pdparam">geomfield</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36217152"></a><h2>Description</h2><p>ST_Extent returns a bounding box that encloses a set of geometries. The ST_Extent function is an "aggregate" function in the
terminology of SQL. That means that it operates on lists
of data, in the same way the SUM() and AVG() functions do.</p><p>Since it returns a bounding box, the spatial Units are in the units of the spatial reference system in use denoted by the SRID</p><p>ST_Extent is similar in concept to Oracle Spatial/Locator's SDO_AGGR_MBR</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Since ST_Extent returns a bounding box, the SRID meta-data is lost. Use ST_SetSRID to force it back into
a geometry with SRID meta data. The coordinates are in the units of the spatial ref of the orginal geometries.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>ST_Extent will return boxes with only an x and y component even with (x,y,z) coordinate geometries. To maintain x,y,z use ST_Extent3D instead.</p></td></tr></table></div><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Availability: 1.4.0 As of 1.4.0 now returns a box3d_extent instead of box2d object.</p></td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36217195"></a><h2>Examples</h2><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Examples below use Massachusetts State Plane ft (SRID=2249)</p></td></tr></table></div><pre class="programlisting">
SELECT ST_Extent(the_geom) as bextent FROM sometable;
st_bextent
------------------------------------
BOX(739651.875 2908247.25,794875.8125 2970042.75)
--Return extent of each category of geometries
SELECT ST_Extent(the_geom) as bextent
FROM sometable
GROUP BY category ORDER BY category;
bextent | name
----------------------------------------------------+----------------
BOX(778783.5625 2951741.25,794875.8125 2970042.75) | A
BOX(751315.8125 2919164.75,765202.6875 2935417.25) | B
BOX(739651.875 2917394.75,756688.375 2935866) | C
--Force back into a geometry
-- and render the extended text representation of that geometry
SELECT ST_SetSRID(ST_Extent(the_geom),2249) as bextent FROM sometable;
bextent
--------------------------------------------------------------------------------
SRID=2249;POLYGON((739651.875 2908247.25,739651.875 2970042.75,794875.8125 2970042.75,
794875.8125 2908247.25,739651.875 2908247.25))
</pre></div><div class="refsection" title="See Also"><a name="id36217220"></a><h2>See Also</h2><p><a class="xref" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>, <a class="xref" href="#ST_Extent3D" title="ST_Extent3D">ST_Extent3D</a>, <a class="xref" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a>, <a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a></p></div></div><div class="refentry" title="ST_Extent3D"><div class="refentry.separator"><hr></div><a name="ST_Extent3D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Extent3D — an aggregate function that returns the box3D bounding box that bounds rows of geometries.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">box3d <b class="fsfunc">ST_Extent3D</b>(</code>geometry set <var class="pdparam">geomfield</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36217291"></a><h2>Description</h2><p>ST_Extent3D returns a box3d (includes Z coordinate) bounding box that encloses a set of geometries. The ST_Extent3D function is an "aggregate" function in the
terminology of SQL. That means that it operates on lists
of data, in the same way the SUM() and AVG() functions do.</p><p>Since it returns a bounding box, the spatial Units are in the units of the spatial reference system in use denoted by the SRID</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Since ST_Extent3D returns a bounding box, the SRID meta-data is lost. Use ST_SetSRID to force it back into
a geometry with SRID meta data. The coordinates are in the units of the spatial ref of the orginal geometries.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36217341"></a><h2>Examples</h2><pre class="programlisting">
SELECT ST_Extent3D(foo.the_geom) As b3extent
FROM (SELECT ST_MakePoint(x,y,z) As the_geom
FROM generate_series(1,3) As x
CROSS JOIN generate_series(1,2) As y
CROSS JOIN generate_series(0,2) As Z) As foo;
b3extent
--------------------
BOX3D(1 1 0,3 2 2)
--Get the extent of various elevated circular strings
SELECT ST_Extent3D(foo.the_geom) As b3extent
FROM (SELECT ST_Translate(ST_Force_3DZ(ST_LineToCurve(ST_Buffer(ST_MakePoint(x,y),1))),0,0,z) As the_geom
FROM generate_series(1,3) As x
CROSS JOIN generate_series(1,2) As y
CROSS JOIN generate_series(0,2) As Z) As foo;
b3extent
--------------------
BOX3D(1 0 0,4 2 2)
</pre></div><div class="refsection" title="See Also"><a name="id36217358"></a><h2>See Also</h2><p><a class="xref" href="#ST_Extent" title="ST_Extent">ST_Extent</a>, <a class="xref" href="#ST_Force_3DZ" title="ST_Force_3DZ">ST_Force_3DZ</a></p></div></div><div class="refentry" title="Find_SRID"><div class="refentry.separator"><hr></div><a name="Find_SRID"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>Find_SRID — The syntax is find_srid(<db/schema>, <table>,
<column>) and the function returns the integer SRID of the
specified column by searching through the GEOMETRY_COLUMNS table.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">Find_SRID</b>(</code>varchar <var class="pdparam">a_schema_name</var>, varchar <var class="pdparam">a_table_name</var>, varchar <var class="pdparam">a_geomfield_name</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36217442"></a><h2>Description</h2><p>The syntax is find_srid(<db/schema>, <table>,
<column>) and the function returns the integer SRID of the
specified column by searching through the GEOMETRY_COLUMNS table.
If the geometry column has not been properly added with the
AddGeometryColumns() function, this function will not work
either.</p></div><div class="refsection" title="Examples"><a name="id36217459"></a><h2>Examples</h2><pre class="programlisting"> SELECT Find_SRID('public', 'tiger_us_state_2007', 'the_geom_4269');
find_srid
----------
4269
</pre></div><div class="refsection" title="See Also"><a name="id36217473"></a><h2>See Also</h2><p><a class="xref" href="#ST_SRID" title="ST_SRID">ST_SRID</a></p></div></div><div class="refentry" title="ST_Mem_Size"><div class="refentry.separator"><hr></div><a name="ST_Mem_Size"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Mem_Size — Returns the amount of space (in bytes) the geometry takes.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">integer <b class="fsfunc">ST_Mem_Size</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36217529"></a><h2>Description</h2><p>Returns the amount of space (in bytes) the geometry takes. </p><p>This is a nice compliment to PostgreSQL built in functions pg_size_pretty, pg_relation_size, pg_total_relation_size.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>pg_relation_size which gives the byte size of a table may return byte size lower than ST_Mem_Size. This is because
pg_relation_size does not add toasted table contribution and large geometries are stored in TOAST tables.</p><p>pg_total_relation_size - includes, the table, the toasted tables, and the indexes.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36217580"></a><h2>Examples</h2><pre class="programlisting">
--Return how much byte space Boston takes up in our Mass data set
SELECT pg_size_pretty(SUM(ST_Mem_Size(the_geom))) as totgeomsum,
pg_size_pretty(SUM(CASE WHEN town = 'BOSTON' THEN st_mem_size(the_geom) ELSE 0 END)) As bossum,
CAST(SUM(CASE WHEN town = 'BOSTON' THEN st_mem_size(the_geom) ELSE 0 END)*1.00 /
SUM(st_mem_size(the_geom))*100 As numeric(10,2)) As perbos
FROM towns;
totgeomsum bossum perbos
---------- ------ ------
1522 kB 30 kB 1.99
SELECT ST_Mem_Size(ST_GeomFromText('CIRCULARSTRING(220268 150415,220227 150505,220227 150406)'));
---
73
--What percentage of our table is taken up by just the geometry
SELECT pg_total_relation_size('public.neighborhoods') As fulltable_size, sum(ST_Mem_Size(the_geom)) As geomsize,
sum(ST_Mem_Size(the_geom))*1.00/pg_total_relation_size('public.neighborhoods')*100 As pergeom
FROM neighborhoods;
fulltable_size geomsize pergeom
------------------------------------------------
262144 96238 36.71188354492187500000
</pre></div><div class="refsection" title="See Also"><a name="id36217603"></a><h2>See Also</h2><p></p></div></div><div class="refentry" title="ST_Point_Inside_Circle"><div class="refentry.separator"><hr></div><a name="ST_Point_Inside_Circle"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_Point_Inside_Circle — Is the point geometry insert circle defined by center_x, center_y , radius</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">ST_Point_Inside_Circle</b>(</code>geometry <var class="pdparam">a_point</var>, float <var class="pdparam">center_x</var>, float <var class="pdparam">center_y</var>, float <var class="pdparam">radius</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36217685"></a><h2>Description</h2><p>The syntax for this functions is
point_inside_circle(<geometry>,<circle_center_x>,<circle_center_y>,<radius>).
Returns the true if the geometry is a point and is inside the
circle. Returns false otherwise.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top">This only works for points as the name suggests</td></tr></table></div></div><div class="refsection" title="Examples"><a name="id36217703"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_Point_Inside_Circle(ST_Point(1,2), 0.5, 2, 3);
st_point_inside_circle
------------------------
t
</pre></div><div class="refsection" title="See Also"><a name="id36217719"></a><h2>See Also</h2><p><a class="xref" href="#ST_DWithin" title="ST_DWithin">ST_DWithin</a></p></div></div><div class="refentry" title="ST_XMax"><div class="refentry.separator"><hr></div><a name="ST_XMax"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_XMax — Returns X maxima of a bounding box 2d or 3d or a geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_XMax</b>(</code>box3d <var class="pdparam">aGeomorBox2DorBox3D</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36217774"></a><h2>Description</h2><p>Returns X maxima of a bounding box 2d or 3d or a geometry.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Although this function is only defined for box3d, it will work for box2d and geometry because of the auto-casting behavior
defined for geometries and box2d. However you can not feed it a geometry or box2d text represenation, since that will not auto-cast.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36217818"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_XMax('BOX3D(1 2 3, 4 5 6)');
st_xmax
-------
4
SELECT ST_XMax(ST_GeomFromText('LINESTRING(1 3 4, 5 6 7)'));
st_xmax
-------
5
SELECT ST_XMax(CAST('BOX(-3 2, 3 4)' As box2d));
st_xmax
-------
3
--Observe THIS DOES NOT WORK because it will try to autocast the string representation to a BOX3D
SELECT ST_XMax('LINESTRING(1 3, 5 6)');
--ERROR: BOX3D parser - doesnt start with BOX3D(
SELECT ST_XMax(ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)'));
st_xmax
--------
220288.248780547
</pre></div><div class="refsection" title="See Also"><a name="id36217837"></a><h2>See Also</h2><p><a class="xref" href="#ST_XMin" title="ST_XMin">ST_XMin</a>, <a class="xref" href="#ST_YMax" title="ST_YMax">ST_YMax</a>, <a class="xref" href="#ST_YMin" title="ST_YMin">ST_YMin</a>, <a class="xref" href="#ST_ZMax" title="ST_ZMax">ST_ZMax</a>, <a class="xref" href="#ST_ZMin" title="ST_ZMin">ST_ZMin</a></p></div></div><div class="refentry" title="ST_XMin"><div class="refentry.separator"><hr></div><a name="ST_XMin"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_XMin — Returns X minima of a bounding box 2d or 3d or a geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_XMin</b>(</code>box3d <var class="pdparam">aGeomorBox2DorBox3D</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36217913"></a><h2>Description</h2><p>Returns X minima of a bounding box 2d or 3d or a geometry.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Although this function is only defined for box3d, it will work for box2d and geometry because of the auto-casting behavior
defined for geometries and box2d. However you can not feed it a geometry or box2d text represenation, since that will not auto-cast.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36217957"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_XMin('BOX3D(1 2 3, 4 5 6)');
st_xmin
-------
1
SELECT ST_XMin(ST_GeomFromText('LINESTRING(1 3 4, 5 6 7)'));
st_xmin
-------
1
SELECT ST_XMin(CAST('BOX(-3 2, 3 4)' As box2d));
st_xmin
-------
-3
--Observe THIS DOES NOT WORK because it will try to autocast the string representation to a BOX3D
SELECT ST_XMin('LINESTRING(1 3, 5 6)');
--ERROR: BOX3D parser - doesnt start with BOX3D(
SELECT ST_XMin(ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)'));
st_xmin
--------
220186.995121892
</pre></div><div class="refsection" title="See Also"><a name="id36217972"></a><h2>See Also</h2><p><a class="xref" href="#ST_XMax" title="ST_XMax">ST_XMax</a>, <a class="xref" href="#ST_YMax" title="ST_YMax">ST_YMax</a>, <a class="xref" href="#ST_YMin" title="ST_YMin">ST_YMin</a>, <a class="xref" href="#ST_ZMax" title="ST_ZMax">ST_ZMax</a>, <a class="xref" href="#ST_ZMin" title="ST_ZMin">ST_ZMin</a></p></div></div><div class="refentry" title="ST_YMax"><div class="refentry.separator"><hr></div><a name="ST_YMax"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_YMax — Returns Y maxima of a bounding box 2d or 3d or a geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_YMax</b>(</code>box3d <var class="pdparam">aGeomorBox2DorBox3D</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36218047"></a><h2>Description</h2><p>Returns Y maxima of a bounding box 2d or 3d or a geometry.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Although this function is only defined for box3d, it will work for box2d and geometry because of the auto-casting behavior
defined for geometries and box2d. However you can not feed it a geometry or box2d text represenation, since that will not auto-cast.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36218091"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_YMax('BOX3D(1 2 3, 4 5 6)');
st_ymax
-------
5
SELECT ST_YMax(ST_GeomFromText('LINESTRING(1 3 4, 5 6 7)'));
st_ymax
-------
6
SELECT ST_YMax(CAST('BOX(-3 2, 3 4)' As box2d));
st_ymax
-------
4
--Observe THIS DOES NOT WORK because it will try to autocast the string representation to a BOX3D
SELECT ST_YMax('LINESTRING(1 3, 5 6)');
--ERROR: BOX3D parser - doesnt start with BOX3D(
SELECT ST_YMax(ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)'));
st_ymax
--------
150506.126829327
</pre></div><div class="refsection" title="See Also"><a name="id36218111"></a><h2>See Also</h2><p><a class="xref" href="#ST_XMin" title="ST_XMin">ST_XMin</a>, <a class="xref" href="#ST_XMax" title="ST_XMax">ST_XMax</a>, <a class="xref" href="#ST_YMin" title="ST_YMin">ST_YMin</a>, <a class="xref" href="#ST_ZMax" title="ST_ZMax">ST_ZMax</a>, <a class="xref" href="#ST_ZMin" title="ST_ZMin">ST_ZMin</a></p></div></div><div class="refentry" title="ST_YMin"><div class="refentry.separator"><hr></div><a name="ST_YMin"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_YMin — Returns Y minima of a bounding box 2d or 3d or a geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_YMin</b>(</code>box3d <var class="pdparam">aGeomorBox2DorBox3D</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36218186"></a><h2>Description</h2><p>Returns Y minima of a bounding box 2d or 3d or a geometry.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Although this function is only defined for box3d, it will work for box2d and geometry because of the auto-casting behavior
defined for geometries and box2d. However you can not feed it a geometry or box2d text represenation, since that will not auto-cast.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36218230"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_YMin('BOX3D(1 2 3, 4 5 6)');
st_ymin
-------
2
SELECT ST_YMin(ST_GeomFromText('LINESTRING(1 3 4, 5 6 7)'));
st_ymin
-------
3
SELECT ST_YMin(CAST('BOX(-3 2, 3 4)' As box2d));
st_ymin
-------
2
--Observe THIS DOES NOT WORK because it will try to autocast the string representation to a BOX3D
SELECT ST_YMin('LINESTRING(1 3, 5 6)');
--ERROR: BOX3D parser - doesnt start with BOX3D(
SELECT ST_YMin(ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)'));
st_ymin
--------
150406
</pre></div><div class="refsection" title="See Also"><a name="id36218250"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_XMin" title="ST_XMin">ST_XMin</a>, <a class="xref" href="#ST_XMax" title="ST_XMax">ST_XMax</a>, <a class="xref" href="#ST_YMax" title="ST_YMax">ST_YMax</a>, <a class="xref" href="#ST_ZMax" title="ST_ZMax">ST_ZMax</a>, <a class="xref" href="#ST_ZMin" title="ST_ZMin">ST_ZMin</a></p></div></div><div class="refentry" title="ST_ZMax"><div class="refentry.separator"><hr></div><a name="ST_ZMax"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_ZMax — Returns Z minima of a bounding box 2d or 3d or a geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_ZMax</b>(</code>box3d <var class="pdparam">aGeomorBox2DorBox3D</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36218330"></a><h2>Description</h2><p>Returns Z maxima of a bounding box 2d or 3d or a geometry.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Although this function is only defined for box3d, it will work for box2d and geometry because of the auto-casting behavior
defined for geometries and box2d. However you can not feed it a geometry or box2d text represenation, since that will not auto-cast.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36218374"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_ZMax('BOX3D(1 2 3, 4 5 6)');
st_zmax
-------
6
SELECT ST_ZMax(ST_GeomFromEWKT('LINESTRING(1 3 4, 5 6 7)'));
st_zmax
-------
7
SELECT ST_ZMax('BOX3D(-3 2 1, 3 4 1)' );
st_zmax
-------
1
--Observe THIS DOES NOT WORK because it will try to autocast the string representation to a BOX3D
SELECT ST_ZMax('LINESTRING(1 3 4, 5 6 7)');
--ERROR: BOX3D parser - doesnt start with BOX3D(
SELECT ST_ZMax(ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)'));
st_zmax
--------
3
</pre></div><div class="refsection" title="See Also"><a name="id36218393"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_XMin" title="ST_XMin">ST_XMin</a>, <a class="xref" href="#ST_XMax" title="ST_XMax">ST_XMax</a>, <a class="xref" href="#ST_YMax" title="ST_YMax">ST_YMax</a>, <a class="xref" href="#ST_YMin" title="ST_YMin">ST_YMin</a>, <a class="xref" href="#ST_ZMax" title="ST_ZMax">ST_ZMax</a></p></div></div><div class="refentry" title="ST_ZMin"><div class="refentry.separator"><hr></div><a name="ST_ZMin"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ST_ZMin — Returns Z minima of a bounding box 2d or 3d or a geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">float <b class="fsfunc">ST_ZMin</b>(</code>box3d <var class="pdparam">aGeomorBox2DorBox3D</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36218473"></a><h2>Description</h2><p>Returns Z minima of a bounding box 2d or 3d or a geometry.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Although this function is only defined for box3d, it will work for box2d and geometry because of the auto-casting behavior
defined for geometries and box2d. However you can not feed it a geometry or box2d text represenation, since that will not auto-cast.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This function supports 3d and will not drop the z-index.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36218517"></a><h2>Examples</h2><pre class="programlisting">SELECT ST_ZMin('BOX3D(1 2 3, 4 5 6)');
st_zmin
-------
3
SELECT ST_ZMin(ST_GeomFromEWKT('LINESTRING(1 3 4, 5 6 7)'));
st_zmin
-------
4
SELECT ST_ZMin('BOX3D(-3 2 1, 3 4 1)' );
st_zmin
-------
1
--Observe THIS DOES NOT WORK because it will try to autocast the string representation to a BOX3D
SELECT ST_ZMin('LINESTRING(1 3 4, 5 6 7)');
--ERROR: BOX3D parser - doesnt start with BOX3D(
SELECT ST_ZMin(ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)'));
st_zmin
--------
1
</pre></div><div class="refsection" title="See Also"><a name="id36218537"></a><h2>See Also</h2><p><a class="xref" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>, <a class="xref" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>, <a class="xref" href="#ST_XMin" title="ST_XMin">ST_XMin</a>, <a class="xref" href="#ST_XMax" title="ST_XMax">ST_XMax</a>, <a class="xref" href="#ST_YMax" title="ST_YMax">ST_YMax</a>, <a class="xref" href="#ST_YMin" title="ST_YMin">ST_YMin</a>, <a class="xref" href="#ST_ZMax" title="ST_ZMax">ST_ZMax</a></p></div></div></div><div class="sect1" title="7.13.Exceptional Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Exceptional_Functions"></a>7.13.Exceptional Functions</h2></div></div></div><div class="toc"><dl><dt><span class="refentrytitle"><a href="#PostGIS_AddBBox">PostGIS_AddBBox</a></span><span class="refpurpose"> — Add bounding box to the geometry.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_DropBBox">PostGIS_DropBBox</a></span><span class="refpurpose"> — Drop the bounding box cache from the geometry.</span></dt><dt><span class="refentrytitle"><a href="#PostGIS_HasBBox">PostGIS_HasBBox</a></span><span class="refpurpose"> — Returns TRUE if the bbox of this geometry is cached, FALSE otherwise.</span></dt></dl></div><p>These functions are rarely used functions that should only be used if your data is corrupted in someway. They are used for troubleshooting corruption
and also fixing things that should under normal circumstances, never happen.</p><div class="refentry" title="PostGIS_AddBBox"><a name="PostGIS_AddBBox"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_AddBBox — Add bounding box to the geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">PostGIS_AddBBox</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36220980"></a><h2>Description</h2><p>Add bounding box to the geometry. This would make bounding
box based queries faster, but will increase the size of the
geometry.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Bounding boxes are automatically added to geometries so in general this is not needed
unless the generated bounding box somehow becomes corrupted or you have an old install that is lacking bounding boxes. Then you need to drop the old and readd.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36221011"></a><h2>Examples</h2><pre class="programlisting">UPDATE sometable
SET the_geom = PostGIS_AddBBox(the_geom)
WHERE PostGIS_HasBBox(the_geom) = false;</pre></div><div class="refsection" title="See Also"><a name="id36221027"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_DropBBox" title="PostGIS_DropBBox">PostGIS_DropBBox</a>, <a class="xref" href="#PostGIS_HasBBox" title="PostGIS_HasBBox">PostGIS_HasBBox</a></p></div></div><div class="refentry" title="PostGIS_DropBBox"><div class="refentry.separator"><hr></div><a name="PostGIS_DropBBox"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_DropBBox — Drop the bounding box cache from the geometry.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">geometry <b class="fsfunc">PostGIS_DropBBox</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36221090"></a><h2>Description</h2><p>Drop the bounding box cache from the geometry. This reduces
geometry size, but makes bounding-box based queries slower. It is also used to drop a corrupt bounding box. A tale-tell sign of a corrupt cached bounding box
is when your ST_Intersects and other relation queries leave out geometries that rightfully should return true.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Bounding boxes are automatically added to geometries and improve speed of queries so in general this is not needed
unless the generated bounding box somehow becomes corrupted or you have an old install that is lacking bounding boxes.
Then you need to drop the old and readd. This kind of corruption has been observed in 8.3-8.3.6 series whereby cached bboxes were not always recalculated when a geometry changed and upgrading to a newer version without a dump reload will not
correct already corrupted boxes. So one can manually correct using below and readd the bbox or do a dump reload.</p></td></tr></table></div><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36221126"></a><h2>Examples</h2><pre class="programlisting">--This example drops bounding boxes where the cached box is not correct
--The force to ST_AsBinary before applying Box2D forces a recalculation of the box, and Box2D applied to the table geometry always
-- returns the cached bounding box.
UPDATE sometable
SET the_geom = PostGIS_DropBBox(the_geom)
WHERE Not (Box2D(ST_AsBinary(the_geom)) = Box2D(the_geom));
UPDATE sometable
SET the_geom = PostGIS_AddBBox(the_geom)
WHERE Not PostGIS_HasBBOX(the_geom);
</pre></div><div class="refsection" title="See Also"><a name="id36221144"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_AddBBox" title="PostGIS_AddBBox">PostGIS_AddBBox</a>, <a class="xref" href="#PostGIS_HasBBox" title="PostGIS_HasBBox">PostGIS_HasBBox</a>, <a class="xref" href="#Box2D" title="Box2D">Box2D</a></p></div></div><div class="refentry" title="PostGIS_HasBBox"><div class="refentry.separator"><hr></div><a name="PostGIS_HasBBox"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>PostGIS_HasBBox — Returns TRUE if the bbox of this geometry is cached, FALSE otherwise.</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><p><code class="funcdef">boolean <b class="fsfunc">PostGIS_HasBBox</b>(</code>geometry <var class="pdparam">geomA</var><code>)</code>;</p></div></div><div class="refsection" title="Description"><a name="id36221210"></a><h2>Description</h2><p>Returns TRUE if the bbox of this geometry is cached, FALSE
otherwise. Use <a class="xref" href="#PostGIS_AddBBox" title="PostGIS_AddBBox">PostGIS_AddBBox</a> and <a class="xref" href="#PostGIS_DropBBox" title="PostGIS_DropBBox">PostGIS_DropBBox</a> to control caching.</p><p><span class="inlinemediaobject"><img src="images/check.png"></span>
This method supports Circular Strings and Curves</p></div><div class="refsection" title="Examples"><a name="id36221243"></a><h2>Examples</h2><pre class="programlisting">SELECT the_geom
FROM sometable WHERE PostGIS_HasBBox(the_geom) = false;</pre></div><div class="refsection" title="See Also"><a name="id36221258"></a><h2>See Also</h2><p><a class="xref" href="#PostGIS_AddBBox" title="PostGIS_AddBBox">PostGIS_AddBBox</a>, <a class="xref" href="#PostGIS_DropBBox" title="PostGIS_DropBBox">PostGIS_DropBBox</a></p></div></div></div></div><div class="chapter" title="Chapter8.PostGIS Special Functions Index"><div class="titlepage"><div><div><h2 class="title"><a name="id36258574"></a>Chapter8.PostGIS Special Functions Index</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#PostGIS_Aggregate_Functions">8.1. PostGIS Aggregate Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_SQLMM_Functions">8.2. PostGIS SQL-MM Compliant Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_GeographyFunctions">8.3. PostGIS Geography Support Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_Geometry_DumpFunctions">8.4. PostGIS Geometry Dump Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_BoxFunctions">8.5. PostGIS Box Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_3D_Functions">8.6. PostGIS Functions that support 3D</a></span></dt><dt><span class="sect1"><a href="#PostGIS_Curved_GeometryFunctions">8.7. PostGIS Curved Geometry Support Functions</a></span></dt><dt><span class="sect1"><a href="#PostGIS_TypeFunctionMatrix">8.8. PostGIS Function Support Matrix</a></span></dt><dt><span class="sect1"><a href="#NewFunctions">8.9. New PostGIS Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#NewFunctions_1_5">8.9.1. PostGIS Functions new, behavior changed, or enhanced in 1.5</a></span></dt><dt><span class="sect2"><a href="#NewFunctions_1_4">8.9.2. PostGIS Functions new, behavior changed, or enhanced in 1.4</a></span></dt><dt><span class="sect2"><a href="#NewFunctions_1_3">8.9.3. PostGIS Functions new in 1.3</a></span></dt></dl></dd></dl></div><div class="sect1" title="8.1.PostGIS Aggregate Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PostGIS_Aggregate_Functions"></a>8.1.PostGIS Aggregate Functions</h2></div></div></div><p>The functions given below are spatial aggregate functions provided with PostGIS that can be used just like any other sql aggregate function such as sum, average.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><a class="link" href="#ST_Accum" title="ST_Accum">ST_Accum</a> - Aggregate. Constructs an array of geometries.</li><li class="listitem"><a class="link" href="#ST_Collect" title="ST_Collect">ST_Collect</a> - Return a specified ST_Geometry value from a collection of other geometries.</li><li class="listitem"><a class="link" href="#ST_Extent" title="ST_Extent">ST_Extent</a> - an aggregate function that returns the bounding box that bounds rows of geometries.</li><li class="listitem"><a class="link" href="#ST_Extent3D" title="ST_Extent3D">ST_Extent3D</a> - an aggregate function that returns the box3D bounding box that bounds rows of geometries.</li><li class="listitem"><a class="link" href="#ST_MakeLine" title="ST_MakeLine">ST_MakeLine</a> - Creates a Linestring from point geometries.</li><li class="listitem"><a class="link" href="#ST_MemUnion" title="ST_MemUnion">ST_MemUnion</a> - Same as ST_Union, only memory-friendly (uses less memory and more processor time).</li><li class="listitem"><a class="link" href="#ST_Polygonize" title="ST_Polygonize">ST_Polygonize</a> - Aggregate. Creates a GeometryCollection containing possible polygons formed from the constituent linework of a set of geometries.</li><li class="listitem"><a class="link" href="#ST_Union" title="ST_Union">ST_Union</a> - Returns a geometry that represents the point set union of the Geometries.</li></ul></div></div><div class="sect1" title="8.2.PostGIS SQL-MM Compliant Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PostGIS_SQLMM_Functions"></a>8.2.PostGIS SQL-MM Compliant Functions</h2></div></div></div><p>The functions given below are PostGIS functions that conform to the SQL/MM 3 standard</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>SQL-MM defines the default SRID of all geometry constructors as 0.
PostGIS uses a default SRID of -1.</p></td></tr></table></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><a class="link" href="#ST_Area" title="ST_Area">ST_Area</a> - Returns the area of the surface if it is a polygon or multi-polygon. For "geometry" type area is in SRID units. For "geography" area is in square meters.
This method implements the SQL/MM specification. SQL-MM 3: 8.1.2, 9.5.3</li><li class="listitem"><a class="link" href="#ST_AsBinary" title="ST_AsBinary">ST_AsBinary</a> - Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.37</li><li class="listitem"><a class="link" href="#ST_AsText" title="ST_AsText">ST_AsText</a> - Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.25</li><li class="listitem"><a class="link" href="#ST_Boundary" title="ST_Boundary">ST_Boundary</a> - Returns the closure of the combinatorial boundary of this Geometry.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.14</li><li class="listitem"><a class="link" href="#ST_Buffer" title="ST_Buffer">ST_Buffer</a> - (T) For geometry: Returns a geometry that represents all points whose distance from this Geometry is less than or equal to distance. Calculations are in the Spatial Reference System of this Geometry. For geography: Uses a planar transform wrapper. Introduced in 1.5 support for different end cap and mitre settings to control shape. buffer_style options: quad_segs=#,endcap=round|flat|square,join=round|mitre|bevel,mitre_limit=#.#
This method implements the SQL/MM specification. SQL-MM 3: 5.1.17</li><li class="listitem"><a class="link" href="#ST_Centroid" title="ST_Centroid">ST_Centroid</a> - Returns the geometric center of a geometry.
This method implements the SQL/MM specification. SQL-MM 3: 8.1.4, 9.5.5</li><li class="listitem"><a class="link" href="#ST_Contains" title="ST_Contains">ST_Contains</a> - Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.31</li><li class="listitem"><a class="link" href="#ST_ConvexHull" title="ST_ConvexHull">ST_ConvexHull</a> - The convex hull of a geometry represents the minimum convex geometry that encloses all geometries within the set.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.16</li><li class="listitem"><a class="link" href="#ST_CoordDim" title="ST_CoordDim">ST_CoordDim</a> - Return the coordinate dimension of the ST_Geometry value.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.3</li><li class="listitem"><a class="link" href="#ST_Crosses" title="ST_Crosses">ST_Crosses</a> - Returns TRUE if the supplied geometries have some, but not all, interior points in common.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.29</li><li class="listitem"><a class="link" href="#ST_CurveToLine" title="ST_CurveToLine">ST_CurveToLine</a> - Converts a CIRCULARSTRING/CURVEDPOLYGON to a LINESTRING/POLYGON
This method implements the SQL/MM specification. SQL-MM 3: 7.1.7</li><li class="listitem"><a class="link" href="#ST_Difference" title="ST_Difference">ST_Difference</a> - Returns a geometry that represents that part of geometry A that does not intersect with geometry B.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.20</li><li class="listitem"><a class="link" href="#ST_Dimension" title="ST_Dimension">ST_Dimension</a> - The inherent dimension of this Geometry object, which must be less than or equal to the coordinate dimension.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.2</li><li class="listitem"><a class="link" href="#ST_Disjoint" title="ST_Disjoint">ST_Disjoint</a> - Returns TRUE if the Geometries do not "spatially intersect" - if they do not share any space together.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.26</li><li class="listitem"><a class="link" href="#ST_Distance" title="ST_Distance">ST_Distance</a> - For geometry type Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units. For geography type defaults to return spheroidal minimum distance between two geographies in meters.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.23</li><li class="listitem"><a class="link" href="#ST_EndPoint" title="ST_EndPoint">ST_EndPoint</a> - Returns the last point of a LINESTRING geometry as a POINT.
This method implements the SQL/MM specification. SQL-MM 3: 7.1.4</li><li class="listitem"><a class="link" href="#ST_Envelope" title="ST_Envelope">ST_Envelope</a> - Returns a geometry representing the double precision (float8) bounding box of the supplied geometry.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.15</li><li class="listitem"><a class="link" href="#ST_Equals" title="ST_Equals">ST_Equals</a> - Returns true if the given geometries represent the same geometry. Directionality is ignored.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.24</li><li class="listitem"><a class="link" href="#ST_ExteriorRing" title="ST_ExteriorRing">ST_ExteriorRing</a> - Returns a line string representing the exterior ring of the POLYGON geometry. Return NULL if the geometry is not a polygon. Will not work with MULTIPOLYGON
This method implements the SQL/MM specification. SQL-MM 3: 8.2.3, 8.3.3</li><li class="listitem"><a class="link" href="#ST_GMLToSQL" title="ST_GMLToSQL">ST_GMLToSQL</a> - Return a specified ST_Geometry value from GML representation. This is an alias name for ST_GeomFromGML
This method implements the SQL/MM specification. SQL-MM 3: 5.1.50 (except for curves support).</li><li class="listitem"><a class="link" href="#ST_GeomCollFromText" title="ST_GeomCollFromText">ST_GeomCollFromText</a> - Makes a collection Geometry from collection WKT with the given SRID. If SRID is not give, it defaults to -1.
This method implements the SQL/MM specification.</li><li class="listitem"><a class="link" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a> - Return a specified ST_Geometry value from Well-Known Text representation (WKT).
This method implements the SQL/MM specification. SQL-MM 3: 5.1.40</li><li class="listitem"><a class="link" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a> - Creates a geometry instance from a Well-Known Binary geometry representation (WKB) and optional SRID.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.41</li><li class="listitem"><a class="link" href="#ST_GeometryFromText" title="ST_GeometryFromText">ST_GeometryFromText</a> - Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an alias name for ST_GeomFromText
This method implements the SQL/MM specification. SQL-MM 3: 5.1.40</li><li class="listitem"><a class="link" href="#ST_GeometryN" title="ST_GeometryN">ST_GeometryN</a> - Return the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or MULTIPOLYGON. Otherwise, return NULL.
This method implements the SQL/MM specification. SQL-MM 3: 9.1.5</li><li class="listitem"><a class="link" href="#ST_GeometryType" title="ST_GeometryType">ST_GeometryType</a> - Return the geometry type of the ST_Geometry value.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.4</li><li class="listitem"><a class="link" href="#ST_InteriorRingN" title="ST_InteriorRingN">ST_InteriorRingN</a> - Return the Nth interior linestring ring of the polygon geometry. Return NULL if the geometry is not a polygon or the given N is out of range.
This method implements the SQL/MM specification. SQL-MM 3: 8.2.6, 8.3.5</li><li class="listitem"><a class="link" href="#ST_Intersection" title="ST_Intersection">ST_Intersection</a> - (T) Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation does a transform to geometry to do the intersection and then transform back to WGS84.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.18</li><li class="listitem"><a class="link" href="#ST_Intersects" title="ST_Intersects">ST_Intersects</a> - Returns TRUE if the Geometries/Geography "spatially intersect" - (share any portion of space) and FALSE if they don't (they are Disjoint). For geography -- tolerance is 0.00001 meters (so any points that close are considered to intersect)
This method implements the SQL/MM specification. SQL-MM 3: 5.1.27</li><li class="listitem"><a class="link" href="#ST_IsClosed" title="ST_IsClosed">ST_IsClosed</a> - Returns TRUE if the LINESTRING's start and end points are coincident.
This method implements the SQL/MM specification. SQL-MM 3: 7.1.5, 9.3.3</li><li class="listitem"><a class="link" href="#ST_IsEmpty" title="ST_IsEmpty">ST_IsEmpty</a> - Returns true if this Geometry is an empty geometry . If true, then this Geometry represents the empty point set - i.e. GEOMETRYCOLLECTION(EMPTY).
This method implements the SQL/MM specification. SQL-MM 3: 5.1.7</li><li class="listitem"><a class="link" href="#ST_IsRing" title="ST_IsRing">ST_IsRing</a> - Returns TRUE if this LINESTRING is both closed and simple.
This method implements the SQL/MM specification. SQL-MM 3: 7.1.6</li><li class="listitem"><a class="link" href="#ST_IsSimple" title="ST_IsSimple">ST_IsSimple</a> - Returns (TRUE) if this Geometry has no anomalous geometric points, such as self intersection or self tangency.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.8</li><li class="listitem"><a class="link" href="#ST_IsValid" title="ST_IsValid">ST_IsValid</a> - Returns true if the ST_Geometry is well formed.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.9</li><li class="listitem"><a class="link" href="#ST_Length" title="ST_Length">ST_Length</a> - Returns the 2d length of the geometry if it is a linestring or multilinestring. geometry are in units of spatial reference and geography are in meters (default spheroid)
This method implements the SQL/MM specification. SQL-MM 3: 7.1.2, 9.3.4</li><li class="listitem"><a class="link" href="#ST_LineFromText" title="ST_LineFromText">ST_LineFromText</a> - Makes a Geometry from WKT representation with the given SRID. If SRID is not given, it defaults to -1.
This method implements the SQL/MM specification. SQL-MM 3: 7.2.8</li><li class="listitem"><a class="link" href="#ST_LineFromWKB" title="ST_LineFromWKB">ST_LineFromWKB</a> - Makes a LINESTRING from WKB with the given SRID
This method implements the SQL/MM specification. SQL-MM 3: 7.2.9</li><li class="listitem"><a class="link" href="#ST_LinestringFromWKB" title="ST_LinestringFromWKB">ST_LinestringFromWKB</a> - Makes a geometry from WKB with the given SRID.
This method implements the SQL/MM specification. SQL-MM 3: 7.2.9</li><li class="listitem"><a class="link" href="#ST_M" title="ST_M">ST_M</a> - Return the M coordinate of the point, or NULL if not available. Input must be a point.
This method implements the SQL/MM specification.</li><li class="listitem"><a class="link" href="#ST_MLineFromText" title="ST_MLineFromText">ST_MLineFromText</a> - Return a specified ST_MultiLineString value from WKT representation.
This method implements the SQL/MM specification.SQL-MM 3: 9.4.4</li><li class="listitem"><a class="link" href="#ST_MPointFromText" title="ST_MPointFromText">ST_MPointFromText</a> - Makes a Geometry from WKT with the given SRID. If SRID is not give, it defaults to -1.
This method implements the SQL/MM specification. SQL-MM 3: 9.2.4</li><li class="listitem"><a class="link" href="#ST_MPolyFromText" title="ST_MPolyFromText">ST_MPolyFromText</a> - Makes a MultiPolygon Geometry from WKT with the given SRID. If SRID is not give, it defaults to -1.
This method implements the SQL/MM specification. SQL-MM 3: 9.6.4</li><li class="listitem"><a class="link" href="#ST_NumGeometries" title="ST_NumGeometries">ST_NumGeometries</a> - If geometry is a GEOMETRYCOLLECTION (or MULTI*) return the number of geometries, otherwise return NULL.
This method implements the SQL/MM specification. SQL-MM 3: 9.1.4</li><li class="listitem"><a class="link" href="#ST_NumInteriorRing" title="ST_NumInteriorRing">ST_NumInteriorRing</a> - Return the number of interior rings of the first polygon in the geometry. Synonym to ST_NumInteriorRings.
This method implements the SQL/MM specification. SQL-MM 3: 8.2.5</li><li class="listitem"><a class="link" href="#ST_NumInteriorRings" title="ST_NumInteriorRings">ST_NumInteriorRings</a> - Return the number of interior rings of the first polygon in the geometry. This will work with both POLYGON and MULTIPOLYGON types but only looks at the first polygon. Return NULL if there is no polygon in the geometry.
This method implements the SQL/MM specification. SQL-MM 3: 8.2.5</li><li class="listitem"><a class="link" href="#ST_NumPoints" title="ST_NumPoints">ST_NumPoints</a> - Return the number of points in an ST_LineString or ST_CircularString value.
This method implements the SQL/MM specification. SQL-MM 3: 7.2.4</li><li class="listitem"><a class="link" href="#ST_OrderingEquals" title="ST_OrderingEquals">ST_OrderingEquals</a> - Returns true if the given geometries represent the same geometry and points are in the same directional order.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.43</li><li class="listitem"><a class="link" href="#ST_Overlaps" title="ST_Overlaps">ST_Overlaps</a> - Returns TRUE if the Geometries share space, are of the same dimension, but are not completely contained by each other.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.32</li><li class="listitem"><a class="link" href="#ST_Perimeter" title="ST_Perimeter">ST_Perimeter</a> - Return the length measurement of the boundary of an ST_Surface or ST_MultiSurface value. (Polygon, Multipolygon)
This method implements the SQL/MM specification. SQL-MM 3: 8.1.3, 9.5.4</li><li class="listitem"><a class="link" href="#ST_Point" title="ST_Point">ST_Point</a> - Returns an ST_Point with the given coordinate values. OGC alias for ST_MakePoint.
This method implements the SQL/MM specification. SQL-MM 3: 6.1.2</li><li class="listitem"><a class="link" href="#ST_PointFromText" title="ST_PointFromText">ST_PointFromText</a> - Makes a point Geometry from WKT with the given SRID. If SRID is not given, it defaults to unknown.
This method implements the SQL/MM specification. SQL-MM 3: 6.1.8</li><li class="listitem"><a class="link" href="#ST_PointFromWKB" title="ST_PointFromWKB">ST_PointFromWKB</a> - Makes a geometry from WKB with the given SRID
This method implements the SQL/MM specification. SQL-MM 3: 6.1.9</li><li class="listitem"><a class="link" href="#ST_PointN" title="ST_PointN">ST_PointN</a> - Return the Nth point in the first linestring or circular linestring in the geometry. Return NULL if there is no linestring in the geometry.
This method implements the SQL/MM specification. SQL-MM 3: 7.2.5, 7.3.5</li><li class="listitem"><a class="link" href="#ST_PointOnSurface" title="ST_PointOnSurface">ST_PointOnSurface</a> - Returns a POINT guaranteed to lie on the surface.
This method implements the SQL/MM specification. SQL-MM 3: 8.1.5, 9.5.6.
According to the specs, ST_PointOnSurface works for surface geometries (POLYGONs, MULTIPOLYGONS, CURVED POLYGONS). So PostGIS seems to be extending what
the spec allows here. Most databases Oracle,DB II, ESRI SDE seem to only support this function for surfaces. SQL Server 2008 like PostGIS supports for all common geometries.</li><li class="listitem"><a class="link" href="#ST_Polygon" title="ST_Polygon">ST_Polygon</a> - Returns a polygon built from the specified linestring and SRID.
This method implements the SQL/MM specification. SQL-MM 3: 8.3.2</li><li class="listitem"><a class="link" href="#ST_PolygonFromText" title="ST_PolygonFromText">ST_PolygonFromText</a> - Makes a Geometry from WKT with the given SRID. If SRID is not give, it defaults to -1.
This method implements the SQL/MM specification. SQL-MM 3: 8.3.6</li><li class="listitem"><a class="link" href="#ST_Relate" title="ST_Relate">ST_Relate</a> - Returns true if this Geometry is spatially related to anotherGeometry, by testing for intersections between the Interior, Boundary and Exterior of the two geometries as specified by the values in the intersectionMatrixPattern. If no intersectionMatrixPattern is passed in, then returns the maximum intersectionMatrixPattern that relates the 2 geometries.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.25</li><li class="listitem"><a class="link" href="#ST_SRID" title="ST_SRID">ST_SRID</a> - Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.5</li><li class="listitem"><a class="link" href="#ST_StartPoint" title="ST_StartPoint">ST_StartPoint</a> - Returns the first point of a LINESTRING geometry as a POINT.
This method implements the SQL/MM specification. SQL-MM 3: 7.1.3</li><li class="listitem"><a class="link" href="#ST_SymDifference" title="ST_SymDifference">ST_SymDifference</a> - Returns a geometry that represents the portions of A and B that do not intersect. It is called a symmetric difference because ST_SymDifference(A,B) = ST_SymDifference(B,A).
This method implements the SQL/MM specification. SQL-MM 3: 5.1.21</li><li class="listitem"><a class="link" href="#ST_Touches" title="ST_Touches">ST_Touches</a> - Returns TRUE if the geometries have at least one point in common, but their interiors do not intersect.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.28</li><li class="listitem"><a class="link" href="#ST_Transform" title="ST_Transform">ST_Transform</a> - Returns a new geometry with its coordinates transformed to the SRID referenced by the integer parameter.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.6</li><li class="listitem"><a class="link" href="#ST_Union" title="ST_Union">ST_Union</a> - Returns a geometry that represents the point set union of the Geometries.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.19
the z-index (elevation) when polygons are involved.</li><li class="listitem"><a class="link" href="#ST_WKBToSQL" title="ST_WKBToSQL">ST_WKBToSQL</a> - Return a specified ST_Geometry value from Well-Known Binary representation (WKB). This is an alias name for ST_GeomFromWKB that takes no srid
This method implements the SQL/MM specification. SQL-MM 3: 5.1.36</li><li class="listitem"><a class="link" href="#ST_WKTToSQL" title="ST_WKTToSQL">ST_WKTToSQL</a> - Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an alias name for ST_GeomFromText
This method implements the SQL/MM specification. SQL-MM 3: 5.1.34</li><li class="listitem"><a class="link" href="#ST_Within" title="ST_Within">ST_Within</a> - Returns true if the geometry A is completely inside geometry B
This method implements the SQL/MM specification. SQL-MM 3: 5.1.30</li><li class="listitem"><a class="link" href="#ST_X" title="ST_X">ST_X</a> - Return the X coordinate of the point, or NULL if not available. Input must be a point.
This method implements the SQL/MM specification. SQL-MM 3: 6.1.3</li><li class="listitem"><a class="link" href="#ST_Y" title="ST_Y">ST_Y</a> - Return the Y coordinate of the point, or NULL if not available. Input must be a point.
This method implements the SQL/MM specification. SQL-MM 3: 6.1.4</li><li class="listitem"><a class="link" href="#ST_Z" title="ST_Z">ST_Z</a> - Return the Z coordinate of the point, or NULL if not available. Input must be a point.
This method implements the SQL/MM specification.</li></ul></div></div><div class="sect1" title="8.3.PostGIS Geography Support Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PostGIS_GeographyFunctions"></a>8.3.PostGIS Geography Support Functions</h2></div></div></div><p>The functions and operators given below are PostGIS functions/operators that take as input or return as output a <a class="link" href="#PostGIS_Geography" title="4.2.PostGIS Geography Type">geography</a> data type object.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Functions with a (T) are not native geodetic functions, and use a ST_Transform call to and from geometry to do the operation. As a result, they may not behave as expected when going over dateline, poles,
and for large geometries or geometry pairs that cover more than one UTM zone. Basic tranform - (favoring UTM, Lambert Azimuthal (North/South), and falling back on mercator in worst case scenario)</p></td></tr></table></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><a class="link" href="#ST_Area" title="ST_Area">ST_Area</a> - Returns the area of the surface if it is a polygon or multi-polygon. For "geometry" type area is in SRID units. For "geography" area is in square meters.</li><li class="listitem"><a class="link" href="#ST_AsBinary" title="ST_AsBinary">ST_AsBinary</a> - Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.</li><li class="listitem"><a class="link" href="#ST_AsGML" title="ST_AsGML">ST_AsGML</a> - Return the geometry as a GML version 2 or 3 element.</li><li class="listitem"><a class="link" href="#ST_AsGeoJSON" title="ST_AsGeoJSON">ST_AsGeoJSON</a> - Return the geometry as a GeoJSON element.</li><li class="listitem"><a class="link" href="#ST_AsKML" title="ST_AsKML">ST_AsKML</a> - Return the geometry as a KML element. Several variants. Default version=2, default precision=15</li><li class="listitem"><a class="link" href="#ST_AsSVG" title="ST_AsSVG">ST_AsSVG</a> - Returns a Geometry in SVG path data given a geometry or geography object.</li><li class="listitem"><a class="link" href="#ST_AsText" title="ST_AsText">ST_AsText</a> - Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.</li><li class="listitem"><a class="link" href="#ST_Buffer" title="ST_Buffer">ST_Buffer</a> - (T) For geometry: Returns a geometry that represents all points whose distance from this Geometry is less than or equal to distance. Calculations are in the Spatial Reference System of this Geometry. For geography: Uses a planar transform wrapper. Introduced in 1.5 support for different end cap and mitre settings to control shape. buffer_style options: quad_segs=#,endcap=round|flat|square,join=round|mitre|bevel,mitre_limit=#.#</li><li class="listitem"><a class="link" href="#ST_CoveredBy" title="ST_CoveredBy">ST_CoveredBy</a> - Returns 1 (TRUE) if no point in Geometry/Geography A is outside Geometry/Geography B</li><li class="listitem"><a class="link" href="#ST_Covers" title="ST_Covers">ST_Covers</a> - Returns 1 (TRUE) if no point in Geometry B is outside Geometry A. For geography: if geography point B is not outside Polygon Geography A</li><li class="listitem"><a class="link" href="#ST_DWithin" title="ST_DWithin">ST_DWithin</a> - Returns true if the geometries are within the specified distance of one another. For geometry units are in those of spatial reference and For geography units are in meters and measurement is defaulted to use_spheroid=true (measure around spheroid), for faster check, use_spheroid=false to measure along sphere.</li><li class="listitem"><a class="link" href="#ST_Distance" title="ST_Distance">ST_Distance</a> - For geometry type Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units. For geography type defaults to return spheroidal minimum distance between two geographies in meters.</li><li class="listitem"><a class="link" href="#ST_GeogFromText" title="ST_GeogFromText">ST_GeogFromText</a> - Return a specified geography value from Well-Known Text representation or extended (WKT).</li><li class="listitem"><a class="link" href="#ST_GeogFromWKB" title="ST_GeogFromWKB">ST_GeogFromWKB</a> - Creates a geography instance from a Well-Known Binary geometry representation (WKB) or extended Well Known Binary (EWKB).</li><li class="listitem"><a class="link" href="#ST_GeographyFromText" title="ST_GeographyFromText">ST_GeographyFromText</a> - Return a specified geography value from Well-Known Text representation or extended (WKT).</li><li class="listitem"><a class="link" href="#ST_Geometry_EQ" title="=">=</a> - Returns TRUE if A's bounding box is the same as B's.</li><li class="listitem"><a class="link" href="#ST_Geometry_Overlap" title="&&">&&</a> - Returns TRUE if A's bounding box overlaps B's.</li><li class="listitem"><a class="link" href="#ST_Intersection" title="ST_Intersection">ST_Intersection</a> - (T) Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation does a transform to geometry to do the intersection and then transform back to WGS84.</li><li class="listitem"><a class="link" href="#ST_Intersects" title="ST_Intersects">ST_Intersects</a> - Returns TRUE if the Geometries/Geography "spatially intersect" - (share any portion of space) and FALSE if they don't (they are Disjoint). For geography -- tolerance is 0.00001 meters (so any points that close are considered to intersect)</li><li class="listitem"><a class="link" href="#ST_Length" title="ST_Length">ST_Length</a> - Returns the 2d length of the geometry if it is a linestring or multilinestring. geometry are in units of spatial reference and geography are in meters (default spheroid)</li></ul></div></div><div class="sect1" title="8.4.PostGIS Geometry Dump Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PostGIS_Geometry_DumpFunctions"></a>8.4.PostGIS Geometry Dump Functions</h2></div></div></div><p>The functions given below are PostGIS functions that take as input or return as output a set of or single <a class="link" href="#geometry_dump" title="geometry_dump">geometry_dump</a> data type object.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><a class="link" href="#ST_Dump" title="ST_Dump">ST_Dump</a> - Returns a set of geometry_dump (geom,path) rows, that make up a geometry g1.</li><li class="listitem"><a class="link" href="#ST_DumpPoints" title="ST_DumpPoints">ST_DumpPoints</a> - Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.</li><li class="listitem"><a class="link" href="#ST_DumpRings" title="ST_DumpRings">ST_DumpRings</a> - Returns a set of geometry_dump rows, representing the exterior and interior rings of a polygon.</li></ul></div></div><div class="sect1" title="8.5.PostGIS Box Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PostGIS_BoxFunctions"></a>8.5.PostGIS Box Functions</h2></div></div></div><p>The functions given below are PostGIS functions that take as input or return as output the box* family of PostGIS spatial types.
The box family of types consists of <a class="link" href="#box2d" title="box2d">box2d</a>, <a class="link" href="#box3d" title="box3d">box3d</a>, <a class="link" href="#box3d_extent" title="box3d_extent">box3d_extent</a></p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><a class="link" href="#Box2D" title="Box2D">Box2D</a> - Returns a BOX2D representing the maximum extents of the geometry.</li><li class="listitem"><a class="link" href="#Box3D" title="Box3D">Box3D</a> - Returns a BOX3D representing the maximum extents of the geometry.</li><li class="listitem"><a class="link" href="#ST_Estimated_Extent" title="ST_Estimated_Extent">ST_Estimated_Extent</a> - Return the 'estimated' extent of the given spatial table. The estimated is taken from the geometry column's statistics. The current schema will be used if not specified.</li><li class="listitem"><a class="link" href="#ST_Expand" title="ST_Expand">ST_Expand</a> - Returns bounding box expanded in all directions from the bounding box of the input geometry. Uses double-precision</li><li class="listitem"><a class="link" href="#ST_Extent" title="ST_Extent">ST_Extent</a> - an aggregate function that returns the bounding box that bounds rows of geometries.</li><li class="listitem"><a class="link" href="#ST_Extent3D" title="ST_Extent3D">ST_Extent3D</a> - an aggregate function that returns the box3D bounding box that bounds rows of geometries.</li><li class="listitem"><a class="link" href="#ST_MakeBox2D" title="ST_MakeBox2D">ST_MakeBox2D</a> - Creates a BOX2D defined by the given point geometries.</li><li class="listitem"><a class="link" href="#ST_MakeBox3D" title="ST_MakeBox3D">ST_MakeBox3D</a> - Creates a BOX3D defined by the given 3d point geometries.</li><li class="listitem"><a class="link" href="#ST_XMax" title="ST_XMax">ST_XMax</a> - Returns X maxima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_XMin" title="ST_XMin">ST_XMin</a> - Returns X minima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_YMax" title="ST_YMax">ST_YMax</a> - Returns Y maxima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_YMin" title="ST_YMin">ST_YMin</a> - Returns Y minima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_ZMax" title="ST_ZMax">ST_ZMax</a> - Returns Z minima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_ZMin" title="ST_ZMin">ST_ZMin</a> - Returns Z minima of a bounding box 2d or 3d or a geometry.</li></ul></div></div><div class="sect1" title="8.6.PostGIS Functions that support 3D"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PostGIS_3D_Functions"></a>8.6.PostGIS Functions that support 3D</h2></div></div></div><p>The functions given below are PostGIS functions that do not throw away the Z-Index.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><a class="link" href="#AddGeometryColumn" title="AddGeometryColumn">AddGeometryColumn</a> - Adds a geometry column to an existing table of attributes.</li><li class="listitem"><a class="link" href="#Box3D" title="Box3D">Box3D</a> - Returns a BOX3D representing the maximum extents of the geometry.</li><li class="listitem"><a class="link" href="#DropGeometryColumn" title="DropGeometryColumn">DropGeometryColumn</a> - Removes a geometry column from a spatial table.</li><li class="listitem"><a class="link" href="#ST_Accum" title="ST_Accum">ST_Accum</a> - Aggregate. Constructs an array of geometries.</li><li class="listitem"><a class="link" href="#ST_AddMeasure" title="ST_AddMeasure">ST_AddMeasure</a> - Return a derived geometry with measure elements linearly interpolated between the start and end points. If the geometry has no measure dimension, one is added. If the geometry has a measure dimension, it is over-written with new values. Only LINESTRINGS and MULTILINESTRINGS are supported.</li><li class="listitem"><a class="link" href="#ST_AddPoint" title="ST_AddPoint">ST_AddPoint</a> - Adds a point to a LineString before point <position> (0-based index).</li><li class="listitem"><a class="link" href="#ST_Affine" title="ST_Affine">ST_Affine</a> - Applies a 3d affine transformation to the geometry to do things like translate, rotate, scale in one step.</li><li class="listitem"><a class="link" href="#ST_AsEWKB" title="ST_AsEWKB">ST_AsEWKB</a> - Return the Well-Known Binary (WKB) representation of the geometry with SRID meta data.</li><li class="listitem"><a class="link" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a> - Return the Well-Known Text (WKT) representation of the geometry with SRID meta data.</li><li class="listitem"><a class="link" href="#ST_AsGML" title="ST_AsGML">ST_AsGML</a> - Return the geometry as a GML version 2 or 3 element.</li><li class="listitem"><a class="link" href="#ST_AsGeoJSON" title="ST_AsGeoJSON">ST_AsGeoJSON</a> - Return the geometry as a GeoJSON element.</li><li class="listitem"><a class="link" href="#ST_AsHEXEWKB" title="ST_AsHEXEWKB">ST_AsHEXEWKB</a> - Returns a Geometry in HEXEWKB format (as text) using either little-endian (NDR) or big-endian (XDR) encoding.</li><li class="listitem"><a class="link" href="#ST_AsKML" title="ST_AsKML">ST_AsKML</a> - Return the geometry as a KML element. Several variants. Default version=2, default precision=15</li><li class="listitem"><a class="link" href="#ST_Boundary" title="ST_Boundary">ST_Boundary</a> - Returns the closure of the combinatorial boundary of this Geometry.</li><li class="listitem"><a class="link" href="#ST_Collect" title="ST_Collect">ST_Collect</a> - Return a specified ST_Geometry value from a collection of other geometries.</li><li class="listitem"><a class="link" href="#ST_ConvexHull" title="ST_ConvexHull">ST_ConvexHull</a> - The convex hull of a geometry represents the minimum convex geometry that encloses all geometries within the set.</li><li class="listitem"><a class="link" href="#ST_CoordDim" title="ST_CoordDim">ST_CoordDim</a> - Return the coordinate dimension of the ST_Geometry value.</li><li class="listitem"><a class="link" href="#ST_CurveToLine" title="ST_CurveToLine">ST_CurveToLine</a> - Converts a CIRCULARSTRING/CURVEDPOLYGON to a LINESTRING/POLYGON</li><li class="listitem"><a class="link" href="#ST_Difference" title="ST_Difference">ST_Difference</a> - Returns a geometry that represents that part of geometry A that does not intersect with geometry B.</li><li class="listitem"><a class="link" href="#ST_Dump" title="ST_Dump">ST_Dump</a> - Returns a set of geometry_dump (geom,path) rows, that make up a geometry g1.</li><li class="listitem"><a class="link" href="#ST_DumpPoints" title="ST_DumpPoints">ST_DumpPoints</a> - Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.</li><li class="listitem"><a class="link" href="#ST_DumpRings" title="ST_DumpRings">ST_DumpRings</a> - Returns a set of geometry_dump rows, representing the exterior and interior rings of a polygon.</li><li class="listitem"><a class="link" href="#ST_EndPoint" title="ST_EndPoint">ST_EndPoint</a> - Returns the last point of a LINESTRING geometry as a POINT.</li><li class="listitem"><a class="link" href="#ST_Extent3D" title="ST_Extent3D">ST_Extent3D</a> - an aggregate function that returns the box3D bounding box that bounds rows of geometries.</li><li class="listitem"><a class="link" href="#ST_ExteriorRing" title="ST_ExteriorRing">ST_ExteriorRing</a> - Returns a line string representing the exterior ring of the POLYGON geometry. Return NULL if the geometry is not a polygon. Will not work with MULTIPOLYGON</li><li class="listitem"><a class="link" href="#ST_ForceRHR" title="ST_ForceRHR">ST_ForceRHR</a> - Forces the orientation of the vertices in a polygon to follow the Right-Hand-Rule.</li><li class="listitem"><a class="link" href="#ST_Force_3D" title="ST_Force_3D">ST_Force_3D</a> - Forces the geometries into XYZ mode. This is an alias for ST_Force_3DZ.</li><li class="listitem"><a class="link" href="#ST_Force_3DZ" title="ST_Force_3DZ">ST_Force_3DZ</a> - Forces the geometries into XYZ mode. This is a synonym for ST_Force_3D.</li><li class="listitem"><a class="link" href="#ST_Force_4D" title="ST_Force_4D">ST_Force_4D</a> - Forces the geometries into XYZM mode.</li><li class="listitem"><a class="link" href="#ST_Force_Collection" title="ST_Force_Collection">ST_Force_Collection</a> - Converts the geometry into a GEOMETRYCOLLECTION.</li><li class="listitem"><a class="link" href="#ST_GeomFromEWKB" title="ST_GeomFromEWKB">ST_GeomFromEWKB</a> - Return a specified ST_Geometry value from Extended Well-Known Binary representation (EWKB).</li><li class="listitem"><a class="link" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a> - Return a specified ST_Geometry value from Extended Well-Known Text representation (EWKT).</li><li class="listitem"><a class="link" href="#ST_GeomFromGML" title="ST_GeomFromGML">ST_GeomFromGML</a> - Takes as input GML representation of geometry and outputs a PostGIS geometry object</li><li class="listitem"><a class="link" href="#ST_GeomFromKML" title="ST_GeomFromKML">ST_GeomFromKML</a> - Takes as input KML representation of geometry and outputs a PostGIS geometry object</li><li class="listitem"><a class="link" href="#ST_GeometryN" title="ST_GeometryN">ST_GeometryN</a> - Return the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or MULTIPOLYGON. Otherwise, return NULL.</li><li class="listitem"><a class="link" href="#ST_HasArc" title="ST_HasArc">ST_HasArc</a> - Returns true if a geometry or geometry collection contains a circular string</li><li class="listitem"><a class="link" href="#ST_InteriorRingN" title="ST_InteriorRingN">ST_InteriorRingN</a> - Return the Nth interior linestring ring of the polygon geometry. Return NULL if the geometry is not a polygon or the given N is out of range.</li><li class="listitem"><a class="link" href="#ST_IsClosed" title="ST_IsClosed">ST_IsClosed</a> - Returns TRUE if the LINESTRING's start and end points are coincident.</li><li class="listitem"><a class="link" href="#ST_IsSimple" title="ST_IsSimple">ST_IsSimple</a> - Returns (TRUE) if this Geometry has no anomalous geometric points, such as self intersection or self tangency.</li><li class="listitem"><a class="link" href="#ST_Length3D" title="ST_Length3D">ST_Length3D</a> - Returns the 3-dimensional or 2-dimensional length of the geometry if it is a linestring or multi-linestring.</li><li class="listitem"><a class="link" href="#ST_Length3D_Spheroid" title="ST_Length3D_Spheroid">ST_Length3D_Spheroid</a> - Calculates the length of a geometry on an ellipsoid, taking the elevation into account. This is just an alias for ST_Length_Spheroid.</li><li class="listitem"><a class="link" href="#ST_Length_Spheroid" title="ST_Length_Spheroid">ST_Length_Spheroid</a> - Calculates the 2D or 3D length of a linestring/multilinestring on an ellipsoid. This is useful if the coordinates of the geometry are in longitude/latitude and a length is desired without reprojection.</li><li class="listitem"><a class="link" href="#ST_LineFromMultiPoint" title="ST_LineFromMultiPoint">ST_LineFromMultiPoint</a> - Creates a LineString from a MultiPoint geometry.</li><li class="listitem"><a class="link" href="#ST_LineToCurve" title="ST_LineToCurve">ST_LineToCurve</a> - Converts a LINESTRING/POLYGON to a CIRCULARSTRING, CURVED POLYGON</li><li class="listitem"><a class="link" href="#ST_Line_Interpolate_Point" title="ST_Line_Interpolate_Point">ST_Line_Interpolate_Point</a> - Returns a point interpolated along a line. Second argument is a float8 between 0 and 1 representing fraction of total length of linestring the point has to be located.</li><li class="listitem"><a class="link" href="#ST_Line_Substring" title="ST_Line_Substring">ST_Line_Substring</a> - Return a linestring being a substring of the input one starting and ending at the given fractions of total 2d length. Second and third arguments are float8 values between 0 and 1.</li><li class="listitem"><a class="link" href="#ST_LocateBetweenElevations" title="ST_LocateBetweenElevations">ST_LocateBetweenElevations</a> - Return a derived geometry (collection) value with elements that intersect the specified range of elevations inclusively. Only 3D, 4D LINESTRINGS and MULTILINESTRINGS are supported.</li><li class="listitem"><a class="link" href="#ST_M" title="ST_M">ST_M</a> - Return the M coordinate of the point, or NULL if not available. Input must be a point.</li><li class="listitem"><a class="link" href="#ST_MakeBox3D" title="ST_MakeBox3D">ST_MakeBox3D</a> - Creates a BOX3D defined by the given 3d point geometries.</li><li class="listitem"><a class="link" href="#ST_MakeLine" title="ST_MakeLine">ST_MakeLine</a> - Creates a Linestring from point geometries.</li><li class="listitem"><a class="link" href="#ST_MakePoint" title="ST_MakePoint">ST_MakePoint</a> - Creates a 2D,3DZ or 4D point geometry.</li><li class="listitem"><a class="link" href="#ST_MakePolygon" title="ST_MakePolygon">ST_MakePolygon</a> - Creates a Polygon formed by the given shell. Input geometries must be closed LINESTRINGS.</li><li class="listitem"><a class="link" href="#ST_MemUnion" title="ST_MemUnion">ST_MemUnion</a> - Same as ST_Union, only memory-friendly (uses less memory and more processor time).</li><li class="listitem"><a class="link" href="#ST_Mem_Size" title="ST_Mem_Size">ST_Mem_Size</a> - Returns the amount of space (in bytes) the geometry takes.</li><li class="listitem"><a class="link" href="#ST_NDims" title="ST_NDims">ST_NDims</a> - Returns coordinate dimension of the geometry as a small int. Values are: 2,3 or 4.</li><li class="listitem"><a class="link" href="#ST_NPoints" title="ST_NPoints">ST_NPoints</a> - Return the number of points (vertexes) in a geometry.</li><li class="listitem"><a class="link" href="#ST_NRings" title="ST_NRings">ST_NRings</a> - If the geometry is a polygon or multi-polygon returns the number of rings.</li><li class="listitem"><a class="link" href="#ST_Perimeter3D" title="ST_Perimeter3D">ST_Perimeter3D</a> - Returns the 3-dimensional perimeter of the geometry, if it is a polygon or multi-polygon.</li><li class="listitem"><a class="link" href="#ST_PointFromWKB" title="ST_PointFromWKB">ST_PointFromWKB</a> - Makes a geometry from WKB with the given SRID</li><li class="listitem"><a class="link" href="#ST_PointN" title="ST_PointN">ST_PointN</a> - Return the Nth point in the first linestring or circular linestring in the geometry. Return NULL if there is no linestring in the geometry.</li><li class="listitem"><a class="link" href="#ST_PointOnSurface" title="ST_PointOnSurface">ST_PointOnSurface</a> - Returns a POINT guaranteed to lie on the surface.</li><li class="listitem"><a class="link" href="#ST_Polygon" title="ST_Polygon">ST_Polygon</a> - Returns a polygon built from the specified linestring and SRID.</li><li class="listitem"><a class="link" href="#ST_RemovePoint" title="ST_RemovePoint">ST_RemovePoint</a> - Removes point from a linestring. Offset is 0-based.</li><li class="listitem"><a class="link" href="#ST_Rotate" title="ST_Rotate">ST_Rotate</a> - This is a synonym for ST_RotateZ</li><li class="listitem"><a class="link" href="#ST_RotateX" title="ST_RotateX">ST_RotateX</a> - Rotate a geometry rotRadians about the X axis.</li><li class="listitem"><a class="link" href="#ST_RotateY" title="ST_RotateY">ST_RotateY</a> - Rotate a geometry rotRadians about the Y axis.</li><li class="listitem"><a class="link" href="#ST_RotateZ" title="ST_RotateZ">ST_RotateZ</a> - Rotate a geometry rotRadians about the Z axis.</li><li class="listitem"><a class="link" href="#ST_Scale" title="ST_Scale">ST_Scale</a> - Scales the geometry to a new size by multiplying the ordinates with the parameters. Ie: ST_Scale(geom, Xfactor, Yfactor, Zfactor).</li><li class="listitem"><a class="link" href="#ST_SetPoint" title="ST_SetPoint">ST_SetPoint</a> - Replace point N of linestring with given point. Index is 0-based.</li><li class="listitem"><a class="link" href="#ST_Shift_Longitude" title="ST_Shift_Longitude">ST_Shift_Longitude</a> - Reads every point/vertex in every component of every feature in a geometry, and if the longitude coordinate is <0, adds 360 to it. The result would be a 0-360 version of the data to be plotted in a 180 centric map</li><li class="listitem"><a class="link" href="#ST_SnapToGrid" title="ST_SnapToGrid">ST_SnapToGrid</a> - Snap all points of the input geometry to the grid defined by its origin and cell size. Remove consecutive points falling on the same cell, eventually returning NULL if output points are not enough to define a geometry of the given type. Collapsed geometries in a collection are stripped from it. Useful for reducing precision.</li><li class="listitem"><a class="link" href="#ST_StartPoint" title="ST_StartPoint">ST_StartPoint</a> - Returns the first point of a LINESTRING geometry as a POINT.</li><li class="listitem"><a class="link" href="#ST_Summary" title="ST_Summary">ST_Summary</a> - Returns a text summary of the contents of the ST_Geometry.</li><li class="listitem"><a class="link" href="#ST_SymDifference" title="ST_SymDifference">ST_SymDifference</a> - Returns a geometry that represents the portions of A and B that do not intersect. It is called a symmetric difference because ST_SymDifference(A,B) = ST_SymDifference(B,A).</li><li class="listitem"><a class="link" href="#ST_TransScale" title="ST_TransScale">ST_TransScale</a> - Translates the geometry using the deltaX and deltaY args, then scales it using the XFactor, YFactor args, working in 2D only.</li><li class="listitem"><a class="link" href="#ST_Translate" title="ST_Translate">ST_Translate</a> - Translates the geometry to a new location using the numeric parameters as offsets. Ie: ST_Translate(geom, X, Y) or ST_Translate(geom, X, Y,Z).</li><li class="listitem"><a class="link" href="#ST_X" title="ST_X">ST_X</a> - Return the X coordinate of the point, or NULL if not available. Input must be a point.</li><li class="listitem"><a class="link" href="#ST_XMax" title="ST_XMax">ST_XMax</a> - Returns X maxima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_XMin" title="ST_XMin">ST_XMin</a> - Returns X minima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_Y" title="ST_Y">ST_Y</a> - Return the Y coordinate of the point, or NULL if not available. Input must be a point.</li><li class="listitem"><a class="link" href="#ST_YMax" title="ST_YMax">ST_YMax</a> - Returns Y maxima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_YMin" title="ST_YMin">ST_YMin</a> - Returns Y minima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_Z" title="ST_Z">ST_Z</a> - Return the Z coordinate of the point, or NULL if not available. Input must be a point.</li><li class="listitem"><a class="link" href="#ST_ZMax" title="ST_ZMax">ST_ZMax</a> - Returns Z minima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_ZMin" title="ST_ZMin">ST_ZMin</a> - Returns Z minima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_Zmflag" title="ST_Zmflag">ST_Zmflag</a> - Returns ZM (dimension semantic) flag of the geometries as a small int. Values are: 0=2d, 1=3dm, 2=3dz, 3=4d.</li><li class="listitem"><a class="link" href="#UpdateGeometrySRID" title="UpdateGeometrySRID">UpdateGeometrySRID</a> - Updates the SRID of all features in a geometry column, geometry_columns metadata and srid table constraint</li></ul></div></div><div class="sect1" title="8.7.PostGIS Curved Geometry Support Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PostGIS_Curved_GeometryFunctions"></a>8.7.PostGIS Curved Geometry Support Functions</h2></div></div></div><p>The functions given below are PostGIS functions that can use CIRCULARSTRING, CURVEDPOLYGON, and other curved geometry types</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><a class="link" href="#AddGeometryColumn" title="AddGeometryColumn">AddGeometryColumn</a> - Adds a geometry column to an existing table of attributes.</li><li class="listitem"><a class="link" href="#Box2D" title="Box2D">Box2D</a> - Returns a BOX2D representing the maximum extents of the geometry.</li><li class="listitem"><a class="link" href="#Box3D" title="Box3D">Box3D</a> - Returns a BOX3D representing the maximum extents of the geometry.</li><li class="listitem"><a class="link" href="#DropGeometryColumn" title="DropGeometryColumn">DropGeometryColumn</a> - Removes a geometry column from a spatial table.</li><li class="listitem"><a class="link" href="#GeometryType" title="GeometryType">GeometryType</a> - Returns the type of the geometry as a string. Eg: 'LINESTRING', 'POLYGON', 'MULTIPOINT', etc.</li><li class="listitem"><a class="link" href="#PostGIS_AddBBox" title="PostGIS_AddBBox">PostGIS_AddBBox</a> - Add bounding box to the geometry.</li><li class="listitem"><a class="link" href="#PostGIS_DropBBox" title="PostGIS_DropBBox">PostGIS_DropBBox</a> - Drop the bounding box cache from the geometry.</li><li class="listitem"><a class="link" href="#PostGIS_HasBBox" title="PostGIS_HasBBox">PostGIS_HasBBox</a> - Returns TRUE if the bbox of this geometry is cached, FALSE otherwise.</li><li class="listitem"><a class="link" href="#ST_Accum" title="ST_Accum">ST_Accum</a> - Aggregate. Constructs an array of geometries.</li><li class="listitem"><a class="link" href="#ST_Affine" title="ST_Affine">ST_Affine</a> - Applies a 3d affine transformation to the geometry to do things like translate, rotate, scale in one step.</li><li class="listitem"><a class="link" href="#ST_AsBinary" title="ST_AsBinary">ST_AsBinary</a> - Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.</li><li class="listitem"><a class="link" href="#ST_AsEWKB" title="ST_AsEWKB">ST_AsEWKB</a> - Return the Well-Known Binary (WKB) representation of the geometry with SRID meta data.</li><li class="listitem"><a class="link" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a> - Return the Well-Known Text (WKT) representation of the geometry with SRID meta data.</li><li class="listitem"><a class="link" href="#ST_AsHEXEWKB" title="ST_AsHEXEWKB">ST_AsHEXEWKB</a> - Returns a Geometry in HEXEWKB format (as text) using either little-endian (NDR) or big-endian (XDR) encoding.</li><li class="listitem"><a class="link" href="#ST_AsText" title="ST_AsText">ST_AsText</a> - Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.</li><li class="listitem"><a class="link" href="#ST_Collect" title="ST_Collect">ST_Collect</a> - Return a specified ST_Geometry value from a collection of other geometries.</li><li class="listitem"><a class="link" href="#ST_CoordDim" title="ST_CoordDim">ST_CoordDim</a> - Return the coordinate dimension of the ST_Geometry value.</li><li class="listitem"><a class="link" href="#ST_CurveToLine" title="ST_CurveToLine">ST_CurveToLine</a> - Converts a CIRCULARSTRING/CURVEDPOLYGON to a LINESTRING/POLYGON</li><li class="listitem"><a class="link" href="#ST_Dump" title="ST_Dump">ST_Dump</a> - Returns a set of geometry_dump (geom,path) rows, that make up a geometry g1.</li><li class="listitem"><a class="link" href="#ST_DumpPoints" title="ST_DumpPoints">ST_DumpPoints</a> - Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.</li><li class="listitem"><a class="link" href="#ST_Estimated_Extent" title="ST_Estimated_Extent">ST_Estimated_Extent</a> - Return the 'estimated' extent of the given spatial table. The estimated is taken from the geometry column's statistics. The current schema will be used if not specified.</li><li class="listitem"><a class="link" href="#ST_Extent3D" title="ST_Extent3D">ST_Extent3D</a> - an aggregate function that returns the box3D bounding box that bounds rows of geometries.</li><li class="listitem"><a class="link" href="#ST_Force_2D" title="ST_Force_2D">ST_Force_2D</a> - Forces the geometries into a "2-dimensional mode" so that all output representations will only have the X and Y coordinates.</li><li class="listitem"><a class="link" href="#ST_Force_3D" title="ST_Force_3D">ST_Force_3D</a> - Forces the geometries into XYZ mode. This is an alias for ST_Force_3DZ.</li><li class="listitem"><a class="link" href="#ST_Force_3DM" title="ST_Force_3DM">ST_Force_3DM</a> - Forces the geometries into XYM mode.</li><li class="listitem"><a class="link" href="#ST_Force_3DZ" title="ST_Force_3DZ">ST_Force_3DZ</a> - Forces the geometries into XYZ mode. This is a synonym for ST_Force_3D.</li><li class="listitem"><a class="link" href="#ST_Force_4D" title="ST_Force_4D">ST_Force_4D</a> - Forces the geometries into XYZM mode.</li><li class="listitem"><a class="link" href="#ST_Force_Collection" title="ST_Force_Collection">ST_Force_Collection</a> - Converts the geometry into a GEOMETRYCOLLECTION.</li><li class="listitem"><a class="link" href="#ST_GeoHash" title="ST_GeoHash">ST_GeoHash</a> - Return a GeoHash representation (geohash.org) of the geometry.</li><li class="listitem"><a class="link" href="#ST_GeogFromWKB" title="ST_GeogFromWKB">ST_GeogFromWKB</a> - Creates a geography instance from a Well-Known Binary geometry representation (WKB) or extended Well Known Binary (EWKB).</li><li class="listitem"><a class="link" href="#ST_GeomFromEWKB" title="ST_GeomFromEWKB">ST_GeomFromEWKB</a> - Return a specified ST_Geometry value from Extended Well-Known Binary representation (EWKB).</li><li class="listitem"><a class="link" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a> - Return a specified ST_Geometry value from Extended Well-Known Text representation (EWKT).</li><li class="listitem"><a class="link" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a> - Return a specified ST_Geometry value from Well-Known Text representation (WKT).</li><li class="listitem"><a class="link" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a> - Creates a geometry instance from a Well-Known Binary geometry representation (WKB) and optional SRID.</li><li class="listitem"><a class="link" href="#ST_GeometryN" title="ST_GeometryN">ST_GeometryN</a> - Return the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or MULTIPOLYGON. Otherwise, return NULL.</li><li class="listitem"><a class="link" href="#ST_Geometry_EQ" title="=">=</a> - Returns TRUE if A's bounding box is the same as B's.</li><li class="listitem"><a class="link" href="#ST_Geometry_Overbelow" title="&<|">&<|</a> - Returns TRUE if A's bounding box overlaps or is below B's.</li><li class="listitem"><a class="link" href="#ST_Geometry_Overlap" title="&&">&&</a> - Returns TRUE if A's bounding box overlaps B's.</li><li class="listitem"><a class="link" href="#ST_HasArc" title="ST_HasArc">ST_HasArc</a> - Returns true if a geometry or geometry collection contains a circular string</li><li class="listitem"><a class="link" href="#ST_IsClosed" title="ST_IsClosed">ST_IsClosed</a> - Returns TRUE if the LINESTRING's start and end points are coincident.</li><li class="listitem"><a class="link" href="#ST_IsEmpty" title="ST_IsEmpty">ST_IsEmpty</a> - Returns true if this Geometry is an empty geometry . If true, then this Geometry represents the empty point set - i.e. GEOMETRYCOLLECTION(EMPTY).</li><li class="listitem"><a class="link" href="#ST_LineToCurve" title="ST_LineToCurve">ST_LineToCurve</a> - Converts a LINESTRING/POLYGON to a CIRCULARSTRING, CURVED POLYGON</li><li class="listitem"><a class="link" href="#ST_Mem_Size" title="ST_Mem_Size">ST_Mem_Size</a> - Returns the amount of space (in bytes) the geometry takes.</li><li class="listitem"><a class="link" href="#ST_NPoints" title="ST_NPoints">ST_NPoints</a> - Return the number of points (vertexes) in a geometry.</li><li class="listitem"><a class="link" href="#ST_NRings" title="ST_NRings">ST_NRings</a> - If the geometry is a polygon or multi-polygon returns the number of rings.</li><li class="listitem"><a class="link" href="#ST_PointFromWKB" title="ST_PointFromWKB">ST_PointFromWKB</a> - Makes a geometry from WKB with the given SRID</li><li class="listitem"><a class="link" href="#ST_PointN" title="ST_PointN">ST_PointN</a> - Return the Nth point in the first linestring or circular linestring in the geometry. Return NULL if there is no linestring in the geometry.</li><li class="listitem"><a class="link" href="#ST_Rotate" title="ST_Rotate">ST_Rotate</a> - This is a synonym for ST_RotateZ</li><li class="listitem"><a class="link" href="#ST_RotateZ" title="ST_RotateZ">ST_RotateZ</a> - Rotate a geometry rotRadians about the Z axis.</li><li class="listitem"><a class="link" href="#ST_SRID" title="ST_SRID">ST_SRID</a> - Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table.</li><li class="listitem"><a class="link" href="#ST_Scale" title="ST_Scale">ST_Scale</a> - Scales the geometry to a new size by multiplying the ordinates with the parameters. Ie: ST_Scale(geom, Xfactor, Yfactor, Zfactor).</li><li class="listitem"><a class="link" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a> - Sets the SRID on a geometry to a particular integer value.</li><li class="listitem"><a class="link" href="#ST_TransScale" title="ST_TransScale">ST_TransScale</a> - Translates the geometry using the deltaX and deltaY args, then scales it using the XFactor, YFactor args, working in 2D only.</li><li class="listitem"><a class="link" href="#ST_Transform" title="ST_Transform">ST_Transform</a> - Returns a new geometry with its coordinates transformed to the SRID referenced by the integer parameter.</li><li class="listitem"><a class="link" href="#ST_Translate" title="ST_Translate">ST_Translate</a> - Translates the geometry to a new location using the numeric parameters as offsets. Ie: ST_Translate(geom, X, Y) or ST_Translate(geom, X, Y,Z).</li><li class="listitem"><a class="link" href="#ST_XMax" title="ST_XMax">ST_XMax</a> - Returns X maxima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_XMin" title="ST_XMin">ST_XMin</a> - Returns X minima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_YMax" title="ST_YMax">ST_YMax</a> - Returns Y maxima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_YMin" title="ST_YMin">ST_YMin</a> - Returns Y minima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_ZMax" title="ST_ZMax">ST_ZMax</a> - Returns Z minima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_ZMin" title="ST_ZMin">ST_ZMin</a> - Returns Z minima of a bounding box 2d or 3d or a geometry.</li><li class="listitem"><a class="link" href="#ST_Zmflag" title="ST_Zmflag">ST_Zmflag</a> - Returns ZM (dimension semantic) flag of the geometries as a small int. Values are: 0=2d, 1=3dm, 2=3dz, 3=4d.</li><li class="listitem"><a class="link" href="#UpdateGeometrySRID" title="UpdateGeometrySRID">UpdateGeometrySRID</a> - Updates the SRID of all features in a geometry column, geometry_columns metadata and srid table constraint</li></ul></div></div><div class="sect1" title="8.8.PostGIS Function Support Matrix"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PostGIS_TypeFunctionMatrix"></a>8.8.PostGIS Function Support Matrix</h2></div></div></div><p>Below is an alphabetical listing of spatial specific functions in PostGIS and the kinds of spatial
types they work with or OGC/SQL compliance they try to conform to.</p><p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">A <span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span> means the function works with the type or subtype natively.</li><li class="listitem">A <span class="inlinemediaobject"><img src="images/matrix_transform.png"></span> means it works but with a transform cast built-in using cast to geometry, transform to a "best srid" spatial ref and then cast back. Results may not be as expected for large areas or areas at poles
and may accumulate floating point junk.</li><li class="listitem">A <span class="inlinemediaobject"><img src="images/matrix_autocast.png"></span> means the function works with the type because of a auto-cast to another such as to box3d rather than direct type support.</li></ul></div><p>
</p><p>
</p><div class="informaltable"><table border="1"><colgroup><col align="left" class="function"><col align="center" class="geometry"><col align="center" class="geography"><col align="center" class="3D"><col align="center" class="Curves"><col align="center" class="SQLMM"></colgroup><thead><tr><th align="left">Function</th><th align="center">geometry</th><th align="center">geography</th><th align="center">3D (2.5D)</th><th align="center">Curves</th><th align="center">SQL MM</th></tr></thead><tbody><tr><td align="left">
<a class="link" href="#Box2D" title="Box2D">Box2D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#Box3D" title="Box3D">Box3D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#Find_SRID" title="Find_SRID">Find_SRID</a>
</td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#GeometryType" title="GeometryType">GeometryType</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Accum" title="ST_Accum">ST_Accum</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_AddMeasure" title="ST_AddMeasure">ST_AddMeasure</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_AddPoint" title="ST_AddPoint">ST_AddPoint</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Affine" title="ST_Affine">ST_Affine</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Area" title="ST_Area">ST_Area</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_AsBinary" title="ST_AsBinary">ST_AsBinary</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_AsEWKB" title="ST_AsEWKB">ST_AsEWKB</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_AsEWKT" title="ST_AsEWKT">ST_AsEWKT</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_AsGML" title="ST_AsGML">ST_AsGML</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_AsGeoJSON" title="ST_AsGeoJSON">ST_AsGeoJSON</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_AsHEXEWKB" title="ST_AsHEXEWKB">ST_AsHEXEWKB</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_AsKML" title="ST_AsKML">ST_AsKML</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_AsSVG" title="ST_AsSVG">ST_AsSVG</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_AsText" title="ST_AsText">ST_AsText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Azimuth" title="ST_Azimuth">ST_Azimuth</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_BdMPolyFromText" title="ST_BdMPolyFromText">ST_BdMPolyFromText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_BdPolyFromText" title="ST_BdPolyFromText">ST_BdPolyFromText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Boundary" title="ST_Boundary">ST_Boundary</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Buffer" title="ST_Buffer">ST_Buffer</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_transform.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_BuildArea" title="ST_BuildArea">ST_BuildArea</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Centroid" title="ST_Centroid">ST_Centroid</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_ClosestPoint" title="ST_ClosestPoint">ST_ClosestPoint</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Collect" title="ST_Collect">ST_Collect</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_CollectionExtract" title="ST_CollectionExtract">ST_CollectionExtract</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Contains" title="ST_Contains">ST_Contains</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_ContainsProperly" title="ST_ContainsProperly">ST_ContainsProperly</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_ConvexHull" title="ST_ConvexHull">ST_ConvexHull</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_CoordDim" title="ST_CoordDim">ST_CoordDim</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_CoveredBy" title="ST_CoveredBy">ST_CoveredBy</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Covers" title="ST_Covers">ST_Covers</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Crosses" title="ST_Crosses">ST_Crosses</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_CurveToLine" title="ST_CurveToLine">ST_CurveToLine</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_DFullyWithin" title="ST_DFullyWithin">ST_DFullyWithin</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_DWithin" title="ST_DWithin">ST_DWithin</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Difference" title="ST_Difference">ST_Difference</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Dimension" title="ST_Dimension">ST_Dimension</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Disjoint" title="ST_Disjoint">ST_Disjoint</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Distance" title="ST_Distance">ST_Distance</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Distance_Sphere" title="ST_Distance_Sphere">ST_Distance_Sphere</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Distance_Spheroid" title="ST_Distance_Spheroid">ST_Distance_Spheroid</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Dump" title="ST_Dump">ST_Dump</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_DumpPoints" title="ST_DumpPoints">ST_DumpPoints</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_DumpRings" title="ST_DumpRings">ST_DumpRings</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_EndPoint" title="ST_EndPoint">ST_EndPoint</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Envelope" title="ST_Envelope">ST_Envelope</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Equals" title="ST_Equals">ST_Equals</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Estimated_Extent" title="ST_Estimated_Extent">ST_Estimated_Extent</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_autocast.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Expand" title="ST_Expand">ST_Expand</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Extent" title="ST_Extent">ST_Extent</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Extent3D" title="ST_Extent3D">ST_Extent3D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_ExteriorRing" title="ST_ExteriorRing">ST_ExteriorRing</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_ForceRHR" title="ST_ForceRHR">ST_ForceRHR</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Force_2D" title="ST_Force_2D">ST_Force_2D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Force_3D" title="ST_Force_3D">ST_Force_3D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Force_3DM" title="ST_Force_3DM">ST_Force_3DM</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Force_3DZ" title="ST_Force_3DZ">ST_Force_3DZ</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Force_4D" title="ST_Force_4D">ST_Force_4D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Force_Collection" title="ST_Force_Collection">ST_Force_Collection</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_GMLToSQL" title="ST_GMLToSQL">ST_GMLToSQL</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_GeoHash" title="ST_GeoHash">ST_GeoHash</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_GeogFromText" title="ST_GeogFromText">ST_GeogFromText</a>
</td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_GeogFromWKB" title="ST_GeogFromWKB">ST_GeogFromWKB</a>
</td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_GeographyFromText" title="ST_GeographyFromText">ST_GeographyFromText</a>
</td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_GeomCollFromText" title="ST_GeomCollFromText">ST_GeomCollFromText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_GeomFromEWKB" title="ST_GeomFromEWKB">ST_GeomFromEWKB</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_GeomFromEWKT" title="ST_GeomFromEWKT">ST_GeomFromEWKT</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_GeomFromGML" title="ST_GeomFromGML">ST_GeomFromGML</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_GeomFromKML" title="ST_GeomFromKML">ST_GeomFromKML</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_GeomFromText" title="ST_GeomFromText">ST_GeomFromText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_GeomFromWKB" title="ST_GeomFromWKB">ST_GeomFromWKB</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_GeometryFromText" title="ST_GeometryFromText">ST_GeometryFromText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_GeometryN" title="ST_GeometryN">ST_GeometryN</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_GeometryType" title="ST_GeometryType">ST_GeometryType</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Above" title="|>>">|>></a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Below" title="<<|"><<|</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Contain" title="~">~</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Contained" title="@">@</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_EQ" title="=">=</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Left" title="<<"><<</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Overabove" title="|&>">|&></a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Overbelow" title="&<|">&<|</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Overlap" title="&&">&&</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Overleft" title="&<">&<</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Overright" title="&>">&></a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Right" title=">>">>></a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Geometry_Same" title="~=">~=</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_HasArc" title="ST_HasArc">ST_HasArc</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_HausdorffDistance" title="ST_HausdorffDistance">ST_HausdorffDistance</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_InteriorRingN" title="ST_InteriorRingN">ST_InteriorRingN</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Intersection" title="ST_Intersection">ST_Intersection</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_transform.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Intersects" title="ST_Intersects">ST_Intersects</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_IsClosed" title="ST_IsClosed">ST_IsClosed</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_IsEmpty" title="ST_IsEmpty">ST_IsEmpty</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_IsRing" title="ST_IsRing">ST_IsRing</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_IsSimple" title="ST_IsSimple">ST_IsSimple</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_IsValid" title="ST_IsValid">ST_IsValid</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_IsValidReason" title="ST_IsValidReason">ST_IsValidReason</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Length" title="ST_Length">ST_Length</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Length2D" title="ST_Length2D">ST_Length2D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Length2D_Spheroid" title="ST_Length2D_Spheroid">ST_Length2D_Spheroid</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Length3D" title="ST_Length3D">ST_Length3D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Length3D_Spheroid" title="ST_Length3D_Spheroid">ST_Length3D_Spheroid</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Length_Spheroid" title="ST_Length_Spheroid">ST_Length_Spheroid</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_LineCrossingDirection" title="ST_LineCrossingDirection">ST_LineCrossingDirection</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_LineFromMultiPoint" title="ST_LineFromMultiPoint">ST_LineFromMultiPoint</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_LineFromText" title="ST_LineFromText">ST_LineFromText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_LineFromWKB" title="ST_LineFromWKB">ST_LineFromWKB</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_LineMerge" title="ST_LineMerge">ST_LineMerge</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_LineToCurve" title="ST_LineToCurve">ST_LineToCurve</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Line_Interpolate_Point" title="ST_Line_Interpolate_Point">ST_Line_Interpolate_Point</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Line_Locate_Point" title="ST_Line_Locate_Point">ST_Line_Locate_Point</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Line_Substring" title="ST_Line_Substring">ST_Line_Substring</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_LinestringFromWKB" title="ST_LinestringFromWKB">ST_LinestringFromWKB</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_LocateBetweenElevations" title="ST_LocateBetweenElevations">ST_LocateBetweenElevations</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Locate_Along_Measure" title="ST_Locate_Along_Measure">ST_Locate_Along_Measure</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Locate_Between_Measures" title="ST_Locate_Between_Measures">ST_Locate_Between_Measures</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_LongestLine" title="ST_LongestLine">ST_LongestLine</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_M" title="ST_M">ST_M</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_MLineFromText" title="ST_MLineFromText">ST_MLineFromText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_MPointFromText" title="ST_MPointFromText">ST_MPointFromText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_MPolyFromText" title="ST_MPolyFromText">ST_MPolyFromText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_MakeBox2D" title="ST_MakeBox2D">ST_MakeBox2D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_MakeBox3D" title="ST_MakeBox3D">ST_MakeBox3D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_MakeEnvelope" title="ST_MakeEnvelope">ST_MakeEnvelope</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_MakeLine" title="ST_MakeLine">ST_MakeLine</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_MakePoint" title="ST_MakePoint">ST_MakePoint</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_MakePointM" title="ST_MakePointM">ST_MakePointM</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_MakePolygon" title="ST_MakePolygon">ST_MakePolygon</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_MaxDistance" title="ST_MaxDistance">ST_MaxDistance</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_MemUnion" title="ST_MemUnion">ST_MemUnion</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Mem_Size" title="ST_Mem_Size">ST_Mem_Size</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_MinimumBoundingCircle" title="ST_MinimumBoundingCircle">ST_MinimumBoundingCircle</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Multi" title="ST_Multi">ST_Multi</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_NDims" title="ST_NDims">ST_NDims</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_NPoints" title="ST_NPoints">ST_NPoints</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_NRings" title="ST_NRings">ST_NRings</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_NumGeometries" title="ST_NumGeometries">ST_NumGeometries</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_NumInteriorRing" title="ST_NumInteriorRing">ST_NumInteriorRing</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_NumInteriorRings" title="ST_NumInteriorRings">ST_NumInteriorRings</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_NumPoints" title="ST_NumPoints">ST_NumPoints</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_OrderingEquals" title="ST_OrderingEquals">ST_OrderingEquals</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Overlaps" title="ST_Overlaps">ST_Overlaps</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Perimeter" title="ST_Perimeter">ST_Perimeter</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Perimeter2D" title="ST_Perimeter2D">ST_Perimeter2D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Perimeter3D" title="ST_Perimeter3D">ST_Perimeter3D</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Point" title="ST_Point">ST_Point</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_PointFromText" title="ST_PointFromText">ST_PointFromText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_PointFromWKB" title="ST_PointFromWKB">ST_PointFromWKB</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_PointN" title="ST_PointN">ST_PointN</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_PointOnSurface" title="ST_PointOnSurface">ST_PointOnSurface</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Point_Inside_Circle" title="ST_Point_Inside_Circle">ST_Point_Inside_Circle</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Polygon" title="ST_Polygon">ST_Polygon</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_PolygonFromText" title="ST_PolygonFromText">ST_PolygonFromText</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Polygonize" title="ST_Polygonize">ST_Polygonize</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Relate" title="ST_Relate">ST_Relate</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_RemovePoint" title="ST_RemovePoint">ST_RemovePoint</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Reverse" title="ST_Reverse">ST_Reverse</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Rotate" title="ST_Rotate">ST_Rotate</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_RotateX" title="ST_RotateX">ST_RotateX</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_RotateY" title="ST_RotateY">ST_RotateY</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_RotateZ" title="ST_RotateZ">ST_RotateZ</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_SRID" title="ST_SRID">ST_SRID</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Scale" title="ST_Scale">ST_Scale</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Segmentize" title="ST_Segmentize">ST_Segmentize</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_SetPoint" title="ST_SetPoint">ST_SetPoint</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_SetSRID" title="ST_SetSRID">ST_SetSRID</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Shift_Longitude" title="ST_Shift_Longitude">ST_Shift_Longitude</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_ShortestLine" title="ST_ShortestLine">ST_ShortestLine</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Simplify" title="ST_Simplify">ST_Simplify</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_SimplifyPreserveTopology" title="ST_SimplifyPreserveTopology">ST_SimplifyPreserveTopology</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_SnapToGrid" title="ST_SnapToGrid">ST_SnapToGrid</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_StartPoint" title="ST_StartPoint">ST_StartPoint</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Summary" title="ST_Summary">ST_Summary</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_SymDifference" title="ST_SymDifference">ST_SymDifference</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Touches" title="ST_Touches">ST_Touches</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_TransScale" title="ST_TransScale">ST_TransScale</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Transform" title="ST_Transform">ST_Transform</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Translate" title="ST_Translate">ST_Translate</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Union" title="ST_Union">ST_Union</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_WKBToSQL" title="ST_WKBToSQL">ST_WKBToSQL</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_WKTToSQL" title="ST_WKTToSQL">ST_WKTToSQL</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_Within" title="ST_Within">ST_Within</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_X" title="ST_X">ST_X</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_XMax" title="ST_XMax">ST_XMax</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_autocast.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_XMin" title="ST_XMin">ST_XMin</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_autocast.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Y" title="ST_Y">ST_Y</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_YMax" title="ST_YMax">ST_YMax</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_autocast.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_YMin" title="ST_YMin">ST_YMin</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_autocast.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Z" title="ST_Z">ST_Z</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td></tr><tr><td align="left">
<a class="link" href="#ST_ZMax" title="ST_ZMax">ST_ZMax</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_autocast.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_ZMin" title="ST_ZMin">ST_ZMin</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_autocast.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr><tr><td align="left">
<a class="link" href="#ST_Zmflag" title="ST_Zmflag">ST_Zmflag</a>
</td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"><span class="inlinemediaobject"><img src="images/matrix_checkmark.png"></span></td><td align="center"></td></tr></tbody></table></div><p>
</p></div><div class="sect1" title="8.9.New PostGIS Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="NewFunctions"></a>8.9.New PostGIS Functions</h2></div></div></div><div class="toc"><dl><dt><span class="sect2"><a href="#NewFunctions_1_5">8.9.1. PostGIS Functions new, behavior changed, or enhanced in 1.5</a></span></dt><dt><span class="sect2"><a href="#NewFunctions_1_4">8.9.2. PostGIS Functions new, behavior changed, or enhanced in 1.4</a></span></dt><dt><span class="sect2"><a href="#NewFunctions_1_3">8.9.3. PostGIS Functions new in 1.3</a></span></dt></dl></div><div class="sect2" title="8.9.1.PostGIS Functions new, behavior changed, or enhanced in 1.5"><div class="titlepage"><div><div><h3 class="title"><a name="NewFunctions_1_5"></a>8.9.1.PostGIS Functions new, behavior changed, or enhanced in 1.5</h3></div></div></div><p>The functions given below are PostGIS functions that were introduced or enhanced in this major release.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><a class="link" href="#PostGIS_LibXML_Version" title="PostGIS_LibXML_Version">PostGIS_LibXML_Version</a> - Availability: 1.5 Returns the version number of the libxml2 library.</li><li class="listitem"><a class="link" href="#ST_AddMeasure" title="ST_AddMeasure">ST_AddMeasure</a> - Availability: 1.5.0 Return a derived geometry with measure elements linearly interpolated between the start and end points. If the geometry has no measure dimension, one is added. If the geometry has a measure dimension, it is over-written with new values. Only LINESTRINGS and MULTILINESTRINGS are supported.</li><li class="listitem"><a class="link" href="#ST_AsBinary" title="ST_AsBinary">ST_AsBinary</a> - Availability: 1.5.0 geography support was introduced. Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.</li><li class="listitem"><a class="link" href="#ST_AsGeoJSON" title="ST_AsGeoJSON">ST_AsGeoJSON</a> - Availability: 1.5.0 geography support was introduced. Return the geometry as a GeoJSON element.</li><li class="listitem"><a class="link" href="#ST_AsText" title="ST_AsText">ST_AsText</a> - Availability: 1.5 - support for geography was introduced. Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.</li><li class="listitem"><a class="link" href="#ST_Buffer" title="ST_Buffer">ST_Buffer</a> - Availability: 1.5 - ST_Buffer was enhanced to support different endcaps and join types. These are useful for example to convert road linestrings
into polygon roads with flat or square edges instead of rounded edges. Thin wrapper for geography was added. - requires GEOS >= 3.2 to take advantage of advanced geometry functionality.
(T) For geometry: Returns a geometry that represents all points whose distance from this Geometry is less than or equal to distance. Calculations are in the Spatial Reference System of this Geometry. For geography: Uses a planar transform wrapper. Introduced in 1.5 support for different end cap and mitre settings to control shape. buffer_style options: quad_segs=#,endcap=round|flat|square,join=round|mitre|bevel,mitre_limit=#.#</li><li class="listitem"><a class="link" href="#ST_ClosestPoint" title="ST_ClosestPoint">ST_ClosestPoint</a> - Availability: 1.5.0 Returns the 2-dimensional point on g1 that is closest to g2. This is the first point of the shortest line.</li><li class="listitem"><a class="link" href="#ST_CollectionExtract" title="ST_CollectionExtract">ST_CollectionExtract</a> - Availability: 1.5.0 Given a GEOMETRYCOLLECTION, returns a MULTI* geometry consisting only of the specified type. Sub-geometries that are not the specified type are ignored. If there are no sub-geometries of the right type, an EMPTY collection will be returned. Only points, lines and polygons are supported. Type numbers are 1 == POINT, 2 == LINESTRING, 3 == POLYGON.</li><li class="listitem"><a class="link" href="#ST_Covers" title="ST_Covers">ST_Covers</a> - Availability: 1.5 - support for geography was introduced. Returns 1 (TRUE) if no point in Geometry B is outside Geometry A. For geography: if geography point B is not outside Polygon Geography A</li><li class="listitem"><a class="link" href="#ST_DFullyWithin" title="ST_DFullyWithin">ST_DFullyWithin</a> - Availability: 1.5.0 Returns true if all of the geometries are within the specified distance of one another</li><li class="listitem"><a class="link" href="#ST_DWithin" title="ST_DWithin">ST_DWithin</a> - Availability: 1.5.0 support for geography was introduced Returns true if the geometries are within the specified distance of one another. For geometry units are in those of spatial reference and For geography units are in meters and measurement is defaulted to use_spheroid=true (measure around spheroid), for faster check, use_spheroid=false to measure along sphere.</li><li class="listitem"><a class="link" href="#ST_Distance" title="ST_Distance">ST_Distance</a> - Availability: 1.5.0 geography support was introduced in 1.5. Speed improvements for planar to better handle large or many vertex geometries For geometry type Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units. For geography type defaults to return spheroidal minimum distance between two geographies in meters.</li><li class="listitem"><a class="link" href="#ST_Distance_Sphere" title="ST_Distance_Sphere">ST_Distance_Sphere</a> - Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points. Returns minimum distance in meters between two lon/lat geometries. Uses a spherical earth and radius of 6370986 meters. Faster than ST_Distance_Spheroid, but less accurate. PostGIS versions prior to 1.5 only implemented for points.</li><li class="listitem"><a class="link" href="#ST_Distance_Spheroid" title="ST_Distance_Spheroid">ST_Distance_Spheroid</a> - Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points. Returns the minimum distance between two lon/lat geometries given a particular spheroid. PostGIS versions prior to 1.5 only support points.</li><li class="listitem"><a class="link" href="#ST_DumpPoints" title="ST_DumpPoints">ST_DumpPoints</a> - Availability: 1.5.0 Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.</li><li class="listitem"><a class="link" href="#ST_Envelope" title="ST_Envelope">ST_Envelope</a> - Availability: 1.5.0 behavior changed to output double precision instead of float4 Returns a geometry representing the double precision (float8) bounding box of the supplied geometry.</li><li class="listitem"><a class="link" href="#ST_GMLToSQL" title="ST_GMLToSQL">ST_GMLToSQL</a> - Availability: 1.5 Return a specified ST_Geometry value from GML representation. This is an alias name for ST_GeomFromGML</li><li class="listitem"><a class="link" href="#ST_GeomFromGML" title="ST_GeomFromGML">ST_GeomFromGML</a> - Availability: 1.5 Takes as input GML representation of geometry and outputs a PostGIS geometry object</li><li class="listitem"><a class="link" href="#ST_GeomFromKML" title="ST_GeomFromKML">ST_GeomFromKML</a> - Availability: 1.5 Takes as input KML representation of geometry and outputs a PostGIS geometry object</li><li class="listitem"><a class="link" href="#ST_Geometry_Overlap" title="&&">&&</a> - Availability: 1.5.0 support for geography was introduced. Returns TRUE if A's bounding box overlaps B's.</li><li class="listitem"><a class="link" href="#ST_Geometry_Same" title="~=">~=</a> - Availability: 1.5.0 changed behavior Returns TRUE if A's bounding box is the same as B's.</li><li class="listitem"><a class="link" href="#ST_HausdorffDistance" title="ST_HausdorffDistance">ST_HausdorffDistance</a> - Availability: 1.5.0 - requires GEOS >= 3.2.0 Returns the Hausdorff distance between two geometries. Basically a measure of how similar or dissimilar 2 geometries are. Units are in the units of the spatial reference system of the geometries.</li><li class="listitem"><a class="link" href="#ST_Intersection" title="ST_Intersection">ST_Intersection</a> - Availability: 1.5 support for geography data type was introduced. (T) Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation does a transform to geometry to do the intersection and then transform back to WGS84.</li><li class="listitem"><a class="link" href="#ST_Intersects" title="ST_Intersects">ST_Intersects</a> - Availability: 1.5 support for geography was introduced. Returns TRUE if the Geometries/Geography "spatially intersect" - (share any portion of space) and FALSE if they don't (they are Disjoint). For geography -- tolerance is 0.00001 meters (so any points that close are considered to intersect)</li><li class="listitem"><a class="link" href="#ST_Length" title="ST_Length">ST_Length</a> - Availability: 1.5.0 geography support was introduced in 1.5. Returns the 2d length of the geometry if it is a linestring or multilinestring. geometry are in units of spatial reference and geography are in meters (default spheroid)</li><li class="listitem"><a class="link" href="#ST_Line_Locate_Point" title="ST_Line_Locate_Point">ST_Line_Locate_Point</a> - Availability: 1.5.1 - support for MULTILINESTRINGS was introduced. Returns a float between 0 and 1 representing the location of the closest point on LineString to the given Point, as a fraction of total 2d line length.</li><li class="listitem"><a class="link" href="#ST_LongestLine" title="ST_LongestLine">ST_LongestLine</a> - Availability: 1.5.0 Returns the 2-dimensional longest line points of two geometries. The function will only return the first longest line if more than one, that the function finds. The line returned will always start in g1 and end in g2. The length of the line this function returns will always be the same as st_maxdistance returns for g1 and g2.</li><li class="listitem"><a class="link" href="#ST_MakeEnvelope" title="ST_MakeEnvelope">ST_MakeEnvelope</a> - Availability: 1.5 Creates a rectangular Polygon formed from the given minimums and maximums. Input values must be in SRS specified by the SRID.</li><li class="listitem"><a class="link" href="#ST_MaxDistance" title="ST_MaxDistance">ST_MaxDistance</a> - Availability: 1.5.0 Returns the 2-dimensional largest distance between two geometries in projected units.</li><li class="listitem"><a class="link" href="#ST_ShortestLine" title="ST_ShortestLine">ST_ShortestLine</a> - Availability: 1.5.0 Returns the 2-dimensional shortest line between two geometries</li></ul></div></div><div class="sect2" title="8.9.2.PostGIS Functions new, behavior changed, or enhanced in 1.4"><div class="titlepage"><div><div><h3 class="title"><a name="NewFunctions_1_4"></a>8.9.2.PostGIS Functions new, behavior changed, or enhanced in 1.4</h3></div></div></div><p>The functions given below are PostGIS functions that were introduced or enhanced in the 1.4 release.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><a class="link" href="#Populate_Geometry_Columns" title="Populate_Geometry_Columns">Populate_Geometry_Columns</a> - Ensures geometry columns have appropriate spatial constraints and exist in the geometry_columns table. Availability: 1.4.0</li><li class="listitem"><a class="link" href="#ST_AsSVG" title="ST_AsSVG">ST_AsSVG</a> - Returns a Geometry in SVG path data given a geometry or geography object.
Availability: 1.2.2 . Availability: 1.4.0 Changed in PostGIS 1.4.0 to include L command in absolute path to conform to http://www.w3.org/TR/SVG/paths.html#PathDataBNF
</li><li class="listitem"><a class="link" href="#ST_Collect" title="ST_Collect">ST_Collect</a> - Return a specified ST_Geometry value from a collection of other geometries. Availability: 1.4.0 - ST_Collect(geomarray) was introduced. ST_Collect was enhanced to handle more geometries faster.</li><li class="listitem"><a class="link" href="#ST_ContainsProperly" title="ST_ContainsProperly">ST_ContainsProperly</a> - Returns true if B intersects the interior of A but not the boundary (or exterior). A does not contain properly itself, but does contain itself. Availability: 1.4.0 - requires GEOS >= 3.1.0.</li><li class="listitem"><a class="link" href="#ST_Extent" title="ST_Extent">ST_Extent</a> - an aggregate function that returns the bounding box that bounds rows of geometries.
Availability: 1.4.0 As of 1.4.0 now returns a box3d_extent instead of box2d object.
</li><li class="listitem"><a class="link" href="#ST_GeoHash" title="ST_GeoHash">ST_GeoHash</a> - Return a GeoHash representation (geohash.org) of the geometry. Availability: 1.4.0</li><li class="listitem"><a class="link" href="#ST_IsValidReason" title="ST_IsValidReason">ST_IsValidReason</a> - Returns text stating if a geometry is valid or not and if not valid, a reason why. Availability: 1.4 - requires GEOS >= 3.1.0.</li><li class="listitem"><a class="link" href="#ST_LineCrossingDirection" title="ST_LineCrossingDirection">ST_LineCrossingDirection</a> - Given 2 linestrings, returns a number between -3 and 3 denoting what kind of crossing behavior. 0 is no crossing. Availability: 1.4</li><li class="listitem"><a class="link" href="#ST_LocateBetweenElevations" title="ST_LocateBetweenElevations">ST_LocateBetweenElevations</a> - Return a derived geometry (collection) value with elements that intersect the specified range of elevations inclusively. Only 3D, 4D LINESTRINGS and MULTILINESTRINGS are supported. Availability: 1.4.0</li><li class="listitem"><a class="link" href="#ST_MakeLine" title="ST_MakeLine">ST_MakeLine</a> - Creates a Linestring from point geometries. Availability: 1.4.0 - ST_MakeLine(geomarray) was introduced. ST_MakeLine aggregate functions was enhanced to handle more points faster.</li><li class="listitem"><a class="link" href="#ST_MinimumBoundingCircle" title="ST_MinimumBoundingCircle">ST_MinimumBoundingCircle</a> - Returns the smallest circle polygon that can fully contain a geometry. Default uses 48 segments per quarter circle. Availability: 1.4.0 - requires GEOS</li><li class="listitem"><a class="link" href="#ST_Union" title="ST_Union">ST_Union</a> - Returns a geometry that represents the point set union of the Geometries. Availability: 1.4.0 - ST_Union was enhanced. ST_Union(geomarray) was introduced and also faster aggregate collection in PostgreSQL. If you are using GEOS 3.1.0+
ST_Union will use the faster Cascaded Union algorithm described in
http://blog.cleverelephant.ca/2009/01/must-faster-unions-in-postgis-14.html</li></ul></div></div><div class="sect2" title="8.9.3.PostGIS Functions new in 1.3"><div class="titlepage"><div><div><h3 class="title"><a name="NewFunctions_1_3"></a>8.9.3.PostGIS Functions new in 1.3</h3></div></div></div><p>The functions given below are PostGIS functions that were introduced in the 1.3 release.</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><a class="link" href="#ST_AsGeoJSON" title="ST_AsGeoJSON">ST_AsGeoJSON</a> - Return the geometry as a GeoJSON element. Availability: 1.3.4</li><li class="listitem"><a class="link" href="#ST_SimplifyPreserveTopology" title="ST_SimplifyPreserveTopology">ST_SimplifyPreserveTopology</a> - Returns a "simplified" version of the given geometry using the Douglas-Peucker algorithm. Will avoid creating derived geometries (polygons in particular) that are invalid. Availability: 1.3.3</li></ul></div></div></div></div><div class="chapter" title="Chapter9.Reporting Problems"><div class="titlepage"><div><div><h2 class="title"><a name="id36279034"></a>Chapter9.Reporting Problems</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#id36279040">9.1. Reporting Software Bugs</a></span></dt><dt><span class="sect1"><a href="#id36279094">9.2. Reporting Documentation Issues</a></span></dt></dl></div><div class="sect1" title="9.1.Reporting Software Bugs"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36279040"></a>9.1.Reporting Software Bugs</h2></div></div></div><p>Reporting bugs effectively is a fundamental way to help PostGIS
development. The most effective bug report is that enabling PostGIS
developers to reproduce it, so it would ideally contain a script
triggering it and every information regarding the environment in which it
was detected. Good enough info can be extracted running <code class="code">SELECT
postgis_full_version()</code> [for postgis] and <code class="code">SELECT
version()</code> [for postgresql].</p><p>If you aren't using the latest release, it's worth taking a look at
its <a class="ulink" href="http://svn.osgeo.org/postgis/trunk/NEWS" target="_top">release
changelog</a> first, to find out if your bug has already been
fixed.</p><p>Using the <a class="ulink" href="http://trac.osgeo.org/postgis/" target="_top">PostGIS bug
tracker</a> will ensure your reports are not discarded, and will keep
you informed on its handling process. Before reporting a new bug please
query the database to see if it is a known one, and if it is please add
any new information you have about it.</p><p>You might want to read Simon Tatham's paper about <a class="ulink" href="http://www.chiark.greenend.org.uk/~sgtatham/bugs.html" target="_top">How to Report
Bugs Effectively</a> before filing a new report.</p></div><div class="sect1" title="9.2.Reporting Documentation Issues"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36279094"></a>9.2.Reporting Documentation Issues</h2></div></div></div><p>The documentation should accurately reflect the features and
behavior of the software. If it doesn't, it could be because of a software
bug or because the documentation is in error or deficient.</p><p>Documentation issues can also be reported to the <a class="ulink" href="http://trac.osgeo.org/postgis" target="_top">PostGIS bug
tracker</a>.</p><p>If your revision is trivial, just describe it in a new bug tracker
issue, being specific about its location in the documentation.</p><p>If your changes are more extensive, a Subversion patch is definitely
preferred. This is a four step process on Unix (assuming you already have
<a class="ulink" href="http://subversion.tigris.org/" target="_top">Subversion</a>
installed):</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Check out a copy of PostGIS' Subversion trunk. On Unix,
type:</p><p><span class="command"><strong>svn checkout
http://svn.osgeo.org/postgis/trunk/</strong></span></p><p>This will be stored in the directory ./trunk</p></li><li class="listitem"><p>Make your changes to the documentation with your favorite text
editor. On Unix, type (for example):</p><p><span class="command"><strong>vim trunk/doc/postgis.xml</strong></span></p><p>Note that the documentation is written in SGML rather than HTML,
so if you are not familiar with it please follow the example of the
rest of the documentation.</p></li><li class="listitem"><p>Make a patch file containing the differences from the master
copy of the documentation. On Unix, type:</p><p><span class="command"><strong>svn diff trunk/doc/postgis.xml >
doc.patch</strong></span></p></li><li class="listitem"><p>Attach the patch to a new issue in bug tracker.</p></li></ol></div></div></div><div class="appendix" title="AppendixA.Appendix"><div class="titlepage"><div><div><h2 class="title"><a name="release_notes"></a>AppendixA.Appendix</h2></div><div><h3 class="subtitle"><i>Release Notes</i></h3></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#id36279370">A.1. Release 1.5.3</a></span></dt><dt><span class="sect1"><a href="#id36279459">A.2. Release 1.5.2</a></span></dt><dt><span class="sect1"><a href="#id36279562">A.3. Release 1.5.1</a></span></dt><dt><span class="sect1"><a href="#id36279618">A.4. Release 1.5.0</a></span></dt><dt><span class="sect1"><a href="#id36279818">A.5. Release 1.4.0</a></span></dt><dt><span class="sect1"><a href="#id36280015">A.6. Release 1.3.6</a></span></dt><dt><span class="sect1"><a href="#id36280031">A.7. Release 1.3.5</a></span></dt><dt><span class="sect1"><a href="#id36280046">A.8. Release 1.3.4</a></span></dt><dt><span class="sect1"><a href="#id36280067">A.9. Release 1.3.3</a></span></dt><dt><span class="sect1"><a href="#id36280082">A.10. Release 1.3.2</a></span></dt><dt><span class="sect1"><a href="#id36280097">A.11. Release 1.3.1</a></span></dt><dt><span class="sect1"><a href="#id36280112">A.12. Release 1.3.0</a></span></dt><dt><span class="sect1"><a href="#id36280179">A.13. Release 1.2.1</a></span></dt><dt><span class="sect1"><a href="#id36280220">A.14. Release 1.2.0</a></span></dt><dt><span class="sect1"><a href="#id36280249">A.15. Release 1.1.6</a></span></dt><dt><span class="sect1"><a href="#id36280354">A.16. Release 1.1.5</a></span></dt><dt><span class="sect1"><a href="#id36280453">A.17. Release 1.1.4</a></span></dt><dt><span class="sect1"><a href="#id36280560">A.18. Release 1.1.3</a></span></dt><dt><span class="sect1"><a href="#id36280844">A.19. Release 1.1.2</a></span></dt><dt><span class="sect1"><a href="#id36280963">A.20. Release 1.1.1</a></span></dt><dt><span class="sect1"><a href="#id36281079">A.21. Release 1.1.0</a></span></dt><dt><span class="sect1"><a href="#id36281369">A.22. Release 1.0.6</a></span></dt><dt><span class="sect1"><a href="#id36281467">A.23. Release 1.0.5</a></span></dt><dt><span class="sect1"><a href="#id36281587">A.24. Release 1.0.4</a></span></dt><dt><span class="sect1"><a href="#rel_1.0.3_upgrading">A.25. Release 1.0.3</a></span></dt><dt><span class="sect1"><a href="#id36281806">A.26. Release 1.0.2</a></span></dt><dt><span class="sect1"><a href="#id36281878">A.27. Release 1.0.1</a></span></dt><dt><span class="sect1"><a href="#id36281969">A.28. Release 1.0.0</a></span></dt><dt><span class="sect1"><a href="#id36282059">A.29. Release 1.0.0RC6</a></span></dt><dt><span class="sect1"><a href="#id36282127">A.30. Release 1.0.0RC5</a></span></dt><dt><span class="sect1"><a href="#id36282193">A.31. Release 1.0.0RC4</a></span></dt><dt><span class="sect1"><a href="#id36282307">A.32. Release 1.0.0RC3</a></span></dt><dt><span class="sect1"><a href="#id36282462">A.33. Release 1.0.0RC2</a></span></dt><dt><span class="sect1"><a href="#id36282553">A.34. Release 1.0.0RC1</a></span></dt></dl></div><div class="sect1" title="A.1.Release 1.5.3"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36279370"></a>A.1.Release 1.5.3</h2></div></div></div><p>Release date: 2011/06/25</p><p>This is a bug fix release, addressing issues that have been filed since the 1.5.2 release.</p><div class="simplesect" title="Bug Fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36279383"></a>Bug Fixes</h3></div></div></div><p>#1007, ST_IsValid crash fix requires GEOS 3.3.0+ or 3.2.3+
(Sandro Santilli, reported by Birgit Laggner)</p><p> #940, support for PostgreSQL 9.1 beta 1
(Regina Obe, Paul Ramsey, patch submitted by stl)</p><p>#845, ST_Intersects precision error (Sandro Santilli, Nicklas Avn)
Reported by cdestigter</p><p>#884, Unstable results with ST_Within, ST_Intersects (Chris Hodgson)</p><p>#779, shp2pgsql -S option seems to fail on points (Jeff Adams)</p><p>#666, ST_DumpPoints is not null safe (Regina Obe)</p><p>#631, Update NZ projections for grid transformation support (jpalmer)</p><p>#630, Peculiar Null treatment in arrays in ST_Collect (Chris Hodgson)
Reported by David Bitner</p><p>#624, Memory leak in ST_GeogFromText (ryang, Paul Ramsey)</p><p>#609, Bad source code in manual section 5.2 Java Clients (simoc, Regina Obe)</p><p>#604, shp2pgsql usage touchups (Mike Toews, Paul Ramsey)</p><p>#573 ST_Union fails on a group of linestrings
Not a PostGIS bug, fixed in GEOS 3.3.0</p><p>#457 ST_CollectionExtract returns non-requested type
(Nicklas Avn, Paul Ramsey)</p><p>#441 ST_AsGeoJson Bbox on GeometryCollection error (Olivier Courtin)</p><p>#411 Ability to backup invalid geometries (Sando Santilli)
Reported by Regione Toscana</p><p>#409 ST_AsSVG - degraded (Olivier Courtin)
Reported by Sdikiy</p><p>#373 Documentation syntax error in hard upgrade (Paul Ramsey)
Reported by psvensso</p></div></div><div class="sect1" title="A.2.Release 1.5.2"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36279459"></a>A.2.Release 1.5.2</h2></div></div></div><p>Release date: 2010/09/27</p><p>This is a bug fix release, addressing issues that have been filed since the 1.5.1 release.</p><div class="simplesect" title="Bug Fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36279472"></a>Bug Fixes</h3></div></div></div><p>Loader: fix handling of empty (0-verticed) geometries in shapefiles. (Sandro Santilli)</p><p>#536, Geography ST_Intersects, ST_Covers, ST_CoveredBy and Geometry ST_Equals not using spatial index (Regina Obe, Nicklas Aven)</p><p>#573, Improvement to ST_Contains geography (Paul Ramsey)</p><p>Loader: Add support for command-q shutdown in Mac GTK build (Paul Ramsey)</p><p>#393, Loader: Add temporary patch for large DBF files (Maxime Guillaud, Paul Ramsey)</p><p>#507, Fix wrong OGC URN in GeoJSON and GML output (Olivier Courtin)</p><p>spatial_ref_sys.sql Add datum conversion for projection SRID 3021 (Paul Ramsey)</p><p>Geography - remove crash for case when all geographies are out of the estimate (Paul Ramsey)</p><p>#469, Fix for array_aggregation error (Greg Stark, Paul Ramsey)</p><p>#532, Temporary geography tables showing up in other user sessions (Paul Ramsey)</p><p>#562, ST_Dwithin errors for large geographies (Paul Ramsey)</p><p>#513, shape loading GUI tries to make spatial index when loading DBF only mode (Paul Ramsey)</p><p>#527, shape loading GUI should always append log messages (Mark Cave-Ayland)</p><p>#504, shp2pgsql should rename xmin/xmax fields (Sandro Santilli)</p><p>#458, postgis_comments being installed in contrib instead of version folder (Mark Cave-Ayland)</p><p>#474, Analyzing a table with geography column crashes server (Paul Ramsey)</p><p>#581, LWGEOM-expand produces inconsistent results (Mark Cave-Ayland)</p><p>#513, Add dbf filter to shp2pgsql-gui and allow uploading dbf only (Paul Ramsey)</p><p>Fix further build issues against PostgreSQL 9.0 (Mark Cave-Ayland)</p><p>#572, Password whitespace for Shape File</p><p>#603, shp2pgsql: "-w" produces invalid WKT for MULTI* objects. (Mark Cave-Ayland)</p></div></div><div class="sect1" title="A.3.Release 1.5.1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36279562"></a>A.3.Release 1.5.1</h2></div></div></div><p>Release date: 2010/03/11</p><p>This is a bug fix release, addressing issues that have been filed since the 1.4.1 release.</p><div class="simplesect" title="Bug Fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36279575"></a>Bug Fixes</h3></div></div></div><p>#410, update embedded bbox when applying ST_SetPoint, ST_AddPoint ST_RemovePoint to a linestring (Paul Ramsey)</p><p>#411, allow dumping tables with invalid geometries (Sandro Santilli, for Regione Toscana-SIGTA)</p><p>#414, include geography_columns view when running upgrade scripts (Paul Ramsey)</p><p>#419, allow support for multilinestring in ST_Line_Substring (Paul Ramsey, for Lidwala Consulting Engineers)</p><p>#421, fix computed string length in ST_AsGML() (Olivier Courtin)</p><p>#441, fix GML generation with heterogeneous collections (Olivier Courtin)</p><p>#443, incorrect coordinate reversal in GML 3 generation (Olivier Courtin)</p><p>#450, #451, wrong area calculation for geography features that cross the date line (Paul Ramsey)</p><p>Ensure support for upcoming 9.0 PgSQL release (Paul Ramsey)</p></div></div><div class="sect1" title="A.4.Release 1.5.0"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36279618"></a>A.4.Release 1.5.0</h2></div></div></div><p>Release date: 2010/02/04</p><p>This release provides support for geographic coordinates (lat/lon) via a new GEOGRAPHY type. Also performance enhancements, new input format support (GML,KML) and general upkeep.</p><div class="simplesect" title="API Stability"><div class="titlepage"><div><div><h3 class="title"><a name="id36279632"></a>API Stability</h3></div></div></div><p>The public API of PostGIS will not change during minor (0.0.X) releases.</p><p>The definition of the =~ operator has changed from an exact geometric equality check to a bounding box equality check.</p></div><div class="simplesect" title="Compatibility"><div class="titlepage"><div><div><h3 class="title"><a name="id36279647"></a>Compatibility</h3></div></div></div><p>GEOS, Proj4, and LibXML2 are now mandatory dependencies</p><p>The library versions below are the minimum requirements for PostGIS 1.5</p><p>PostgreSQL 8.3 and higher on all platforms</p><p>GEOS 3.1 and higher only (GEOS 3.2+ to take advantage of all features)</p><p>LibXML2 2.5+ related to new ST_GeomFromGML/KML functionality</p><p>Proj4 4.5 and higher only</p></div><div class="simplesect" title="New Features"><div class="titlepage"><div><div><h3 class="title"><a name="id36279675"></a>New Features</h3></div></div></div><p><a class="xref" href="#NewFunctions_1_5" title="8.9.1.PostGIS Functions new, behavior changed, or enhanced in 1.5">Section8.9.1, “PostGIS Functions new, behavior changed, or enhanced in 1.5”</a></p><p>Added Hausdorff distance calculations (#209) (Vincent Picavet)</p><p>Added parameters argument to ST_Buffer operation to support one-sided buffering and other buffering styles (Sandro Santilli)</p><p>Addition of other Distance related visualization and analysis functions (Nicklas Aven)</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>ST_ClosestPoint</p></li><li class="listitem"><p>ST_DFullyWithin</p></li><li class="listitem"><p>ST_LongestLine</p></li><li class="listitem"><p>ST_MaxDistance</p></li><li class="listitem"><p>ST_ShortestLine</p></li></ul></div><p>ST_DumpPoints (Maxime van Noppen)</p><p>KML, GML input via ST_GeomFromGML and ST_GeomFromKML (Olivier Courtin)</p><p>Extract homogeneous collection with ST_CollectionExtract (Paul Ramsey)</p><p>Add measure values to an existing linestring with ST_AddMeasure (Paul Ramsey)</p><p>History table implementation in utils (George Silva)</p><p>Geography type and supporting functions</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Spherical algorithms (Dave Skea)</p></li><li class="listitem"><p>Object/index implementation (Paul Ramsey)</p></li><li class="listitem"><p>Selectivity implementation (Mark Cave-Ayland)</p></li><li class="listitem"><p>Serializations to KML, GML and JSON (Olivier Courtin)</p></li><li class="listitem"><p>ST_Area, ST_Distance, ST_DWithin, ST_GeogFromText, ST_GeogFromWKB, ST_Intersects, ST_Covers, ST_Buffer (Paul Ramsey)</p></li></ul></div></div><div class="simplesect" title="Enhancements"><div class="titlepage"><div><div><h3 class="title"><a name="id36279776"></a>Enhancements</h3></div></div></div><p>Performance improvements to ST_Distance (Nicklas Aven)</p><p>Documentation updates and improvements (Regina Obe, Kevin Neufeld)</p><p>Testing and quality control (Regina Obe)</p><p>PostGIS 1.5 support PostgreSQL 8.5 trunk (Guillaume Lelarge)</p><p>Win32 support and improvement of core shp2pgsql-gui (Mark Cave-Ayland)</p><p>In place 'make check' support (Paul Ramsey)</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36279805"></a>Bug fixes</h3></div></div></div><p>http://trac.osgeo.org/postgis/query?status=closed&milestone=postgis+1.5.0&order=priority</p></div></div><div class="sect1" title="A.5.Release 1.4.0"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36279818"></a>A.5.Release 1.4.0</h2></div></div></div><p>Release date: 2009/07/24</p><p>This release provides performance enhancements, improved internal structures and testing, new features, and upgraded documentation.</p><div class="simplesect" title="API Stability"><div class="titlepage"><div><div><h3 class="title"><a name="id36279831"></a>API Stability</h3></div></div></div><p>As of the 1.4 release series, the public API of PostGIS will not change during minor releases.</p></div><div class="simplesect" title="Compatibility"><div class="titlepage"><div><div><h3 class="title"><a name="id36279841"></a>Compatibility</h3></div></div></div><p>The versions below are the *minimum* requirements for PostGIS 1.4</p><p>PostgreSQL 8.2 and higher on all platforms</p><p>GEOS 3.0 and higher only</p><p>PROJ4 4.5 and higher only</p></div><div class="simplesect" title="New Features"><div class="titlepage"><div><div><h3 class="title"><a name="id36279862"></a>New Features</h3></div></div></div><p>ST_Union() uses high-speed cascaded union when compiled against
GEOS 3.1+ (Paul Ramsey)</p><p>ST_ContainsProperly() requires GEOS 3.1+</p><p>ST_Intersects(), ST_Contains(), ST_Within() use high-speed cached prepared geometry against GEOS 3.1+ (Paul Ramsey)</p><p>Vastly improved documentation and reference manual (Regina Obe & Kevin Neufeld)</p><p>Figures and diagram examples in the reference manual (Kevin Neufeld)</p><p>ST_IsValidReason() returns readable explanations for validity failures (Paul Ramsey)</p><p>ST_GeoHash() returns a geohash.org signature for geometries (Paul Ramsey)</p><p>GTK+ multi-platform GUI for shape file loading (Paul Ramsey)</p><p>ST_LineCrossingDirection() returns crossing directions (Paul Ramsey)</p><p>ST_LocateBetweenElevations() returns sub-string based on Z-ordinate. (Paul Ramsey)</p><p>Geometry parser returns explicit error message about location of syntax errors (Mark Cave-Ayland)</p><p>ST_AsGeoJSON() return JSON formatted geometry (Olivier Courtin)</p><p>Populate_Geometry_Columns() -- automatically add records to geometry_columns for TABLES and VIEWS (Kevin Neufeld)</p><p>ST_MinimumBoundingCircle() -- returns the smallest circle polygon that can encompass a geometry (Bruce Rindahl)</p></div><div class="simplesect" title="Enhancements"><div class="titlepage"><div><div><h3 class="title"><a name="id36279924"></a>Enhancements</h3></div></div></div><p>Core geometry system moved into independent library, liblwgeom. (Mark Cave-Ayland)</p><p>New build system uses PostgreSQL "pgxs" build bootstrapper. (Mark Cave-Ayland)</p><p>Debugging framework formalized and simplified. (Mark Cave-Ayland)</p><p>All build-time #defines generated at configure time and placed in headers for easier cross-platform support (Mark Cave-Ayland)</p><p>Logging framework formalized and simplified (Mark Cave-Ayland)</p><p>Expanded and more stable support for CIRCULARSTRING, COMPOUNDCURVE and CURVEPOLYGON, better parsing, wider support in functions (Mark Leslie & Mark Cave-Ayland)</p><p>Improved support for OpenSolaris builds (Paul Ramsey)</p><p>Improved support for MSVC builds (Mateusz Loskot)</p><p>Updated KML support (Olivier Courtin)</p><p>Unit testing framework for liblwgeom (Paul Ramsey)</p><p>New testing framework to comprehensively exercise every PostGIS function (Regine Obe)</p><p>Performance improvements to all geometry aggregate functions (Paul Ramsey)</p><p>Support for the upcoming PostgreSQL 8.4 (Mark Cave-Ayland, Talha Bin Rizwan)</p><p>Shp2pgsql and pgsql2shp re-worked to depend on the common parsing/unparsing code in liblwgeom (Mark Cave-Ayland)</p><p>Use of PDF DbLatex to build PDF docs and preliminary instructions for build (Jean David Techer)</p><p>Automated User documentation build (PDF and HTML) and Developer Doxygen Documentation (Kevin Neufeld)</p><p>Automated build of document images using ImageMagick from WKT geometry text files (Kevin Neufeld)</p><p>More attractive CSS for HTML documentation (Dane Springmeyer)</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280004"></a>Bug fixes</h3></div></div></div><p>http://trac.osgeo.org/postgis/query?status=closed&milestone=postgis+1.4.0&order=priority</p></div></div><div class="sect1" title="A.6.Release 1.3.6"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280015"></a>A.6.Release 1.3.6</h2></div></div></div><p>Release date: 2009/05/04</p><p>This release adds support for PostgreSQL 8.4, exporting
prj files from the database with shape data, some crash fixes for shp2pgsql, and several small
bug fixes in the handling of "curve" types, logical error importing dbf only files, improved error handling of AddGeometryColumns.</p></div><div class="sect1" title="A.7.Release 1.3.5"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280031"></a>A.7.Release 1.3.5</h2></div></div></div><p>Release date: 2008/12/15</p><p>This release is a bug fix release to address a failure
in ST_Force_Collection and related functions that critically
affects using Mapserver with LINE layers.</p></div><div class="sect1" title="A.8.Release 1.3.4"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280046"></a>A.8.Release 1.3.4</h2></div></div></div><p>Release date: 2008/11/24</p><p>This release adds support for GeoJSON output, building
with PostgreSQL 8.4, improves documentation quality and
output aesthetics, adds function-level SQL documentation,
and improves performance for some spatial predicates
(point-in-polygon tests).</p><p>Bug fixes include removal of crashers in handling
circular strings for many functions, some memory leaks
removed, a linear referencing failure for measures on vertices,
and more. See the NEWS file for details.</p></div><div class="sect1" title="A.9.Release 1.3.3"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280067"></a>A.9.Release 1.3.3</h2></div></div></div><p>Release date: 2008/04/12</p><p>This release fixes bugs shp2pgsql, adds enhancements to SVG and
KML support, adds a ST_SimplifyPreserveTopology function, makes the
build more sensitive to GEOS versions, and fixes a handful of severe but
rare failure cases.</p></div><div class="sect1" title="A.10.Release 1.3.2"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280082"></a>A.10.Release 1.3.2</h2></div></div></div><p>Release date: 2007/12/01</p><p>This release fixes bugs in ST_EndPoint() and ST_Envelope, improves
support for JDBC building and OS/X, and adds better support for GML
output with ST_AsGML(), including GML3 output.</p></div><div class="sect1" title="A.11.Release 1.3.1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280097"></a>A.11.Release 1.3.1</h2></div></div></div><p>Release date: 2007/08/13</p><p>This release fixes some oversights in the previous release around
version numbering, documentation, and tagging.</p></div><div class="sect1" title="A.12.Release 1.3.0"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280112"></a>A.12.Release 1.3.0</h2></div></div></div><p>Release date: 2007/08/09</p><p>This release provides performance enhancements to the relational
functions, adds new relational functions and begins the migration of our
function names to the SQL-MM convention, using the spatial type (SP)
prefix.</p><div class="simplesect" title="Added Functionality"><div class="titlepage"><div><div><h3 class="title"><a name="id36280126"></a>Added Functionality</h3></div></div></div><p>JDBC: Added Hibernate Dialect (thanks to Norman Barker)</p><p>Added ST_Covers and ST_CoveredBy relational functions.
Description and justification of these functions can be found at
http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html</p><p>Added ST_DWithin relational function.</p></div><div class="simplesect" title="Performance Enhancements"><div class="titlepage"><div><div><h3 class="title"><a name="id36280144"></a>Performance Enhancements</h3></div></div></div><p>Added cached and indexed point-in-polygon short-circuits for the
functions ST_Contains, ST_Intersects, ST_Within and ST_Disjoint</p><p>Added inline index support for relational functions (except
ST_Disjoint)</p></div><div class="simplesect" title="Other Changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280159"></a>Other Changes</h3></div></div></div><p>Extended curved geometry support into the geometry accessor and
some processing functions</p><p>Began migration of functions to the SQL-MM naming convention;
using a spatial type (ST) prefix.</p><p>Added initial support for PostgreSQL 8.3</p></div></div><div class="sect1" title="A.13.Release 1.2.1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280179"></a>A.13.Release 1.2.1</h2></div></div></div><p>Release date: 2007/01/11</p><p>This release provides bug fixes in PostgreSQL 8.2 support and some
small performance enhancements.</p><div class="simplesect" title="Changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280192"></a>Changes</h3></div></div></div><p>Fixed point-in-polygon shortcut bug in Within().</p><p>Fixed PostgreSQL 8.2 NULL handling for indexes.</p><p>Updated RPM spec files.</p><p>Added short-circuit for Transform() in no-op case.</p><p>JDBC: Fixed JTS handling for multi-dimensional geometries
(thanks to Thomas Marti for hint and partial patch). Additionally, now
JavaDoc is compiled and packaged. Fixed classpath problems with GCJ.
Fixed pgjdbc 8.2 compatibility, losing support for jdk 1.3 and
older.</p></div></div><div class="sect1" title="A.14.Release 1.2.0"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280220"></a>A.14.Release 1.2.0</h2></div></div></div><p>Release date: 2006/12/08</p><p>This release provides type definitions along with
serialization/deserialization capabilities for SQL-MM defined curved
geometries, as well as performance enhancements.</p><div class="simplesect" title="Changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280233"></a>Changes</h3></div></div></div><p>Added curved geometry type support for
serialization/deserialization</p><p>Added point-in-polygon shortcircuit to the Contains and Within
functions to improve performance for these cases.</p></div></div><div class="sect1" title="A.15.Release 1.1.6"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280249"></a>A.15.Release 1.1.6</h2></div></div></div><p>Release date: 2006/11/02</p><p>This is a bugfix release, in particular fixing a critical error
with GEOS interface in 64bit systems. Includes an updated of the SRS
parameters and an improvement in reprojections (take Z in
consideration). Upgrade is <span class="emphasis"><em>encouraged</em></span>.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36280267"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.3 or later follow the
<a class="link" href="#soft_upgrade" title="2.7.1.Soft upgrade">soft upgrade</a> procedure.</p><p>If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6
and 1.0.2</em></span> (inclusive) and really want a live upgrade read
the <a class="link" href="#rel_1.0.3_upgrading" title="A.25.Release 1.0.3">upgrade section</a> of the
1.0.3 release notes chapter.</p><p>Upgrade from any release prior to 1.0.0RC6 requires an <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard upgrade</a>.</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280310"></a>Bug fixes</h3></div></div></div><p>fixed CAPI change that broke 64-bit platforms</p><p>loader/dumper: fixed regression tests and usage output</p><p>Fixed setSRID() bug in JDBC, thanks to Thomas Marti</p></div><div class="simplesect" title="Other changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280328"></a>Other changes</h3></div></div></div><p>use Z ordinate in reprojections</p><p>spatial_ref_sys.sql updated to EPSG 6.11.1</p><p>Simplified Version.config infrastructure to use a single pack of
version variables for everything.</p><p>Include the Version.config in loader/dumper USAGE
messages</p><p>Replace hand-made, fragile JDBC version parser with
Properties</p></div></div><div class="sect1" title="A.16.Release 1.1.5"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280354"></a>A.16.Release 1.1.5</h2></div></div></div><p>Release date: 2006/10/13</p><p>This is an bugfix release, including a critical segfault on win32.
Upgrade is <span class="emphasis"><em>encouraged</em></span>.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36280370"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.3 or later follow the
<a class="link" href="#soft_upgrade" title="2.7.1.Soft upgrade">soft upgrade</a> procedure.</p><p>If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6
and 1.0.2</em></span> (inclusive) and really want a live upgrade read
the <a class="link" href="#rel_1.0.3_upgrading" title="A.25.Release 1.0.3">upgrade section</a> of the
1.0.3 release notes chapter.</p><p>Upgrade from any release prior to 1.0.0RC6 requires an <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard upgrade</a>.</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280411"></a>Bug fixes</h3></div></div></div><p>Fixed MingW link error that was causing pgsql2shp to segfault on
Win32 when compiled for PostgreSQL 8.2</p><p>fixed nullpointer Exception in Geometry.equals() method in
Java</p><p>Added EJB3Spatial.odt to fulfill the GPL requirement of
distributing the "preferred form of modification"</p><p>Removed obsolete synchronization from JDBC Jts code.</p><p>Updated heavily outdated README files for shp2pgsql/pgsql2shp by
merging them with the manpages.</p><p>Fixed version tag in jdbc code that still said "1.1.3" in the
"1.1.4" release.</p></div><div class="simplesect" title="New Features"><div class="titlepage"><div><div><h3 class="title"><a name="id36280442"></a>New Features</h3></div></div></div><p>Added -S option for non-multi geometries to shp2pgsql</p></div></div><div class="sect1" title="A.17.Release 1.1.4"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280453"></a>A.17.Release 1.1.4</h2></div></div></div><p>Release date: 2006/09/27</p><p>This is an bugfix release including some improvements in the Java
interface. Upgrade is <span class="emphasis"><em>encouraged</em></span>.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36280470"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.3 or later follow the
<a class="link" href="#soft_upgrade" title="2.7.1.Soft upgrade">soft upgrade</a> procedure.</p><p>If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6
and 1.0.2</em></span> (inclusive) and really want a live upgrade read
the <a class="link" href="#rel_1.0.3_upgrading" title="A.25.Release 1.0.3">upgrade section</a> of the
1.0.3 release notes chapter.</p><p>Upgrade from any release prior to 1.0.0RC6 requires an <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard upgrade</a>.</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280511"></a>Bug fixes</h3></div></div></div><p>Fixed support for PostgreSQL 8.2</p><p>Fixed bug in collect() function discarding SRID of input</p><p>Added SRID match check in MakeBox2d and MakeBox3d</p><p>Fixed regress tests to pass with GEOS-3.0.0</p><p>Improved pgsql2shp run concurrency.</p></div><div class="simplesect" title="Java changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280536"></a>Java changes</h3></div></div></div><p>reworked JTS support to reflect new upstream JTS developers'
attitude to SRID handling. Simplifies code and drops build depend on
GNU trove.</p><p>Added EJB2 support generously donated by the "Geodetix s.r.l.
Company" http://www.geodetix.it/</p><p>Added EJB3 tutorial / examples donated by Norman Barker
<nbarker@ittvis.com></p><p>Reorganized java directory layout a little.</p></div></div><div class="sect1" title="A.18.Release 1.1.3"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280560"></a>A.18.Release 1.1.3</h2></div></div></div><p>Release date: 2006/06/30</p><p>This is an bugfix release including also some new functionalities
(most notably long transaction support) and portability enhancements.
Upgrade is <span class="emphasis"><em>encouraged</em></span>.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36280577"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.3 or later follow the
<a class="link" href="#soft_upgrade" title="2.7.1.Soft upgrade">soft upgrade</a> procedure.</p><p>If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6
and 1.0.2</em></span> (inclusive) and really want a live upgrade read
the <a class="link" href="#rel_1.0.3_upgrading" title="A.25.Release 1.0.3">upgrade section</a> of the
1.0.3 release notes chapter.</p><p>Upgrade from any release prior to 1.0.0RC6 requires an <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard upgrade</a>.</p></div><div class="simplesect" title="Bug fixes / correctness"><div class="titlepage"><div><div><h3 class="title"><a name="id36280753"></a>Bug fixes / correctness</h3></div></div></div><p>BUGFIX in distance(poly,poly) giving wrong results.</p><p>BUGFIX in pgsql2shp successful return code.</p><p>BUGFIX in shp2pgsql handling of MultiLine WKT.</p><p>BUGFIX in affine() failing to update bounding box.</p><p>WKT parser: forbidden construction of multigeometries with EMPTY
elements (still supported for GEOMETRYCOLLECTION).</p></div><div class="simplesect" title="New functionalities"><div class="titlepage"><div><div><h3 class="title"><a name="id36280779"></a>New functionalities</h3></div></div></div><p>NEW Long Transactions support.</p><p>NEW DumpRings() function.</p><p>NEW AsHEXEWKB(geom, XDR|NDR) function.</p></div><div class="simplesect" title="JDBC changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280796"></a>JDBC changes</h3></div></div></div><p>Improved regression tests: MultiPoint and scientific
ordinates</p><p>Fixed some minor bugs in jdbc code</p><p>Added proper accessor functions for all fields in preparation of
making those fields private later</p></div><div class="simplesect" title="Other changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280814"></a>Other changes</h3></div></div></div><p>NEW regress test support for loader/dumper.</p><p>Added --with-proj-libdir and --with-geos-libdir configure
switches.</p><p>Support for build Tru64 build.</p><p>Use Jade for generating documentation.</p><p>Don't link pgsql2shp to more libs then required.</p><p>Initial support for PostgreSQL 8.2.</p></div></div><div class="sect1" title="A.19.Release 1.1.2"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280844"></a>A.19.Release 1.1.2</h2></div></div></div><p>Release date: 2006/03/30</p><p>This is an bugfix release including some new functions and
portability enhancements. Upgrade is
<span class="emphasis"><em>encouraged</em></span>.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36280860"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.3 or later follow the
<a class="link" href="#soft_upgrade" title="2.7.1.Soft upgrade">soft upgrade</a> procedure.</p><p>If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6
and 1.0.2</em></span> (inclusive) and really want a live upgrade read
the <a class="link" href="#rel_1.0.3_upgrading" title="A.25.Release 1.0.3">upgrade section</a> of the
1.0.3 release notes chapter.</p><p>Upgrade from any release prior to 1.0.0RC6 requires an <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard upgrade</a>.</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280901"></a>Bug fixes</h3></div></div></div><p>BUGFIX in SnapToGrid() computation of output bounding box</p><p>BUGFIX in EnforceRHR()</p><p>jdbc2 SRID handling fixes in JTS code</p><p>Fixed support for 64bit archs</p></div><div class="simplesect" title="New functionalities"><div class="titlepage"><div><div><h3 class="title"><a name="id36280922"></a>New functionalities</h3></div></div></div><p>Regress tests can now be run *before* postgis
installation</p><p>New affine() matrix transformation functions</p><p>New rotate{,X,Y,Z}() function</p><p>Old translating and scaling functions now use affine()
internally</p><p>Embedded access control in estimated_extent() for builds against
pgsql >= 8.0.0</p></div><div class="simplesect" title="Other changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36280949"></a>Other changes</h3></div></div></div><p>More portable ./configure script</p><p>Changed ./run_test script to have more sane default
behaviour</p></div></div><div class="sect1" title="A.20.Release 1.1.1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36280963"></a>A.20.Release 1.1.1</h2></div></div></div><p>Release date: 2006/01/23</p><p>This is an important Bugfix release, upgrade is <span class="emphasis"><em>highly
recommended</em></span>. Previous version contained a bug in
postgis_restore.pl preventing <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard
upgrade</a> procedure to complete and a bug in GEOS-2.2+ connector
preventing GeometryCollection objects to be used in topological
operations.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36280987"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.3 or later follow the
<a class="link" href="#soft_upgrade" title="2.7.1.Soft upgrade">soft upgrade</a> procedure.</p><p>If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6
and 1.0.2</em></span> (inclusive) and really want a live upgrade read
the <a class="link" href="#rel_1.0.3_upgrading" title="A.25.Release 1.0.3">upgrade section</a> of the
1.0.3 release notes chapter.</p><p>Upgrade from any release prior to 1.0.0RC6 requires an <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard upgrade</a>.</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281028"></a>Bug fixes</h3></div></div></div><p>Fixed a premature exit in postgis_restore.pl</p><p>BUGFIX in geometrycollection handling of GEOS-CAPI
connector</p><p>Solaris 2.7 and MingW support improvements</p><p>BUGFIX in line_locate_point()</p><p>Fixed handling of postgresql paths</p><p>BUGFIX in line_substring()</p><p>Added support for localized cluster in regress tester</p></div><div class="simplesect" title="New functionalities"><div class="titlepage"><div><div><h3 class="title"><a name="id36281060"></a>New functionalities</h3></div></div></div><p>New Z and M interpolation in line_substring()</p><p>New Z and M interpolation in line_interpolate_point()</p><p>added NumInteriorRing() alias due to OpenGIS ambiguity</p></div></div><div class="sect1" title="A.21.Release 1.1.0"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36281079"></a>A.21.Release 1.1.0</h2></div></div></div><p>Release date: 2005/12/21</p><p>This is a Minor release, containing many improvements and new
things. Most notably: build procedure greatly simplified; transform()
performance drastically improved; more stable GEOS connectivity (CAPI
support); lots of new functions; draft topology support.</p><p>It is <span class="emphasis"><em>highly recommended</em></span> that you upgrade to
GEOS-2.2.x before installing PostGIS, this will ensure future GEOS
upgrades won't require a rebuild of the PostGIS library.</p><div class="simplesect" title="Credits"><div class="titlepage"><div><div><h3 class="title"><a name="id36281102"></a>Credits</h3></div></div></div><p>This release includes code from Mark Cave Ayland for caching of
proj4 objects. Markus Schaber added many improvements in his JDBC2
code. Alex Bodnaru helped with PostgreSQL source dependency relief and
provided Debian specfiles. Michael Fuhr tested new things on Solaris
arch. David Techer and Gerald Fenoy helped testing GEOS C-API
connector. Hartmut Tschauner provided code for the azimuth() function.
Devrim GUNDUZ provided RPM specfiles. Carl Anderson helped with the
new area building functions. See the <a class="link" href="#credits" title="1.2.Contributors Past and Present">credits</a> section for more names.</p></div><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36281124"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.3 or later you
<span class="emphasis"><em>DO NOT</em></span> need a dump/reload. Simply sourcing the
new lwpostgis_upgrade.sql script in all your existing databases will
work. See the <a class="link" href="#soft_upgrade" title="2.7.1.Soft upgrade">soft upgrade</a> chapter
for more information.</p><p>If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6
and 1.0.2</em></span> (inclusive) and really want a live upgrade read
the <a class="link" href="#rel_1.0.3_upgrading" title="A.25.Release 1.0.3">upgrade section</a> of the
1.0.3 release notes chapter.</p><p>Upgrade from any release prior to 1.0.0RC6 requires an <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard upgrade</a>.</p></div><div class="simplesect" title="New functions"><div class="titlepage"><div><div><h3 class="title"><a name="id36281169"></a>New functions</h3></div></div></div><p>scale() and transscale() companion methods to translate()</p><p>line_substring()</p><p>line_locate_point()</p><p>M(point)</p><p>LineMerge(geometry)</p><p>shift_longitude(geometry)</p><p>azimuth(geometry)</p><p>locate_along_measure(geometry, float8)</p><p>locate_between_measures(geometry, float8, float8)</p><p>SnapToGrid by point offset (up to 4d support)</p><p>BuildArea(any_geometry)</p><p>OGC BdPolyFromText(linestring_wkt, srid)</p><p>OGC BdMPolyFromText(linestring_wkt, srid)</p><p>RemovePoint(linestring, offset)</p><p>ReplacePoint(linestring, offset, point)</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281229"></a>Bug fixes</h3></div></div></div><p>Fixed memory leak in polygonize()</p><p>Fixed bug in lwgeom_as_anytype cast functions</p><p>Fixed USE_GEOS, USE_PROJ and USE_STATS elements of
postgis_version() output to always reflect library state.</p></div><div class="simplesect" title="Function semantic changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281247"></a>Function semantic changes</h3></div></div></div><p>SnapToGrid doesn't discard higher dimensions</p><p>Changed Z() function to return NULL if requested dimension is
not available</p></div><div class="simplesect" title="Performance improvements"><div class="titlepage"><div><div><h3 class="title"><a name="id36281261"></a>Performance improvements</h3></div></div></div><p>Much faster transform() function, caching proj4 objects</p><p>Removed automatic call to fix_geometry_columns() in
AddGeometryColumns() and update_geometry_stats()</p></div><div class="simplesect" title="JDBC2 works"><div class="titlepage"><div><div><h3 class="title"><a name="id36281276"></a>JDBC2 works</h3></div></div></div><p>Makefile improvements</p><p>JTS support improvements</p><p>Improved regression test system</p><p>Basic consistency check method for geometry collections</p><p>Support for (Hex)(E)wkb</p><p>Autoprobing DriverWrapper for HexWKB / EWKT switching</p><p>fix compile problems in ValueSetter for ancient jdk
releases.</p><p>fix EWKT constructors to accept SRID=4711; representation</p><p>added preliminary read-only support for java2d geometries</p></div><div class="simplesect" title="Other new things"><div class="titlepage"><div><div><h3 class="title"><a name="id36281315"></a>Other new things</h3></div></div></div><p>Full autoconf-based configuration, with PostgreSQL source
dependency relief</p><p>GEOS C-API support (2.2.0 and higher)</p><p>Initial support for topology modelling</p><p>Debian and RPM specfiles</p><p>New lwpostgis_upgrade.sql script</p></div><div class="simplesect" title="Other changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281340"></a>Other changes</h3></div></div></div><p>JTS support improvements</p><p>Stricter mapping between DBF and SQL integer and string
attributes</p><p>Wider and cleaner regression test suite</p><p>old jdbc code removed from release</p><p>obsoleted direct use of postgis_proc_upgrade.pl</p><p>scripts version unified with release version</p></div></div><div class="sect1" title="A.22.Release 1.0.6"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36281369"></a>A.22.Release 1.0.6</h2></div></div></div><p>Release date: 2005/12/06</p><p>Contains a few bug fixes and improvements.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36281382"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.3 or later you
<span class="emphasis"><em>DO NOT</em></span> need a dump/reload.</p><p>If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6
and 1.0.2</em></span> (inclusive) and really want a live upgrade read
the <a class="link" href="#rel_1.0.3_upgrading" title="A.25.Release 1.0.3">upgrade section</a> of the
1.0.3 release notes chapter.</p><p>Upgrade from any release prior to 1.0.0RC6 requires an <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard upgrade</a>.</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281420"></a>Bug fixes</h3></div></div></div><p>Fixed palloc(0) call in collection deserializer (only gives
problem with --enable-cassert)</p><p>Fixed bbox cache handling bugs</p><p>Fixed geom_accum(NULL, NULL) segfault</p><p>Fixed segfault in addPoint()</p><p>Fixed short-allocation in lwcollection_clone()</p><p>Fixed bug in segmentize()</p><p>Fixed bbox computation of SnapToGrid output</p></div><div class="simplesect" title="Improvements"><div class="titlepage"><div><div><h3 class="title"><a name="id36281452"></a>Improvements</h3></div></div></div><p>Initial support for postgresql 8.2</p><p>Added missing SRID mismatch checks in GEOS ops</p></div></div><div class="sect1" title="A.23.Release 1.0.5"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36281467"></a>A.23.Release 1.0.5</h2></div></div></div><p>Release date: 2005/11/25</p><p>Contains memory-alignment fixes in the library, a segfault fix in
loader's handling of UTF8 attributes and a few improvements and
cleanups.</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"></th></tr><tr><td align="left" valign="top"><p>Return code of shp2pgsql changed from previous releases to
conform to unix standards (return 0 on success).</p></td></tr></table></div><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36281488"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.3 or later you
<span class="emphasis"><em>DO NOT</em></span> need a dump/reload.</p><p>If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6
and 1.0.2</em></span> (inclusive) and really want a live upgrade read
the <a class="link" href="#rel_1.0.3_upgrading" title="A.25.Release 1.0.3">upgrade section</a> of the
1.0.3 release notes chapter.</p><p>Upgrade from any release prior to 1.0.0RC6 requires an <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard upgrade</a>.</p></div><div class="simplesect" title="Library changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281526"></a>Library changes</h3></div></div></div><p>Fixed memory alignment problems</p><p>Fixed computation of null values fraction in analyzer</p><p>Fixed a small bug in the getPoint4d_p() low-level
function</p><p>Speedup of serializer functions</p><p>Fixed a bug in force_3dm(), force_3dz() and force_4d()</p></div><div class="simplesect" title="Loader changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281551"></a>Loader changes</h3></div></div></div><p>Fixed return code of shp2pgsql</p><p>Fixed back-compatibility issue in loader (load of null
shapefiles)</p><p>Fixed handling of trailing dots in dbf numerical
attributes</p><p>Segfault fix in shp2pgsql (utf8 encoding)</p></div><div class="simplesect" title="Other changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281572"></a>Other changes</h3></div></div></div><p>Schema aware postgis_proc_upgrade.pl, support for pgsql
7.2+</p><p>New "Reporting Bugs" chapter in manual</p></div></div><div class="sect1" title="A.24.Release 1.0.4"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36281587"></a>A.24.Release 1.0.4</h2></div></div></div><p>Release date: 2005/09/09</p><p>Contains important bug fixes and a few improvements. In
particular, it fixes a memory leak preventing successful build of GiST
indexes for large spatial tables.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36281601"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.3 you <span class="emphasis"><em>DO
NOT</em></span> need a dump/reload.</p><p>If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6
and 1.0.2</em></span> (inclusive) and really want a live upgrade read
the <a class="link" href="#rel_1.0.3_upgrading" title="A.25.Release 1.0.3">upgrade section</a> of the
1.0.3 release notes chapter.</p><p>Upgrade from any release prior to 1.0.0RC6 requires an <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard upgrade</a>.</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281639"></a>Bug fixes</h3></div></div></div><p>Memory leak plugged in GiST indexing</p><p>Segfault fix in transform() handling of proj4 errors</p><p>Fixed some proj4 texts in spatial_ref_sys (missing +proj)</p><p>Loader: fixed string functions usage, reworked NULL objects
check, fixed segfault on MULTILINESTRING input.</p><p>Fixed bug in MakeLine dimension handling</p><p>Fixed bug in translate() corrupting output bounding box</p></div><div class="simplesect" title="Improvements"><div class="titlepage"><div><div><h3 class="title"><a name="id36281668"></a>Improvements</h3></div></div></div><p>Documentation improvements</p><p>More robust selectivity estimator</p><p>Minor speedup in distance()</p><p>Minor cleanups</p><p>GiST indexing cleanup</p><p>Looser syntax acceptance in box3d parser</p></div></div><div class="sect1" title="A.25.Release 1.0.3"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="rel_1.0.3_upgrading"></a>A.25.Release 1.0.3</h2></div></div></div><p>Release date: 2005/08/08</p><p>Contains some bug fixes - <span class="emphasis"><em>including a severe one
affecting correctness of stored geometries</em></span> - and a few
improvements.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36281716"></a>Upgrading</h3></div></div></div><p>Due to a bug in a bounding box computation routine, the upgrade
procedure requires special attention, as bounding boxes cached in the
database could be incorrect.</p><p>An <a class="link" href="#hard_upgrade" title="2.7.2.Hard upgrade">hard upgrade</a> procedure
(dump/reload) will force recomputation of all bounding boxes (not
included in dumps). This is <span class="emphasis"><em>required</em></span> if upgrading
from releases prior to 1.0.0RC6.</p><p>If you are upgrading from versions 1.0.0RC6 or up, this release
includes a perl script (utils/rebuild_bbox_caches.pl) to force
recomputation of geometries' bounding boxes and invoke all operations
required to propagate eventual changes in them (geometry statistics
update, reindexing). Invoke the script after a make install (run with
no args for syntax help). Optionally run utils/postgis_proc_upgrade.pl
to refresh postgis procedures and functions signatures (see <a class="link" href="#soft_upgrade" title="2.7.1.Soft upgrade">Soft upgrade</a>).</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281756"></a>Bug fixes</h3></div></div></div><p>Severe bugfix in lwgeom's 2d bounding box computation</p><p>Bugfix in WKT (-w) POINT handling in loader</p><p>Bugfix in dumper on 64bit machines</p><p>Bugfix in dumper handling of user-defined queries</p><p>Bugfix in create_undef.pl script</p></div><div class="simplesect" title="Improvements"><div class="titlepage"><div><div><h3 class="title"><a name="id36281780"></a>Improvements</h3></div></div></div><p>Small performance improvement in canonical input function</p><p>Minor cleanups in loader</p><p>Support for multibyte field names in loader</p><p>Improvement in the postgis_restore.pl script</p><p>New rebuild_bbox_caches.pl util script</p></div></div><div class="sect1" title="A.26.Release 1.0.2"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36281806"></a>A.26.Release 1.0.2</h2></div></div></div><p>Release date: 2005/07/04</p><p>Contains a few bug fixes and improvements.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36281819"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.0RC6 or up you
<span class="emphasis"><em>DO NOT</em></span> need a dump/reload.</p><p>Upgrading from older releases requires a dump/reload. See the
<a class="link" href="#upgrading" title="2.7.Upgrading">upgrading</a> chapter for more
informations.</p></div><div class="simplesect" title="Bug fixes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281843"></a>Bug fixes</h3></div></div></div><p>Fault tolerant btree ops</p><p>Memory leak plugged in pg_error</p><p>Rtree index fix</p><p>Cleaner build scripts (avoided mix of CFLAGS and
CXXFLAGS)</p></div><div class="simplesect" title="Improvements"><div class="titlepage"><div><div><h3 class="title"><a name="id36281864"></a>Improvements</h3></div></div></div><p>New index creation capabilities in loader (-I switch)</p><p>Initial support for postgresql 8.1dev</p></div></div><div class="sect1" title="A.27.Release 1.0.1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36281878"></a>A.27.Release 1.0.1</h2></div></div></div><p>Release date: 2005/05/24</p><p>Contains a few bug fixes and some improvements.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36281891"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.0RC6 or up you
<span class="emphasis"><em>DO NOT</em></span> need a dump/reload.</p><p>Upgrading from older releases requires a dump/reload. See the
<a class="link" href="#upgrading" title="2.7.Upgrading">upgrading</a> chapter for more
informations.</p></div><div class="simplesect" title="Library changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36281915"></a>Library changes</h3></div></div></div><p>BUGFIX in 3d computation of length_spheroid()</p><p>BUGFIX in join selectivity estimator</p></div><div class="simplesect" title="Other changes/additions"><div class="titlepage"><div><div><h3 class="title"><a name="id36281929"></a>Other changes/additions</h3></div></div></div><p>BUGFIX in shp2pgsql escape functions</p><p>better support for concurrent postgis in multiple schemas</p><p>documentation fixes</p><p>jdbc2: compile with "-target 1.2 -source 1.2" by default</p><p>NEW -k switch for pgsql2shp</p><p>NEW support for custom createdb options in
postgis_restore.pl</p><p>BUGFIX in pgsql2shp attribute names unicity enforcement</p><p>BUGFIX in Paris projections definitions</p><p>postgis_restore.pl cleanups</p></div></div><div class="sect1" title="A.28.Release 1.0.0"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36281969"></a>A.28.Release 1.0.0</h2></div></div></div><p>Release date: 2005/04/19</p><p>Final 1.0.0 release. Contains a few bug fixes, some improvements
in the loader (most notably support for older postgis versions), and
more docs.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36281983"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.0RC6 you <span class="emphasis"><em>DO
NOT</em></span> need a dump/reload.</p><p>Upgrading from any other precedent release requires a
dump/reload. See the <a class="link" href="#upgrading" title="2.7.Upgrading">upgrading</a>
chapter for more informations.</p></div><div class="simplesect" title="Library changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282007"></a>Library changes</h3></div></div></div><p>BUGFIX in transform() releasing random memory address</p><p>BUGFIX in force_3dm() allocating less memory then
required</p><p>BUGFIX in join selectivity estimator (defaults, leaks,
tuplecount, sd)</p></div><div class="simplesect" title="Other changes/additions"><div class="titlepage"><div><div><h3 class="title"><a name="id36282025"></a>Other changes/additions</h3></div></div></div><p>BUGFIX in shp2pgsql escape of values starting with tab or
single-quote</p><p>NEW manual pages for loader/dumper</p><p>NEW shp2pgsql support for old (HWGEOM) postgis versions</p><p>NEW -p (prepare) flag for shp2pgsql</p><p>NEW manual chapter about OGC compliancy enforcement</p><p>NEW autoconf support for JTS lib</p><p>BUGFIX in estimator testers (support for LWGEOM and schema
parsing)</p></div></div><div class="sect1" title="A.29.Release 1.0.0RC6"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36282059"></a>A.29.Release 1.0.0RC6</h2></div></div></div><p>Release date: 2005/03/30</p><p>Sixth release candidate for 1.0.0. Contains a few bug fixes and
cleanups.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36282072"></a>Upgrading</h3></div></div></div><p>You need a dump/reload to upgrade from precedent releases. See
the <a class="link" href="#upgrading" title="2.7.Upgrading">upgrading</a> chapter for more
informations.</p></div><div class="simplesect" title="Library changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282089"></a>Library changes</h3></div></div></div><p>BUGFIX in multi()</p><p>early return [when noop] from multi()</p></div><div class="simplesect" title="Scripts changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282102"></a>Scripts changes</h3></div></div></div><p>dropped {x,y}{min,max}(box2d) functions</p></div><div class="simplesect" title="Other changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282112"></a>Other changes</h3></div></div></div><p>BUGFIX in postgis_restore.pl scrip</p><p>BUGFIX in dumper's 64bit support</p></div></div><div class="sect1" title="A.30.Release 1.0.0RC5"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36282127"></a>A.30.Release 1.0.0RC5</h2></div></div></div><p>Release date: 2005/03/25</p><p>Fifth release candidate for 1.0.0. Contains a few bug fixes and a
improvements.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36282140"></a>Upgrading</h3></div></div></div><p>If you are upgrading from release 1.0.0RC4 you <span class="emphasis"><em>DO
NOT</em></span> need a dump/reload.</p><p>Upgrading from any other precedent release requires a
dump/reload. See the <a class="link" href="#upgrading" title="2.7.Upgrading">upgrading</a>
chapter for more informations.</p></div><div class="simplesect" title="Library changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282165"></a>Library changes</h3></div></div></div><p>BUGFIX (segfaulting) in box3d computation (yes,
another!).</p><p>BUGFIX (segfaulting) in estimated_extent().</p></div><div class="simplesect" title="Other changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282179"></a>Other changes</h3></div></div></div><p>Small build scripts and utilities refinements.</p><p>Additional performance tips documented.</p></div></div><div class="sect1" title="A.31.Release 1.0.0RC4"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36282193"></a>A.31.Release 1.0.0RC4</h2></div></div></div><p>Release date: 2005/03/18</p><p>Fourth release candidate for 1.0.0. Contains bug fixes and a few
improvements.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36282206"></a>Upgrading</h3></div></div></div><p>You need a dump/reload to upgrade from precedent releases. See
the <a class="link" href="#upgrading" title="2.7.Upgrading">upgrading</a> chapter for more
informations.</p></div><div class="simplesect" title="Library changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282223"></a>Library changes</h3></div></div></div><p>BUGFIX (segfaulting) in geom_accum().</p><p>BUGFIX in 64bit architectures support.</p><p>BUGFIX in box3d computation function with collections.</p><p>NEW subselects support in selectivity estimator.</p><p>Early return from force_collection.</p><p>Consistency check fix in SnapToGrid().</p><p>Box2d output changed back to 15 significant digits.</p></div><div class="simplesect" title="Scripts changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282256"></a>Scripts changes</h3></div></div></div><p>NEW distance_sphere() function.</p><p>Changed get_proj4_from_srid implementation to use PL/PGSQL
instead of SQL.</p></div><div class="simplesect" title="Other changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282270"></a>Other changes</h3></div></div></div><p>BUGFIX in loader and dumper handling of MultiLine shapes</p><p>BUGFIX in loader, skipping all but first hole of
polygons.</p><p>jdbc2: code cleanups, Makefile improvements</p><p>FLEX and YACC variables set *after* pgsql Makefile.global is
included and only if the pgsql *stripped* version evaluates to the
empty string</p><p>Added already generated parser in release</p><p>Build scripts refinements</p><p>improved version handling, central Version.config</p><p>improvements in postgis_restore.pl</p></div></div><div class="sect1" title="A.32.Release 1.0.0RC3"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36282307"></a>A.32.Release 1.0.0RC3</h2></div></div></div><p>Release date: 2005/02/24</p><p>Third release candidate for 1.0.0. Contains many bug fixes and
improvements.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36282320"></a>Upgrading</h3></div></div></div><p>You need a dump/reload to upgrade from precedent releases. See
the <a class="link" href="#upgrading" title="2.7.Upgrading">upgrading</a> chapter for more
informations.</p></div><div class="simplesect" title="Library changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282337"></a>Library changes</h3></div></div></div><p>BUGFIX in transform(): missing SRID, better error
handling.</p><p>BUGFIX in memory alignment handling</p><p>BUGFIX in force_collection() causing mapserver connector
failures on simple (single) geometry types.</p><p>BUGFIX in GeometryFromText() missing to add a bbox cache.</p><p>reduced precision of box2d output.</p><p>prefixed DEBUG macros with PGIS_ to avoid clash with pgsql
one</p><p>plugged a leak in GEOS2POSTGIS converter</p><p>Reduced memory usage by early releasing query-context palloced
one.</p></div><div class="simplesect" title="Scripts changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282374"></a>Scripts changes</h3></div></div></div><p>BUGFIX in 72 index bindings.</p><p>BUGFIX in probe_geometry_columns() to work with PG72 and support
multiple geometry columns in a single table</p><p>NEW bool::text cast</p><p>Some functions made IMMUTABLE from STABLE, for performance
improvement.</p></div><div class="simplesect" title="JDBC changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282396"></a>JDBC changes</h3></div></div></div><p>jdbc2: small patches, box2d/3d tests, revised docs and
license.</p><p>jdbc2: bug fix and testcase in for pgjdbc 8.0 type
autoregistration</p><p>jdbc2: Removed use of jdk1.4 only features to enable build with
older jdk releases.</p><p>jdbc2: Added support for building against pg72jdbc2.jar</p><p>jdbc2: updated and cleaned makefile</p><p>jdbc2: added BETA support for jts geometry classes</p><p>jdbc2: Skip known-to-fail tests against older PostGIS
servers.</p><p>jdbc2: Fixed handling of measured geometries in EWKT.</p></div><div class="simplesect" title="Other changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282433"></a>Other changes</h3></div></div></div><p>new performance tips chapter in manual</p><p>documentation updates: pgsql72 requirement, lwpostgis.sql</p><p>few changes in autoconf</p><p>BUILDDATE extraction made more portable</p><p>fixed spatial_ref_sys.sql to avoid vacuuming the whole
database.</p><p>spatial_ref_sys: changed Paris entries to match the ones
distributed with 0.x.</p></div></div><div class="sect1" title="A.33.Release 1.0.0RC2"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36282462"></a>A.33.Release 1.0.0RC2</h2></div></div></div><p>Release date: 2005/01/26</p><p>Second release candidate for 1.0.0 containing bug fixes and a few
improvements.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36282476"></a>Upgrading</h3></div></div></div><p>You need a dump/reload to upgrade from precedent releases. See
the <a class="link" href="#upgrading" title="2.7.Upgrading">upgrading</a> chapter for more
informations.</p></div><div class="simplesect" title="Library changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282492"></a>Library changes</h3></div></div></div><p>BUGFIX in pointarray box3d computation</p><p>BUGFIX in distance_spheroid definition</p><p>BUGFIX in transform() missing to update bbox cache</p><p>NEW jdbc driver (jdbc2)</p><p>GEOMETRYCOLLECTION(EMPTY) syntax support for backward
compatibility</p><p>Faster binary outputs</p><p>Stricter OGC WKB/WKT constructors</p></div><div class="simplesect" title="Scripts changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282524"></a>Scripts changes</h3></div></div></div><p>More correct STABLE, IMMUTABLE, STRICT uses in
lwpostgis.sql</p><p>stricter OGC WKB/WKT constructors</p></div><div class="simplesect" title="Other changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282538"></a>Other changes</h3></div></div></div><p>Faster and more robust loader (both i18n and not)</p><p>Initial autoconf script</p></div></div><div class="sect1" title="A.34.Release 1.0.0RC1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id36282553"></a>A.34.Release 1.0.0RC1</h2></div></div></div><p>Release date: 2005/01/13</p><p>This is the first candidate of a major postgis release, with
internal storage of postgis types redesigned to be smaller and faster on
indexed queries.</p><div class="simplesect" title="Upgrading"><div class="titlepage"><div><div><h3 class="title"><a name="id36282567"></a>Upgrading</h3></div></div></div><p>You need a dump/reload to upgrade from precedent releases. See
the <a class="link" href="#upgrading" title="2.7.Upgrading">upgrading</a> chapter for more
informations.</p></div><div class="simplesect" title="Changes"><div class="titlepage"><div><div><h3 class="title"><a name="id36282584"></a>Changes</h3></div></div></div><p>Faster canonical input parsing.</p><p>Lossless canonical output.</p><p>EWKB Canonical binary IO with PG>73.</p><p>Support for up to 4d coordinates, providing lossless
shapefile->postgis->shapefile conversion.</p><p>New function: UpdateGeometrySRID(), AsGML(), SnapToGrid(),
ForceRHR(), estimated_extent(), accum().</p><p>Vertical positioning indexed operators.</p><p>JOIN selectivity function.</p><p>More geometry constructors / editors.</p><p>PostGIS extension API.</p><p>UTF8 support in loader.</p></div></div></div></div></body></html>
|