<?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 Generate grid line features using SQL in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/generate-grid-line-features-using-sql/m-p/1182860#M33342</link>
    <description>&lt;DIV class=""&gt;&lt;P&gt;&lt;EM&gt;Oracle 18c:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Using an SQL query, I want to generate&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/Lattice_graph" target="_blank" rel="nofollow noopener noreferrer"&gt;square grid graph&lt;/A&gt;&amp;nbsp;features:&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_0-1655423673438.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43679iD7EFC41019AB3676/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bud_0-1655423673438.png" alt="Bud_0-1655423673438.png" /&gt;&lt;/span&gt;&lt;P&gt;&lt;BR /&gt;The underlying vertices would look like this:&lt;/P&gt;&lt;PRE&gt;STARTPOINT_X STARTPOINT_Y ENDPOINT_X ENDPOINT_Y      SHAPE
&lt;SPAN class=""&gt;------------ ------------ ---------- ---------- ----------&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;1&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;    [SHAPE]     &lt;SPAN class=""&gt;--horizontal lines&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;1&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;2&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;2&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;3&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;3&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;4&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;4&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;5&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;5&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;6&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0    [SHAPE]&lt;/SPAN&gt;
         ...
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;1    [SHAPE]     &lt;/SPAN&gt; &lt;SPAN class=""&gt;--vertical lines&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;1&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;2    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;2&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;3    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;3&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;4    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;4&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;5    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;5&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;6    [SHAPE]&lt;/SPAN&gt;
         ...
[&lt;SPAN class=""&gt;220&lt;/SPAN&gt; &lt;SPAN class=""&gt;rows&lt;/SPAN&gt; selected]&lt;/PRE&gt;&lt;HR /&gt;&lt;P&gt;Details:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The lines would be split at each intersection. So, in the image above, there are 220 lines. Each line is composed of two vertices.&lt;/LI&gt;&lt;LI&gt;Ideally, I would have the option of specifying in the query what the overall grid dimensions would be. For example, specify this somewhere in the SQL:&lt;SPAN&gt;&amp;nbsp;DIMENSIONS = 10 x 10&amp;nbsp;(or&amp;nbsp;DIMENSIONS = 100 x 100, etc.).&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;To keep things simple, we can:&lt;UL&gt;&lt;LI&gt;Assume the grid's overall shape will always be a square (length = width).&lt;/LI&gt;&lt;LI&gt;For the purpose of this question, we can make the cell size&amp;nbsp;1 unit.&lt;/LI&gt;&lt;LI&gt;And the grid can start at 0,0 and be built &lt;EM&gt;"up and right"&lt;/EM&gt; (to the northeast).&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;I've supplied&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sample data&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in this&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://dbfiddle.uk/?rdbms=oracle_18&amp;amp;fiddle=01eb6652a33664d0565546d5b88352ea" target="_blank" rel="nofollow noopener noreferrer"&gt;db&amp;lt;&amp;gt;fiddle&lt;/A&gt;&amp;nbsp;(non-spatial XY coordinates). I created that data using Excel.&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;Hint: The vertical grid lines start at row 111.&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;HR /&gt;&lt;P&gt;The reason I want to generate this data is:&lt;/P&gt;&lt;P&gt;I want sample line data to work with when testing Oracle Spatial queries. Sometimes I need a few hundred lines. Other times, I need thousands of lines. And I need to share the data online via &lt;A href="https://dbfiddle.uk" target="_blank" rel="noopener"&gt;https://dbfiddle.uk&lt;/A&gt;, so I can't use real/proprietary GIS data.&lt;/P&gt;&lt;P&gt;Also, if the lines are in a grid pattern, then it will be obvious if any lines are missing in my analysis results (by looking for gaps in the data in a map).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm aware that there are ways to do this with ArcGIS tools. In this case, I want to do it using SQL.&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;How can I generate those grid lines using Oracle SQL?&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 17 Jun 2022 02:08:16 GMT</pubDate>
    <dc:creator>Bud</dc:creator>
    <dc:date>2022-06-17T02:08:16Z</dc:date>
    <item>
      <title>Generate grid line features using SQL</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/generate-grid-line-features-using-sql/m-p/1182860#M33342</link>
      <description>&lt;DIV class=""&gt;&lt;P&gt;&lt;EM&gt;Oracle 18c:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Using an SQL query, I want to generate&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/Lattice_graph" target="_blank" rel="nofollow noopener noreferrer"&gt;square grid graph&lt;/A&gt;&amp;nbsp;features:&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_0-1655423673438.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43679iD7EFC41019AB3676/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bud_0-1655423673438.png" alt="Bud_0-1655423673438.png" /&gt;&lt;/span&gt;&lt;P&gt;&lt;BR /&gt;The underlying vertices would look like this:&lt;/P&gt;&lt;PRE&gt;STARTPOINT_X STARTPOINT_Y ENDPOINT_X ENDPOINT_Y      SHAPE
