[R-sig-Geo] Reading and using shapefile metadata?

Don MacQueen macq at llnl.gov
Wed Mar 31 01:45:07 CEST 2010


I'm reading shapefiles from the US Census Bureau known as Tiger files. See
   http://www.census.gov/geo/www/tiger/tgrshp2008/tgrshp2008.html

An example is:

   kc.edges.ll <- 
readOGR(file.path(tiger.king.dir,'tl_2009_53033_edges'),'tl_2009_53033_edges')

which creates (in this case) a SpatialLinesDataFrame.

The directory ( "dsn" argument to readOGR()) in this example includes 
six files:
    tl_2009_53033_edges.dbf
    tl_2009_53033_edges.prj
    tl_2009_53033_edges.shp
    tl_2009_53033_edges.shp.xml
    tl_2009_53033_edges.shx

The Tiger documentation says that the .shp.xml file contains 
metadata, and indeed it does. For example, here is an excerpt:
(I have removed indentation)

<attr>
<attrlabl>MTFCC</attrlabl>
<attrdef>MAF/TIGER feature class code of the primary feature for the 
edge</attrdef>
<attrdefs>U.S. Census Bureau</attrdefs>
<attrdomv>
	<edom>
	<edomv>C3023</edomv>
	<edomvd>Island</edomvd>
	<edomvds>U.S. Census Bureau</edomvds>
	</edom>

In brief, this section of metadata decodes the codes in the "MTFCC" 
column in kc.edges.ll at data into human-friendly text string.

I would like to be able to somehow link to or display the decoded 
values when I look at the data.

Is there some function or package or something that I can use to gain 
access to the xml metadata and work with it in subsequent scripts 
that operate on this kc.edges.ll SpatialLinesDataFrame object?

R, QGis, or even GRASS tools would be much appreciated.

Thanks
-Don
-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062



More information about the R-sig-Geo mailing list