Skip to main content
Question

Distance between two location from table with two coordinates per location


ivan
Participant
Forum|alt.badge.img+1
  • Participant

I have a csv which has two sets of coordinates per row and I need to calculate the distance between these two location on meters or Km but I am getting results that are not correct not sure any one can help please?

 

here is a sample of input file (blue columns) and the distance calculated with another tool like ID=1 is about 204 Km

here is what I tried

here is the output of this module where it is sayin the length for Id=1 is 1.946

 

 

4 replies

chrisatsafe
Contributor
Forum|alt.badge.img+2
  • Contributor
  • January 9, 2019

Hi @ivan,

The reason your points are so close together is that your coordinate system is set to UTM84-14N but you are creating points that are recorded in Lat/Long. Try setting the coordinate system in the Reprojector to LL84, create the points, reproject to UTM84-14N, and then calculate the length of the line. This should help you calculate the distance between your points in meters.

Alternatively, you can specify the source coordinate system (LL84 in this case) when adding the reader and create points by setting the attribute type (x_coordinate & y_coordinate) in the reader parameters as shown in the How to Convert CSV to Shapefile (Non-spatial to Spatial) article.

Distance_Between_Two_Points.fmwt


jovitaatsafe
Safer
Forum|alt.badge.img+11

Hi @ivan,

Elaborating on Chris's answer, the lengths you are calculating now are in degrees because the input into FME was lat/long degrees. I was able to successfully calculate the length after reprojecting data from LL84 to UTM84-14N using the LengthCalculator following up on our conversation earlier today.

 

Another potential alternative is to use the ReprojectLengthCalculator which will shorten the number of steps for you.


ivan
Participant
Forum|alt.badge.img+1
  • Author
  • Participant
  • January 9, 2019
chrisatsafe wrote:

Hi @ivan,

The reason your points are so close together is that your coordinate system is set to UTM84-14N but you are creating points that are recorded in Lat/Long. Try setting the coordinate system in the Reprojector to LL84, create the points, reproject to UTM84-14N, and then calculate the length of the line. This should help you calculate the distance between your points in meters.

Alternatively, you can specify the source coordinate system (LL84 in this case) when adding the reader and create points by setting the attribute type (x_coordinate & y_coordinate) in the reader parameters as shown in the How to Convert CSV to Shapefile (Non-spatial to Spatial) article.

Distance_Between_Two_Points.fmwt

adding one reprojector before and after the vertex creator works I tried using one at the time i would never guess that you need two reprojectors thank you for the answer


ivan
Participant
Forum|alt.badge.img+1
  • Author
  • Participant
  • January 9, 2019
jovitaatsafe wrote:

Hi @ivan,

Elaborating on Chris's answer, the lengths you are calculating now are in degrees because the input into FME was lat/long degrees. I was able to successfully calculate the length after reprojecting data from LL84 to UTM84-14N using the LengthCalculator following up on our conversation earlier today.

 

Another potential alternative is to use the ReprojectLengthCalculator which will shorten the number of steps for you.

could you share how could I use this transformer? I tried but it combined all the points and it did create a single long polyline which is not what I need on this case


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