ThinkGeo.com    |     Documentation    |     Premium Support

Error loading shapefile

Hi,

We’re trying to load a shapefile into memory using class “ShapeFileFeatureSource” but it throws an exception with the following message/stacktrace:

System.IO.FileLoadException
The record is invalid, please call Validate method to check the failed reason.Record index: 48
at ThinkGeo.MapSuite.Core.ShapeFile.sBQ=(Int32 recordIndex)
at ThinkGeo.MapSuite.Core.ShapeFileFeatureSource.GetAllFeaturesCore(IEnumerable1 returningColumnNames) at ThinkGeo.MapSuite.Core.FeatureSource.<GetAllFeatures>b__d(IEnumerable1 cns)
at ThinkGeo.MapSuite.Core.FeatureSource.eBQ=(IEnumerable1 returningColumnNames, Func2 getFeatures, IEnumerable1 filters) at ThinkGeo.MapSuite.Core.FeatureSource.GetAllFeatures(IEnumerable1 returningColumnNames)
at ThinkGeo.MapSuite.Core.FeatureSource.GetAllFeatures(ReturningColumnsType returningColumnNamesType)
(…)

There’s some problem with shapefile data and we don’t understand what is it.

We’ve uploaded a Visual Studio project into WeTransfer service with which you can replicate this problem. You can download it with the following link:

https://wetransfer.com/downloads/227c23a261ef661231fa3be57ec664b820170516160812/75f2ebc692e845f3a163da1bac83f65020170516160812/4e00ff

Best regards,
BdaF

Hi BdaF,

If the sample is small you can directly upload it here, if that’s big you can choose to sent us via our FTP.

This exception is because your 48 and 49 record is invalid, we improve related logic so it will skip invalid records, we tried some other utility which also skip invalid records.

Please get our latest code to have a try.

For V9 it’s 9.0.694.0 or higher version
For V10 it’s ThinkGeo MapSuite ShapeFile Layer 11.0.0-beta002 or higher version

We will refresh the download link in one or two days, please keep you eyes on it.

Regards,

Don

Hi Don,

What do you mean by “(…) we improve related logic so it will skip invalid records, we tried some other utility which also skip invalid records (…)”? Does that mean that the features will not be loaded into memory or it will have a null geometry?

We are using V9 and we must keep it. Those TG 9.0 versions are beta or release versions? Some time ago we used a BETA version and it was really unstable. We cannot afford to use unstable versions on our software solutions.

Best regards,
BdaF

BTW Ron,

Can you explain the reason why is this happening?

We open this shapefile on QGIS and perform “Geometry Validation Check” over it and it doesn’t detect any problem.

For now, we want to know the problem and solve it with some spatial tool or other methodology. We don’t want to replace TG DLL versions.

Best regards,
BdaF

Hi BadF,

Your record 48 and record 49 is invalid both in shp and dbf file, the other spatial tool for example QGis and GlobalMapper just ignore the invalid record, so you cannot validate that.

We help you remove the invalid record in the file attached, you can use it directly no need to replace dll, wish it’s helpful.

Issue ShapeFile Resolved.zip (5.5 KB)

Regards,

Don