[GRASSLIST:9776] Re: Converst lat/long to x,y
Glynn Clements
glynn at gclements.plus.com
Mon Jan 9 23:48:40 EST 2006
Michael Ash wrote:
> I am reposting an email to which I did not receive a response. Here
> is a very brief summary of the problem, and a longer description is
> below:
>
> I would like to transform a set of lat/long maps to a new location on
> an x,y basis using the following formula,
> X = Radius*cos(Lat)*Long
> Y = Lat * Radius
> where Lat and Long are latitude and longitude (measured in radians)
> and Radius is an earth's radius. I know that there are problems
> (datum, spheroid, non-preservation of area, etc.) with this model
> (which measures x as arc length along a line of latitude from the
> prime meridian and y as arc length along a line of longitude from the
> equator), BUT this is what I want to do.
>
> Is there an easy way to have GRASS go through every lat/long point in
> a vector map and create a matching point in an x,y map USING A
> SPECIFIED FORMULA? I do not want to use v.transform (why stretch,
> when I have a formula).
You could try v.out.ascii, awk, v.in.ascii, e.g.
v.out.ascii $srcmap format=standard output=srcfile
awk -v radius=$radius '{ if ($0 ~ /^ [0-9]+\.[0-9]+ [0-9]+\.[0-9]+$/) print " "radius*cos($2)*$1" "radius*$2 ; else print}' < srcfile > dstfile
v.in.ascii $dstmap format=standard input=dstfile
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list