Hi.<br><br>You must write data in the DBF. <br><br>Use DBFAddField and: DBFWriteStringAttribute, DBFWriteIntegerAttribute... to write values into fields.<br><br>For example you can write the x and y values (double values): <br>
<br>DBFAddField(hDBF, "X", FTDouble, 15, 15);<br>DBFAddField(hDBF, "Y", FTDouble, 15, 15);<br><br>for(int i=0;i<3;i++) {<br>  DBFWriteDoubleAttribute(hDBF, i, 0,X[i]);<br>  DBFWriteDoubleAttribute(hDBF, i, 1,Y[i]);<br>
}<br><br>Good luck!<br><br><br><div class="gmail_quote">2011/5/31  <span dir="ltr"><<a href="mailto:shapelib-request@lists.maptools.org">shapelib-request@lists.maptools.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Send Shapelib mailing list submissions to<br>
        <a href="mailto:shapelib@lists.maptools.org">shapelib@lists.maptools.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://lists.maptools.org/mailman/listinfo/shapelib" target="_blank">http://lists.maptools.org/mailman/listinfo/shapelib</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:shapelib-request@lists.maptools.org">shapelib-request@lists.maptools.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:shapelib-owner@lists.maptools.org">shapelib-owner@lists.maptools.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Shapelib digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. Point shp file is created with empty dbf. (Rakib Solaimani)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Tue, 31 May 2011 01:03:30 +0600<br>
From: Rakib Solaimani <<a href="mailto:rakib114@gmail.com">rakib114@gmail.com</a>><br>
Subject: [Shapelib] Point shp file is created with empty dbf.<br>
To: <a href="mailto:shapelib@lists.maptools.org">shapelib@lists.maptools.org</a><br>
Message-ID: <<a href="mailto:BANLkTinzpKCdF3jNrzPOS4r39Wu6OUuZ7g@mail.gmail.com">BANLkTinzpKCdF3jNrzPOS4r39Wu6OUuZ7g@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Hi,<br>
<br>
I am new to shapelib. I want to create a simple shp file. I want to draw<br>
point on specific latitude and longitude. I tried to execute the following<br>
code which I found by google research.<br>
I successfully create the shp file and viewed it by ShapeViewer but I found<br>
my dbf file empty. I am wondering if data in dbf file is created while<br>
creating new shp file or should it be created<br>
manually? If so how can I link shp and dbf file. Basically I want to apply<br>
some rule on dbf file. Can anyone help me please. Here I attach my sample<br>
code.<br>
<br>
<br>
 #include "stdafx.h"<br>
 #include <iostream<br>
 #include <cstdlib<br>
 #include "shapefil.h"<br>
 #include <string<br>
<br>
 using namespace std;<br>
<br>
 int _tmain(int argc, _TCHAR* argv[])<br>
 {<br>
     SHPHandle    hSHP;<br>
     DBFHandle    hDBF;<br>
     int        nShapeType, Vertices;<br>
     string  shape_name, Col1;<br>
     SHPObject    *psObject;<br>
<br>
     double X[3], Y[3];<br>
<br>
     X[0] = -130;<br>
     Y[0]= 54;<br>
<br>
     X[1] = -120;<br>
     Y[1]= 30;<br>
<br>
     X[2] = -100;<br>
     Y[2]= 10;<br>
<br>
     nShapeType = MultiPoint;<br>
     Vertices = 3;<br>
<br>
<br>
     hSHP = SHPCreate( "T:\\shapefolder\\test.shp",<br>
nShapeType);<br>
<br>
     hDBF = DBFCreate(T:\\shapefolder\\test.dbf);<br>
<br>
     psObject = SHPCreateSimpleObject( nShapeType, Vertices, X, Y, NULL);<br>
     SHPWriteObject( hSHP, -1, psObject );<br>
<br>
<br>
     DBFClose( hDBF );<br>
     SHPClose( hSHP );<br>
<br>
<br>
<br>
     return 0;<br>
 }<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.maptools.org/pipermail/shapelib/attachments/20110531/669da739/attachment-0001.htm" target="_blank">http://lists.maptools.org/pipermail/shapelib/attachments/20110531/669da739/attachment-0001.htm</a><br>

<br>
------------------------------<br>
<br>
_______________________________________________<br>
Shapelib mailing list<br>
<a href="mailto:Shapelib@lists.maptools.org">Shapelib@lists.maptools.org</a><br>
<a href="http://lists.maptools.org/mailman/listinfo/shapelib" target="_blank">http://lists.maptools.org/mailman/listinfo/shapelib</a><br>
<br>
<br>
End of Shapelib Digest, Vol 73, Issue 1<br>
***************************************<br>
</blockquote></div><br>