IOHandlers.wkt – Well Known Text (geometry) plugin

New in version 1.0.

PySAL plugin for Well Known Text (geometry)

class pysal.core.IOHandlers.wkt.WKTReader(*args, **kwargs)[source]
Parameters:
  • Well-Known Text (Reads) –
  • a list of PySAL Polygon objects (Returns) –

Examples

Read in WKT-formatted file

>>> import pysal
>>> f = pysal.open(pysal.examples.get_path('stl_hom.wkt'), 'r')

Convert wkt to pysal polygons

>>> polys = f.read()

Check length

>>> len(polys)
78

Return centroid of polygon at index 1

>>> polys[1].centroid
(-91.19578469430738, 39.990883050220845)

Type dir(polys[1]) at the python interpreter to get a list of supported methods

FORMATS = ['wkt']
MODES = ['r']
by_row
cast(key, typ)

cast key as typ

check()

Prints the contents of the registry

close()[source]
flush()
get(n)

Seeks the file to n and returns n If .ids is set n should be an id, else, n should be an offset

getType(dataPath, mode, dataFormat=None)

Parse the dataPath and return the data type

ids
next()

A FileIO object is its own iterator, see StringIO

open()[source]
rIds
read(n=-1)

Read at most n objects, less if read hits EOF if size is negative or omitted read all objects until EOF returns None if EOF is reached before any objects.

seek(n)[source]
tell()

Return id (or offset) of next object

truncate(size=None)

Should be implemented by subclasses and redefine this doc string

write(obj)

Must be implemented by subclasses that support ‘w’ subclasses should increment .pos subclasses should also check if obj is an instance of type(list) and redefine this doc string