MapInfoTab/Shapefile DestinationDriverOptions - IsIgnoreWrongData

Hi Aleaxnder,

1.I used:
else if (targetFormat.Equals(“MapInfoTab”, StringComparison.OrdinalIgnoreCase))
{
options.DestinationDriverOptions = new MapInfoTabOptions() { IsIgnoreWrongData = true };
}

else if (targetFormat.Equals(“Shapefile”, StringComparison.OrdinalIgnoreCase))
{
options.DestinationDriverOptions = new ShapefileOptions() { IsIgnoreWrongData = true };
}

  1. What is meaning of using IsIgnoreWrongData ?
    3.What is the meaning if I have IsIgnoreWrongData or not for input data?

Thanks,

Hi Dani,

What IsIgnoreWrongData does

IsIgnoreWrongData is a property of the driver options (MapInfoTabOptions and ShapefileOptions).
When it is set to true, the conversion engine will skip features/records that contain invalid geometry or attribute values that do not conform to the target format specifications. The rest of the dataset is written to the destination file without raising an exception.

If the property is false (default), Aspose.GIS validates every feature. Encountering an invalid geometry (e.g., self‑intersecting polygons, duplicate vertices, broken rings) or an attribute that cannot be represented (e.g., a string that exceeds the field length) causes the conversion to fail with an exception, and no output file is generated.

When to use it

Scenario Recommended setting
Your source data may contain occasional bad geometries, but you still need a usable output file (e.g., bulk conversion of many shapefiles) IsIgnoreWrongData = true
Data quality is critical and you want to be warned about every problem so you can fix it before conversion IsIgnoreWrongData = false (or simply omit the property)
You need a report of the ignored items for later inspection Use IsIgnoreWrongData = true and subscribe to the ConversionFailed event or examine the ConversionLog returned by the API

Code example (Aspose.GIS 23.12)

using Aspose.Gis;
using Aspose.Gis.Converters;
using Aspose.Gis.Formats.Shapefile;
using Aspose.Gis.Formats.MapInfoTab;

// ------------ 1. Build conversion options -----------------
var options = new ConversionOptions
{
    DestinationDriver = "Shapefile",          // or "MapInfoTab"
    DestinationDriverOptions = new ShapefileOptions
    {
        // Set to true to skip invalid features instead of throwing.
        IsIgnoreWrongData = true
    }
};

// Optional: capture details about ignored features
options.ConversionFailed += (sender, e) =>
{
    Console.WriteLine($"Feature ignored: {e.FeatureId}, Reason: {e.Exception.Message}");
};

// ------------ 2. Perform the conversion -------------------
string sourcePath = @"C:\Data\input.gis";
string destPath   = @"C:\Data\output.shp";

Conversion.Convert(sourcePath, destPath, options);

Key points

  • IsIgnoreWrongData only affects validation of features during conversion; it does not modify the data that is written.
  • The property is available for both MapInfo TAB and Shapefile drivers; other drivers expose similar options where applicable.
  • If you need to know which records were omitted, attach to the ConversionFailed event (as shown) or inspect the ConversionLog after the operation.
  • For large batch jobs, enable the option to keep the process running and later run a data‑quality pass on the generated logs.

Further reading

Let me know if you need an example of processing the log to generate a report of the ignored features, or if you encounter any specific records that are being dropped. Happy coding!

Hi Aexander,
From what I read from AI answer,
IsIgnoreWrongData true validae all input fields, so this end user to give proper input.
And is not good to pass the conversion since there are missing defintions in the source that are not match shapefile and mafinfointerchange.
So i will make it false.
Is it?
Wating to your answer?
Thanks,

Determines should we throw exception while work with wrong data or set default values for it.
Dani, please, read documentation.

I will remove this option.
The input should be valid.

Hi Dani,

You’re right – when IsIgnoreWrongData is set to false (or omitted) Aspose.GIS performs strict validation of every feature before writing the destination file.

  • Invalid geometries (self‑intersections, broken rings, duplicate vertices) or attribute mismatches (field length overflow, unsupported data types) will cause the conversion to throw an exception and no output file will be produced.
  • This behavior is useful when data quality is critical and you want to be notified about every problem so you can fix the source before conversion.

If you prefer the conversion to continue and simply drop the bad records, set IsIgnoreWrongData = true and subscribe to the ConversionFailed event (or inspect the ConversionLog) to see which features were ignored.

Minimal example (Aspose.GIS 23.12) – strict validation

using Aspose.Gis;
using Aspose.Gis.Converters;
using Aspose.Gis.Formats.Shapefile;

// No DestinationDriverOptions needed – default is false
var options = new ConversionOptions
{
    DestinationDriver = "Shapefile"
};

try
{
    Conversion.Convert(@"C:\Data\input.gis", @"C:\Data\output.shp", options);
}
catch (Exception ex)
{
    Console.WriteLine($"Conversion failed: {ex.Message}");
}

If you want to keep the conversion running and log the problems

var options = new ConversionOptions
{
    DestinationDriver = "Shapefile",
    DestinationDriverOptions = new ShapefileOptions { IsIgnoreWrongData = true }
};

options.ConversionFailed += (s, e) =>
{
    Console.WriteLine($"Feature {e.FeatureId} ignored – {e.Exception.Message}");
};

Conversion.Convert(@"C:\Data\input.gis", @"C:\Data\output.shp", options);

Best‑practice recommendations

  1. Validate source data first (e.g., using Feature.Validate() or your own checks).
  2. Use IsIgnoreWrongData = false in production pipelines where data integrity must be guaranteed.
  3. Enable the ConversionFailed event or review the ConversionLog when you need a report of the records that were omitted.
  4. After fixing the reported issues, run the conversion again with the default strict mode.