&lt;SPAN class=""&gt;------------ ------------ ---------- ---------- ----------&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;1&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;    [SHAPE]     &lt;SPAN class=""&gt;--horizontal lines&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;1&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;2&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;2&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;3&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;3&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;4&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;4&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;5&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;5&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;6&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0    [SHAPE]&lt;/SPAN&gt;
         ...
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;1    [SHAPE]     &lt;/SPAN&gt; &lt;SPAN class=""&gt;--vertical lines&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;1&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;2    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;2&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;3    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;3&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;4    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;4&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;5    [SHAPE]&lt;/SPAN&gt;
           &lt;SPAN class=""&gt;0&lt;/SPAN&gt;            &lt;SPAN class=""&gt;5&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0&lt;/SPAN&gt;          &lt;SPAN class=""&gt;6    [SHAPE]&lt;/SPAN&gt;
         ...
[&lt;SPAN class=""&gt;220&lt;/SPAN&gt; &lt;SPAN class=""&gt;rows&lt;/SPAN&gt; selected]&lt;/PRE&gt;&lt;HR /&gt;&lt;P&gt;Details:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The lines would be split at each intersection. So, in the image above, there are 220 lines. Each line is composed of two vertices.&lt;/LI&gt;&lt;LI&gt;Ideally, I would have the option of specifying in the query what the overall grid dimensions would be. For example, specify this somewhere in the SQL:&lt;SPAN&gt;&amp;nbsp;DIMENSIONS = 10 x 10&amp;nbsp;(or&amp;nbsp;DIMENSIONS = 100 x 100, etc.).&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;To keep things simple, we can:&lt;UL&gt;&lt;LI&gt;Assume the grid's overall shape will always be a square (length = width).&lt;/LI&gt;&lt;LI&gt;For the purpose of this question, we can make the cell size&amp;nbsp;1 unit.&lt;/LI&gt;&lt;LI&gt;And the grid can start at 0,0 and be built &lt;EM&gt;"up and right"&lt;/EM&gt; (to the northeast).&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;I've supplied&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sample data&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in this&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://dbfiddle.uk/?rdbms=oracle_18&amp;amp;fiddle=01eb6652a33664d0565546d5b88352ea" target="_blank" rel="nofollow noopener noreferrer"&gt;db&amp;lt;&amp;gt;fiddle&lt;/A&gt;&amp;nbsp;(non-spatial XY coordinates). I created that data using Excel.&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;Hint: The vertical grid lines start at row 111.&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;HR /&gt;&lt;P&gt;The reason I want to generate this data is:&lt;/P&gt;&lt;P&gt;I want sample line data to work with when testing Oracle Spatial queries. Sometimes I need a few hundred lines. Other times, I need thousands of lines. And I need to share the data online via &lt;A href="https://dbfiddle.uk" target="_blank" rel="noopener"&gt;https://dbfiddle.uk&lt;/A&gt;, so I can't use real/proprietary GIS data.&lt;/P&gt;&lt;P&gt;Also, if the lines are in a grid pattern, then it will be obvious if any lines are missing in my analysis results (by looking for gaps in the data in a map).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm aware that there are ways to do this with ArcGIS tools. In this case, I want to do it using SQL.&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;How can I generate those grid lines using Oracle SQL?&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 17 Jun 2022 02:08:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/generate-grid-line-features-using-sql/m-p/1182860#M33342</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2022-06-17T02:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: Generate grid line features using SQL</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/generate-grid-line-features-using-sql/m-p/1182869#M33343</link>
      <description>&lt;P&gt;Here's one way of doing it:&lt;/P&gt;&lt;PRE&gt;--create or replace view sdo_geom_grid_vw as (
