Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathshptree.html
More file actions
284 lines (241 loc) · 16.6 KB
/
Copy pathshptree.html
File metadata and controls
284 lines (241 loc) · 16.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<!DOCTYPE html>
<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>shptree — MapServer 8.6.4 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx.css?v=48f05237" />
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx_collapse.css?v=226d88b4" />
<link rel="stylesheet" type="text/css" href="../_static/custom.css?v=dd298242" />
<link rel="stylesheet" type="text/css" href="../_static/ribbon.css?v=ea091bf4" />
<script src="../_static/jquery.js?v=5d32c60e"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../_static/documentation_options.js?v=f59c4a7a"></script>
<script src="../_static/doctools.js?v=fd6eb6e6"></script>
<script src="../_static/sphinx_highlight.js?v=6ffebe34"></script>
<script src="../_static/clipboard.min.js?v=a7894cd8"></script>
<script src="../_static/copybutton.js?v=f281be69"></script>
<link rel="icon" href="../_static/mapserver.ico"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="next" title="shptreetst" href="shptreetst.html" />
<link rel="prev" title="scalebar" href="scalebar.html" />
</head><body>
<!-- for main branch only, do not backport this -->
<table width="100%" style="width: 100%; background-color: white;">
<tr>
<td rowspan="2" style="padding: 10px 0px 10px 10px;">
<a href="../index.html" title="Home"><img src="../_static/banner.png" alt="MapServer banner" border="0" /></a>
</td>
<td style="padding: 10px 10px 0px 0px; text-align: right; vertical-align: top;">
<a href="../index.html" title="Home">Home</a> |
<a href="../products.html" title="Products (MapServer core, MapCache, TinyOWS">Products</a> |
<a href="https://github.com/MapServer/MapServer/issues/" title="Issue Tracker (MapServer core)">Issue Tracker</a> |
<a href="../community/service_providers.html" title="Professional Service Providers">Service Providers</a> |
<a href="../faq.html" title="Frequently Asked Questions">FAQ</a> |
<a href="https://fosstodon.org/@mapserver" title="Mastodon" target="_blank">Mastodon</a> |
<a href="../download.html" title="Download Source or Binaries">Download </a> |
<a class="badge" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KRJ2X44N3HA6U&source=url" target="_blank">
<img src="https://img.shields.io/badge/donate-%E2%9D%A4%C2%A0-ff69b4.svg?style=flat" alt="Donate to MapServer">
</a>
</td>
</tr>
<tr>
<td style="padding: 0px 10px 0px 0px; text-align: right; vertical-align: bottom;">
<img src="../_static/flagicons/en.png" alt="en" title="en" border="0" width="18px" height="13px"/>
<a href="../ar/utilities/shptree.html"><img src="../_static/flagicons/ar.png" alt="ar" title="ar" border="0" /></a>
<a href="../de/utilities/shptree.html"><img src="../_static/flagicons/de.png" alt="de" title="de" border="0" /></a>
<a href="../el/utilities/shptree.html"><img src="../_static/flagicons/el.png" alt="el" title="el" border="0" /></a>
<a href="../es/utilities/shptree.html"><img src="../_static/flagicons/es.png" alt="es" title="es" border="0" /></a>
<a href="../fr/utilities/shptree.html"><img src="../_static/flagicons/fr.png" alt="fr" title="fr" border="0" /></a>
<a href="../id/utilities/shptree.html"><img src="../_static/flagicons/id.png" alt="id" title="id" border="0" /></a>
<a href="../it/utilities/shptree.html"><img src="../_static/flagicons/it.png" alt="it" title="it" border="0" /></a>
<a href="../ja/utilities/shptree.html"><img src="../_static/flagicons/ja.png" alt="ja" title="ja" border="0" /></a>
<a href="../nl_NL/utilities/shptree.html"><img src="../_static/flagicons/nl_NL.png" alt="nl_NL" title="nl_NL" border="0" /></a>
<a href="../pl/utilities/shptree.html"><img src="../_static/flagicons/pl.png" alt="pl" title="pl" border="0" /></a>
<a href="../ru/utilities/shptree.html"><img src="../_static/flagicons/ru.png" alt="ru" title="ru" border="0" /></a>
<a href="../sq/utilities/shptree.html"><img src="../_static/flagicons/sq.png" alt="sq" title="sq" border="0" /></a>
<a href="../tr/utilities/shptree.html"><img src="../_static/flagicons/tr.png" alt="tr" title="tr" border="0" /></a>
</td>
</tr>
</table>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="shptreetst.html" title="shptreetst"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="scalebar.html" title="scalebar"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Home</a> »</li>
<li class="nav-item nav-item-1"><a href="../documentation.html" >MapServer 8.6.4 Documentation</a> »</li>
<li class="nav-item nav-item-2"><a href="index.html" accesskey="U">Utilities</a> »</li>
<li class="nav-item nav-item-this"><a href="">shptree</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="shptree">
<span id="index-0"></span><span id="id1"></span><h1>shptree<a class="headerlink" href="#shptree" title="Link to this heading">¶</a></h1>
<section id="purpose">
<h2>Purpose<a class="headerlink" href="#purpose" title="Link to this heading">¶</a></h2>
<p>Creates a quadtree-based spatial index for a shapefile. The
default tree depth is calculated so that each tree node (quadtree
cell) contains 8 shapes. Do not use the default with point files, a
value between 6 and 10 seems to work ok. Your mileage may vary and
you’ll need to do some experimenting.</p>
<p>The <a class="reference external" href="https://github.com/MapServer/MapServer/wiki/ShpTree">shptree wiki page</a> may also contain
information on this utility.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>view the quadtree quadrants that are part of a <cite>.qix</cite> file with the <a class="reference internal" href="shptreevis.html#shptreevis"><span class="std std-ref">shptreevis</span></a> utility</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>execute a spatial query and examine the <cite>.qix</cite> file with the <a class="reference internal" href="shptreetst.html#shptreetst"><span class="std std-ref">shptreetst</span></a> utility</p>
</div>
</section>
<section id="description">
<h2>Description<a class="headerlink" href="#description" title="Link to this heading">¶</a></h2>
<p>This utility is a must for any MapServer application that uses Esri shapefiles.
Shptree creates a spatial index of your shapefile,
using a quadtree method. This means that MapServer will use this
index to quickly find the appropriate shapes to draw. It creates a
file of the same name as your shapefile, with a <em>.qix</em> file
extension. The quadtree method breaks the file into 4 quadrants,
recursively until only a few shapes are contained in each quadrant.
This minimum number can be set with the <depth> parameter of the
command.</p>
</section>
<section id="syntax">
<h2>Syntax<a class="headerlink" href="#syntax" title="Link to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shptree</span> <span class="o"><</span><span class="n">shpfile</span><span class="o">></span> <span class="p">[</span><span class="o"><</span><span class="n">depth</span><span class="o">></span><span class="p">]</span> <span class="p">[</span><span class="o"><</span><span class="n">index_format</span><span class="o">></span><span class="p">]</span>
<span class="n">Where</span><span class="p">:</span>
<span class="o"><</span><span class="n">shpfile</span><span class="o">></span> <span class="ow">is</span> <span class="n">the</span> <span class="n">name</span> <span class="n">of</span> <span class="n">the</span> <span class="o">.</span><span class="n">shp</span> <span class="n">file</span> <span class="n">to</span> <span class="n">index</span><span class="o">.</span>
<span class="o"><</span><span class="n">depth</span><span class="o">></span> <span class="p">(</span><span class="n">optional</span><span class="p">)</span> <span class="ow">is</span> <span class="n">the</span> <span class="n">maximum</span> <span class="n">depth</span> <span class="n">of</span> <span class="n">the</span> <span class="n">inde</span>
<span class="n">to</span> <span class="n">create</span><span class="p">,</span> <span class="n">default</span> <span class="ow">is</span> <span class="mi">0</span> <span class="n">meaning</span> <span class="n">that</span> <span class="n">shptre</span>
<span class="n">will</span> <span class="n">calculate</span> <span class="n">a</span> <span class="n">reasonable</span> <span class="n">default</span> <span class="n">depth</span><span class="o">.</span>
<span class="o"><</span><span class="n">index_format</span><span class="o">></span> <span class="p">(</span><span class="n">optional</span><span class="p">)</span> <span class="ow">is</span> <span class="n">one</span> <span class="n">of</span><span class="p">:</span>
<span class="n">NL</span><span class="p">:</span> <span class="n">LSB</span> <span class="n">byte</span> <span class="n">order</span><span class="p">,</span> <span class="n">using</span> <span class="n">new</span> <span class="n">index</span> <span class="nb">format</span>
<span class="n">NM</span><span class="p">:</span> <span class="n">MSB</span> <span class="n">byte</span> <span class="n">order</span><span class="p">,</span> <span class="n">using</span> <span class="n">new</span> <span class="n">index</span> <span class="nb">format</span>
<span class="n">The</span> <span class="n">following</span> <span class="n">old</span> <span class="nb">format</span> <span class="n">options</span> <span class="n">are</span> <span class="n">deprecated</span>
<span class="n">N</span><span class="p">:</span> <span class="n">Native</span> <span class="n">byte</span> <span class="n">order</span>
<span class="n">L</span><span class="p">:</span> <span class="n">LSB</span> <span class="p">(</span><span class="n">intel</span><span class="p">)</span> <span class="n">byte</span> <span class="n">order</span>
<span class="n">M</span><span class="p">:</span> <span class="n">MSB</span> <span class="n">byte</span> <span class="n">order</span>
<span class="n">The</span> <span class="n">default</span> <span class="n">index_format</span> <span class="n">on</span> <span class="n">this</span> <span class="n">system</span> <span class="ow">is</span><span class="p">:</span> <span class="n">NL</span>
</pre></div>
</div>
<p>Example</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shptree</span> <span class="n">us_states</span><span class="o">.</span><span class="n">shp</span>
<span class="n">creating</span> <span class="n">index</span> <span class="n">of</span> <span class="n">new</span> <span class="n">LSB</span> <span class="nb">format</span>
</pre></div>
</div>
<dl class="simple">
<dt>Result</dt><dd><p>A file named ‘us_states.qix’ is created in the same location. (note
that you can use the shptreevis utility, described next, to view the
actual quadtree quadrants that are used by MapServer in this qix
file)</p>
</dd>
</dl>
</section>
<section id="mapfile-notes">
<h2>Mapfile Notes<a class="headerlink" href="#mapfile-notes" title="Link to this heading">¶</a></h2>
<p>Shapefiles are native to MapServer, and therefore do not require
the <em>.shp</em> extension in the DATA path of the LAYER, but it is always
recommended to specify the extension. For earlier versions of MapServer
(before MapServer 5.2), in order for MapServer to use the <em>.qix</em> extension
you were required to <em>NOT</em> specify the extension, for example:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">DATA</span> <span class="s">"us_states"</span> <span class="c1">#MapServer <5.2 will search for us_states.qix and will use it</span>
<span class="p">...</span>
<span class="k">END</span>
<span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">DATA</span> <span class="s">"us_states.shp"</span> <span class="c1">#MapServer <5.2 will search for us_states.shp.qix and won't find it</span>
<span class="p">...</span>
<span class="k">END</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>As of MapServer 5.2 the <cite>qix</cite> index will be used even when the <cite>.shp</cite> extension is specified</p>
</div>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script><h3>Navigation</h3>
<p>
<a href="../about.html" title="About">About</a><br>
<a href="../products.html" title="Products">Products</a><br>
<a href="../community/index.html" title="Community">Community</a><br>
<a href="../development/index.html" title="Development">Development</a><br>
<a href="../download.html" title="Downloads">Downloads</a><br>
<a href="../documentation.html" title="Documentation">Documentation</a><br>
<a href="../faq.html" title="FAQ">FAQ</a><br>
<a href="../psc.html" title="PSC">PSC</a><br>
<a href="https://fosstodon.org/@mapserver" title="Mastodon">Mastodon</a>
</p>
<h3>Current Table Of Contents</h3>
<ul>
<li><a class="reference internal" href="#">shptree</a><ul>
<li><a class="reference internal" href="#purpose">Purpose</a></li>
<li><a class="reference internal" href="#description">Description</a></li>
<li><a class="reference internal" href="#syntax">Syntax</a></li>
<li><a class="reference internal" href="#mapfile-notes">Mapfile Notes</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="shptreetst.html" title="shptreetst"
>next</a> |</li>
<li class="right" >
<a href="scalebar.html" title="scalebar"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Home</a> »</li>
<li class="nav-item nav-item-1"><a href="../documentation.html" >MapServer 8.6.4 Documentation</a> »</li>
<li class="nav-item nav-item-2"><a href="index.html" >Utilities</a> »</li>
<li class="nav-item nav-item-this"><a href="">shptree</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
© <a href="../copyright.html">Copyright</a> 2026, Open Source Geospatial Foundation.
Last updated on 2026-07-03.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 9.1.0.
</div>
</body>
</html>
You can’t perform that action at this time.
