Skip to main content
Solved

Change Degree Minute Seconds Hemisphere to decimal degrees split


darkspatiallord
Forum|alt.badge.img+6

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.

View original
Did this help you find an answer to your question?

9 replies

david_r
Evangelist
  • 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+43

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
Forum|alt.badge.img+6
david_r wrote:

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

  • July 4, 2017
david_r wrote:

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
  • 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
david_r wrote:

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
Contributor
Forum|alt.badge.img+19
  • Contributor
  • March 8, 2019
cquadrini56 wrote:

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
geosander wrote:

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
  • March 27, 2019
gisbradokla_t wrote:

I really like your DegreeFormatter!

Thanks! :)


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings