Previous topic


Next topic


This Page

JSON, output=<open file '<stdout>', mode 'w' at 0xbe>)

Writes a Layer object as GeoJSON. This method also accepts a Cursor.

output specifies what to write the JSON to, a file or some other output stream.

>>> import os
>>> from geoscript.layer import Layer
>>> from geoscript.geom import Point
>>> l = Layer()
>>> l.add([Point(1,2)])
>>> l.add([Point(3,4)])
>>> out = file(os.devnull, 'w')
>>> writeJSON(l, output=out)
>>> writeJSON(l.cursor('INTERSECTS(geom, POINT (1 2))'), output=out)

Reads a Layer from GML.

input is the GML to read specified as a str, file, or some other input stream.

ver specifies the gml version to encode. Supported versions include 2, 3,

>>> json = '{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[1,2]},"properties":{},"id":"fid"}]}'
>>> l = readJSON(json)
>>> l.count()