[FWTools] Python object serialization (pickle) of OGRGeometry
Jack L. Riley
Jack.Riley at noaa.gov
Mon Feb 12 13:07:43 EST 2007
Hello Frank et al,
I have a Python (v2.3.5-based) application which stores OGR feature
geometry objects (<OGRFeature>.GetGeometryRef().Clone()) in a dict. To
support pickling of these OGRGeometry instances (w/o spatial reference
system), I added the following __getstate__ and __setstate__ methods to
ogr.y:
def __getstate__(self):
return self.ExportToWkb()
def __setstate__(self, state):
result = CreateGeometryFromWkb(state)
self._o = result._o
self.thisown = result.thisown
result.thisown = 0
Note that a similar thing was done in Python Cartographic Library's
geometry.py--see trac changeset 411:
http://trac.gispython.org/projects/PCL/changeset/411
Might this be included in future releases of FWTools/ogr.py (read: would
this be wise, or am I overlooking something)?
Best regards,
Jack
More information about the FWTools
mailing list