dialogs: shp2dta Title

shp2dta -- Converts shape boundary files to Stata datasets

Syntax

shp2dta using shpfilename, database(filename) coordinates(filename) [options]

options Description ------------------------------------------------------------------------- Main database(filename) Specifies filename of new dBase dataset coordinates(filename) Specifies filename of new coordinates dataset replace Overwrites existing database and coordinates filenames genid(newvarname) Creates unique id variable for database.dta gencentroids(stub) Creates centroid variables -------------------------------------------------------------------------

If shpfilename is specified without an extension, .shp is assumed. If filename is specified without an extension, .dta is assumed. Windows and Macintosh users: if shpfilename or filename contains embedded spaces, remember to enclose them in double quotes.

Description

shp2dta reads a shape (.shp) and dBase (.dbf) file from disk and converts them into Stata datasets. The shape and dBase files must have the same name and be saved in the same directory. The user-written command tmap can use the two datasets that shp2dta creates. shp2dta can convert only point, line, and polygon shapefiles (type 1, 3, and 5).

Options

+------+ ----+ Main +-------------------------------------------------------------

database(filename) specifies the name of the new Stata dataset to contain the .dbf file data. This option is required.

coordinates(filename) specifies the name of the new Stata dataset to contain the .shp file data. This option is required.

replace overwrites any existing Stata dataset with the names specified in the database(filename) and coordinates(filename) options.

genid(newvarname) specifies the name of the new numeric variable that, in file database.dta, will uniquely identify the different geographical areas of interest. The values taken on by newvarname will correspond to the values taken on by variable _ID in file coordinates.dta.

gencentroids(stub) requests that the coordinates of the centroids of the geographical areas of interest be computed, stored in variables x_stub and y_stub, and added to file database.dta. You must also specify the genid(newvarname) option.

Examples

To demonstrate the use of shp2dta let's suppose we have two files, asia.dbf and asia.shp, in our current working directory. Two convert these files to two Stata datasets we type:

. shp2dta using asia, data("asia_data") coor("asia_coordinates")

In the current working directory we now have two files, asia_data.dta and asia_coordinates.dta, that have the converted data.

Author

Kevin Crow StataCorp L.P. kcrow@stata.com