June 24, 2009

Converting coordinates to a local SRS

I am currently doing some work for a small junior mining company which requires that a number of data sets be translated between UTM NAD83 Zone 11 and a local coordinate system. If you have never had any dealings with mining projects you may not know that it is common practice to create a local coordinate system aligned to the estimated ore body (sometimes called a mine grid). In some cases this CS may have been developed many years previous when the mine was originally developed and, often times, there is no adequate documentation to help define the system. If you are lucky you may be able to establish shift, rotation and scale values but this will likely require the assistance of a surveyor.
In this case, however, I was lucky enough to have the translation parameters. As it is very difficult to use traditional methods to convert from a earth centered to non-earth reference system I decided it would be much easier to do the transformation in a more manual fashion. By this I mean an x/y shift and rotation (no scaling required). Now having said that I also realized that this was a task that would be required many more times as the project progressed. For this reason I decided to roll up my sleeves and create a little stand alone utility. This is always a little daunting during an active project but I felt it could be accomplished fairly quickly and for very little additional cost to the client as I was going to utilize the open source ActiveX MapWinGIS and SharpMap dlls to do most of the work for me. After some fairly basic survey geometry calculations I had an algorithm that could be applied to convert all UTM coordinates to the local grid and vise versa.
Now to put it into a utility that would convert the features in a shapefile using this algorithm. As I am very familiar with MapWinGIS and SharpMap, I decided these would be the ideal ActiveX libraries to perform this task. It was fairly simple as the MapWinGIS dll provides read/write access to many of the attributes of features (shapes) such as the x and y coordinates of the individual vertices (points). The conversions can be applied to the vertices very simply such as:
MapWinGIS.Shape s = osf.Shape(shpindex);
string[] xy = toMine(s.Point(k).x, s.Point(k).y);

Where toMine is a Private Function within the VB.NET class that performs the conversion and s is the current feature (shape). The string array xy() will then hold the converted coordinates that can be applied to the shape point as follows:
s.Point(k).x = xy[0]

When all is complete you will have a new data set with all the features "projected" to the local coordinate system. Now the geologists and engineers using sophisticated modeling software (that apparently cannot easily do this kind of conversion) can quickly and easily convert the data for use in resource estimates and mine design applications.
One other issue lay in the fact that many of the data sets might be provided in other data types (i.e. MapInfo TAB files). For this reason I chose to use the open source GIS ActiveX dll SharpMap. This allowed me to convert these files into a common format (ESRI Shapefile).
This example illustrates how easy it is to create a versatile tool box using open source applications and libraries without having to bother with expensive licensing. MapWinGIS has been developed to work seamlessly within the .NET framework so, once you have referenced the dll, you can easily access all of these calls. I suggest downloading all the files from http://www.mapwindow.org or http://www.codeplex.com/SharpMap and try it out. I think you will find they will become an invaluable tool in your GIS toolbox.

1 comment:

Brando said...

Hi Jerry,

You have already accomplished what I need to accomplish. I am surveying for a mine in UT and need to convert my points from UT NAD83 to an arbitrary mine grid. Would you be able to help?