# Finding new point, with proportion, between two points Postgis

I couldn't find a topic related to my problem, thus I am going to ask. I have the following problem:

I need to create a new Point based on three variables: P1 (Geometry), P2 (Geometry) and length (Integer in meters). I know the geometry of two points and want to crate a new point the lies between them given a determined length, like in the picture below:

How can I do it using only Postgis?

I am using Postgis 2.2 with PostgreSQL 9.4.

• So far I have nothing, the most reasonable solution would be finding the slope of the line and sum the X and Y components of the vector created with the length. But I couldn't find anything like in postgis and I am trying to create something with php right now. – Mateus Batista Jan 26 '17 at 14:11

## 2 Answers

One potential solution is to combine 3 things:

Good luck

You can use st_project function. A sample is as follows. To find a point at a distance of 100 meters between points '77.0541494 28.5091006' and '77.054473971709 28.5095594' from the first point.

``````select st_astext(st_project('POINT(77.0541494 28.5091006)'::geography, 100, st_azimuth(st_geomfromtext('POINT(77.0541494 28.5091006)'), st_geomfromtext('POINT(77.054473971709 28.5095594)'))));
``````

OUTPUT: POINT(77.0547393477234 28.5098372103161)

For reference: