[GRASSLIST:907] Re: GMT / GRASS use / shp2gmt

Allan Hollander adh at ice.ucdavis.edu
Wed Apr 26 14:30:59 EDT 2006


Trevor,

I'm sorry that was a bit terse. Basically, both the use of shp2gmt and the
awk script are preprocessing steps before you run psxy. The processing
flow is like this:

1) Run the shp2gmt script over the shapefile to produce a 
preliminary input file for psxy. In a bash shell, this would be something 
like:

% shp2gmt usstates > usstates0.xy

2) Run the awk script over the preliminary input file to produce the final
version of the input file for psxy which is tagged for polygon-by-polygon
symbology. Assuming the awk script below is in a file named alaska.awk,
the command line here would be:

% awk -f alaska.awk usstates0.xy > usstates.xy

3) You can then plot this input file using psxy, as follows:

% psxy usstates.xy [other GMT parameters go here...] >> outputplot.ps

By the way, there's nothing magical about using awk -- most any scripting 
language can be used for this sort of processing (a lot of people would 
use perl, for instance).

Hope this helps,

Allan


On Tue, 25 Apr 2006, Trevor Wiens wrote:

> On Tue, 25 Apr 2006 16:14:35 -0700 (PDT)
> Allan Hollander <adh at ice.ucdavis.edu> wrote:
> 
> > Trevor,
> > 
> > I'm a rank beginner at GMT but in my one exercise to date with it I
> > learned the following. Mark Fenbers has modified the shp2gmt.c file to
> > include the attribute info from the dbf file into the multi-segment
> > separator of the psxy input file. His code is given in his message here:  
> > http://www.mechanik.tu-darmstadt.de/GMT-Help/Archiv/11021.html.
> 
> Thanks for the helpful information. I do have a question however.
> 
> > 
> > The output from his shp2gmt version looks like this for a tiny extract 
> > from a state map of the US:
> > 
> > >       Polygon #0      nVertices=17    nParts=1        cat=2   AREA=0  PERIMETER=0.224 STATESP020=3    STATE="Alaska"  STATE_FIPS="02"  
> > -2.86129e+06    6.01613e+06
> > -2.86152e+06    6.01607e+06
> > -2.86163e+06    6.01615e+06
> > -2.86178e+06    6.01631e+06
> > -2.86248e+06    6.01724e+06
> > -2.86327e+06    6.01807e+06
> > etc.
> > 
> 
> OK. Got that code and that is working as reported.
> 
> > What I can then do is write an awk script to substitute in the correct
> > -G and -W plotting parameters depending on the attributes. For instance
> > running this bit of awk over the above input file
> > 
> > {if ($0 ~ /Alaska/) printf "> -G175 -Wblack\n";
> > else print;}
> 
> You lost me here. In what context am I going to process the file with
> awk, in the psxy command line or before hand?
> 
> Please provide a slightly more fleshed out example for me to follow.
> 
> Thanks in advance.
> 
> T
> 

-- 




More information about the grass-user mailing list