Build a point with distance and degrees

959
11
Jump to solution
04-08-2013 05:31 AM
OlivierLevasseur
New Contributor II
Hello everyone,

First of all, sorry for my english.

I am looking for how to build a point from another point according to a distance(meters) and a angle(degree).

Olivier
0 Kudos
1 Solution

Accepted Solutions
OlivierLevasseur
New Contributor II
Hi,

I finaly found a solution on the website http://www.movable-type.co.uk/scripts/latlong.html

Cheers for your help

Olivier

View solution in original post

0 Kudos
11 Replies
DavideLimosani
Occasional Contributor II
Hello everyone,

First of all, sorry for my english.

I am looking for how to build a point from another point according to a distance(meters) and a angle(degree).

Olivier


Use trigonometry:

distance along x-axis = cos(angle)*distance

distance along y-axis = sin(angle)*distance

if you have a projected coordinate system add this values to your starting point.
0 Kudos
OlivierLevasseur
New Contributor II
Hi,

Thank you for your answer.

I am worry that this method will not be precise enough as the earth is a sphere. But I could still have a try.

I keep you in touch.

Olivier
0 Kudos
DavideLimosani
Occasional Contributor II
Hi,

Thank you for your answer.

I am worry that this method will not be precise enough as the earth is a sphere. But I could still have a try.

I keep you in touch.

Olivier


Yeah, you are right. It depends on your purposes. But if you use a local projected coordinate system (UTM for example) it could be enough. Don't try it with Web Mercator 🙂
0 Kudos
OlivierLevasseur
New Contributor II
Hello,

it is working with the following method :

function buildPoint(point,angle, nav_long){
    var x = Math.cos(angle/180*Math.PI)*(nav_long*1/111111);
    var y = Math.sin(angle/180*Math.PI)*(nav_long*1/111111);
    newPoint = point.offset(x,y);
    return newPoint;
}

My problem is now the distance which is in meters. I found that 1 degree (latitude) = 111.11 km but it doesn't seem to work.

Olivier
0 Kudos
OlivierLevasseur
New Contributor II
My bad, this is working; I just have troubles with angles
0 Kudos
DavideLimosani
Occasional Contributor II
Hey, that's why i said you that you should use a projected coordinate system, because it has coordinates in meters!

I think that using the equation 1 degree (latitude) = 111.11 km  is very dangerous.

If you are using a geographic coordinate system, I suggest you to use a geometry service to convert your point in a proper projected coordinates system, add to the new coordinates the new distances ( x and y ), and than convert again the new point to you map reference system.... maybe that there are other solutions less muddled but this is the only one that comes in my mind atm....

Davide
0 Kudos
OlivierLevasseur
New Contributor II
Hello Dlimos,

I tried what you advised me to do and this is perfectly working !! Thank you a lot !

To any people that might face this problem, this is the js function I used :

function buildPoint(point,angle, nav_long){
    var coord = esri.geometry.lngLatToXY(point.getLongitude(),point.getLatitude(),true);
    var ox = coord[0]+ Math.cos(angle/180*Math.PI)*nav_long;
    var oy = coord[1] + Math.sin(angle/180*Math.PI)*nav_long;
    var newPoint = new esri.geometry.Point(esri.geometry.xyToLngLat(ox,oy),new esri.SpatialReference({
        wkid:4326
    }));
    return newPoint;
}

OlivierL
0 Kudos
DavideLimosani
Occasional Contributor II
Hello Dlimos,

I tried what you advised me to do and this is perfectly working !! Thank you a lot !

To any people that might face this problem, this is the js function I used :

function buildPoint(point,angle, nav_long){
    var coord = esri.geometry.lngLatToXY(point.getLongitude(),point.getLatitude(),true);
    var ox = coord[0]+ Math.cos(angle/180*Math.PI)*nav_long;
    var oy = coord[1] + Math.sin(angle/180*Math.PI)*nav_long;
    var newPoint = new esri.geometry.Point(esri.geometry.xyToLngLat(ox,oy),new esri.SpatialReference({
        wkid:4326
    }));
    return newPoint;
}

OlivierL



Hey, esri.geometry.xyToLngLat and esri.geometry.lngLatToXY convert coordinates from wgs84 to webMercator and vice versa.

If you use Web Mercator u will get huge errors!

read this: http://blogs.esri.com/esri/arcgis/2010/03/05/measuring-distances-and-areas-when-your-map-uses-the-me...

use a geometry service to project your point in a local coordinate system please...

p.s. ty for removing the "correct answer" flag from my post  ahah 😉
0 Kudos
OlivierLevasseur
New Contributor II
Hey,

I though it was good because the angles fit but the length of the polyline are wrong (too small).

As I am a beginner in GIS, I will explain what I did and what I try to do. I hope you could hepl me to understand my mistakes.

I built a map of the harbor of le Havre (France) where boats are placed in.
I used google map to get the GPS location of the wharf which are the only locations I need to build everything.

I have to switch from google map to arcgis to get more accurate and more actual map.

I don't really understand which locale system to choose. Do you mean that I have to choose a wkid of spatialreference? Or should I build my own local system?

OlivierL
0 Kudos