<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Working with spatial objects in tables</title>
    <link>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/</link>
    <description>Recent content in Working with spatial objects in tables on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Data-Analysis: Defining table columns for spatial data</title>
      <link>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/defining-table-columns-spatial-data/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/defining-table-columns-spatial-data/</guid>
      <description>
        
        
        &lt;p&gt;To define columns to contain GEOMETRY and GEOGRAPHY data, use this command:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE [[db-name.]schema.]table-name (
   column-name GEOMETRY[(length)],
   column-name GEOGRAPHY[(length)]);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you omit the length specification, the default column size is 1 MB. The maximum column size is 10 MB. The upper limit is not enforced, but the geospatial functions can only accept or return spatial data up to 10 MB.&lt;/p&gt;
&lt;p&gt;You cannot modify the size or data type of a GEOMETRY or GEOGRAPHY column after creation. If the column size you created is not sufficient, create a new column with the desired size. Then copy the data from the old column, and drop the old column from the table.&lt;/p&gt;
&lt;p&gt;You cannot import data to or export data from tables that contain spatial data from another database.

&lt;div class=&#34;admonition important&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Important&lt;/h4&gt;
A column width that is too large could impact performance. Use a column width that fits the data without being excessively large. See &lt;a href=&#34;../../../../en/sql-reference/functions/geospatial-functions/stv-memsize/#&#34;&gt;STV_MemSize&lt;/a&gt;.
&lt;/div&gt;&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Exporting spatial data from a table</title>
      <link>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/exporting-spatial-data-from-table/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/exporting-spatial-data-from-table/</guid>
      <description>
        
        
        &lt;p&gt;You can export spatial data from a table in your database to a shapefile.&lt;/p&gt;
&lt;p&gt;To export spatial data from a table to a shapefile:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;As the &lt;a class=&#34;glosslink&#34; href=&#34;../../../../en/glossary/db-superuser/&#34; title=&#34;&#34;&gt;superuser&lt;/a&gt;., set the shapefile export directory.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT STV_SetExportShapefileDirectory(USING PARAMETERS path = &amp;#39;/home/geo/temp&amp;#39;);
               STV_SetExportShapefileDirectory
