|
|
Hi I need a little help.
*When i run the following code i get 8000 rows instead og 4000
the output is:
Id, ProductType, Fido
null,null,1
1, Prod.name, 2
null,null,3
2, another, 4
How to avoid all the null lines?
Feature f = new Feature();
FeatureSet fs = new FeatureSet(f.FeatureType);
ProjectionInfo dest = default(ProjectionInfo);
dest = KnownCoordinateSystems.Geographic.World.WGS1984;
fs.Projection = dest;
int i = 0;
fs.DataTable.Columns.Add(new DataColumn("ID", typeof(int)));
fs.DataTable.Columns.Add(new DataColumn("ProductTypeName", typeof(string)));
foreach (var item in x)
{
DotSpatial.Topology.Point p = new DotSpatial.Topology.Point();
p.X = Convert.ToDouble(item.xLatWgs84, CultureInfo.InvariantCulture);
p.Y = Convert.ToDouble(item.yLonWgs84, CultureInfo.InvariantCulture);
DotSpatial.Data.IFeature currentFeature = fs.AddFeature(p);
fs.DataTable.Rows.Add(i,item.ProductTypeName);
i++;
}
fs.SaveAs("point.shp", true);
|
|
|
|
I believe it should suffice to replace line:
fs.DataTable.Rows.Add(i,item.ProductTypeName);
with:
currentFeature.DataRow["ID"] = i; currentFeature.DataRow["ProductTypeName"] = item.ProductTypeName;
|
|