Wednesday 17 January 2018

qgis - How to transform data points from WGS84 to NAD27?


Preface: I have a set of lat and long data points from Google Maps, which I believe are in WGS84. My project data is in NAD27(BLM14). These points are in West Texas, where NAD27 differs from WGS84 by about 50 meters. Using QGIS, I loaded my shapefile into one layer and set the CRS to WGS84, then I loaded the same data again and set its layer to NAD27. I was hoping to see a difference between the two layers, but I saw none. (I zoomed in to 47:1.)


Question: Did I actually transform my data points from WGS84 to NAD27? If so, shouldn't I see a discrepancy? I checked the properties of the layers, and one says +datum=WGS84, while the other says +datum=NAD27. Am I missing something obvious? (I never took any GIS classes in school, and I've only been working at this for a few weeks.)



Should I use the NADCON converter at http://www.ngs.noaa.gov/cgi-bin/nadcon.prl to convert my WGS84 coordinate data to NAD27? Or is there a QGIS or (better) an OSGeo solution?



Answer




Did I actually transform my data points from WGS84 to NAD27?



Not really. Assuming your original coordinates are actually WGS84, you just assigned an erroneous CRS of NAD27(BLM14) the second time you imported the data. Assigning the CRS does not transform the data.



I was hoping to see a difference between the two layers, but I saw none.



You may have on-the-fly transformations on for your project. If so, your WGS84 points were automatically reprojected (or projected in this case) to NAD27(BLM14). Turn it off (under Project Properties -> CRS) to see the actual differences.



To more clearly see the difference, relative to your Google Maps points (which may be in a different CRS), load the layer, defining it as having a CRS as WGS84 (probably accurate), then right-click on the layer and choose Save As..., defining your project CRS of NAD27(BLM14) for the resultant file.


Turn off on-the-fly transformations for you project and load the saved NAD27(BLM14) file in. You should see the difference between the projections, i.e. your ~ 50 meters.


You can also use command line utilities to convert your coordinates:


PROJ's cs2cs utility


GDAL's gdaltransform utility


One way to use gdaltransform is to start a terminal session (OSGeo4W if you are on Windows) and interactively execute:


gdaltransform -s_srs EPSG: -t_srs EPSG:

EPSG stands for European Petroleum Survey Group. Reference codes may be found at spatialreference.org.


For example, EPSG:4326 and EPSG:4267 are reference codes for WGS84 and NAD27, respectively:



gdaltransform -s_srs EPSG:4326 -t_srs EPSG:4267
-102.60930001 32.16984002 <-- user input

will return the corresponding coordinate in NAD27,


-102.608865426754 32.1697300184475

or, depending upon your platform, you may use stdin/stdout redirection as follows,


gdaltransform -s_srs EPSG:4326 -t_srs EPSG:4267 < input.csv > output.txt

This way, if you construct your lon/lat data as a csv with one coordinate pair per line, like,



-102.60930001, 32.16984002
-102.60350002, 32.14630999

then the input redirector, '<', will feed your data in, and the output redirector, '>', will write output.txt, which will look like,


-102.608865426754 32.1697300184475 0
-102.603066486342 32.1461989948827 0

See also: Proper gdaltransform syntax to transform a list of coordinates?


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...