Hello everyone, I need a GRASS function for obtaining for each cell its UTM coordinate. |
---|
Posta, news, sport, oroscopo: tutto in una sola pagina
Crea l’home page che piace a te!.
Hello everyone, I need a GRASS function for obtaining for each cell its UTM coordinate. |
---|
Posta, news, sport, oroscopo: tutto in una sola pagina
Crea l’home page che piace a te!.
roberto caselli wrote:
I need a GRASS function for obtaining for each cell its UTM
coordinate.
In C, G_col_to_easting() and G_row_to_northing() translate col/row
coordinates to geographic or cartographic coordinates. Note that the
arguments are floating point values, so you need to use e.g. col+0.5
and row+0.5 if you want the coordinate of the cell's centre.
In r.mapcalc, the x() and y() functions return the coordinates of the
cell's centre.
--
Glynn Clements <glynn@gclements.plus.com>
double G_col_to_easting |
( |
double |
col, |
|
const struct Cell_head * |
window |
|||
) |
I don’t know how using G_col_to_easting and G_row_to_northing to have these translations
— Ven 25/7/08, Glynn Clements glynn@gclements.plus.com ha scritto:
Da: Glynn Clements glynn@gclements.plus.com
Oggetto: Re: [GRASS-dev] A function for obtaining UTM coordinate
A: roberto.caselli@yahoo.it
Cc: grass-dev@lists.osgeo.org
Data: Venerdì 25 luglio 2008, 21:03roberto caselli wrote: > I need a GRASS function for obtaining for each cell its UTM > coordinate. In C, G_col_to_easting() and G_row_to_northing() translate col/row coordinates to geographic or cartographic coordinates. Note that the arguments are floating point values, so you need to use e.g. col+0.5 and row+0.5 if you want the coordinate of the cell's centre. In r.mapcalc, the x() and y() functions return the coordinates of the cell's centre. -- Glynn Clements <glynn@gclements.plus.com>
Posta, news, sport, oroscopo: tutto in una sola pagina
Crea l’home page che piace a te!.
roberto caselli wrote:
This is the prototype of the function
double G_col_to_easting
(
double
col,
const struct Cell_head *
window
)
For each cell I know the geographic decimal coordinate (for example
-78.847804 , -2.814949) but what I'd like to know is its UTM
coordinate (x=739254.864 , y=9688649.285594).I don't know how using G_col_to_easting and G_row_to_northing to
have these translations
If it is actually a cell of a GRASS raster map, then you also know its
row and column, which you can use with these functions.
If you want to transform arbitrary lat/lon coordinates to or from the
cartographic coordinate system used by the current location, see the
source code for v.proj for example code.
OTOH, if this doesn't actually involve GRASS in any way, you are
probably better off using the PROJ library directly. The only reason
to use the GRASS interface is if you want to use the projection
information from a location's PROJ_INFO file.
--
Glynn Clements <glynn@gclements.plus.com>
Ok, row and col are known, but when I call<br>G_col_to_easting or G_row_to_northing, they return lat/lon coordinates.<br>So I don't know how to tell to these functions that I want UTM coordinates.<br><br><br><br> — Sab 26/7/08, Glynn Clements glynn@gclements.plus.com ha scritto: > Da: Glynn Clements glynn@gclements.plus.com > Oggetto: Re: [GRASS-dev] A function for obtaining UTM coordinate > A: roberto.caselli@yahoo.it > Cc: grass-dev@lists.osgeo.org > Data: Sabato 26 luglio 2008, 15:13 > > <br>> roberto caselli wrote:<br>> <br>> > This is the prototype of the function <br>> > double G_col_to_easting <br>> > (<br>> > double <br>> > col, <br>> > const struct<br>> Cell_head * <br>> > window <br>> > )<br>> <br>> > For each cell I know the geographic decimal coordinate (for example<br>> > -78.847804 , -2.814949) but what I'd like to know is its UTM<br>> > coordinate (x=739254.864 , y=9688649.285594).<br>> > <br>> > I don't know how using G_col_to_easting and G_row_to_northing to<br>> > have these translations<br>> <br>> If it is actually a cell of a GRASS raster map, then you also know its<br>> row and column, which you can use with these functions.<br>> <br>> If you want to transform arbitrary lat/lon coordinates to or from the<br>> cartographic coordinate system used by the current location, see the<br>> source code for v.proj for example code.<br>> <br>> OTOH, if this doesn't actually involve GRASS in any way, you are<br>> probably better off using the PROJ library directly. The only reason<br>> to use the GRASS interface is if you want to use the projection<br>> information from a location's<br>> PROJ_INFO file.<br>> <br>> -- <br>> Glynn Clements <glynn@gclements.plus.com><br>> <br>> |
---|
Posta, news, sport, oroscopo: tutto in una sola pagina
Crea l’home page che piace a te!.
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@gclements.plus.com>