|Presenting Easting and Northings in a Browser Window |
| ||So, Tom Probert gave the all clear to provide a quick example of using the MapBasic window to sort out how to best present map coordinates from a UTM projected dataset. It is an oldie, but a goodie. Ideal for you MapInfo Scripting Samurai out there that like to get the job done quickly and easily. |
I have a table of data (Cadastre) that is projected onto a UTM map projection for Australia called MGA (Map Grid for Australia). I would like to make a quick report that shows a selection of records in a browser with their associated Easting and Northing values in each row.
Easy enough right? Well, sort of. If I use the CentroidX(OBJ) and CentroidY(OBJ) functions to grab some coordinates of objects in the map I will be returned Longitude and Latitude - not Eastings and Northings.
The thing is that MGA is a map projection based on a geodetic datum called GDA94 (Geodetic Datum for Australia). GDA94 locations are represented in Longitude and Latitude: the spherical kind. But, I am looking for Easting and Northings: the flat-Earth kind.
If I create a Browser window of my selection and add X and Y for my polygon centroids I get the following;
Not e the CentroidX/CentroidY columns. Clearly this something only a rocket scientist can apply in the field. Mere mortals require something more workable when interpreting map locations. Eastings and Northings are great for getting a workable, flat, metric distance between objects.
Let employ a simple MapBasic script command that will instruct MapInfo Professional to present the coordinates of the projection, as opposed to the geodetic datum.
Note: 'Cadastre' is the name of my table that has, funny enough, cadastral parcel objects. The table is projected to MGA(GDA94) Zone 56. Please read the MapBasic Reference Guide (available for free on our web site) if you would like to understand all the background to this command.
- Choose Options > Show MapBasic Window
- Type the following in the MapBasic window: Set Coordsys Table Cadastre
- In a map window containing the Cadastre layer I make a selection of objects from the layer
- Create a new Browser window of the selection
- Go into Browse > Pick Fields and add Expression fields using the Functions CentroidX(OBJ) and CentroidY(OBJ)
- You should have something like this. Choose OK.
You will now have Eastings and Northings in your browser instead of Longitude and Latitude. Great success!
To give a little polish to the result we will change the column heading names so they can be deciphered by those not of the MapInfo Scripting Samurai clan.
- Go back into Browse > Pick Fields and click on the CentroidX(OBJ) field on the right. In the edit box type in a friendly name for the column, like Eastings. Do the same for CentroidY(OBJ) and call it Northings. Choose OK.
Done. You have now taken control of working with coordinates for data that may be stored against a coordinate system, yet projected onto specific map projection.
Article by Sean Richards, Director Product Management
When not writing articles for "The MapInfo Professional" journal, Sean helps to make sure our products meet the needs of our customers in the Asia Pacific region. When not working Sean enjoys going to the Gold Coast with his wife and seven year old daughter. Oh, and also enjoys movies with car crashes, explosions and Kung-fu fighting.