Sunday, 11 February 2018

c# - How to find nearby objects using Easting and Northing range


I have a bunch of objects which have associated Eastings and Northings in format OSGB36


for example:


265397  869562

547297 179002

If I have a starting Easting and Northing, and wanted to find related objects within X km is it possible to compute a Start/End Northing and Start/End Easting range that I can search for programatically?


I am using C#.


I.e. searching for objects using pseudo-code :


Easting >= 265390 && Easting <= 265400 &&
Northing >= 869560 && Northing <= 869564

would this find nearby objects? What resolution do these coordinates operate to? I can operate in miles or km, just need to know the scale - if such a thing is possible.


Sorry this is new to me.




Answer



See National Grid Reference Converter for help on the precision of OSGB map references.


If you just use a search range to create a box surrounding your query point, as indicated by


(east_QP - range)  <= east  <= (east_QP + range)
(north_QP - range) <= north <= (north_QP + range)

a variation on your pseudo code, it is fast but biased.


If you "create a circle" around your query point


hypot ((east_QP - east), (north_QP - north)) <= range


where hypot() computes distance, it is a tiny bit slower but less biased as it cuts out the box corners.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...