ShapefileObject, ShapObject and atributes

Tim Schaub noreply at GEOCARTIC.COM
Tue Oct 3 17:44:17 EDT 2006


> How is possible to add in the new shapefile shape with 
> attributes in dbf file?!

I've always assumed that mapscript only created the shp part of a shapefile,
and that it was up to you to add attributes to the dbf as you were adding
shapes.  It would be good to get confirmation that mapscript indeed does not
handle dbf creation.

In Python, you can use something like the dbfwriter recipe on ASPN
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362715).

In PHP, use the the dbase functions (http://us2.php.net/dbase).

Maris Nartiss just left a comment on the ShapefileObj Class docs to the
effect that mapscript doesn't deal in dbf writing.  If this is indeed true,
I could contribute some examples of the above methods to the docs.

Tim

(Peteris, if I'm right about this, you need to create a new dbf file when
you create your new shapefile.  For each shape that you add, add a record to
the dbf with the shape's attribute values.  As long as the number of shapes
equals the number of records in the dbf, a shape will be associated with the
attributes added in the same order.)

> 
> TNX,
> Peteris.
> 
> 



More information about the mapserver-users mailing list