Select to view content in your preferred language

finding the centroid between two points

4053
6
02-01-2013 10:42 AM
janehansen
Regular Contributor
Hi, I have a very large data set. Each row has a lat/long for a start point, and a lat/long for an end point. I am looking for the easiest way to locate the centroid between these two points and display them with out also showing the start and end point locations.

    Thanks,
    Jane
Tags (2)
0 Kudos
6 Replies
MikeMacRae
Frequent Contributor
Hi, I have a very large data set. Each row has a lat/long for a start point, and a lat/long for an end point. I am looking for the easiest way to locate the centroid between these two points and display them with out also showing the start and end point locations.

    Thanks,
    Jane


Jane, is this a line dataset with a beginning point and ending point coordinates? You can add 2 new fields called "CENTROID_X and CENTROID_Y and then right click on the heading and 'Calculate Geometry' and in the first drop down, choose the associated centroid calculation (X Coordinate of Midpoint, Y Coordinate of Midpoint)

Mike
0 Kudos
janehansen
Regular Contributor
Jane, is this a line dataset with a beginning point and ending point coordinates? You can add 2 new fields called "CENTROID_X and CENTROID_Y and then right click on the heading and 'Calculate Geometry' and in the first drop down, choose the associated centroid calculation (X Coordinate of Midpoint, Y Coordinate of Midpoint)

Mike


Hi Mike, no at this point it is an excel spreadsheet that contains the locational coordinates for both the start and end points for a specific event.  Once I import the data into arc map I will end up points only. One for the start point and one for the end point for each event/row in the table. I need to find the centroid for each of these events.

Jn
0 Kudos
MikeMacRae
Frequent Contributor
You could possible just do some math in python and program it to find the different between the x value of the start point and the x value of the end point and then divide by 2 and then do the same for the y values?

Something like (assuming you're using UTM coordinates)

start x = 39500
end x = 40500

difference is (40500 - 39500)/2 = 500 + 39500 = 40000 centroid x

Same for y

And then you can write that to your excel spreadsheet to 2 new fields (or in memory, depending on how you want to manage the centroid coordinate values) and then plot the centroid coordinates instead of the start and end coordinates.

Hope that points you in the right direction?
0 Kudos
MikeMacRae
Frequent Contributor
Sorry, i missed the part that you are working in Lat\Long. You could possibly calculate the lat\long to decimal degrees and then do the math on that and then convert back to lat long?
0 Kudos
janehansen
Regular Contributor
Sorry, i missed the part that you are working in Lat\Long. You could possibly calculate the lat\long to decimal degrees and then do the math on that and then convert back to lat long?


Thanks Mike, so using decimal degrees I would use the same calculation as you did for UTM but using the decimal degrees?
0 Kudos
MikeMacRae
Frequent Contributor
Yes, I found a python function that you could probably use to do the conversion and then just do the math on the values it returns

http://stackoverflow.com/questions/2579535/how-to-convert-dd-to-dms-in-python

The stackoverflow site has tons of good python scripting examples.
0 Kudos