Skip to main content
Solved

Change Degree Minute Seconds Hemisphere to decimal degrees split

  • June 27, 2017
  • 9 replies
  • 471 views

darkspatiallord
Contributor
Forum|alt.badge.img+7

Hi

Does anyone have a transformer or groups of transformers prebuilt to extract this 32°25'20.4"S 151°29'40.5"E 2145.1 to decimal degrees split into degrees minutes decimal seconds

 

yes i am lazy.....but pressed for time

Best answer by david_r

You can use a StringSearcher with the following regex to split the values:

(\d+\.?\d*)|([NSEW])

You'll have to set the "All matches list name" to something like _parts, which will be a list that will contain all the separate elements of your DMS string, e.g.:

`_parts{0}.match' has value `32'
`_parts{1}.match' has value `25'
`_parts{2}.match' has value `20.4'
`_parts{3}.match' has value `S'
`_parts{4}.match' has value `151'
`_parts{5}.match' has value `29'
`_parts{6}.match' has value `40.5'
`_parts{7}.match' has value `E'
`_parts{8}.match' has value `2145.1'

You can then feed the individual numbers into a DecimalDegreesCalculator, e.g.:

0684Q00000ArLWuQAN.png

You may also want to use something like a TestFilter and a couple of ExpressionEvaluators for values that aren't situated in the north-eastern hemisphere.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

9 replies

david_r
Celebrity
  • 8394 replies
  • Best Answer
  • June 27, 2017

You can use a StringSearcher with the following regex to split the values:

(\d+\.?\d*)|([NSEW])

You'll have to set the "All matches list name" to something like _parts, which will be a list that will contain all the separate elements of your DMS string, e.g.:

`_parts{0}.match' has value `32'
`_parts{1}.match' has value `25'
`_parts{2}.match' has value `20.4'
`_parts{3}.match' has value `S'
`_parts{4}.match' has value `151'
`_parts{5}.match' has value `29'
`_parts{6}.match' has value `40.5'
`_parts{7}.match' has value `E'
`_parts{8}.match' has value `2145.1'

You can then feed the individual numbers into a DecimalDegreesCalculator, e.g.:

0684Q00000ArLWuQAN.png

You may also want to use something like a TestFilter and a couple of ExpressionEvaluators for values that aren't situated in the north-eastern hemisphere.


mark2atsafe
Safer
Forum|alt.badge.img+56
  • Safer
  • 2554 replies
  • June 27, 2017

I notice in the DecimalDegreesCalculator help it suggests:

...if the attribute has the format:

-DDDMMSS.SS°

the following regular expression could be used in the StringSearcher to parse it into a list attribute with three elements:

^(-?[0-9]+)([0-9][0-9])([0-9][0-9][.][0-9]*)

Obviously you'd need to clean up your string a little first, removing some excess characters.


darkspatiallord
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • 60 replies
  • June 27, 2017

You can use a StringSearcher with the following regex to split the values:

(\d+\.?\d*)|([NSEW])

You'll have to set the "All matches list name" to something like _parts, which will be a list that will contain all the separate elements of your DMS string, e.g.:

`_parts{0}.match' has value `32'
`_parts{1}.match' has value `25'
`_parts{2}.match' has value `20.4'
`_parts{3}.match' has value `S'
`_parts{4}.match' has value `151'
`_parts{5}.match' has value `29'
`_parts{6}.match' has value `40.5'
`_parts{7}.match' has value `E'
`_parts{8}.match' has value `2145.1'

You can then feed the individual numbers into a DecimalDegreesCalculator, e.g.:

0684Q00000ArLWuQAN.png

You may also want to use something like a TestFilter and a couple of ExpressionEvaluators for values that aren't situated in the north-eastern hemisphere.

 

That award is well deserved...thankyou superstar !!!

  • 3 replies
  • July 4, 2017

You can use a StringSearcher with the following regex to split the values:

(\d+\.?\d*)|([NSEW])

