[gdal-dev] Help on creating polygon shapefile
Limei Ran
lran at unc.edu
Fri Feb 8 19:35:32 EST 2008
Hi:
I am new in using OGR. I tried to create a polygon shapefile using the
following codes:
===============
.......
OGRPolygon *poG = new OGRPolygon();
printf ("Declared OGRPolygon.\n");
char mesg[256];
unsigned char *geom;
sprintf(mesg,
"POLYGON(%f,%f,%f,%f,%f,%f,%f,%f,%f,%f)\0",x1,y1,x2,y2,x3,y3,x4,y4,x1,y1);
geom = (unsigned char *) mesg;
printf("POLYGON: %s\n",geom);
printf ("Import Wkb.\n");
if ( poG->importFromWkb(geom,0) != OGRERR_NONE )
{
printf( "Importing a Wkb polygon failed.\n" );
exit( 1 );
}
.......
==============
But, poG->importFromWkb failed. Could you tell me what is wrong with
the codes? Is Wkb POLYGON wrong? I tried to find some sample codes
and could not find them? Should I use OGRPolygon::addRingDirectly
function instead?
Thanks,
Limei
More information about the gdal-dev
mailing list