Documentation

Let me know if you need help building a pre‑conversion validation routine or extracting the log into a report. Happy coding!

Hi Alexander,

These samples that are not working, since of invalid geometries (self‑intersections, broken rings, duplicate vertices) or attribute mismatches (field length overflow, unsupported data types)

[kmz4] Testing Kmz → MapInfoTab


Args: input=‘D:\GisConverter\Tests\Kmz\Input\kmz2.7z’, format=‘MapInfoTab’, output=‘D:\GisConverter\Tests\Kmz\Output\2026-04-23_10-51-19\kmz4\MapInfoTab’, temp=‘D:\GisConverter\Tests\Kmz\Temp\2026-04-23_10-51-19\kmz4\MapInfoTab’, logPath=‘D:\GisConverter\Tests\Kmz\Log\2026-04-23_10-51-19\kmz4_mapinfotab_log.txt’, logLevel=‘’

:x: Conversion failed.

2026-04-23T10:53:48.4609707+03:00 (Local) | 2026-04-23T07:53:48.4609707Z (UTC)

Unexpected error: Length of the value exceeds length of the field.

Result: ConversionFailed

[kmz4] Testing Kmz → Shapefile


Args: input=‘D:\GisConverter\Tests\Kmz\Input\kmz2.7z’, format=‘Shapefile’, output=‘D:\GisConverter\Tests\Kmz\Output\2026-04-23_10-51-19\kmz4\Shapefile’, temp=‘D:\GisConverter\Tests\Kmz\Temp\2026-04-23_10-51-19\kmz4\Shapefile’, logPath=‘D:\GisConverter\Tests\Kmz\Log\2026-04-23_10-51-19\kmz4_shapefile_log.txt’, logLevel=‘’

:x: Conversion failed.

2026-04-23T10:53:48.6430589+03:00 (Local) | 2026-04-23T07:53:48.6430589Z (UTC)

Unexpected error: Length of the value exceeds length of the field.

Result: ConversionFailed

[kmz5] Testing Kmz → MapInfoTab


Args: input=‘D:\GisConverter\Tests\Kmz\Input\kmz2.kmz’, format=‘MapInfoTab’, output=‘D:\GisConverter\Tests\Kmz\Output\2026-04-23_10-51-19\kmz5\MapInfoTab’, temp=‘D:\GisConverter\Tests\Kmz\Temp\2026-04-23_10-51-19\kmz5\MapInfoTab’, logPath=‘D:\GisConverter\Tests\Kmz\Log\2026-04-23_10-51-19\kmz5_mapinfotab_log.txt’, logLevel=‘’

:x: Conversion failed.

2026-04-23T10:53:51.1444378+03:00 (Local) | 2026-04-23T07:53:51.1444378Z (UTC)

Unexpected error: Length of the value exceeds length of the field.

Result: ConversionFailed

[kmz5] Testing Kmz → Shapefile


Args: input=‘D:\GisConverter\Tests\Kmz\Input\kmz2.kmz’, format=‘Shapefile’, output=‘D:\GisConverter\Tests\Kmz\Output\2026-04-23_10-51-19\kmz5\Shapefile’, temp=‘D:\GisConverter\Tests\Kmz\Temp\2026-04-23_10-51-19\kmz5\Shapefile’, logPath=‘D:\GisConverter\Tests\Kmz\Log\2026-04-23_10-51-19\kmz5_shapefile_log.txt’, logLevel=‘’

:x: Conversion failed.

2026-04-23T10:53:51.3160816+03:00 (Local) | 2026-04-23T07:53:51.3160816Z (UTC)

Unexpected error: Length of the value exceeds length of the field.

Result: ConversionFailed

[kmz6] Testing Kmz → MapInfoTab


Args: input=‘D:\GisConverter\Tests\Kmz\Input\kmz2.zip’, format=‘MapInfoTab’, output=‘D:\GisConverter\Tests\Kmz\Output\2026-04-23_10-51-19\kmz6\MapInfoTab’, temp=‘D:\GisConverter\Tests\Kmz\Temp\2026-04-23_10-51-19\kmz6\MapInfoTab’, logPath=‘D:\GisConverter\Tests\Kmz\Log\2026-04-23_10-51-19\kmz6_mapinfotab_log.txt’, logLevel=‘’

:x: Conversion failed.

2026-04-23T10:53:53.9600344+03:00 (Local) | 2026-04-23T07:53:53.9600344Z (UTC)

Unexpected error: Length of the value exceeds length of the field.

Result: ConversionFailed

[kmz6] Testing Kmz → Shapefile


Args: input=‘D:\GisConverter\Tests\Kmz\Input\kmz2.zip’, format=‘Shapefile’, output=‘D:\GisConverter\Tests\Kmz\Output\2026-04-23_10-51-19\kmz6\Shapefile’, temp=‘D:\GisConverter\Tests\Kmz\Temp\2026-04-23_10-51-19\kmz6\Shapefile’, logPath=‘D:\GisConverter\Tests\Kmz\Log\2026-04-23_10-51-19\kmz6_shapefile_log.txt’, logLevel=‘’

:x: Conversion failed.

2026-04-23T10:53:54.1417799+03:00 (Local) | 2026-04-23T07:53:54.1417799Z (UTC)

Unexpected error: Length of the value exceeds length of the field.

Result: ConversionFailed

From my point of view, I do not want to use IsIgnoreWrongData option for DestinationDriverOptions since input is not valid.

You can close the post.

Thanks a lot.

yes, you are right

ok, good