Export coordinates of a single polygon in GRASS

Today needed to export the coordinates of a polygon into a *.csv file in GRASS. My solution was:


echo "lon,lat" >  convex_hull.csv
 v.out.ascii in=convex_hull format=standard | awk '/B/, /C/{if(!/B/ && !/C/) print $1","$2}' >> $i/chull.csv

This works fine for me, knowing that I have only one single polygon. v.out.ascii returns a header, the coordinates of the vertices and the centroid. In order to extract only the coordinates of the polygon (I am not really interested in the centroid), I use awk and only select (print) the lines that are between (header for coordinates of the polygon) and C (header for the coordinates of the centroid.

Advertisements
This entry was posted in BASH, GRASS. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s