Hi,
I have a functionality in which I am searching the data from the DB and then based on that filtered data I am creating a feature layer. But that feature layer is created in In Memory database. And then using SchemaBuilder I am creating a table in that database.
var schemaBuilder = new SchemaBuilder(m_Database);
var shapeDescription = new ShapeDescription(geometryType, spatialReference);
var featureClassDescription = new FeatureClassDescription(name, fields, shapeDescription);
schemaBuilder.Create(featureClassDescription);
var tableCreated = schemaBuilder.Build();
The spatial reference used in the Shape Description is taken from the Geometry of the data returned from the database.
After this I am inserting the data into that table. But then getting this error "Geometry cannot have Z values".
I am fetching the data using QueryDef since it involves multiple joins. When I am simply converting the geometry data from the database (which is of object type) to Geometry this issue is coming.
Shape = (Geometry)row["SHAPE"]
I tried one thing which is not to convert directly to Geometry type but to do this:
var wktWithoutZ = GeometryEngine.Instance.ExportToWKT(WktExportFlags.WktExportStripZs, geometry);
var mapSpatialReference = ArcGIS.Desktop.Mapping.MapView.Active?.Map?.SpatialReference;
return GeometryEngine.Instance
.ImportFromWKT(WktImportFlags.WktImportDefaults, wktWithoutZ, mapSpatialReference ?? SpatialReferenceBuilder.CreateSpatialReference(3006));
This is working fine.
But why the issue is coming if not using the above way?
@Wolf @GKmieliauskas @CharlesMacleod
Solved! Go to Solution.
Hi,
Add line after creating ShapeDescription:
shapeDescription.HasZ = true;
Your original geometry has Z value, but your created FeatureClass not.
Hi,
Add line after creating ShapeDescription:
shapeDescription.HasZ = true;
Your original geometry has Z value, but your created FeatureClass not.