<?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: Querying point X,Y data stored in a database in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198991#M11388</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gagag,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not that I know of, but I am not by any means a SQL expert, maybe there is someone else that may know better&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anthony&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Sep 2012 21:14:03 GMT</pubDate>
    <dc:creator>AnthonyGiles</dc:creator>
    <dc:date>2012-09-18T21:14:03Z</dc:date>
    <item>
      <title>Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198988#M11385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Due to some reasons, I am required to store X,Y point data in a database (and not convert them to point features). The X,Y data represents points in a UTM projection. I need to search for a point that is nearest to a given point in a query. The given point is also in the same UTM projection. Is there an efficient way of accomplishing this using SQL query? Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 18:36:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198988#M11385</guid>
      <dc:creator>GagagDa_Morvi</dc:creator>
      <dc:date>2012-09-18T18:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198989#M11386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gagag,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not tested but you will need to do some pythagoras to work out the distance, ie:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SELECT sqrt(pow(inputxvalue - fieldx,2) +(pow(inputyvalue - fieldy,2)) AS Distance FROM tablename ORDER BY Distance LIMIT 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anthony&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 18:50:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198989#M11386</guid>
      <dc:creator>AnthonyGiles</dc:creator>
      <dc:date>2012-09-18T18:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198990#M11387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;SELECT sqrt(pow(inputxvalue - fieldx,2) +(pow(inputyvalue - fieldy,2)) AS Distance FROM tablename ORDER BY Distance LIMIT &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Thansk, anthony. This query involves full table scan (I think). Is there a way to avoid that?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 21:01:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198990#M11387</guid>
      <dc:creator>GagagDa_Morvi</dc:creator>
      <dc:date>2012-09-18T21:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198991#M11388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gagag,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not that I know of, but I am not by any means a SQL expert, maybe there is someone else that may know better&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anthony&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 21:14:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198991#M11388</guid>
      <dc:creator>AnthonyGiles</dc:creator>
      <dc:date>2012-09-18T21:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198992#M11389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In software engineering terms, the "big O notation" of a query on the closest distance from any&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;single point is inherently "O(N)" [the effort required to solve the problem is proprtional to the &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;number of rows in the table -- aka, full table scan].&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only to way to reduce processing is to put a limit on the magnitude of the distance by&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;indexing both X and Y ("CREATE INDEX foo ON table(xcol,ycol)") and adding a WHERE&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;clause to the query:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;WHERE xcol between (inputx - theshold) and (inputx + theshold)
&amp;nbsp; AND ycol between (inputy - theshold) and (inputy + theshold) &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is, in essence, what you're losing by not being able to generate a buffer about the search&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;point and use the spatial index to limit return results [an unbounded query on a spatial relationship&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;of distance(inputpt,ptcol) would also be O(N)].&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- V&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:55:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198992#M11389</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2021-12-11T09:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198993#M11390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;In software engineering terms, the "big O notation" of a query on the closest distance from any&lt;BR /&gt;single point is inherently "O(N)" [the effort required to solve the problem is proprtional to the &lt;BR /&gt;number of rows in the table -- aka, full table scan].&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;The only to way to reduce processing is to put a limit on the magnitude of the distance by&lt;BR /&gt;indexing both X and Y ("CREATE INDEX foo ON table(xcol,ycol)") and adding a WHERE&lt;BR /&gt;clause to the query:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;WHERE xcol between (inputx - theshold) and (inputx + theshold)
&amp;nbsp; AND ycol between (inputy - theshold) and (inputy + theshold) &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;This is, in essence, what you're losing by not being able to generate a buffer about the search&lt;BR /&gt;point and use the spatial index to limit return results [an unbounded query on a spatial relationship&lt;BR /&gt;of distance(inputpt,ptcol) would also be O(N)].&lt;BR /&gt;- V&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks! I do have the index as you have suggested - I will try out the where clause and see how it goes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:55:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198993#M11390</guid>
      <dc:creator>GagagDa_Morvi</dc:creator>
      <dc:date>2021-12-11T09:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198994#M11391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The index won't do any good without a where clause constraint to exploit it&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(in fact, it would just slow down INSERT performance).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- V&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Sep 2012 16:56:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198994#M11391</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2012-09-19T16:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198995#M11392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have the freedom to alter the schema of your table you could implement a geohash-based query:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://code.google.com/p/python-geohash/"&gt;http://code.google.com/p/python-geohash/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You would need to calculate a hash onto each point, with a precision to suit your data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then your nearby query would devolve into a string range query.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 14:02:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198995#M11392</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2012-09-20T14:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198996#M11393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;See the attached functions; requires ArcGIS 10.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 15:47:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198996#M11393</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2012-09-24T15:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198997#M11394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi&lt;BR /&gt;&lt;BR /&gt;If you have the freedom to alter the schema of your table you could implement a geohash-based query:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://code.google.com/p/python-geohash/"&gt;http://code.google.com/p/python-geohash/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;You would need to calculate a hash onto each point, with a precision to suit your data.&lt;BR /&gt;&lt;BR /&gt;Then your nearby query would devolve into a string range query.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Very interesting approach. Will try. Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Sep 2012 13:59:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198997#M11394</guid>
      <dc:creator>GagagDa_Morvi</dc:creator>
      <dc:date>2012-09-25T13:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198998#M11395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I updated the functions to be a little more robust.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Sep 2012 17:21:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198998#M11395</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2012-09-25T17:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Querying point X,Y data stored in a database</title>
      <link>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198999#M11396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I updated the functions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Sep 2012 17:32:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/querying-point-x-y-data-stored-in-a-database/m-p/198999#M11396</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2012-09-25T17:32:33Z</dc:date>
    </item>
  </channel>
</rss>

