# RtreeSpatialIndex

**URL:** <https://community.thinkgeo.com/t/rtreespatialindex/1252>\
**Category:** WinForms\
**Created:** [May 25, 2010, 11:13pm UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252 "2010-05-25T23:13:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [May 25, 2010, 11:13pm UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/1 "2010-05-25T23:13:55Z")

</div>

Hello,

Please&nbsp;give&nbsp;me&nbsp;a&nbsp;sample&nbsp;to&nbsp;show&nbsp;how&nbsp;to&nbsp;use&nbsp;this&nbsp;API.&nbsp;it&nbsp;is&nbsp;wrong&nbsp;as&nbsp;follows&nbsp;code:

string&nbsp;shpFile&nbsp;=&nbsp;@"D:\Road\_AL.shp";

RtreeSpatialIndex.CreateRectangleSpatialIndex(shpFile&nbsp;,RtreeSpatialIndexPageSize.SixteenKilobytes,RtreeSpatialIndexDataFormat.Double);Sorry,

I&nbsp;just&nbsp;want&nbsp;to&nbsp;know&nbsp;how&nbsp;to&nbsp;use&nbsp;it&nbsp;and&nbsp;see&nbsp;if&nbsp;it&nbsp;is&nbsp;useful&nbsp;for&nbsp;my&nbsp;app.

What&nbsp;is&nbsp;difference&nbsp;between&nbsp;CreatePointSatialIndex&nbsp;and&nbsp;CreateRectangleSpatialIndex?

I&nbsp;hope&nbsp;you&nbsp;can&nbsp;add&nbsp;new&nbsp;samples&nbsp;to&nbsp;show&nbsp;how&nbsp;to&nbsp;use&nbsp;new&nbsp;APIs.

it&nbsp;is&nbsp;inconvenience.

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [May 26, 2010, 1:52am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/2 "2010-05-26T01:52:21Z")

</div>

Carol,&nbsp;  
&nbsp;&nbsp;  
&nbsp;We&nbsp;started&nbsp;to&nbsp;expose&nbsp;the&nbsp;DBF&nbsp;(GeoDbf)&nbsp;module&nbsp;and&nbsp;RTree(RTreeSpatialIndex)&nbsp;module&nbsp;only&nbsp;from&nbsp;last&nbsp;public&nbsp;release(4.0.0.0).&nbsp;So&nbsp;maybe&nbsp;some&nbsp;documentation&nbsp;are&nbsp;still&nbsp;missing,&nbsp;sorry&nbsp;for&nbsp;the&nbsp;inconvenience.&nbsp;  
&nbsp;&nbsp;  
&nbsp;The&nbsp;static&nbsp;APIs&nbsp;CreateRectangleSpatialIndex&nbsp;and&nbsp;CreatePointSpatialIndex&nbsp;are&nbsp;used&nbsp;to&nbsp;create&nbsp;an&nbsp;empty&nbsp;RTree&nbsp;file,&nbsp;the&nbsp;second&nbsp;parameter&nbsp;is&nbsp;to&nbsp;specifies&nbsp;the&nbsp;bytes&nbsp;stored&nbsp;for&nbsp;each&nbsp;page,&nbsp;and&nbsp;the&nbsp;third&nbsp;is&nbsp;the&nbsp;value&nbsp;type&nbsp;stored&nbsp;in&nbsp;the&nbsp;file.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Normally,&nbsp;if&nbsp;you&nbsp;do&nbsp;not&nbsp;want&nbsp;to&nbsp;operate&nbsp;the&nbsp;RTree&nbsp;file&nbsp;separately,&nbsp;you&nbsp;do&nbsp;not&nbsp;need&nbsp;to&nbsp;use&nbsp;this&nbsp;module&nbsp;separately,&nbsp;you&nbsp;only&nbsp;need&nbsp;to&nbsp;know&nbsp;and&nbsp;understand&nbsp;the&nbsp;APIs&nbsp;in&nbsp;the&nbsp;ShapeFileFeatureSource&nbsp;and&nbsp;ShapeFileFeatureLayer&nbsp;which&nbsp;will&nbsp;handle&nbsp;all&nbsp;the&nbsp;files&nbsp;together.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yale&nbsp;

---

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [May 26, 2010, 2:49am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/3 "2010-05-26T02:49:50Z")

</div>

Thanks&nbsp;for&nbsp;your&nbsp;reply,&nbsp;Yale&nbsp;  
&nbsp;You&nbsp;update&nbsp;API,&nbsp;but&nbsp;no&nbsp;update&nbsp;samples.&nbsp;  
&nbsp;I&nbsp;want&nbsp;to&nbsp;find&nbsp;whcih&nbsp;new&nbsp;APIs&nbsp;is&nbsp;useful&nbsp;that&nbsp;I&nbsp;can&nbsp;use&nbsp;in&nbsp;my&nbsp;app.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I’d&nbsp;like&nbsp;to&nbsp;know&nbsp;if&nbsp;I&nbsp;change&nbsp;RtreeSpatialIndexPageSize/RtreeSpatialIndexDataFormat.&nbsp;&nbsp;  
&nbsp;Does&nbsp;it&nbsp;affect&nbsp;Map&nbsp;performance?&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [May 26, 2010, 3:11am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/4 "2010-05-26T03:11:50Z")

</div>

Carol,&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;The&nbsp;RTreeSpatialIndexPageSize&nbsp;will&nbsp;affect&nbsp;the&nbsp;map&nbsp;performance&nbsp;,&nbsp;while&nbsp;this&nbsp;kind&nbsp;of&nbsp;effects&nbsp;can&nbsp;be&nbsp;ignored.&nbsp;The&nbsp;DataFormat&nbsp;will&nbsp;affect&nbsp;the&nbsp;precision&nbsp;of&nbsp;data&nbsp;stored&nbsp;in&nbsp;the&nbsp;RTree.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yale&nbsp;

---

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [May 27, 2010, 12:33am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/5 "2010-05-27T00:33:18Z")

</div>

Thanks&nbsp;for&nbsp;your&nbsp;reply,&nbsp;Yale&nbsp;  
&nbsp;How&nbsp;long&nbsp;you&nbsp;can&nbsp;release&nbsp;RtreeSpatialIndex&nbsp;and&nbsp;UpdateColumnName?&nbsp;  
&nbsp;&nbsp;  
&nbsp;And,&nbsp;I’d&nbsp;like&nbsp;to&nbsp;know&nbsp;the&nbsp;progress&nbsp;of&nbsp;Ticket&nbsp;2788.&nbsp;

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [May 27, 2010, 1:39am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/6 "2010-05-27T01:39:23Z")

</div>

Carol,&nbsp;  
&nbsp;&nbsp;  
&nbsp;It&nbsp;seems&nbsp;our&nbsp;support&nbsp;is&nbsp;out&nbsp;of&nbsp;office&nbsp;yesterday,&nbsp;the&nbsp;ticket&nbsp;2788&nbsp;is&nbsp;still&nbsp;on&nbsp;moderate&nbsp;state.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;think&nbsp;you&nbsp;can&nbsp;get&nbsp;the&nbsp;latest&nbsp;version&nbsp;to&nbsp;see&nbsp;both&nbsp;of&nbsp;the&nbsp;issues&nbsp;should&nbsp;be&nbsp;fixed.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yale&nbsp;

---

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [May 28, 2010, 2:12am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/7 "2010-05-28T02:12:52Z")

</div>

Yale,&nbsp;  
&nbsp;Could&nbsp;you&nbsp;give&nbsp;me&nbsp;a&nbsp;sample&nbsp;to&nbsp;show&nbsp;how&nbsp;to&nbsp;use&nbsp;CreateRectangleSpatialIndex&nbsp;API?&nbsp;  
&nbsp;I&nbsp;still&nbsp;can’t&nbsp;work&nbsp;in&nbsp;version&nbsp;4.0.23.0.&nbsp;

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [May 28, 2010, 2:29am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/8 "2010-05-28T02:29:35Z")

</div>

Carol,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;post&nbsp;and&nbsp;questions.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Try&nbsp;following&nbsp;code&nbsp;snippet,&nbsp;after&nbsp;it&nbsp;was&nbsp;run,&nbsp;two&nbsp;files(a.idx,&nbsp;a.ids)&nbsp;will&nbsp;be&nbsp;recreated&nbsp;in&nbsp;the&nbsp;folder&nbsp;C:\temp,&nbsp;while&nbsp;it&nbsp;is&nbsp;empty&nbsp;index&nbsp;files&nbsp;up&nbsp;to&nbsp;now.&nbsp;  
&nbsp;&nbsp;  
&nbsp;string&nbsp;fileName&nbsp;=&nbsp;@"C:\temp\a.idx";&nbsp;  
&nbsp;RtreeSpatialIndex.CreateRectangleSpatialIndex(fileName);&nbsp;  
&nbsp;&nbsp;  
&nbsp;Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yale&nbsp;

---

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [May 28, 2010, 2:40am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/9 "2010-05-28T02:40:28Z")

</div>

Thanks&nbsp;for&nbsp;your&nbsp;reply,&nbsp;Yale&nbsp;  
&nbsp;It&nbsp;works&nbsp;well.&nbsp;  
&nbsp;And,&nbsp;you&nbsp;said,"The&nbsp;RTreeSpatialIndexPageSize&nbsp;will&nbsp;affect&nbsp;the&nbsp;map&nbsp;performance&nbsp;,&nbsp;while&nbsp;this&nbsp;kind&nbsp;of&nbsp;effects&nbsp;can&nbsp;be&nbsp;ignored."&nbsp;  
&nbsp;&nbsp;  
&nbsp;could&nbsp;you&nbsp;explain&nbsp;why&nbsp;this&nbsp;kind&nbsp;of&nbsp;effects&nbsp;can&nbsp;be&nbsp;ignored?..&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;a&nbsp;lot!&nbsp;

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [May 28, 2010, 3:01am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/10 "2010-05-28T03:01:17Z")

</div>

Carol,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;inputs.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;am&nbsp;not&nbsp;sure&nbsp;I&nbsp;can&nbsp;make&nbsp;it&nbsp;clear,&nbsp;hope&nbsp;my&nbsp;following&nbsp;answer&nbsp;can&nbsp;give&nbsp;you&nbsp;some&nbsp;help.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;This&nbsp;parameter&nbsp;specifies&nbsp;the&nbsp;content&nbsp;for&nbsp;each&nbsp;page,&nbsp;which&nbsp;is&nbsp;the&nbsp;OS,&nbsp;will&nbsp;read&nbsp;how&nbsp;many&nbsp;kilobytes&nbsp;were&nbsp;stored&nbsp;in&nbsp;each&nbsp;page&nbsp;when&nbsp;stored&nbsp;on&nbsp;disk.&nbsp;If&nbsp;this&nbsp;value&nbsp;is&nbsp;set&nbsp;to&nbsp;too&nbsp;small,&nbsp;more&nbsp;pages&nbsp;need&nbsp;to&nbsp;be&nbsp;read,&nbsp;while&nbsp;other&nbsp;wise,&nbsp;if&nbsp;it&nbsp;is&nbsp;set&nbsp;to&nbsp;too&nbsp;large,&nbsp;each&nbsp;page&nbsp;will&nbsp;cover&nbsp;too&nbsp;much&nbsp;content.&nbsp;We&nbsp;provided&nbsp;four&nbsp;options:&nbsp;4Kb,&nbsp;16KB,&nbsp;32KB,&nbsp;8KB,&nbsp;our&nbsp;default&nbsp;value&nbsp;is&nbsp;8&nbsp;KB.&nbsp;I&nbsp;think&nbsp;these&nbsp;values&nbsp;will&nbsp;have&nbsp;minor&nbsp;effects&nbsp;on&nbsp;current&nbsp;machines&nbsp;which&nbsp;have&nbsp;enough&nbsp;RAM&nbsp;and&nbsp;fast&nbsp;enough&nbsp;CPU.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yale&nbsp;

---

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [May 31, 2010, 1:29am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/11 "2010-05-31T01:29:10Z")

</div>

Thanks&nbsp;for&nbsp;your&nbsp;reply,&nbsp;Yale&nbsp;  
&nbsp;if&nbsp;I&nbsp;want&nbsp;to&nbsp;operate&nbsp;the&nbsp;RTree&nbsp;file&nbsp;separately,&nbsp;how&nbsp;do&nbsp;I&nbsp;do?&nbsp;  
&nbsp;could&nbsp;you&nbsp;give&nbsp;me&nbsp;a&nbsp;sample?&nbsp;

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [May 31, 2010, 1:35am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/12 "2010-05-31T01:35:39Z")

</div>

Carol,

See&nbsp;following&nbsp;code&nbsp;snippet&nbsp;to&nbsp;get&nbsp;the&nbsp;count&nbsp;contained&nbsp;in&nbsp;the&nbsp;RTree&nbsp;file:  
  
`string rTreeFileName = @"C:\Program Files\ThinkGeo\Map Suite Desktop Evaluation Edition 3.0\Samples\SampleData\Data\Countries02.idx"; RtreeSpatialIndex rTreeIndex = new RtreeSpatialIndex(rTreeFileName, RtreeSpatialIndexReadWriteMode.ReadOnly); rTreeIndex.Open(); try{      int count = rTreeIndex.GetFeatureCount();}finally{      rTreeIndex.Close();}`  
&nbsp;  
Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.  
&nbsp;  
Thanks.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
Yale

---

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [May 31, 2010, 2:52am UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/13 "2010-05-31T02:52:48Z")

</div>

Why&nbsp;can’t&nbsp;I&nbsp;do&nbsp;as&nbsp;follows&nbsp;code:&nbsp;  
&nbsp;&nbsp;ShapeFileFeatureLayer&nbsp;Road&nbsp;=&nbsp;new&nbsp;ShapeFileFeatureLayer(@“D:\indexRoad.shp”);&nbsp;  
&nbsp;&nbsp;RtreeSpatialIndex.CreateRectangleSpatialIndex(@“D:\indexRoad.idx”,&nbsp;RtreeSpatialIndexPageSize.FourKilobytes,&nbsp;RtreeSpatialIndexDataFormat.Double);&nbsp;  
&nbsp;&nbsp;RtreeSpatialIndex&nbsp;testIndex&nbsp;=&nbsp;new&nbsp;RtreeSpatialIndex(@“D:\indexRoad.idx”,&nbsp;RtreeSpatialIndexReadWriteMode.ReadWrite);&nbsp;  
&nbsp;&nbsp;Road.Open();&nbsp;  
&nbsp;&nbsp;Feature&nbsp;feature&nbsp;=&nbsp;Road.QueryTools.GetFeatureById(“3”,&nbsp;ReturningColumnsType.AllColumns);&nbsp;  
&nbsp;&nbsp;testIndex.Add(feature);&nbsp;//Error&nbsp;Message:&nbsp;Error&nbsp;on&nbsp;delete&nbsp;point.&nbsp;  
&nbsp;&nbsp;&nbsp;Road.Close();

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [May 31, 2010, 7:09pm UTC](https://community.thinkgeo.com/t/rtreespatialindex/1252/14 "2010-05-31T19:09:00Z")

</div>

Carol,

Thanks&nbsp;for&nbsp;your&nbsp;post&nbsp;and&nbsp;code.  
&nbsp;  
Try&nbsp;following&nbsp;code&nbsp;to&nbsp;insert&nbsp;only&nbsp;one&nbsp;feature&nbsp;to&nbsp;the&nbsp;index&nbsp;file.&nbsp;One&nbsp;thing&nbsp;I&nbsp;want&nbsp;to&nbsp;point&nbsp;out&nbsp;is&nbsp;that&nbsp;after&nbsp;this,&nbsp;the&nbsp;record&nbsp;number&nbsp;in&nbsp;the&nbsp;shape&nbsp;does&nbsp;not&nbsp;match&nbsp;with&nbsp;the&nbsp;record&nbsp;in&nbsp;the&nbsp;RTree&nbsp;index&nbsp;file.  
  
&nbsp;  
`string shapeFile = @"D:\indexRoad.shp";string rTreeFileName = @"D:\indexRoad.idx";            RtreeSpatialIndex.CreateRectangleSpatialIndex(rTreeFileName, RtreeSpatialIndexPageSize.FourKilobytes, RtreeSpatialIndexDataFormat.Double);ShapeFileFeatureLayer Road = new ShapeFileFeatureLayer(shapeFile);Road.Open();Feature feature = Road.QueryTools.GetFeatureById("3", ReturningColumnsType.AllColumns);Road.Close(); RtreeSpatialIndex testIndex = new RtreeSpatialIndex(rTreeFileName, RtreeSpatialIndexReadWriteMode.ReadWrite);testIndex.Open();testIndex.Add(feature);testIndex.Close();`  
  
Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.  
&nbsp;  
Thanks.  
&nbsp;  
Yale
