<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Generating SQL Geometry on the Fly in View or Query Layer in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564385#M32006</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was able to create the Geometry in a view as shown below and then use it as a Query Layer in ArcMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Select [BlueStakeWOId], Geometry::STPointFromText('POINT (' + CAST([Longitude] as varchar(32)) + ' ' + CAST([Latitude] as varchar(32)) + ')', 4326) as shape&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from DBSVR.WaterWO.gis.OpenTickets&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are only about 130 points in this table, so I will have to try with larger datasets and see how it performs&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mele&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Nov 2013 19:33:15 GMT</pubDate>
    <dc:creator>MeleKoneya</dc:creator>
    <dc:date>2013-11-22T19:33:15Z</dc:date>
    <item>
      <title>Generating SQL Geometry on the Fly in View or Query Layer</title>
      <link>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564381#M32002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was watching an ESRI video called "Web Enabling Databases with ArcGIS for Server" and I thought I heard them say that SQL Geomety could be created on the fly in a view or in ESRI terms with a Query Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a couple of SQL tables that have LAT/LONG and I would like to used this information to create SQL geometry for each row rather than creating an event theme from the LAT/LONG values.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Due to restrictions on the database table,&amp;nbsp;&amp;nbsp; I am not able to add a Geomtry field to the table itself so I thought I would try to do it via a view/query layer and bring it into ArcMap that way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have not been able to find any examples of doing this.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if this is possible and more importantly,&amp;nbsp; if there are some examples of doing so.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mele&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 15:05:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564381#M32002</guid>
      <dc:creator>MeleKoneya</dc:creator>
      <dc:date>2013-11-22T15:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Generating SQL Geometry on the Fly in View or Query Layer</title>
      <link>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564382#M32003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The principal problem with creating features on the fly is the inability to use a spatial index.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The draw performance is usually sufficiently awful that you'll be willing to jump through the&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;hoops necessary to have geometries added to the base table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that "Query Layer" is not an Esri term for a view.&amp;nbsp; Query Layers are queries on existing&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;objects, be they tables &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;or&lt;/SPAN&gt;&lt;SPAN&gt; views.&amp;nbsp; If you can construct a view which returns points from&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the lon/lat values, then you can make a Query Layer which queries it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want help with the view construction, you'd have to specify what database you're using&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(product, version, and sub-release), along with details on your ArcGIS version (including.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;service pack) and s full description of the table (and your preferred rowid integer column).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- V&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 15:36:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564382#M32003</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2013-11-22T15:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Generating SQL Geometry on the Fly in View or Query Layer</title>
      <link>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564383#M32004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Vince for the information and clarification of terms.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to give it a try and compare the performance to that of an event theme as I am not sure that our agency is ready to change out tables to add SQL geometry.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using SQL 2008 R2 SP2 with ArcGIS 10.1 SP1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The existing SQL table contains the following fields&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]29289[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I appreciate any further assistance you can provide.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mele&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 16:01:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564383#M32004</guid>
      <dc:creator>MeleKoneya</dc:creator>
      <dc:date>2013-11-22T16:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Generating SQL Geometry on the Fly in View or Query Layer</title>
      <link>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564384#M32005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I was watching an ESRI video called "Web Enabling Databases with ArcGIS for Server" and I thought I heard them say that SQL Geomety could be created on the fly in a view or in ESRI terms with a Query Layer.&lt;BR /&gt;...&lt;BR /&gt;Let me know if this is possible and more importantly,&amp;nbsp; if there are some examples of doing so.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, it is possible. I have recently been testing this on a SQL Server Express 2012 geodatabase using the &lt;/SPAN&gt;&lt;STRONG&gt;Shape.STCentroid()&lt;/STRONG&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;STRONG&gt;Shape.STConvexHull()&lt;/STRONG&gt;&lt;SPAN&gt; statements to dynamically generate derived shapes in a custom SQL Server view (Please note these specific commands imply already existing shapes present in another layer, they do however create new features "on the fly").&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I used the following statements for defining the database views in SQL Server Management Studio:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;SELECT OBJECTID, Shape.STConvexHull() AS ShpConvexHull
