I am trying to read a shapefile using EasyGIS with C#.
My code seems to work except for the last row were i call the GetRecord method.
The exception i get is:
System.ArgumentException: 'fieldIndex must be <= DBFRecordHeader.NumFields and >=0'
What am i doing wrong?
string path = System.IO.Directory.GetCurrentDirectory();
EGIS.ShapeFileLib.ShapeFile shapeFile = new EGIS.ShapeFileLib.ShapeFile();
shapeFile.LoadFromFile(path + "\\CD_VIC_06_imr.shp");
string[] record = shapeFile.GetRecords(shapeFile.RenderSettings.FieldIndex);
Thank you!
Hi @MattiasWesterberg ,
I would debug and verify through the breakpoints if the shapefile was able to read and load through the path.
Also, while in debug mode you might check if the
shapeFile.RenderSettings.FieldIndex
returns the desired value.
Cheers,
Manish
shapeFile.RenderSettings.FieldIndex is -1.
What could be the reason for that?
shapeFile.RenderSettings.FieldIndex is -1.
What could be the reason for that?
If no FieldName is set or FieldName is not in the DBF file Field index returns -1.
When you debug does the shapeFile contain any values, if not then you might want to check the path for the shapefile. You can try to to hard code the path to the shapefile and try if it is able to read that.
Cheers,
Manish
Thanks.
Do you know how i can get the coordinates?
How do i get the long and lat values?