[Xastir] ESRI shapefile troubles

Tom Russo russo at bogodyn.org
Tue Oct 5 17:47:33 EDT 2004


On Wed, Oct 06, 2004 at 12:20:48AM +0300, we recorded a bogon-computron collision of the <oh2kku at iki.fi> flavor, containing:
> Hi,
> 
> I'm trying to use Xastir from CVS (2004-09-18) with ESRI shapefiles that 
> describe a part of the Finnish road network. When I added the shapefiles 
> to xastir's map directory, I only got some dots and a few polygons to 
> the screen, nothing that resembles a road network. No error messages are 
> printed to stdout/stderr, except the "No DBFAWK signature found" that I 
> get from world.shp as well. Shapelib is version 1.2.10.

I can fix the world.shp for you --- simply place the attached dbfawk file
into the same directory as your world.shp file, and call it "world.dbfawk"
I've been using this for months, it allows the shapefile to be displayed with
the country names as well.

> I don't know much about shapefiles so I'm asking here if someone could 
> take a quick look on those shapefiles and tell me if there is something 
> fundamentally wrong with them or are they just some way incompatible 
> with Xastir. I've placed the files temporarily at 
> http://www.oh2kku.ham.fi/misc/, they should describe a road network at 
> about 60 deg 30 minutes north, 25 deg 5 minutes east (the city of 
> J?rvenp??).

I looked at these shapefiles.  Unfortunately, they are three-dimensional
polylines (type "SHPT_ARCZ"), and xastir is not currently set up to read those.
It might be possible to change xastir relatively easily to read 3-D arcs
and ignore the elevation, but I'm not sure.

However, if you install GDAL with OGR (see INSTALL) you get the ogr2ogr
program which can convert your 3D shapefiles to 2D.  I just tried it, and
got your road network to display.

Here's what you do:
  In the directory where DIGIROAD_LIIKENNE_ELEMENTTI.shp lives:

  ogr2ogr -nlt LINESTRING -f "ESRI Shapefile" New_Shapes DIGIROAD_LIIKENNE_ELEMENTTI.shp

This will create a new set of DIGIROAD_LIIKENNE_ELEMENTTI shp, shx, dbf files
that xastir can read.

Until you write a dbfawk file that recognizes your dbf file's structure, though,
you won't get road names displayed along with them, or be able to distinguish
between roads of differing classifications --- they'll all just be black lines.
If I could read the language in which the field names were wirtten I might 
be able to help, but I can't see one that looks anything like "road name"
or "road type".  

Attaching world.dbfawk.

-- 
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/
(1) Ignorance of your profession is best concealed by solemnity and silence,
which pass for profound knowledge upon the generality of mankind.
                -------"Advice to Officers of the British Army", 1783
-------------- next part --------------
# $Id$
# This dbfawk file is used to map arbitrary dbf data that accompanies
# a shapefile into Xastir canoncical values of:
#   key     - search key
#   lanes   - width of feature (usually a road but applies to rivers, etc. too)
#   color   - color to draw the road
#   name    - name of the road for labels
#   filled  - whether a polygon is drawn filled or not
#   pattern - line pattern for road, river, etc.
#   display_level - highest zoom level at which to display the feature
#   label_level - highest zoom level at which to display the label
#   symbol  - 3 char 'TIO': table, ID, overlay
#
# NOTE: This file format is modeled after awk but is nowhere near awk
#  compatible.
#
# This file is used for the world shapefile from http://aprsworld.net/gisdata/world/


# BEGIN is called once per dbf file which contains multiple records.
BEGIN {
# dbfinfo is the "signature" of the dbf file listing the column names in order.
# dbfinfo should match the dbf file that we say this dbfawk file goes with.
dbfinfo="NAME:CAPITAL:APPROX:AREA:SOURCETHM";
# dbffields is which of the above fields we actually want to look at.
# Note that the order we list these is important since we are appending the
# word County or Parish depending on what state the county is in.
dbffields="NAME"}

# BEGIN_RECORD is called once per dbf record which contains multiple fields.
# Use this rule to re-initialize variables between records.
BEGIN_RECORD {key=""; lanes=1; color=8; fill_color=100; name=""; filled=0; pattern=0; display_level=262144; label_level=16384; symbol=""; font_size=2}

# don't need special end case handling...
/^NAME=(.*)$/ {name="$1";next;}
#END_RECORD {name="$name ($key)";}
#END {}


More information about the Xastir mailing list