GeoHelm/app/latest/components/shp2pgsql/index.html

488 lines
23 KiB
HTML
Raw Normal View History

2024-01-27 19:04:46 +00:00
<!DOCTYPE html>
<html lang="en" >
<!-- Mirrored from geohelm.docs.acugis.com/en/latest/components/shp2pgsql/index.html by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 13 Jul 2023 23:22:07 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>shp2pgsql &mdash; AcuGIS GeoHelm 0.4.3 documentation</title>
<!-- AcuGIS 1 -->
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="../../_static/language_data.js"></script>
<script async="async" type="text/javascript" src="../../../../_/static/javascript/readthedocs-doc-embed.js"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="osm2pgsql" href="../osm2pgsql/index.html" />
<link rel="prev" title="PgRouting" href="../pgrouting/index.html" />
<!-- RTD Extra Head -->
<link rel="stylesheet" href="../../../../_/static/css/readthedocs-doc-embed.css" type="text/css" />
<script type="application/json" id="READTHEDOCS_DATA">{"ad_free": false, "api_host": "https://readthedocs.org", "builder": "sphinx", "canonical_url": null, "docroot": "/docs/", "features": {"docsearch_disabled": false}, "global_analytics_code": "UA-17997319-1", "language": "en", "page": "components/shp2pgsql/index", "programming_language": "perl", "project": "geohelm", "proxied_api_host": "/_", "source_suffix": ".rst", "subprojects": {}, "theme": "sphinx_rtd_theme", "user_analytics_code": "", "version": "latest"}</script>
<!--
Using this variable directly instead of using `JSON.parse` is deprecated.
The READTHEDOCS_DATA global variable will be removed in the future.
-->
<script type="text/javascript">
READTHEDOCS_DATA = JSON.parse(document.getElementById('READTHEDOCS_DATA').innerHTML);
</script>
<script type="text/javascript" src="../../../../_/static/javascript/readthedocs-analytics.js" async="async"></script>
<!-- end RTD <extrahead> -->
</head>
<div id="header" style="position: fixed; height: 70px; padding-bottom: 20px; overflow: hidden; background-color: #28728d; display: block; z-index: 1000; width: 100%;">
<div class="acugis_geosuite" style="color:#fff!important; padding-left:30px; font-size:26px; padding-top: 20px;"><a href="https://geohelm.docs.acugis.com/" style="color:#fff!important; text-decoration:none!important">AcuGIS GeoHelm</a></div>
</div>
</div>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div id="header2"> </div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation" style="padding-top: 45px;">
<p class="caption"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Intro</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../installing.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../layout.html">Layout</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../webmin.html">Control Panel</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../webmin.html#removing-the-control-panel">Removing the Control Panel</a></li>
</ul>
<p class="caption"><span class="caption-text">PostGIS</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../createdb/index.html">Create Database</a></li>
<li class="toctree-l1"><a class="reference internal" href="../postgresql/index.html">PostgreSQL</a></li>
<li class="toctree-l1"><a class="reference internal" href="../postgis/index.html">PostGIS</a></li>
<li class="toctree-l1"><a class="reference internal" href="../pgrouting/index.html">PgRouting</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">shp2pgsql</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#shape-loader-tool">Shape Loader Tool</a></li>
<li class="toctree-l2"><a class="reference internal" href="#load-via-shape-file-loader">Load via Shape File Loader</a></li>
<li class="toctree-l2"><a class="reference internal" href="#load-via-comamnd-line">Load via Comamnd Line</a></li>
<li class="toctree-l2"><a class="reference internal" href="#tutorial-load-shp-files">Tutorial: Load shp Files</a></li>
<li class="toctree-l2"><a class="reference internal" href="#troubleshooting">Troubleshooting</a></li>
<li class="toctree-l2"><a class="reference internal" href="#documentation">Documentation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../osm2pgsql/index.html">osm2pgsql</a></li>
<li class="toctree-l1"><a class="reference internal" href="../raster2pgsql/index.html">raster2pgsql</a></li>
</ul>
<p class="caption"><span class="caption-text">GeoServer</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../geoserver/admin/index.html">Access</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../geoserver/geoservers/index.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../geoserver/tomcat/index.html">Apache Tomcat</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../geoserver/workspace/index.html">Create a Workspace</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../geoserver/store/index.html">Create Store</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../geoserver/layer/index.html">Add Layer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../geoserver/shp/index.html">Load ESRI Shapefile</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../geoserver/styles/index.html">Styles</a></li>
</ul>
<p class="caption"><span class="caption-text">pg_tileserv</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../pgtileserv/index.html">pg_tileserv</a></li>
<li class="toctree-l1"><a class="reference internal" href="../pgfeatureserv/index.html">pg_featureserv</a></li>
</ul>
<p class="caption"><span class="caption-text">Database Operations</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../database/snapshot/index.html">Database Snapshots</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../database/clone/index.html">Clone Database</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../database/restore/index.html">Restore Database</a></li>
</ul>
<p class="caption"><span class="caption-text">QGIS</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../qgis/home.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../qgis/pgservice.html">pg_service.conf</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../qgis/qgis.html">Create a QGIS Project</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../qgis/publish.html">Publish Layers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../qgis/style-only.html">Publish Styles Only</a></li>
</ul>
<p class="caption"><span class="caption-text">LeafletJS</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../apps/choropleth.html">Leaflet Choropleth App</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../apps/geojson.html">Leaflet GeoJson</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../apps/php.html">Leaflet and PHP</a></li>
</ul>
<p class="caption"><span class="caption-text">Resources</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../resources/documents.html">Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../resources/css.html">CSS</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../resources/security.html">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../resources/nagios.html">Nagios</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../resources/support.html">Project Support</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../resources/commercial.html">Commercial Support</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../resources/license.html">License</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index-2.html">AcuGIS GeoHelm</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index-2.html" class="icon icon-home"></a> &raquo;</li>
<li>shp2pgsql</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/AcuGIS/GeoHelm/blob/master/docs/components/shp2pgsql/index.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="shp2pgsql">
<h1><a class="toc-backref" href="#id1">shp2pgsql</a><a class="headerlink" href="#shp2pgsql" title="Permalink to this headline"></a></h1>
<div class="contents topic" id="table-of-contents">
<p class="topic-title">Table of Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#shp2pgsql" id="id1">shp2pgsql</a><ul>
<li><a class="reference internal" href="#shape-loader-tool" id="id2">Shape Loader Tool</a></li>
<li><a class="reference internal" href="#load-via-shape-file-loader" id="id3">Load via Shape File Loader</a></li>
<li><a class="reference internal" href="#load-via-comamnd-line" id="id4">Load via Comamnd Line</a></li>
<li><a class="reference internal" href="#tutorial-load-shp-files" id="id5">Tutorial: Load shp Files</a></li>
<li><a class="reference internal" href="#troubleshooting" id="id6">Troubleshooting</a></li>
<li><a class="reference internal" href="#documentation" id="id7">Documentation</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="shape-loader-tool">
<h2><a class="toc-backref" href="#id2">Shape Loader Tool</a><a class="headerlink" href="#shape-loader-tool" title="Permalink to this headline"></a></h2>
<p>An included shp2pgsql tool is available if you installed Webmin.</p>
<p>There are 2 options for loading ESRI Shape files:</p>
<ol class="arabic simple">
<li>Load using the Shape File Loader.</li>
<li>Load using command line.</li>
</ol>
</div>
<div class="section" id="load-via-shape-file-loader">
<h2><a class="toc-backref" href="#id3">Load via Shape File Loader</a><a class="headerlink" href="#load-via-shape-file-loader" title="Permalink to this headline"></a></h2>
<p>Click the Shape File Loader tab as shown below</p>
<img alt="../../_images/shp2pgsql-tab.png" src="../../_images/shp2pgsql-tab.png" />
<img alt="../../_images/spacer5.png" src="../../_images/spacer5.png" />
<p>The load options are displayed below.</p>
<img alt="../../_images/shape-loader.png" src="../../_images/shape-loader.png" />
<img alt="../../_images/spacer5.png" src="../../_images/spacer5.png" />
<p>Also select if load will be into a new Schema and, in the case of New Table creation, the table name to be created.</p>
<p><strong>Load Options</strong></p>
<p>Database: select the database you wish to load the shape file to.</p>
<p>Load Type: Create, Drop, Append, or Prepare</p>
<p>Set SRID: Defaults to 0 if not set</p>
<p>Database Username: Select the user who will own the data</p>
<p>Schema: Select an existing schema or create a new schema.</p>
<p>Table: Select an existing table or create new one</p>
<p>Shape File Source: Local, Upload, or FTP/HTTP</p>
</div>
<div class="section" id="load-via-comamnd-line">
<h2><a class="toc-backref" href="#id4">Load via Comamnd Line</a><a class="headerlink" href="#load-via-comamnd-line" title="Permalink to this headline"></a></h2>
<p>Usage</p>
<p>shp2pgsql usage can be found using the shp2pgsl command.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go"> root@postgis:~# shp2pgsql</span>
<span class="go"> RELEASE: 2.3.2 (r15302)</span>
<span class="go"> USAGE: shp2pgsql [&lt;options&gt;] &lt;shapefile&gt; [[&lt;schema&gt;.]&lt;table&gt;]</span>
<span class="go"> OPTIONS:</span>
<span class="go"> -s [&lt;from&gt;:]&lt;srid&gt; Set the SRID field. Defaults to 0.</span>
<span class="go"> Optionally reprojects from given SRID (cannot be used with -D).</span>
<span class="go"> (-d|a|c|p) These are mutually exclusive options:</span>
<span class="go"> -d Drops the table, then recreates it and populates</span>
<span class="go"> it with current shape file data.</span>
<span class="go"> -a Appends shape file into current table, must be</span>
<span class="go"> exactly the same table schema.</span>
<span class="go"> -c Creates a new table and populates it, this is the</span>
<span class="go"> default if you do not specify any options.</span>
<span class="go"> -p Prepare mode, only creates the table.</span>
<span class="go"> -g &lt;geocolumn&gt; Specify the name of the geometry/geography column</span>
<span class="go"> (mostly useful in append mode).</span>
<span class="go">-D Use postgresql dump format (defaults to SQL insert statements).</span>
<span class="go">-e Execute each statement individually, do not use a transaction.</span>
<span class="go"> Not compatible with -D.</span>
<span class="go">-G Use geography type (requires lon/lat data or -s to reproject).</span>
<span class="go">-k Keep postgresql identifiers case.</span>
<span class="go">-i Use int4 type for all integer dbf fields.</span>
<span class="go">-I Create a spatial index on the geocolumn.</span>
<span class="go">-m &lt;filename&gt; Specify a file containing a set of mappings of (long) column</span>
<span class="go"> names to 10 character DBF column names. The content of the file is one or</span>
<span class="go"> more lines of two names separated by white space and no trailing or</span>
<span class="go"> leading space. For example:</span>
<span class="go"> COLUMNNAME DBFFIELD1</span>
<span class="go"> AVERYLONGCOLUMNNAME DBFFIELD2</span>
<span class="go">-S Generate simple geometries instead of MULTI geometries.</span>
<span class="go">-t &lt;dimensionality&gt; Force geometry to be one of &#39;2D&#39;, &#39;3DZ&#39;, &#39;3DM&#39;, or &#39;4D&#39;</span>
<span class="go">-w Output WKT instead of WKB. Note that this can result in</span>
<span class="go"> coordinate drift.</span>
<span class="go">-W &lt;encoding&gt; Specify the character encoding of Shape&#39;s</span>
<span class="go"> attribute column. (default: &quot;UTF-8&quot;)</span>
<span class="go">-N &lt;policy&gt; NULL geometries handling policy (insert*,skip,abort).</span>
<span class="go">-n Only import DBF file.</span>
<span class="go">-T &lt;tablespace&gt; Specify the tablespace for the new table.</span>
<span class="go"> Note that indexes will still use the default tablespace unless the</span>
<span class="go"> -X flag is also used.</span>
<span class="go">-X &lt;tablespace&gt; Specify the tablespace for the table&#39;s indexes.</span>
<span class="go"> This applies to the primary key, and the spatial index if</span>
<span class="go"> the -I flag is used.</span>
<span class="go">-? Display this help screen.</span>
<span class="go">An argument of `--&#39; disables further option processing.</span>
<span class="gp gp-VirtualEnv">(useful for unusual file names starting with &#39;-&#39;)</span>
</pre></div>
</div>
</div>
<div class="section" id="tutorial-load-shp-files">
<h2><a class="toc-backref" href="#id5">Tutorial: Load shp Files</a><a class="headerlink" href="#tutorial-load-shp-files" title="Permalink to this headline"></a></h2>
<p>GeoSuite comes with 3 shp files, park.zip, waterways.zip, and neighborhoods.zip.</p>
<p>Well load the neighborhoods shp file below. The proceedure is the same for all three files.</p>
<p><strong>1. Go to PostGIS &gt; shp2pgsql</strong></p>
<img alt="../../_images/1-postgis-load-shp2pgsql.png" src="../../_images/1-postgis-load-shp2pgsql.png" />
<img alt="../../_images/spacer5.png" src="../../_images/spacer5.png" />
<p>As shown below -</p>
<p><strong>2. Select postgisftw as the target database</strong></p>
<p></p>
<p><strong>3. Leave load type as default (Create new table)</strong></p>
<p></p>
<p><strong>4. IMPORTANT: Set the SRID to 4326. pg_tileserv and pg_featursrv require a declared SRID.</strong></p>
<p></p>
<p><strong>5. Set database user as pgis</strong></p>
<p></p>
<p><strong>6. For table name, enter neighborhoods</strong></p>
<p></p>
<img alt="../../_images/2-load.png" src="../../_images/2-load.png" />
<img alt="../../_images/spacer5.png" src="../../_images/spacer5.png" />
<p><strong>7. For shp source file, select “local file” and click the file explorer button. Navigate to /opt/data and select the neighborhoods.zip file.</strong>
</p>
<img alt="../../_images/3-load.png" src="../../_images/3-load.png" />
<img alt="../../_images/spacer5.png" src="../../_images/spacer5.png" />
<p><strong>8. Accept all othe configuration defaults and click the Load button</strong>
</p>
<img alt="../../_images/4-load.png" src="../../_images/4-load.png" />
<img alt="../../_images/spacer5.png" src="../../_images/spacer5.png" />
<p>When file has been loaded, output will be displayed as below.</p>
<img alt="../../_images/spacer5.png" src="../../_images/spacer5.png" />
<p>The output also displays the command line used to load the data:</p>
<img alt="../../_images/5-load.png" src="../../_images/5-load.png" />
<img alt="../../_images/spacer5.png" src="../../_images/spacer5.png" />
</div>
<div class="section" id="troubleshooting">
<h2><a class="toc-backref" href="#id6">Troubleshooting</a><a class="headerlink" href="#troubleshooting" title="Permalink to this headline"></a></h2>
<p>If the above commands produce shp2pgsql command not found, do the following:</p>
<p>On Ubuntu:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">apt install postgis</span>
</pre></div>
</div>
<p>On CentOS</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">yum install postgis3_utils</span>
</pre></div>
</div>
</div>
<div class="section" id="documentation">
<h2><a class="toc-backref" href="#id7">Documentation</a><a class="headerlink" href="#documentation" title="Permalink to this headline"></a></h2>
<p>Below are resources to get started with ogr2ogr and gdal_translate:</p>
<ul class="simple">
<li><a class="reference external" href="https://postgis.net/docs/using_postgis_dbmanagement.html#shp2pgsql_usage">Refractions Documentation</a></li>
<li><a class="reference external" href="http://www.bostongis.com/pgsql2shp_shp2pgsql_quickguide.bqg">Boston GIS Cheatsheet</a></li>
</ul>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="../osm2pgsql/index.html" class="btn btn-neutral float-right" title="osm2pgsql" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="../pgrouting/index.html" class="btn btn-neutral float-left" title="PgRouting" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright acugis
<span class="commit">
Revision <code>db2a027e</code>.
</span>
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org/">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book"> Read the Docs</span>
v: latest
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<dl>
<dt>Versions</dt>
<dd><a href="../../index.html">latest</a></dd>
</dl>
<dl>
<dt>Downloads</dt>
<dd><a href="http://geohelm.docs.acugis.com/_/downloads/en/latest/pdf/">pdf</a></dd>
<dd><a href="http://geohelm.docs.acugis.com/_/downloads/en/latest/htmlzip/">html</a></dd>
<dd><a href="http://geohelm.docs.acugis.com/_/downloads/en/latest/epub/">epub</a></dd>
</dl>
<dl>
<dt>On Read the Docs</dt>
<dd>
<a href="http://readthedocs.org/projects/geohelm/?fromdocs=geohelm">Project Home</a>
</dd>
<dd>
<a href="http://readthedocs.org/builds/geohelm/?fromdocs=geohelm">Builds</a>
</dd>
</dl>
</div>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
<!-- Mirrored from geohelm.docs.acugis.com/en/latest/components/shp2pgsql/index.html by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 13 Jul 2023 23:22:10 GMT -->
</html>