I have CSV file like this-
ID,LABEL,X,Y,USER
4,PlatesPatches,2451,1178.86393659181,Rashmitha
4,PlatesPatches,1344.14795244386,772.945838837517,Rashmitha
4,PlatesPatches,1392.76089828269,772.945838837517,Rashmitha
4,PlatesPatches,1840,899.339498018494,Rashmitha
4,PlatesPatches,2450.09247027741,1052.47027741083,Rashmitha
5,SmallPatchesmosaicpavement,2451,1020.87186261559,Rashmitha
5,SmallPatchesmosaicpavement,2451,1057.33157199472,Rashmitha
5,SmallPatchesmosaicpavement,1815.69352708058,894.47820343461,Rashmitha
5,SmallPatchesmosaicpavement,1516.72391017173,809.405548216645,Rashmitha
5,SmallPatchesmosaicpavement,1908.05812417437,875.033025099075,Rashmitha
5,SmallPatchesmosaicpavement,2012.57595772787,896.908850726552,Rashmitha
6,LargePavingnaturalstoneslabs,2451,1295.53500660502,Rashmitha
6,LargePavingnaturalstoneslabs,2272.65521796565,1217.75429326288,Rashmitha
6,LargePavingnaturalstoneslabs,2211.88903566711,1174.00264200793,Rashmitha
6,LargePavingnaturalstoneslabs,2451,1176.43328929987,Rashmitha
7,SmallPatchesmosaicpavement,2228.9035667107,1181.29458388375,Rashmitha
7,SmallPatchesmosaicpavement,1575.05944517834,875.033025099075,Rashmitha
7,SmallPatchesmosaicpavement,1356.30118890357,775.376486129458,Rashmitha
7,SmallPatchesmosaicpavement,1387.89960369881,775.376486129458,Rashmitha
7,SmallPatchesmosaicpavement,1662.56274768824,884.755614266843,Rashmitha
7,SmallPatchesmosaicpavement,2451,1178.86393659181,Rashmitha
i have to convert it into shapefile. the points X and Y are the multipoints and they are polygons, we can only differentiate them by ID because single polygon has a single ID.
how do i convert it into shapefile?
What I have tried:
public void ConvertCSV2SHP(string strFilePath)
{
using (StreamReader sr = new StreamReader(strFilePath))
{
ShapeFiles SHP = new ShapeFiles();
ShapeField NewFld;
Vertice NewVert;
SHP.OpenShape(strFilePath.Substring(0, strFilePath.Length - 3) + "shp", eNew.shpCreate, eShapeType.shpPolygonM);
NewFld = SHP.ShapeFields.CreateField("ID", eFieldType.shpInteger);
NewFld = SHP.ShapeFields.CreateField("LABEL", eFieldType.shpText);
NewFld = SHP.ShapeFields.CreateField("X", eFieldType.shpDouble);
NewFld = SHP.ShapeFields.CreateField("Y", eFieldType.shpDouble);
NewFld = SHP.ShapeFields.CreateField("USER", eFieldType.shpDouble);
SHP.AppendFieldDefs();
while (!sr.EndOfStream)
{
string[] rows = sr.ReadLine().Split(',');
NewVert = SHP.Vertices.AddVertice(Convert.ToDouble(rows[2]), Convert.ToDouble(rows[3]));
for (int i = 0; i < rows.Length; i++)
{
SHP.ShapeFields[i + 1].set_Value(Convert.ToDouble(rows[i]));
}
SHP.CreateShape();
}
}
}
but when i tried this code error is coming "System.FormatException: 'Input string was not in a correct format.'"
what should i do?