--select * from (&lt;BR /&gt;
with dimension as (
    select 0 as point from dual
        union all 
    select level
    from dual
    connect by level &amp;lt;= 10
), points as (
    select 
        a.point as startpoint, 
        b.point as endpoint,
        c.point as fixed
    from dimension a
    cross join dimension b
    cross join dimension c
    where b.point - a.point = 1
)
select
    cast(rownum as number(38,0)) as objectid,
    startpoint_x,
    startpoint_y,
    endpoint_x,
    endpoint_y,
    sdo_geometry('linestring('||startpoint_x||' '||startpoint_y||', '||endpoint_x||' '||endpoint_y||')',26917) as shape
from
    (
    select
        startpoint as startpoint_x,
        fixed as startpoint_y,
        endpoint as endpoint_x,
        fixed as endpoint_y
    from points
        union all
    select
        fixed as startpoint_x,
        startpoint as startpoint_y,
        fixed as endpoint_x,
        endpoint as endpoint_y
    from points
    )
order by startpoint_x, startpoint_y, endpoint_x, endpoint_y&lt;BR /&gt;--))&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;  OBJECTID STARTPOINT_X STARTPOINT_Y ENDPOINT_X ENDPOINT_Y SHAPE         
---------- ------------ ------------ ---------- ---------- --------------
       219            0            0          0          1 [SDO_GEOMETRY]
       109            0            0          1          0 [SDO_GEOMETRY]
       208            0            1          0          2 [SDO_GEOMETRY]
       108            0            1          1          1 [SDO_GEOMETRY]
       120            0            2          0          3 [SDO_GEOMETRY]
        99            0            2          1          2 [SDO_GEOMETRY]&lt;/PRE&gt;&lt;P&gt;Notes:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Source:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/72620062/generate-grid-line-coordinates-using-sql" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/72620062/generate-grid-line-coordinates-using-sql&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Related: Oracle Spatial Community -&amp;nbsp;&lt;A href="https://community.oracle.com/tech/apps-infra/discussion/4499701/generate-grid-line-coordinates/p1?new=1" target="_self"&gt;Generate grid line coordinates&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;The query currently produces SDO_GEOMETRY shapes. But it can very easily be adapted to generate SDE.ST_GEOMETRY shapes — since it converts the coordinates to shapes via WKT (supported by both geometry types). Just change&amp;nbsp;&lt;FONT face="courier new,courier" color="#0000FF"&gt;&lt;STRONG&gt;sdo_geometry&lt;/STRONG&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp; —to—&amp;nbsp; &lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;sde.st_geometry(&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;in the outer query.&lt;/LI&gt;&lt;LI&gt;When I added the query as a view to ArcMap, selecting the features was very buggy. For example, if I selected a few rows of cells at the top of the grid, ArcMap would also select a few random rows/cells at the bottom of the grid too, which was incorrect. That seems to be a problem in general with spatial views in ArcGIS.&lt;BR /&gt;I was able to solve that problem by &lt;STRONG&gt;registering the view with the GDB&lt;/STRONG&gt;. I had the same problem with both SDO_GEOMETRY and SDE.ST_GEOMETRY views. Registering the view solved it for both datatypes.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 17 Jun 2022 02:05:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/generate-grid-line-features-using-sql/m-p/1182869#M33343</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2022-06-17T02:05:25Z</dc:date>
    </item>
  </channel>
</rss>

