bilaldursun1 / nettopologysuite

Automatically exported from code.google.com/p/nettopologysuite
0 stars 0 forks source link

Number of shapes does not match the number of table records #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I get this error when I try opening the generated shape file

For example

When running the following function (which is actually provided by NTS):

public void TestWriteSimpleShapeFile()
        {
            IPoint p1 = Factory.CreatePoint(new Coordinate(100, 100));
            IPoint p2 = Factory.CreatePoint(new Coordinate(200, 200));

            GeometryCollection coll = new GeometryCollection(new 
IGeometry[] { p1, p2, });
            ShapefileWriter writer = new ShapefileWriter(Factory);
            writer.Write(@"c:\test_arcview", coll);

            ShapefileWriter.WriteDummyDbf(@"c:\test_arcview.dbf", 2);

            --> // Not read by ArcView!!! <-- seems you already noticed 
this error!
        }

I get the following error in ArcView:

---------------------------
Open Failed
---------------------------
Error opening feature class
Number of shapes does not match the number of table records
Number of shapes does not match the number of table records
---------------------------
OK   
---------------------------

Original issue reported on code.google.com by aldurg...@gmail.com on 17 May 2010 at 9:40

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
shapefile read/write are an unsupported feature of NTS, and for my tests all 
shapefiles 
are read by gvsig or qgis. 
I know that ArcMap/ArcView are unable toread those kind of files, but I don't 
have any 
way to test it, sorry :(
Try to import that data in gvsig, and then save as a new shapefile, so we could 
check 
if arcview reads the newly saved shapefile. 
Than, if this happens, I cound try to check differences between binaries.

Original comment by diegogu...@gmail.com on 25 May 2010 at 6:41

GoogleCodeExporter commented 9 years ago
Error opening feature class
Number of shapes does not match the number of table records
Number of shapes does not match the number of table records

I had this very same error when trying to reopen a .shp I created myself after
digitising a huge geology map. I have eventually managed to solve it after using
various shapefile fix programs which were unsuccessful.

Here was the solution however;

I downloaded FWTools and installed the .exe file.
Then I opened the corrupted shp file.
It immediately showed up on the viewing window.
I then saved this as a newly named .shp file and this opened fine in ArcGIS.

Thank God I found this solution or I could have kissed goodbye to my Master's
Dissertation!!!

Hope it helps,
Ben Blakeman

Original comment by bphblake...@googlemail.com on 30 May 2010 at 4:19

GoogleCodeExporter commented 9 years ago
I got around this issue by creating the .dBF in a separate step, explicitly 
setting the DbaseFileHeader.NumRecords property BEFORE writing the dBase file.  
The shapefile is read by ArcGIS with no problems after this.

Original comment by cgrub...@gmail.com on 6 Aug 2010 at 1:24

GoogleCodeExporter commented 9 years ago
cgrubb86's suggestion worked! Thank you so much.

Original comment by sendHelp...@gmail.com on 23 Sep 2010 at 7:42

GoogleCodeExporter commented 9 years ago
Thank you bphblake!  You saved my work project.  FWTools was easy to install 
and it opened the corrupted file instantly.  I saved my shapefile with the same 
filename and it works again.

Original comment by pmcat...@gmail.com on 31 Mar 2011 at 8:57

GoogleCodeExporter commented 9 years ago
happy to see that, if someone is able to fix the bug with arcgis (i.e: verify 
that with patched NTS arcgis reads shapefiles correctly) I'm happy to fix the 
code.

Original comment by diegogu...@gmail.com on 1 Apr 2011 at 7:00

GoogleCodeExporter commented 9 years ago
Hi, i have the same problem with my code:( may be smb can look at my code? 
Please:

private void Create_dbf_file(ColumnDBFCollection columnColl, string path, bool 
flag)
        {
            DbaseFileHeader dbfHeader = new DbaseFileHeader();
            dbfHeader.NumRecords = columnColl.Items.Count+2;
            dbfHeader.AddColumn("Description", 'C', 20, 0);

            if (flag) {
                dbfHeader.AddColumn("Length", 'C', 20, 0);
            }
            DbaseFileWriter dw = new DbaseFileWriter(path + ".dbf");
            dw.Write(dbfHeader);
            for (var i = 0; i <= columnColl.Items.Count-1; i++)
            {
                ArrayList columnVals = new ArrayList();
                columnVals.Add(columnColl.Items[i].Description);
                if (flag) { columnVals.Add(columnColl.Items[i].Length.ToString()); }
                dw.Write(columnVals);
            }
            dw.Write(0x1A);
            dw.Close();
        }

Original comment by v.vinogr...@gmail.com on 10 Aug 2011 at 3:24