# Shapefile RequireIndex

**URL:** <https://community.thinkgeo.com/t/shapefile-requireindex/2129>\
**Category:** WinForms\
**Created:** [November 12, 2012, 6:57am UTC](https://community.thinkgeo.com/t/shapefile-requireindex/2129 "2012-11-12T06:57:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torsten](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/8e8cbc/32.png) [@Torsten](https://community.thinkgeo.com/u/Torsten)\
**Post date:** [November 12, 2012, 6:57am UTC](https://community.thinkgeo.com/t/shapefile-requireindex/2129/1 "2012-11-12T06:57:12Z")

</div>

Hello,  
  
If&nbsp;I&nbsp;try&nbsp;to&nbsp;open&nbsp;an&nbsp;existing&nbsp;Shapefile&nbsp;with&nbsp;-&nbsp;layer.RequireIndex&nbsp;=&nbsp;false&nbsp;-&nbsp;(currently&nbsp;exported&nbsp;from&nbsp;Arcgis,&nbsp;without&nbsp;any&nbsp;IndexFiles&nbsp;(ids,&nbsp;idx)&nbsp;I&nbsp;got&nbsp;an&nbsp;error&nbsp;after&nbsp;Map.Refresh&nbsp;"The&nbsp;input&nbsp;double&nbsp;value&nbsp;is&nbsp;out&nbsp;of&nbsp;range,&nbsp;Parametername&nbsp;maxX".  
  
If&nbsp;I&nbsp;create&nbsp;these&nbsp;Indexfiles&nbsp;and&nbsp;set&nbsp;layer.RequireIndex&nbsp;=&nbsp;true,&nbsp;there&nbsp;are&nbsp;no&nbsp;errors.

So&nbsp;my&nbsp;question:&nbsp;Is&nbsp;this&nbsp;now&nbsp;not&nbsp;possible&nbsp;to&nbsp;open&nbsp;Shapefiles&nbsp;without&nbsp;Indexfiles?&nbsp;If&nbsp;so,&nbsp;this&nbsp;is&nbsp;really&nbsp;bad.&nbsp;Often&nbsp;our&nbsp;customers&nbsp;have&nbsp;not&nbsp;"write&nbsp;access"&nbsp;to&nbsp;the&nbsp;gis-folders.

&nbsp;

&nbsp;

ShapeFileFeatureLayer&nbsp;layer&nbsp;=&nbsp;new&nbsp;ShapeFileFeatureLayer(@"d:\kram\_linie.shp");false;ApplyUntilZoomLevel.Level20;try

{

((

}

&nbsp;

LayerOverlay)winformsMap1.Overlays[0]).Layers.Add("test",&nbsp;layer);finally

{

winformsMap1.Overlays[0].Lock.ExitWriteLock();

}

&nbsp;

//&nbsp;allgemein

&nbsp;

&nbsp;

this.SetCurrentExtent();this.winformsMap1.Refresh();

layer.RequireIndex&nbsp;=

SetStyleByWellKnownType(layer);

layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel&nbsp;=

winformsMap1.Overlays[0].Lock.EnterWriteLock();

&nbsp;

---

<div class="post-metadata">

**Author:** ![Ryan](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@Ryan](https://community.thinkgeo.com/u/Ryan)\
**Post date:** [November 12, 2012, 3:10pm UTC](https://community.thinkgeo.com/t/shapefile-requireindex/2129/2 "2012-11-12T15:10:56Z")

</div>

Hi&nbsp;Torsten,&nbsp;  
  
  
  
Thanks&nbsp;for&nbsp;providing&nbsp;your&nbsp;shapefile!&nbsp;  
  
  
  
Map&nbsp;Suite&nbsp;can&nbsp;load&nbsp;shapefiles&nbsp;that&nbsp;do&nbsp;not&nbsp;have&nbsp;IndexFiles.&nbsp;A&nbsp;simple&nbsp;test&nbsp;of&nbsp;this&nbsp;would&nbsp;be&nbsp;to&nbsp;delete&nbsp;the&nbsp;.ids&nbsp;and&nbsp;.idx&nbsp;files&nbsp;from&nbsp;the&nbsp;Countries02.shp&nbsp;that&nbsp;is&nbsp;included&nbsp;with&nbsp;the&nbsp;sample&nbsp;applications&nbsp;and&nbsp;set&nbsp;up&nbsp;your&nbsp;code&nbsp;to&nbsp;not&nbsp;require&nbsp;an&nbsp;index.&nbsp;  
  
  
  
As&nbsp;your&nbsp;shapefile&nbsp;does&nbsp;not&nbsp;contain&nbsp;a&nbsp;.prj&nbsp;file&nbsp;I&nbsp;was&nbsp;not&nbsp;able&nbsp;to&nbsp;determine&nbsp;the&nbsp;correct&nbsp;MapUnit&nbsp;that&nbsp;should&nbsp;be&nbsp;used&nbsp;and&nbsp;believe&nbsp;this&nbsp;might&nbsp;be&nbsp;the&nbsp;issue.&nbsp;I&nbsp;was&nbsp;able&nbsp;to&nbsp;load&nbsp;it&nbsp;into&nbsp;Map&nbsp;Suite&nbsp;Explorer&nbsp;and&nbsp;it&nbsp;would&nbsp;seem&nbsp;that&nbsp;perhaps&nbsp;you&nbsp;are&nbsp;using&nbsp;something&nbsp;smaller&nbsp;than&nbsp;feet&nbsp;or&nbsp;meters&nbsp;for&nbsp;your&nbsp;Unit&nbsp;System.&nbsp;Do&nbsp;you&nbsp;have&nbsp;a&nbsp;.prj&nbsp;file&nbsp;or&nbsp;the&nbsp;Projection&nbsp;information&nbsp;for&nbsp;this&nbsp;shapefile?

---

<div class="post-metadata">

**Author:** ![Torsten](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/8e8cbc/32.png) [@Torsten](https://community.thinkgeo.com/u/Torsten)\
**Post date:** [November 15, 2012, 3:26am UTC](https://community.thinkgeo.com/t/shapefile-requireindex/2129/3 "2012-11-15T03:26:36Z")

</div>

Hi&nbsp;Ryan,  
  
Tanks&nbsp;for&nbsp;yours&nbsp;answer.&nbsp;I&nbsp;havn't&nbsp;a&nbsp;prj&nbsp;file.&nbsp;The&nbsp;Shapefile&nbsp;is&nbsp;in&nbsp;Gauss-Krueger&nbsp;CoordSys&nbsp;(EPSG&nbsp;31468).&nbsp;I&nbsp;set&nbsp;the&nbsp;MapUnit&nbsp;to&nbsp;meter.  
  
Hope&nbsp;this&nbsp;helps..

Regards  
  
Torsten

---

<div class="post-metadata">

**Author:** ![Ryan](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@Ryan](https://community.thinkgeo.com/u/Ryan)\
**Post date:** [November 15, 2012, 1:45pm UTC](https://community.thinkgeo.com/t/shapefile-requireindex/2129/4 "2012-11-15T13:45:05Z")

</div>

Hi&nbsp;Torsten,

I&nbsp;believe&nbsp;the&nbsp;issue&nbsp;is&nbsp;that&nbsp;you&nbsp;have&nbsp;some&nbsp;invalid&nbsp;features&nbsp;in&nbsp;your&nbsp;shapefile.  
  
I&nbsp;setup&nbsp;the&nbsp;following&nbsp;code&nbsp;to&nbsp;check&nbsp;if&nbsp;each&nbsp;of&nbsp;your&nbsp;Featues&nbsp;was&nbsp;Valid:

`winformsMap1.MapUnit = GeographyUnit.Meter;            ShapeFileFeatureLayer testfile = new ShapeFileFeatureLayer(@"C:\shapefiles\kram_linie.shp");            testfile.RequireIndex = false;            BaseShape.GeometryLibrary = GeometryLibrary.Unmanaged;            testfile.Open();            foreach (Feature feature in testfile.FeatureSource.GetAllFeatures(ReturningColumnsType.NoColumns))            {                if (!feature.IsValid())                {                    Debug.WriteLine(feature.Id + " " + feature.IsValid());                }                        }`

The&nbsp;result&nbsp;was&nbsp;that&nbsp;the&nbsp;following&nbsp;features&nbsp;were&nbsp;found&nbsp;to&nbsp;be&nbsp;invalid:&nbsp;(FeatureID,&nbsp;IsValid?)  
  
228&nbsp;False  
  
229&nbsp;False  
  
230&nbsp;False  
  
231&nbsp;False  
  
243&nbsp;False  
  
244&nbsp;False  
  
285&nbsp;False  
  
544&nbsp;False  
  
554&nbsp;False

**Please&nbsp;note&nbsp;that&nbsp;I&nbsp;tested&nbsp;this&nbsp;using&nbsp;the&nbsp;6.0.183.0&nbsp;Dlls&nbsp;and&nbsp;that&nbsp;these&nbsp;dlls&nbsp;by&nbsp;default&nbsp;use&nbsp;BaseShape.GeometryLibrary&nbsp;=&nbsp;GeometryLibrary.Unmanaged.** &nbsp;  
  
This&nbsp;means&nbsp;that&nbsp;the&nbsp;IsValid&nbsp;logic&nbsp;used&nbsp;in&nbsp;my&nbsp;sample&nbsp;is&nbsp;the&nbsp;latest&nbsp;SQL&nbsp;Server&nbsp;Validation&nbsp;test&nbsp;as&nbsp;described&nbsp;at&nbsp;this&nbsp;link:&nbsp;[gis.thinkgeo.com/Support/Dis...fault.aspx](http://gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/16/aft/10443/afv/topic/Default.aspx)  
  
and&nbsp;in&nbsp;the&nbsp; **UnmanagedAssembliesDeploymentGuide.txt&nbsp;** located&nbsp;at&nbsp;'C:\Program&nbsp;Files&nbsp;(x86)\ThinkGeo\Map&nbsp;Suite&nbsp;Desktop&nbsp;Evaluation&nbsp;Edition&nbsp;6.0\Developer&nbsp;Reference\Desktop&nbsp;Edition'&nbsp;on&nbsp;your&nbsp;local&nbsp;system.

Based&nbsp;on&nbsp;this&nbsp;evidence&nbsp;you&nbsp;may&nbsp;want&nbsp;to&nbsp;revisit&nbsp;your&nbsp;shapefile&nbsp;to&nbsp;make&nbsp;sure&nbsp;it&nbsp;meets&nbsp;all&nbsp;the&nbsp;necessary&nbsp;validation&nbsp;tests.
