I am given a spreadsheet with 1 column. In this column, is a long string containing a variable list of gps coordinates. The syntax of the string is always the same, like this:
LINESTRING(lat lon, lat lon, lat lon)
My problem is that I need to switch each coordinate to be lon lat instead of lat lon
Example:
LINESTRING(40.729647749011 -111.83158925119,40.729647749011 -111.82776993746,40.72675329185 -111.82776993746,40.72675329185 -111.83158925119,40.729647749011 -111.83158925119)
needs to be manipulated to be,
LINESTRING(-111.83158925119 40.729647749011,-111.83158925119 40.72675329185,-111.82776993746 40.72675329185,-111.82776993746 40.729647749011,-111.83158925119 40.729647749011)
Any takers? I've been trying a UDF in VBA... haven't had any success.
I've been able to identify these characteristics though,
This solution could prove to help a lot of people. There is an existing problem with Microsoft's SQL Server that expects lon lat while the majority of other spatial systems export into a format of lat lon - so there are plenty of forums out there but I've spent hours searching, and no solution was found (other than third party software).
I use Excel 2010, Visual Studio 2010, SQL Server 2008 R2
Sample
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]LINESTRING(40.729647749011 -111.83158925119,40.729647749011 -111.82776993746,40.72675329185 -111.82776993746,40.72675329185 -111.83158925119,40.729647749011 -111.83158925119)
[/TD]
[/TR]
[TR]
[TD]LINESTRING(40.690679858029 -112.02458551084,40.690708330652 -112.0224933878,40.69148928929 -112.02243974363,40.691468951942 -112.02455868875)
[/TD]
[/TR]
[TR]
[TD]LINESTRING(40.690679858029 -112.02458551084)
[/TD]
[/TR]
</tbody>[/TABLE]
LINESTRING(lat lon, lat lon, lat lon)
My problem is that I need to switch each coordinate to be lon lat instead of lat lon
Example:
LINESTRING(40.729647749011 -111.83158925119,40.729647749011 -111.82776993746,40.72675329185 -111.82776993746,40.72675329185 -111.83158925119,40.729647749011 -111.83158925119)
needs to be manipulated to be,
LINESTRING(-111.83158925119 40.729647749011,-111.83158925119 40.72675329185,-111.82776993746 40.72675329185,-111.82776993746 40.729647749011,-111.83158925119 40.729647749011)
Any takers? I've been trying a UDF in VBA... haven't had any success.
I've been able to identify these characteristics though,
- first coordinate always begins with a (
- last coordinate always ends with a )
- the number of coordinates can be identified by counting the spaces
- coordinates end with a comma (except for the last one, of course!)
- coordinates are not always the same length! trailing zeros would be dropped if a coordinate was 40.72647749000 it would be displayed as 40.72647749
This solution could prove to help a lot of people. There is an existing problem with Microsoft's SQL Server that expects lon lat while the majority of other spatial systems export into a format of lat lon - so there are plenty of forums out there but I've spent hours searching, and no solution was found (other than third party software).
I use Excel 2010, Visual Studio 2010, SQL Server 2008 R2
Sample
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]LINESTRING(40.729647749011 -111.83158925119,40.729647749011 -111.82776993746,40.72675329185 -111.82776993746,40.72675329185 -111.83158925119,40.729647749011 -111.83158925119)
[/TD]
[/TR]
[TR]
[TD]LINESTRING(40.690679858029 -112.02458551084,40.690708330652 -112.0224933878,40.69148928929 -112.02243974363,40.691468951942 -112.02455868875)
[/TD]
[/TR]
[TR]
[TD]LINESTRING(40.690679858029 -112.02458551084)
[/TD]
[/TR]
</tbody>[/TABLE]