[GRASS-dev] A function for obtaining UTM coordinate

Glynn Clements glynn at gclements.plus.com
Sat Jul 26 18:02:14 EDT 2008


roberto caselli wrote:

> Ok, row and col are known, but when I call 
> G_col_to_easting or G_row_to_northing, they return lat/lon coordinates.
> So I don't know how to tell to these functions that I want UTM coordinates.

In that case, you'll need to obtain proj_info structures for both
lat/lon and UTM. Then, you can use pj_do_transform() to perform the
conversion.

The usual way to create a proj_info structure is to pass Key_Value
structures (which contain a set of key/value pairs) to pj_get_kv(). 

You can get the Key_Value structure for a GRASS location (i.e. your
lat/lon location) from G_get_projinfo() and G_get_projunits(), but
you'll need to construct the data for UTM yourself.

One way to do that is to pass a WKT string to GPJ_wkt_to_grass(). 
Another is to construct the Key_Value structure manually with
G_create_key_value() and G_set_key_value().

You can find everything involved in the v.proj code, except for
constructing the Key_Value structure for the UTM location.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list