You'll have to set the "All matches list name" to something like _parts, which will be a list that will contain all the separate elements of your DMS string, e.g.:

`_parts{0}.match' has value `32'
`_parts{1}.match' has value `25'
`_parts{2}.match' has value `20.4'
`_parts{3}.match' has value `S'
`_parts{4}.match' has value `151'
`_parts{5}.match' has value `29'
`_parts{6}.match' has value `40.5'
`_parts{7}.match' has value `E'
`_parts{8}.match' has value `2145.1'

You can then feed the individual numbers into a DecimalDegreesCalculator, e.g.:

0684Q00000ArLWuQAN.png

You may also want to use something like a TestFilter and a couple of ExpressionEvaluators for values that aren't situated in the north-eastern hemisphere.

Using this gave me only the first match. How can I set all the matches to something like _parts?? Thanks

 

 

 


geosander
Forum|alt.badge.img+7
  • 327 replies
  • August 22, 2017

FYI: It's probably way too late now, but I just uploaded the DegreeFormatter to the FME Hub.

With this custom transformer, it should be easy to deal with these kind of problems. Handles multiple attributes at once and is able to work with latitude, longitude or latitude-longitude coordinates without having to use regular expressions (although it does use them under the hood ;)).

 

Can convert DMS, DDM (degrees and decimal minutes), ISO-6709 and DD. And vice versa.

 

Enjoy!

Forum|alt.badge.img
  • 8 replies
  • March 7, 2019

You can use a StringSearcher with the following regex to split the values:

(\d+\.?\d*)|([NSEW])

You'll have to set the "All matches list name" to something like _parts, which will be a list that will contain all the separate elements of your DMS string, e.g.:

`_parts{0}.match' has value `32'
`_parts{1}.match' has value `25'
`_parts{2}.match' has value `20.4'
`_parts{3}.match' has value `S'
`_parts{4}.match' has value `151'
`_parts{5}.match' has value `29'
`_parts{6}.match' has value `40.5'
`_parts{7}.match' has value `E'
`_parts{8}.match' has value `2145.1'

You can then feed the individual numbers into a DecimalDegreesCalculator, e.g.:

0684Q00000ArLWuQAN.png

You may also want to use something like a TestFilter and a couple of ExpressionEvaluators for values that aren't situated in the north-eastern hemisphere.

This tool was exactly what I needed. However, we did find one problem and that is with FME versions. I use FME 2017 locally but our server currently has 2015. While the upgrade cycle is planned, we want to use this in 2015 as well but there appears to be differences in the regex engine. Any help on what needs to be changed for 2015?


takashi
Celebrity
  • 7843 replies
  • March 8, 2019

This tool was exactly what I needed. However, we did find one problem and that is with FME versions. I use FME 2017 locally but our server currently has 2015. While the upgrade cycle is planned, we want to use this in 2015 as well but there appears to be differences in the regex engine. Any help on what needs to be changed for 2015?

You have to specify every part which you need to extract by round brackets in FME 2015. For example, this regular expression might help you.

(\d+)\D(\d+)\D(\d+\.?\d*)\D([NS])\s*(\d+)\D(\d+)\D(\d+\.?\d*)\D([EW])\s*(\d+\.?\d*)

0684Q00000ArNFfQAN.png


Forum|alt.badge.img

FYI: It's probably way too late now, but I just uploaded the DegreeFormatter to the FME Hub.

With this custom transformer, it should be easy to deal with these kind of problems. Handles multiple attributes at once and is able to work with latitude, longitude or latitude-longitude coordinates without having to use regular expressions (although it does use them under the hood ;)).

 

Can convert DMS, DDM (degrees and decimal minutes), ISO-6709 and DD. And vice versa.

 

Enjoy!

I really like your DegreeFormatter!


geosander
Forum|alt.badge.img+7
  • 327 replies
  • March 27, 2019

I really like your DegreeFormatter!

Thanks! :)