| | 1 | [[TOC()]] |
| | 2 | = OGR Geometries = |
| | 3 | |
| | 4 | == Background == |
| | 5 | |
| | 6 | === What is OGR? === |
| | 7 | |
| | 8 | [http://www.gdal.org/ogr/ OGR] is an open source C++ library included in GDAL which allows for reading and writing from a variety of vector file formats. |
| | 9 | |
| | 10 | == OGR Geometry Objects == |
| | 11 | |
| | 12 | |
| | 13 | {{{ |
| | 14 | #!python |
| | 15 | >>> from django.contrib.gis.gdal import OGRGeometry, SpatialReference |
| | 16 | >>> wkt1 = 'POINT(5 23)' # can be initialized with WKT or HEX |
| | 17 | >>> pnt = OGRGeometry(wkt1) |
| | 18 | >>> print pnt |
| | 19 | POINT (5 23) |
| | 20 | >>> print pnt.srs |
| | 21 | None |
| | 22 | >>> pnt.srs = 'WGS84' # set the spatial reference |
| | 23 | >>> pnt.srs |
| | 24 | <django.contrib.gis.gdal.srs.SpatialReference object at 0xb60ab86c> |
| | 25 | >>> pnt.transform_to(SpatialReference('NAD27')) # transform the point to a NAD27 spatial reference |
| | 26 | >>> print pnt |
| | 27 | POINT (5.0 22.999999999997065) |
| | 28 | }}} |
| | 29 | |
| | 30 | |
| | 31 | |
| | 32 | |
| | 33 | |
| | 34 | |