Hello,
I would like to know if there is a simple standard way to copy feature(s) from one layer (any type) to another layer (any type)?
thanks a lot.
jm
Hello,
I would like to know if there is a simple standard way to copy feature(s) from one layer (any type) to another layer (any type)?
thanks a lot.
jm
Hi Jean-marie,
The code should be get all features from source layer then loop the collection and add them to target layer.
Simply like this as below:
InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();
Collection<Feature> inMemoryFeatureLayerFeatures = inMemoryFeatureLayer.InternalFeatures;
ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer("YourFilePath");
Collection<Feature> shapeFileFeatureLayerFeatures = shapeFileFeatureLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
foreach (Feature feature in shapeFileFeatureLayerFeatures)
{
// Add feature to the other feature layer
}
Regards,
Don
Could be nice to have a thinkgeo standar function.
Hi Jean-marie,
If you need copy features to an InMemoryFeatureLayer, I think this code should looks better, but in fact we don’t have a standard function for that.
ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer(“YourFilePath”);
Collection<Feature> shapeFileFeatureLayerFeatures = shapeFileFeatureLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
Collection<FeatureSourceColumn> shapeFileFeatureLayerColumns = shapeFileFeatureLayer.FeatureSource.GetColumns();
InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer(shapeFileFeatureLayerColumns, shapeFileFeatureLayerFeatures);
Regards,
Don
Why should we open and close the from and to feature layers when using the code below?
Hi Jean-marie,
When you try to use some APIs operate featuresource you usually need to open current layer.
Regards,
Don