[Xastir] my DBFAWKifying process [was Re: [Xastir-dev] More Map Questions/Suggestions !]
Tom Russo
russo at bogoflux.losalamos.nm.us
Wed Mar 17 11:13:53 EST 2004
[redirecting to the xastir list instead of xastir-dev]
On Tue, Mar 16, 2004 at 07:52:26PM +0000, a Mr. Richard Feyler of Fort Lee, New Jersey <g1pvz at gmx.net> writes 'Dear Rosanne Rosannadanna':
> 3.Could sombody help with the shapefile map dbfawk for esri maps of
>Europe. I have recently discovered them and they do provide maps of
>the UK which include labels for Cities and Towns but I cannot fathom
>out how to get the labels displayed ! (I have read the readme but I
>don't understand!)
Alan Crosswell is the right person to answer this (he wrote the DBFAWK
stuff), but I had a similar query and worked out a procedure for myself.
Here it is in the hopes it helps out.
0) Use "dbfinfo" (it's part of the shapelib "contrib" directory, you need
to build it separately from shapelib) to reveal the list of attributes
in the DBF file. For example, I have a set of shapefiles converted from
US Forest Service trails
> dbfinfo /usr/local/share/xastir/maps/misc_vector/USFS_SandiaRD
67 Columns, 544 Records in file
FNODE_ integer (11,0)
TNODE_ integer (11,0)
LPOLY_ integer (11,0)
RPOLY_ integer (11,0)
LENGTH float (31,15)
TRAIL_ integer (11,0)
TRAIL_ID integer (11,0)
TYPE string (1,0)
CODE string (2,0)
CODE_MEMO string (80,0)
METHOD string (2,0)
MISC string (1,0)
TE_UNIT string (1,0)
EXISTVEG string (1,0)
FS_OWN string (1,0)
TRAIL string (1,0)
ROAD string (1,0)
WATER string (1,0)
STREAM string (1,0)
PLSS string (1,0)
ADM_DIST string (1,0)
ADM_UNIT string (1,0)
PASTURE string (1,0)
SPEC_MGT string (1,0)
HRTGSRVY string (1,0)
RD_RTE_NO string (35,0)
TR_RTE_NO string (35,0)
STRM_NAME string (80,0)
SURVEY_NUM string (13,0)
CFF1 string (3,0)
CFF2 string (3,0)
CFF3 string (3,0)
CFF4 string (3,0)
CFF5 string (3,0)
CFF6 string (3,0)
CFF7 string (3,0)
CFF8 string (3,0)
CFF9 string (3,0)
CFF10 string (3,0)
NUMBER string (35,0)
NUMBER0 string (35,0)
LEVE string (20,0)
TYPE0 string (20,0)
ROAD_TYPE string (20,0)
LANES string (20,0)
SURFACE string (20,0)
PROBLEM string (20,0)
CLOSURE string (20,0)
DATE integer (8,0)
TIME string (20,0)
OPERATOR string (20,0)
COMMENTS string (50,0)
MAX_PDOP float (31,15)
GPS_DATE integer (8,0)
GPS_TIME string (20,0)
GPS_LENGTH float (31,15)
HORZ_PREC float (31,15)
VERT_PREC float (31,15)
HORZ_PRE0 float (31,15)
VERT_PRE0 float (31,15)
TRAIL_NO string (10,0)
SOURCE string (10,0)
MAPUSE string (25,0)
NAME string (30,0)
MILES2 float (23,16)
COOID string (10,0)
STATUS integer (11,0)
This list of attributes will be used in the DBFAWK file to recognize files
to which the dbfawk file applies.
1) Copy a dbfawk file for a type of map that is close (e.g. tgrlk.dbfawk
is a reasonable starting point for line type shapefiles, but it is
fairly complex and handles a lot of feature types).
2) Replace the contents of the "dbfinfo" variable with the fields you found
in step 0. e.g., for my USFS shapefiles above, the dbfinfo variable
is:
dbfinfo="FNODE_:TNODE_:LPOLY_:RPOLY_:LENGTH:TRAIL_:TRAIL_ID:TYPE:CODE:CODE_MEMO:METHOD:MISC:TE_UNIT:EXISTVEG:FS_OWN:TRAIL:ROAD:WATER:STREAM:PLSS:ADM_DIST:ADM_UNIT:PASTURE:SPEC_MGT:HRTGSRVY:RD_RTE_NO:TR_RTE_NO:STRM_NAME:SURVEY_NUM:CFF1:CFF2:CFF3:CFF4:CFF5:CFF6:CFF7:CFF8:CFF9:CFF10:NUMBER:NUMBER0:LEVE:TYPE0:ROAD_TYPE:LANES:SURFACE:PROBLEM:CLOSURE:DATE:TIME:OPERATOR:COMMENTS:MAX_PDOP:GPS_DATE:GPS_TIME:GPS_LENGTH:HORZ_PREC:VERT_PREC:HORZ_PRE0:VERT_PRE0:TRAIL_NO:SOURCE:MAPUSE:NAME:MILES2:COOID:STATUS";
3) Figure out which of the godzillion attributes corresponds to the
line names you want displayed. In my case it was a
concatenation of the "NAME" and "TRAIL_NO" fields. You then make
sure the "dbffields" variable has those fields in it (and few others,
coz this is the variable that directs xastir to read the attributes
from the file). In my case:
dbffields="CFF1:NAME:TRAIL_NO"
This selects the feature code (CFF), name and trail number.
4) Create rules in your dbfawk file that match various patterns that can show
up in the attributes. Here's where you set the "name" variable to the
appropriate thing you want xastir to display as well as things
like line type, color, label color, and how far out you can be zoomed
and still see the labels. In my case, sometimes trails
are listed in the dbf file as "UNK" and I don't want that name displayed,
other times they're listed with a trail number only and I want it to
show up as "Tr. #". So I do:
# Use this rule to re-initialize variables between records.
# These will be your defaults
# My defaults are "1 lane, color brown, pattern "LineDoubleDash" (see the
# XSetLineAttributes man page), always display the line, display labels if
# zoomed in to level 32 or smaller, black labels, large font)
# The defaults are overridden by specific rules below
BEGIN_RECORD {key=""; lanes=1; color=4; name=""; filled=0; pattern=2; display_level=1; label_level=32; label_color=8; symbol=""; font_size=3}
# hiking trails and unimproved roads
# This sets the color of the line and pattern based on the feature type
# We don't bother showing hiking trails if zoomed out farther than 128
# Rosy brown for hiking trails
/^CFF1=107$/ {lanes=2; color=30; pattern=1;display_level=128;}
# dashed steel blue lines for class 4 unimproved roads.
/^CFF1=106*$/ {lanes=2; color=26; pattern=1;display_level=128;}
# Now look for a name number and/or trail number
# Never display "UNK" as a trail name
/^NAME=[uU][nN][kK]$/ {skip;}
/^TRAIL_NO=[uU][nN][kK]$/ {skip;}
# select the name given in the record
/^NAME=(.+)$/ {name="$1";}
# and append the trail number to the name
/^TRAIL_NO=(.+)$/ {name="$name (Tr. $1)";}
5) Place your DBFAWK file somewhere where it'll be found. If you have a
dbfawk file that applies to many shapefiles, name it something generic
and put it in {base}/share/xastir/config. If it's specific to one
shapefile, give it the same base name as the shapefile and a .dbfawk
suffix and put it in the same directory as the shapefile.
If you would like to play with some shapefiles I've made and their
associated DBFAWK files, go to http://www.swcp.com/~russo/shape_web
and download some of them. You'll have to zoom in on central New
Mexico, USA (usually close to Albuquerque), but you should be able to
see clearly how the various DBFAWK things are mapped to the display. There
are much simpler files than the USFS trails up there, like the National Atlas
shapefiles of wilderness areas, and the very, very simple coastlines file
(that doesn't even have labels).
There are one or two cases in the files on that web site where I don't
properly initialize *all* the dbfawk variables in the BEGIN_RECORD
line, and sometimes that results in defaults being taken from whatever
was used last. I haven't had a chance to go back and fix them all.
README.MAPS does not list *all* the DBFAWK variables that should be
reset in BEGIN_RECORD, you have to look at the dbfawk files that come
with the distribution to pick that up. There are a few new ones since
README.MAPS was updated (font_size, for example).
--
Tom Russo KM5VY SAR502 DM64ux http://www.swcp.com/~russo/
Tijeras, NM QRPL#1592 K2#398 SOC#236 AHTB#1 http://www.qsl.net/~km5vy/
"It is inhumane in my opinion to force people who have a genuine
medical need for coffee to wait in line behind people who apparently
view it as some kind of recreational activity." -- Dave Barry
More information about the Xastir
mailing list