[Shapelib] Adding new shape to shapefile

Vassilis Perantzakis vaspervnp at yahoo.gr
Wed Jun 4 01:22:58 PDT 2008


Hi,

First try not using the extensions. It is possible that the .shx file is not created. So instead of: 

IntPtr ptrSHPCreate = shpFile.SHPCreate(@"\SD-MMCard\TestParcelle\test.shp",
ShapeFile.ShapeFile.ShapeType.Point) 

Try:

IntPtr ptrSHPCreate = shpFile.SHPCreate(@"\SD-MMCard\TestParcelle\test",
ShapeFile.ShapeFile.ShapeType.Point)

The same I think goes for dbf file.

-----Original Message-----
From: shapelib-bounces at lists.maptools.org [mailto:shapelib-bounces at lists.maptools.org] On Behalf Of thecrashteam
Sent: Wednesday, June 04, 2008 11:04 AM
To: shapelib at lists.maptools.org
Subject: Re: [Shapelib] Adding new shape to shapefile


Hi Bram,

I've tested what you told me but it still not work. I have no error, but my
dbf and my shp are not created. I post my new code, so could you tell me if
I do (again ^^) something wrong ?

Thank you

Romain.


My code :

//création du dbf
IntPtr ptrDBFCreate =
shpFile.DBFCreate(@"\SD-MMCard\TestParcelle\test.dbf");

//création du shapefile
IntPtr ptrSHPCreate = shpFile.SHPCreate(@"\SD-MMCard\TestParcelle\test.shp",
ShapeFile.ShapeFile.ShapeType.Point);

//nouvelle colonne dans le dbf
shpFile.DBFAddField(ptrDBFCreate, @"\SD-MMCard\TestParcelle\test.dbf",
ShapeFile.ShapeFile.DBFFieldType.FTString, 255, 0);

//écriture de la valeur liée au futur shape
shpFile.DBFWriteStringAttribute(ptrDBFCreate,
shpFile.DBFGetRecordCount(ptrDBFCreate), 0, "to");

//création du point
double[] x = new double[1];
double[] y = new double[1];
double[] z = new double[1];
x[0] = 803606;
y[0] = 803606;
z[0] = 0;

IntPtr psObject =
shpFile.SHPCreateSimpleObject(ShapeFile.ShapeFile.ShapeType.Point, 1, x, y,
z);

//écriture du point dans le shape
shpFile.SHPWriteObject(ptrSHPCreate, -1, psObject);

//fermeture du dbf et du shapefile
shpFile.SHPClose(ptrSHPCreate);
shpFile.DBFClose(ptrDBFCreate);
-- 
View this message in context: http://www.nabble.com/Adding-new-shape-to-shapefile-tp17536792p17641274.html
Sent from the ShapeLib mailing list archive at Nabble.com.


_______________________________________________
Shapelib mailing list
Shapelib at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/shapelib





More information about the Shapelib mailing list