Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I create a point 1000 meters away from a reference point?

The ST_Translate only supports geometry type.

I also tried using ST_GeomFromText but that returns a unit and not in meters.

Here is my sample query:

SELECT ST_AsText ( ST_Translate ( ST_GeogFromText('SRID=4326;POINT(-70.01 43.27)'), 1000, 0 ) );

Is there a way that I can convert the output of ST_Translate into meters?

share|improve this question

You want ST_Project, which takes in a point, direction and distance http://postgis.net/docs/ST_Project.html

share|improve this answer

To make a meter translation you need a geometry that has a spatial reference system in meter unit. The srid code 31997 for example is metric, so what need to do is feed a metric geometry to st_translate and get back into the desired output spatial reference system.

SELECT st_AsText ( st_transform( st_translate( st_transform( st_GeomFromText('SRID=4326;POINT(-70.01 43.27)'), 31997 ), 1000, 0 ), 4326 ) );
share|improve this answer
    
do you know if mercator (EPSG: 3857) is also in meters units? I do a couple of tests with the ST_Buffer function and they don't return the same area – opensas Nov 16 '13 at 4:11
    
Using srid 31997 only confuses things. – Martin F Nov 18 '13 at 23:19
    
Mercator 3857 is metric system too. Values could change a little based on projection used. Since some projections change the shape of earth figure is expected some value change due to convertion from spherical to a plane(projected) reference system. As answered the srid used is just an example. You can use any that suits better your case. – cavila Nov 20 '13 at 19:35

Use Geometry contructor

ST_GeomFromText()

http://postgis.net/docs/ST_GeomFromText.html

share|improve this answer
    
ST_GeomFromText is returning a unit and not a meter. How do I convert it to meters. – user181677 Dec 19 '12 at 16:46
    
ST_Transform(the_geom, new_srid) , where new_srid should system that uses metric and is well defiend on your are. More information gaia-gis.it/gaia-sins/spatialite-cookbook/html/srid.html – simplexio Dec 20 '12 at 7:39

@user181677 for the question and @Paul Ramsey for the idea. I wanted generate a series of nodes. I didn't need a precise direction or offset really. I just wanted to space out 80 mile markers for OSM. I am still in the process of actually placing the nodes and have not committed the OSM change set yet. All this query does is generate 80 mile markers as the crow flies. However, that ST_Project was a great idea. Here's the pgsql/PostGIS query that I used.

HTH, Greg

/*
 * Finally, We generate most of the OSM XML file format
 * for a node.
 */
select '<node id=''' || mile_markers2 *-1 ||
       ''' action=''modify'' visible=''true'' lat=''' ||
       mile_marker_y || ''' lon=''' ||
       mile_marker_x || '''>' || chr(10) ||
       '<tag k=''distance'' v=''' || mile_markers2 ||
        ' miles'' />' || chr(10) ||
       '<tag k=''highway'' v=''milestone'' />' || chr(10) ||
       '<tag k=''ref'' v=''' || mile_markers2 || ''' />' || chr(10) ||
       '<tag k=''source'' v=''Mapillary'' />' || chr(10) ||
       '<tag k=''traffic_sign'' v=''milestone'' />' || chr(10) ||
       '</node>'  as mc85_mile_marker_nodes
  from (
         select mile_markers, 
                /*
                 * Here we just need to adjust the mile makers so that
                 *  they start at one.
                 */
                mile_markers+1 as mile_markers2,
                meter_constant, meter_offset, general_direction,
                /*
                 * A sample st_project fuction call with both the x,y
                 * coordinates.  We can see the point in the result set.
                 * The -112... 32... numbers are from the first mile
                 * marker.
                 */
                ST_asText(st_project(
                   'POINT( -112.73352547993 32.9328758707 )'::geography,
                   meter_offset,
                   general_direction )) as mile_marker_geom,
                /*
                 * We really need the X for our final presentation.
                 */
                ST_X(ST_asText(st_project(
                   'POINT( -112.73352547993 32.9328758707 )'::geography,
                   meter_offset,
                   general_direction ))) as mile_marker_x,
                /*
                 * We really need the y for our final presentation.
                 */
               ST_Y(ST_asText(st_project(
                   'POINT( -112.73352547993 32.9328758707 )'::geography,
                   meter_offset,
                   general_direction ))) as mile_marker_y
          from (
                select /*
                        * We need a zero mile marker even though one does
                        * not exist.  The zero marker is used to establish
                        * our first offset from where the real mile maker
                        * exits. Hence the (0, 80) in the generate series
                        * call.
                        */
                        mile_markers,
                        /*
                         * One mile in meters for the function call.
                         */
                       1609.344 as meter_constant,
                       /*
                        * Generate an offset for each function call to
                        * create a mile marker.
                        */
                       mile_markers * 1609.344 as meter_offset,
                       /*
                         * This is the general direction that we are heading
                         * to Lukeville/Mexico.
                         */
                       radians(190.00) as general_direction
                  from generate_series(0,80) as mile_markers
               ) as mc85_mile_markers
         order by mile_markers
       ) as final_mc85_mile_markers;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.