Tuesday, October 06, 2009

Part II: Calculating Point Locations

I probably posted my blog post, Calculating Point Locations from One Known Point, Distance and Direction, too soon. I got some more great advice from Andy Anderson at Amherst College, who said it was okay if I shared this here. He calculated out the trig for me. Thanks, Andy!

Here's my solution, which stays in ArcGIS, and may well be more accurate in general than the other two solutions you found (i.e. do you know exactly what procedure Map Maker is using?). In general this isn't a simple problem. It can be approximated either by projecting the coordinates such that there is low distortion over the region covered by the lines, or by assuming a spherical Earth and using spherical trigonometry. The other issue is that a rhumb line is not in general the same as a geodesic, though again over a small region they are basically the same.

I'm going to assume that you are working over a small region. Here's one way to do it, using the Mercator projection, which by design keeps rhumb lines correct, or another way to say it is that a 1-m change in x will cover the same distance on the map as a 1-m change in y.

1) Format your data more or less as follows in a file that ends with .csv:


The length is assumed to be meters, direction in degrees clockwise from north (i.e. the azimuth). The central point is repeated here since it might conceivably change and because the calculations we'll use to generate the distant points all start with that point.

2) Open ArcGIS, preferably a new blank document, then double-click on the data frame (usually named Layers), click on the tab Coordinate System, and navigate to Predefined > Projected Coordinate Systems > World > Mercator (world). This version is based on the datum WGS 84.

3) Menu Tools > Add XY Data... , and import the CSV file; in the dialog assign the correct datum for the above geographic coordinates. If it's not the same as WGS 84, pick an appropriate transformation. The data will be added as (file name) Events.

4) Right-click on (file name) Events and menu Data > Export Data… In the resulting dialog, in the button group Use the same coordinate system as:, click on the data frame. Choose a name and location for the shapefile and click the button OK. When you are asked Do you want to add the exported data to the map as a layer?, click on the button Yes.

5) Open ArcToolbox, then navigate to Data Management Tools > Features and double-click on Add XY Coordinates. In the menu Input Features, select the new shapefile and then click on the button OK. When the tool completes, click on the button Close.

6) Right-click on the new shapefile and menu Open Attribute Table. Two new fields will be present, POINT_X and POINT_Y, which will be Mercator coordinates in meters. Click on the button Options and menu Add Field..., and create a field with the Name: (for example) DISTANT_X with Type: Double. Repeat to create a field with the Name: DISTANT_Y.

7) Right-click on the header of the field DISTANT_X and menu Field Calculator…. In the field DISTANT_X =, type and/or click:

[POINT_X] + [Length_m] * Sin( [ Direction] * Atn(1) / 45 )

Then click the button OK. Now right-click on the header of the field DISTANT_Y and menu Field Calculator….
In the field DISTANT_Y =, type and/or click:

[POINT_Y] + [Length_m] * Cos( [ Direction] * Atn(1) / 45 )

Then click the button OK. Note that the trig functions Sin and Cos are reversed from the "usual" because the angle is azimuthal.
The trig functions "Atn(1)/45" is equal to the degree-radian conversion factor π/180.

8) DISTANT_X and DISTANT_Y are the new point positions. You can now turn them into their own point layer in ArcToolbox by navigating to Data Management Tools > Layers and Table Views and double-clicking on Make XY Event Layer. Choose your shapefile as the XY Table and DISTANT_X and DISTANT_Y as the X Field and Y Field. Choose a name for the layer, and choose the Spatial Reference as Mercator (world) (probably easiest to import it from your shapefile). Click OK.

9) Due to a bug in ArcGIS, the Distant Point layer will not appear in the Table of Contents, which means you can't select it and export it immediately as a shapefile (as in Step 4 above). However, you can save it as an external layer file with ArcToolbox by navigating to Data Management Tools > Layers and Table Views and double-clicking on Save to Layer File; it will appear in the menu Input Layer. Then add it to ArcGIS. This file refers to the shapefile you created for its data, so don't let them get separated. Or, you can now export this file as in Step 4 above.

Andy then suggests that this could be streamlined in Model Builder, as I suggested in my question to the the New York GIS Help Desk. It's so reassuring having smart friends and colleagues!

Also, one more thing. This project is one in which a graduate student is marking conch locations and movements underwater. She is making the measurements alone, diving with scuba gear, and the distances are rather short, less than 15 meters. Cool, huh?

No comments: