ThinkGeo.com    |     Documentation    |     Premium Support

Create Multiple Feature Types in ShapeFileFeatureLayer

Hi,
I create one ShapeFileFeatureLayer as ‘Polyline’.
ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Polyline, sDataPathName + “.shp”, dbfColumns);

Is it possible to create multiple feature types(Polyline and Polygon) in one ShapeFileFeatureLayer. If it is not possible, Is any other way to store Polyline and Polygon feature data as ‘shape file’.

Thanks,
Riyaz

Hi Riyas,

It’s not allow to save more than one shape types into one shapefile. There are 2 options for this:

  • Save the features to memory instead of file(InMemoryFeatureLayer and MapShapeLayer).
  • Save the features to database file (Sqlite database, MS Server database and Oracle database).

Hope it is helpful.

Thanks,
Peter

Hi Peter,
Got it.
One more thing, I am adding the features to shape file one by one. like

ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Polyline, sDataPathName + “.shp”, dbfColumns);
ShapeFileFeatureLayer fixedLayer = new ShapeFileFeatureLayer( sDataPathName + “.shp”);
fixedLayer.Open();
fixedLayer.FeatureSource.BeginTransaction();
fixedLayer.FeatureSource.AddFeature(ft);
fixedLayer.FeatureSource.CommitTransaction();
fixedLayer.Close();

Is any provision for adding all features at once by list?

Thanks,
Riyas

Hi Riyas,

I think you don’t need commit transaction for each feature.

fixedLayer.FeatureSource.BeginTransaction();
For(…) // loop here
{
fixedLayer.FeatureSource.AddFeature(ft);
}
fixedLayer.FeatureSource.CommitTransaction();

Regards,

Don