Skip to content

StringIO example a few more details #36

Open
@apiszcz

Description

@apiszcz

Similar to what is the manual page with a few more details.

from io import BytesIO as StringIO
import shapefile as sf

wb=sf.Writer(shapeType=sf.POINT)

wb.field('test','N',16,3)
wb.record(test=100)
wb.point(1.0,1.0)

wbshp=StringIO()
wbshx=StringIO()
wbdbf=StringIO()
wb.saveShp(wbshp)
wb.saveShx(wbshx)
wb.saveDbf(wbdbf)

with open('testdata.shp', 'wb') as f:
f.write(wbshp.getvalue())
with open('testdata.shx', 'wb') as f:
f.write(wbshx.getvalue())
with open('testdata.dbf', 'wb') as f:
f.write(wbdbf.getvalue())

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions