[gdal-dev] PCIDSK .pix feature attribute information not visible in geomatica.

shashishaw shashishaw at gmail.com
Tue Dec 28 04:23:51 EST 2010


Hi,
I am using the current trunk of GDAL/OGR 
version(v1.7.3, revision 21324) to convert a .shp file 
to .pix file. The steps used  are taken from 
the online tutorial and are as below.

1.  // Open the datasource.
    OGRDataSource* pSrc = OGRSFDriverRegistrar::Open("input.shp",FALSE);

2.  // Read the source layer.
    OGRLayer* pSrcLayer = pSrc->GetLayer(0);

3.  // Initialise the output driver.
    const char* pszDriverName = "PCIDSK";
    OGRSFDriver* pDriver = NULL;
    pDriver = OGRSFDriverRegistrar::GetRegistrar()
	 	 ->GetDriverByName(pszDriverName);

4.  // Test capability.
    int result = pDriver->TestCapability("CreateDataSource");

5.  // Create the data source.
    OGRDataSource* pDst = pDriver->CreateDataSource("out.pix", NULL );

6.  // Create the output layer.
    OGRLayer* pDstLayer = pDst->CreateLayer("out_layer",
       		   	                    pSrcLayer->GetSpatialRef(),
				            pSrcLayer->GetLayerDefn()->GetGeomType());

7.  // Create field definitions for output layer.
    for( int i = 0; i < pSrcLayer->GetLayerDefn()->GetFieldCount(); i++){
	 OGRFieldDefn dstFieldDefn(pSrcLayer->GetLayerDefn()->GetFieldDefn(i));
	
	 // Create the destination field.
	 OGRErr err = pDstLayer->CreateField(&dstFieldDefn);

    }
   
8.  // Read and set the features.
    pSrcLayer->ResetReading();
    OGRFeature* pSrcFeature = NULL;
    while( NULL != (pSrcFeature = pSrcLayer->GetNextFeature())){
        // Create the destination feature.
        OGRFeature* pDstFeature =
OGRFeature::CreateFeature(pDstLayer->GetLayerDefn());
        err = pDstFeature->SetFrom(pSrcFeature,FALSE);
        // Add the feature to the layer.
        err = pDstLayer->CreateFeature(pDstFeature);

        OGRFeature::DestroyFeature(pDstFeature);
        OGRFeature::DestroyFeature(pSrcFeature);
    }

9.  // Cleanup
    OGRDataSource::DestroyDataSource(pDst);
    OGRDataSource::DestroyDataSource(pSrc);

NOTE: Error handling has been ignored.

On viewing the .pix output file in PCI Geomatica(Focus), the geometry
is correctly displayed, however the attribute information(using the
Attribute
Manager) does not show any details(empty fields). The .pix when viewed in a 
text editor does show the attribute information that is present in the .shp
file. 

Lastly, when I read the generated output .pix file using the 
GDAL/OGR apis, I am able to correctly read the feature attribute
information.

Are there some additional steps to be performed in order to correctly set
the attributes for a given file so that they are displayed in PCI Geomatica.

Thanks,
Shashi.
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/PCIDSK-pix-feature-attribute-information-not-visible-in-geomatica-tp5871388p5871388.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list