gis.geos.WKBWriter

class WKBWriter(dim=2) WKBWriter provides the most control over its output. By default it returns OGC-compliant WKB when its write method is called. However, it has properties that allow for the creation of EWKB, a superset of the WKB standard that includes additional information. See the WKBWriter.outdim documentation for more details about the dim argument. Changed in Django 1.10: The ability to pass the dim argument to the constructor was added. write(geom) Returns the WKB of the g

gis.geos.WKBWriter.byteorder

byteorder This property may be set to change the byte-order of the geometry representation. Byteorder Value Description 0 Big Endian (e.g., compatible with RISC systems) 1 Little Endian (e.g., compatible with x86 systems) Example: >>> from django.contrib.gis.geos import Point, WKBWriter >>> wkb_w = WKBWriter() >>> pnt = Point(1, 1) >>> wkb_w.write_hex(pnt) '0101000000000000000000F03F000000000000F03F' >>> wkb_w.byteorder = 0 '00000000013FF0000000

gis.geos.WKBWriter.outdim

outdim This property may be set to change the output dimension of the geometry representation. In other words, if you have a 3D geometry then set to 3 so that the Z value is included in the WKB. Outdim Value Description 2 The default, output 2D WKB. 3 Output 3D WKB. Example: >>> from django.contrib.gis.geos import Point, WKBWriter >>> wkb_w = WKBWriter() >>> wkb_w.outdim 2 >>> pnt = Point(1, 1, 1) >>> wkb_w.write_hex(pnt) # By default, no Z valu

gis.geos.WKBWriter.srid

srid Set this property with a boolean to indicate whether the SRID of the geometry should be included with the WKB representation. Example: >>> from django.contrib.gis.geos import Point, WKBWriter >>> wkb_w = WKBWriter() >>> pnt = Point(1, 1, srid=4326) >>> wkb_w.write_hex(pnt) # By default, no SRID included: '0101000000000000000000F03F000000000000F03F' >>> wkb_w.srid = True # Tell writer to include SRID >>> wkb_w.write_hex(pnt) '01010000

gis.geos.WKBWriter.write()

write(geom) Returns the WKB of the given geometry as a Python buffer object. Example: >>> from django.contrib.gis.geos import Point, WKBWriter >>> pnt = Point(1, 1) >>> wkb_w = WKBWriter() >>> wkb_w.write(pnt) <read-only buffer for 0x103a898f0, size -1, offset 0 at 0x103a89930>

gis.geos.WKBWriter.write_hex()

write_hex(geom) Returns WKB of the geometry in hexadecimal. Example: >>> from django.contrib.gis.geos import Point, WKBWriter >>> pnt = Point(1, 1) >>> wkb_w = WKBWriter() >>> wkb_w.write_hex(pnt) '0101000000000000000000F03F000000000000F03F'

gis.geos.WKTReader

class WKTReader Example: >>> from django.contrib.gis.geos import WKTReader >>> wkt_r = WKTReader() >>> wkt_r.read('POINT(1 1)') <Point object at 0x103a88b50>

gis.geos.WKTWriter

class WKTWriter(dim=2, trim=False, precision=None) This class allows outputting the WKT representation of a geometry. See the WKBWriter.outdim, trim, and precision attributes for details about the constructor arguments. Changed in Django 1.10: The ability to pass the dim, trim, and precision arguments to the constructor was added. write(geom) Returns the WKT of the given geometry. Example: >>> from django.contrib.gis.geos import Point, WKTWriter >>> pnt = Point(1, 1)

gis.geos.WKTWriter.outdim

outdim See WKBWriter.outdim.

gis.geos.WKTWriter.precision

precision New in Django 1.10. This property controls the rounding precision of coordinates; if set to None rounding is disabled. >>> from django.contrib.gis.geos import Point, WKTWriter >>> pnt = Point(1.44, 1.66) >>> wkt_w = WKTWriter() >>> print(wkt_w.precision) None >>> wkt_w.write(pnt) 'POINT (1.4399999999999999 1.6599999999999999)' >>> wkt_w.precision = 0 >>> wkt_w.write(pnt) 'POINT (1 2)' >>> wkt_w.precision = 1