FROM [YOURCOMPUTERNAME\YOURDATABASENAME].YOURLAYERNAME&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;SELECT OBJECTID, Shape.STCentroid() AS ShpCentroid
FROM [YOURCOMPUTERNAME\YOURDATABASENAME].YOURLAYERNAME&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please note the &lt;/SPAN&gt;&lt;STRONG&gt;[YOURCOMPUTERNAME\YOURDATABASENAME]&lt;/STRONG&gt;&lt;SPAN&gt; part is a bit depended on your SQL Server configuration. It should be auto-generated for you once you create a new view in SQL Server and choose the table that serves as the basis. The &lt;/SPAN&gt;&lt;STRONG&gt;ShpConvexHull&lt;/STRONG&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;STRONG&gt;ShpCentroid&lt;/STRONG&gt;&lt;SPAN&gt; are just arbitrary names I defined for the new shape fields, you can name them anything you like.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The principal problem with creating features on the fly is the inability to use a spatial index.&lt;BR /&gt;&lt;STRONG&gt;The draw performance is usually sufficiently awful that you'll be willing to jump through the&lt;BR /&gt;hoops necessary to have geometries added to the base table.&lt;/STRONG&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Depends on what the purpose is and how big the original layer. I did a test based on an un-generalized height contour layer based on a 8x8 meter DEM. It contained 10270 feature records. Creating a view with &lt;/SPAN&gt;&lt;STRONG&gt;Shape.STConvexHull()&lt;/STRONG&gt;&lt;SPAN&gt; statement, resulted in draw times of a few seconds for the entire layer in ArcMap. Not to bad, considering a kind of "worst case" scenario using an un-generalized height contours layer. Of course, with millions of records, it is probably a different story...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This was on a quad core &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;desktop&lt;/SPAN&gt;&lt;SPAN&gt; Core i5-2320 3.00 GHz with 6 GB RAM...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:19:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564384#M32005</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2021-12-12T00:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Generating SQL Geometry on the Fly in View or Query Layer</title>
      <link>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564385#M32006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was able to create the Geometry in a view as shown below and then use it as a Query Layer in ArcMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Select [BlueStakeWOId], Geometry::STPointFromText('POINT (' + CAST([Longitude] as varchar(32)) + ' ' + CAST([Latitude] as varchar(32)) + ')', 4326) as shape&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from DBSVR.WaterWO.gis.OpenTickets&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are only about 130 points in this table, so I will have to try with larger datasets and see how it performs&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mele&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 19:33:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564385#M32006</guid>
      <dc:creator>MeleKoneya</dc:creator>
      <dc:date>2013-11-22T19:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Generating SQL Geometry on the Fly in View or Query Layer</title>
      <link>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564386#M32007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The geometry::Point constructor is likely to be much more efficient than casting to get&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WKT formatted text.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's difficult to make 10k rows render slowly, but easy with 100k rows, and trivial with 1m.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- V&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 23:09:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564386#M32007</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2013-11-22T23:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Generating SQL Geometry on the Fly in View or Query Layer</title>
      <link>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564387#M32008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;It's difficult to make 10k rows render slowly, but easy with 100k rows, and trivial with 1m.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just did another small test based on OpenStreetMap data. The original line layer with &lt;/SPAN&gt;&lt;STRONG&gt;61188&lt;/STRONG&gt;&lt;SPAN&gt; records stored in SQL Server &lt;/SPAN&gt;&lt;STRONG&gt;Geometry&lt;/STRONG&gt;&lt;SPAN&gt;, draws in less than 2 seconds in ArcMap at full extent.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A dynamic SQL view based on this layer though, using the &lt;/SPAN&gt;&lt;STRONG&gt;Shape.STBuffer()&lt;/STRONG&gt;&lt;SPAN&gt; command, takes &lt;/SPAN&gt;&lt;STRONG&gt;75&lt;/STRONG&gt;&lt;SPAN&gt; seconds to draw at full extent. &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Unsurprisingly&lt;/SPAN&gt;&lt;SPAN&gt;, this confirms your remarks. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The lack of spatial index and associated full table scans, also means that zooming in on a part (e.g. 1/10th), still requires some 45 seconds to render. Making a selection of all features in that same section, takes 60 seconds...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I guess an upper limit of about 10k records, is realistic for this kind of operation &lt;/SPAN&gt;&lt;STRONG&gt;where SQL geometry is generated on the fly&lt;/STRONG&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;please note this is not similar to a "normal" spatial view, where you just make a selection of existing shapes in a database view, and an existing spatial index on the original table can be used&lt;/SPAN&gt;&lt;SPAN&gt;). Anything above that will be useless (Core i5 3 GHz).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I now also exported the generated buffers to a polygon Feature Class in the same database. That layer draws in just &lt;/SPAN&gt;&lt;STRONG&gt;4-5&lt;/STRONG&gt;&lt;SPAN&gt; seconds...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Nov 2013 11:04:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/generating-sql-geometry-on-the-fly-in-view-or/m-p/564387#M32008</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2013-11-23T11:04:37Z</dc:date>
    </item>
  </channel>
</rss>

