[GRASS-dev] 2D to 3D points

Markus Neteler neteler at osgeo.org
Sun Mar 2 13:06:42 EST 2008

On Thu, Feb 28, 2008 at 11:26 PM, Michael Barton <michael.barton at asu.edu> wrote:
> Is there some way I've missed to change 2D points with a z attribute
>  field, into 3D points without reimporting them?

I did it like this (borrowed from 3rd GRASS book, p. 211 - NC data set):

# work on map in current mapset
g.copy vect=precip_30ynormals,precip_30ynormals_tmp
v.info -c precip_30ynormals_tmp
v.db.addcol precip_30ynormals_tmp \
             col="x double precision, y double precision"
v.to.db precip_30ynormals_tmp option=coor col=x,y

# we assume that the table name corresponds to input map name
v.in.db precip_30ynormals_tmp out=myprecip_30ynormals \
        x=x y=y z=elev key=cat
v.db.select myprecip_30ynormals

# We can now remove the superfluous 'x' and 'y' columns from the table:
v.db.dropcol myprecip_30ynormals col=x
v.db.dropcol myprecip_30ynormals col=y
v.info -c myprecip_30ynormals
v.db.select myprecip_30ynormals
v.info myprecip_30ynormals
g.remove vect=precip_30ynormals_tmp

# The new map myprecip_30ynormals now contains 3D geometry.

To have this a bit simpler would be great.


More information about the grass-dev mailing list