------------------------------------------------------------
 SUCCESS. Set shapefile export directory: [/home/geo/temp]
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Export your spatial data to a shapefile.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT STV_Export2Shapefile(*
              USING PARAMETERS shapefile = &amp;#39;visualizations/city-data.shp&amp;#39;,
                            shape = &amp;#39;Polygon&amp;#39;) OVER() FROM spatial_data;
 Rows Exported |                          File Path
---------------+----------------------------------------------------------------
       185873 | v_geo-db_node0001: /home/geo/temp/visualizations/city-data.shp
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The value asterisk (*) is the equivalent to listing all columns in the FROM clause.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can specify sub-directories when exporting your shapefile.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Your shapefile must end with the file extension .shp.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Verify that three files now appear in the shapefile export directory.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ ls
city-data.dbf  city-data.shp   city-data.shx
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;

      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Identifying null spatial objects</title>
      <link>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/identifying-null-spatial-objects/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/identifying-null-spatial-objects/</guid>
      <description>
        
        
        &lt;p&gt;You can identify null GEOMETRY and GEOGRAPHY objects using the IS NULL and IS NOT NULL constructs.&lt;/p&gt;
&lt;p&gt;This example uses the following table, where the row with &lt;code&gt;id&lt;/code&gt;=2 has a null value in the &lt;code&gt;geog&lt;/code&gt; field.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT id, ST_AsText(geom), ST_AsText(geog) FROM locations
   ORDER BY 1 ASC;
 id |           ST_AsText              |                 ST_AsText
----+----------------------------------+--------------------------------------
  1 | POINT (2 3)                      | POINT (-85 15)
  2 | POINT (4 5)                      |
  3 | POLYGON ((-1 2, 0 3, 1 2, -1 2)) | POLYGON ((-24 12, -15 23, -20 27, -24 12))
  4 | LINESTRING (-1 2, 1 5)           | LINESTRING (-42.74 23.98, -62.19 23.78)
(4 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Identify all the rows that have a null &lt;code&gt;geog&lt;/code&gt; value:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT id, ST_AsText(geom), (ST_AsText(geog) IS NULL) FROM locations
   ORDER BY 1 ASC;
 id |            ST_AsText             | ?column?
----+----------------------------------+----------
  1 | POINT (2 3)                      | f
  2 | POINT (4 5)                      | t
  3 | POLYGON ((-1 2, 0 3, 1 2, -1 2)) | f
  4 | LINESTRING (-1 2, 1 5)           | f
(4 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Identify the rows where the &lt;code&gt;geog&lt;/code&gt; value is not null:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT id, ST_AsText(geom), (ST_AsText(geog) IS NOT NULL) FROM locations
   ORDER BY 1 ASC;
 id |            st_astext             | ?column?
----+----------------------------------+----------
  1 | POINT (2 3)                      | t
  2 | POINT (4 5)                      | f
  3 | LINESTRING (-1 2, 1 5)           | t
  4 | POLYGON ((-1 2, 0 3, 1 2, -1 2)) | t
(4 rows)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Loading spatial data from shapefiles</title>
      <link>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/loading-spatial-data-from-shapefiles/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/loading-spatial-data-from-shapefiles/</guid>
      <description>
        
        
        &lt;p&gt;OpenText™ Analytics Database provides the capability to load and parse spatial data that is stored in shapefiles. Shapefiles describe points, lines, and polygons. A shapefile is made up of three required files; all three files must be present and in the same directory to define the geometries:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;.shp—Contains the geometry data.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;.shx—Contains the positional index of the geometry.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;.dbf—Contains the attributes for each geometry.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To load spatial data from a shapefile:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Use STV_ShpCreateTable to generate a CREATE TABLE statement.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT STV_ShpCreateTable ( USING PARAMETERS file = &amp;#39;/home/geo/temp/shp-files/spatial_data.shp&amp;#39;)
                               OVER() AS spatial_data;
           spatial_data
----------------------------------
 CREATE TABLE spatial_data(
   gid IDENTITY(64) PRIMARY KEY,
   uniq_id INT8,
   geom GEOMETRY(85)
);
(5 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create the table.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE spatial_data(
   gid IDENTITY(64) PRIMARY KEY,
   uniq_id INT8,
   geom GEOMETRY(85));
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Load the shapefile.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; COPY spatial_data WITH SOURCE STV_ShpSource(file=&amp;#39;/home/geo/temp/shp-files/spatial_data.shp&amp;#39;)
    PARSER STV_ShpParser();
 Rows Loaded
-------------
          10
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;supported-shapefile-shape-types&#34;&gt;Supported shapefile shape types&lt;/h2&gt;
&lt;p&gt;The following table lists the shapefile shape types that OpenText™ Analytics Database supports.

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;
Shapefile Shape Type&lt;/th&gt; 

&lt;th &gt;
Supported&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Null shape&lt;/td&gt; 

&lt;td &gt;
Yes&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Point&lt;/td&gt; 

&lt;td &gt;
Yes&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Polyline&lt;/td&gt; 

&lt;td &gt;
Yes&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Polygon&lt;/td&gt; 

&lt;td &gt;
Yes&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
MultiPoint&lt;/td&gt; 

&lt;td &gt;
Yes&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
PointZ&lt;/td&gt; 

&lt;td &gt;
No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


PolylineZ&lt;/td&gt; 

&lt;td &gt;
No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


PolygonZ&lt;/td&gt; 

&lt;td &gt;
No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


MultiPointZ&lt;/td&gt; 

&lt;td &gt;
No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


PointM&lt;/td&gt; 

&lt;td &gt;
No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


PolylineM&lt;/td&gt; 

&lt;td &gt;
No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


PolygonM&lt;/td&gt; 

&lt;td &gt;
No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
MultiPointM&lt;/td&gt; 

&lt;td &gt;
No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
MultiPatch&lt;/td&gt; 

&lt;td &gt;
No&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Loading spatial data into tables using COPY</title>
      <link>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/loading-spatial-data-into-tables-using-copy/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/loading-spatial-data-into-tables-using-copy/</guid>
      <description>
        
        
        &lt;p&gt;You can load spatial data into a table in the database using a COPY statement. Perform the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create a table.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE spatial_data (id INTEGER, geom GEOMETRY(200));
CREATE TABLE
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a text file named &lt;code&gt;spatial.dat&lt;/code&gt; with the following data.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;1|POINT(2 3)
2|LINESTRING(-1 2, 1 5)
3|POLYGON((-1 2, 0 3, 1 2, -1 2))
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use COPY to load the data into the table.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; COPY spatial_data (id, gx FILLER LONG VARCHAR(605), geom AS ST_GeomFromText(gx)) FROM LOCAL &amp;#39;spatial.dat&amp;#39;;
 Rows Loaded
-------------
           3
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The statement specifies a LONG VARCHAR(32000000) filler, which is the maximum size of WKT. You must specify a filler value large enough to hold the largest WKT you want to insert into the table.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Retrieving spatial data from a table as well-known text (WKT)</title>
      <link>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/retrieving-spatial-data-from-table-as-well-known-text-wkt/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/retrieving-spatial-data-from-table-as-well-known-text-wkt/</guid>
      <description>
        
        
        &lt;p&gt;GEOMETRY and GEOGRAPHY data is stored in database tables as LONG VARBINARY, which isn&#39;t human readable. You can use &lt;a href=&#34;../../../../en/sql-reference/functions/geospatial-functions/st-astext/#&#34;&gt;ST_AsText&lt;/a&gt; to return the spatial data as Well-Known Text (WKT).&lt;/p&gt;
&lt;p&gt;To return spatial data as WKT:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT id, ST_AsText(geom) AS WKT FROM spatial_data;
 id |               WKT
----+----------------------------------
  1 | POINT (2 3)
  2 | LINESTRING (-1 2, 1 5)
  3 | POLYGON ((-1 2, 0 3, 1 2, -1 2))
(3 rows)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Working with GeoHash data</title>
      <link>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/working-with-geohash-data/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/working-with-geohash-data/</guid>
      <description>
        
        
        &lt;p&gt;OpenText™ Analytics Database supports &lt;a href=&#34;http://geohash.org/site/tips.html&#34;&gt;GeoHashes&lt;/a&gt;. A GeoHash is a geocoding system for hierarchically encoding increasingly granular spatial references. Each additional character in a GeoHash drills down to a smaller section of a map.&lt;/p&gt;
&lt;p&gt;You can use the database to generate spatial data from GeoHashes and GeoHashes from spatial data. The following functions are supported for use with GeoHashes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/geospatial-functions/st-geohash/#&#34;&gt;ST_GeoHash&lt;/a&gt; - Returns a GeoHash in the shape of the specified geometry.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/geospatial-functions/st-geomfromgeohash/#&#34;&gt;ST_GeomFromGeoHash&lt;/a&gt; - Returns a polygon in the shape of the specified GeoHash.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/geospatial-functions/st-pointfromgeohash/#&#34;&gt;ST_PointFromGeoHash&lt;/a&gt; - Returns the center point of the specified GeoHash.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, to generate a full precision and partial precision GeoHash from a single point.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ST_GeoHash(ST_GeographyFromText(&amp;#39;POINT(3.14 -1.34)&amp;#39;)), LENGTH(ST_GeoHash(ST_GeographyFromText(&amp;#39;POINT(3.14 -1.34)&amp;#39;))),
                     ST_GeoHash(ST_GeographyFromText(&amp;#39;POINT(3.14 -1.34)&amp;#39;) USING PARAMETERS numchars=5) partial_hash;
      ST_GeoHash      | LENGTH | partial_hash
----------------------+--------+--------------
 kpf0rkn3zmcswks75010 |     20 | kpf0r
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This example shows how to generate a GeoHash from a multipoint point object. The returned polygon is a geometry object of the smallest tile that encloses that GeoHash.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ST_AsText(ST_GeomFromGeoHash(ST_GeoHash(ST_GeomFromText(&amp;#39;MULTIPOINT(0 0, 0.0002 0.0001)&amp;#39;)))) AS region_1,
                    ST_AsText(ST_GeomFromGeoHash(ST_GeoHash(ST_GeomFromText(&amp;#39;MULTIPOINT(0.0001 0.0001, 0.0003 0.0002)&amp;#39;)))) AS region_2;
 -[ RECORD 1 ]---------------------------------------------------------------------------------------------
    region_1 | POLYGON ((0 0, 0.00137329101562 0, 0.00137329101562 0.00137329101562, 0 0.00137329101562, 0 0))
    region_2 | POLYGON ((0 0, 0.010986328125 0, 0.010986328125 0.0054931640625, 0 0.0054931640625, 0 0))
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Spatial joins with ST_Intersects and STV_Intersect</title>
      <link>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/spatial-joins-with-st-intersects-and-stv-intersect/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/geospatial-analytics/working-with-spatial-objects-tables/spatial-joins-with-st-intersects-and-stv-intersect/</guid>
      <description>
        
        
        &lt;p&gt;Spatial joins allow you to identify spatial relationships between two sets of spatial data. For example, you can use spatial joins to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Calculate the density of mobile calls in various regions to determine the location of a new cell phone tower.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Identify homes that fall within the impact zone of a hurricane.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Calculate the number of users who live within a certain ZIP code.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Calculate the number of customers in a retail store at any given time.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
  </channel>
</rss>
