USGS - science for a changing world

Formal metadata: information and software

A Tcl interface to read Shapefiles

tclshp is an extension of Tcl/Tk that provides the Tcl script writer some ability to read shapefiles. Its core is a set of C wrappers that read the files using Frank Warmerdam's shapelib and make the results available to Tcl procedures.

Download

tclshp-1.0.2.zip[an error occurred while processing this directive] ZIP file
tclshp-1.0.2.tgz[an error occurred while processing this directive] gzipped tar file

Resources:

Frank Warmerdam:http://pobox.com/~warmerdam
Shapelib:http://shapelib.maptools.org/

Functions

shp s -open input_file
opens shapefile, returns the name of a command used for subsequent operations
$s info
returns a list containing {shape_type record_count}
$s bounds rowid
returns a list containing {Xmin Ymin Zmin Mmin Xmax Ymax Zmax Mmax} for the whole shapefile or, if rowid is specified, the bounds of that specific shape.
$s coords rowid
returns coordinates for the given shape.

Since shapes can be composed of multiple parts, this function always returns a list of lists; one sublist for each part in the shape. It is the sublists that contain the coordinate values. So the coordinates of a simple shape will be returned as a list containing the list of coordinates. For shapes that are known to be two-dimensional, only the X and Y coordinates are included; if the shape might have Z coordinates or measures, all four coordinate values are given.

$s forget
closes the shapefile

Installation

  1. You'll need Tcl/Tk installed on your system in order to make use of this software. You can download Tcl/Tk from ActiveState, the company that currently provides an excellent free distribution: http://www.activestate.com/Products/ActiveTcl/
  2. If you want to modify or compile the source code, you will need shapelib (URL above). Install that in a directory adjacent to tclshp and run the tcl script setup.tcl included with tclshp.

Technical contact:

    Peter N. Schweitzer
    Mail Stop 954, National Center
    U.S. Geological Survey
    Reston, VA 20192

    Tel: (703) 648-6533
    FAX: (703) 648-6252
    Email: pschweitzer@usgs.gov

Accessibility FOIA Privacy Policies and Notices

Take Pride in America logo USA.gov logo U.S. Department of the Interior | U.S. Geological Survey
URL: http://geology.usgs.gov/tools/metadata/tclshp/
Page Contact Information: Peter Schweitzer
Page Last Modified: Friday, 04-Jan-2013 15:40:42 EST