ShapeLib Tools - User Guide

ShapeLib is maintained by Frank Warmerdam
This guide was created by Eduardo Patto Kanegae < eduardo~at~consultoria~dot~eti~dot~br >

dbfcreate

Purpose: creates a new and empty .dbf file.
Usage: dbfcreate xbase_file [[-s field_name width],[-n field_name width decimals]]...
Example
$ dbfcreate testbase -s NAME 20, -n AREA 9 3, -n VALUE 9 2
# this will create a file named testbase.dbf with 3 fields: NAME ( string (20)), AREA ( float (9,3)) and VALUE ( float (9,2))

dbfadd

Purpose: adds a record into an existing .dbf file.
Usage: dbfadd xbase_file field_values
Example
$ dbfadd testbase.dbf REGION1 25.656 150.22
# assuming that testbase.dbf has 3 fields( NAME, AREA and VALUE), this command line will insert a new record into testbase.dbf with the value "REGION1" for NAME, '25.656' for AREA and '150.22' for VALUE field.

dbfdump

Purpose: dumps the content of a xBase file to the terminal.
Usage: dbfdump [-h] [-r] [-m] xbase_file
Example
$ dbfdump -h testbase.dbf
# assuming that testbase.dbf has 1 record( inserted by previous example using 'dbfadd'), this command line will produce the following output:
Field 0: Type=String, Title=`NAME', Width=20, Decimals=0
Field 1: Type=Double, Title=`AREA', Width=9, Decimals=3
Field 2: Type=Double, Title=`VALUE', Width=9, Decimals=2
NAME AREA VALUE
REGION1 25.656 150.22


shpcreate

Purpose: creates a new and empty shapefile.
Usage: shpcreate shp_file [point|arc|polygon|multipoint]
Example
$ shpcreate testpolygon polygon
# this will create a point shapefile named testpolygon( in fact testpolygon.shp and testpolygon.shx will be created).

shpadd

Purpose: adds a shape into an existing shapefile.
Usage: shpadd shp_file [[x y] [+]]*
Example
$ shpadd testpolygon 100000 7000000 250000 6500000 200000 6000000 100000 7000000
# assuming that testpolygon is a polygon shapefile, this command line will insert a new shape( a triangle) into testpolygon with the following XY coordinates:
vertice 0: 100000 7000000 ( this will also be the vertice where the shape starts and ends)
vertice 1: 250000 6500000
vertice 2: 200000 6000000
vertice 3: 100000 7000000

shpdump

Purpose: dumps content of shapefile showing information like shape type, file extents, total of objects and vertices coordinates.
Usage: shpdump [-validate] shp_file
Example
$ shpdump testpolygon
# assuming that testpolygon is an existing shapefile previously created, this command line will output the following result:
Shapefile Type: Polygon   # of Shapes: 1

File Bounds: (  100000.000, 6000000.000,0,0)
         to  (  250000.000, 7000000.000,0,0)

Shape:0 (Polygon)  nVertices=4, nParts=1
  Bounds:(  100000.000, 6000000.000, 0, 0)
      to (  250000.000, 7000000.000, 0, 0)
     (  100000.000, 7000000.000, 0, 0) Ring
     (  250000.000, 6500000.000, 0, 0)
     (  200000.000, 6000000.000, 0, 0)
     (  100000.000, 7000000.000, 0, 0)

shprewind

Purpose: validates and resets the winding order of rings in polygon geometries to match the ordering required by shapefile specification. This is useful for shapefiles having troubles when checked with a 'shpdump -validate'.
Usage: shprewind in_shp_file out_shp_file
Example
$ shprewind badshapefile newshapefile

dbfinfo

Purpose: displays basic information for a given xBase file, like number of columns, number of records and type of each column.
Usage: dbfinfo xbase_file
Example
$ dbfinfo testbase
Info for testbase.dbf
3 Columns,  1 Records in file
           NAME          string  (20,0)
           AREA           float  (9,3)
          VALUE           float  (9,2)


dbfcat

Purpose: appends the records of a source xBase file into a destiny xBase file. Both files must have the same number of fields.
Usage: dbfcat [-v] [-f] from_DBFfile to_DBFfile
Example
$ dbfcat -v testbase1 testbase2

shpinfo

Purpose: displays basic information for a given shapefile, like shapefile type, number of objects and its extents.
Usage: shpinfo shp_file
Example
$ shpinfo testpolygon
Info for testpolygon
Polygon(5), 1 Records in file
File Bounds: (         100000,        6000000)
        (         250000,        7000000)

shpcat

Purpose: appends the content of a source shapefile into a destiny shapefile. Both files must be the same shapefile type.
Usage: shpcat from_shpfile to_shpfile
Example
$ shpcat shapefile1 shapefile2

shpcentrd

Purpose: computes XY centroid for polygon shapefiles.
Usage: shpcentrd shp_file new_shp_file
Example
$ shpcentrd apolygonfile pointcentrd

shpdxf

Purpose: creates a DXF file from an existing shapefile.
Usage: shpdxf shapefile {idfield}
Example
$ shpdxf testshapefile IDFIELD
# explain the command

shpfix

Purpose: Utility program to fix nulls and inconsistencies in Shapefiles as happens from time to time.
Usage: shpfix shpfile new_file <Record# to Blank>
Example
$ shpfix broken fixed