[R-sig-Geo] Reading and using shapefile metadata?
Dan Putler
dan.putler at sauder.ubc.ca
Wed Mar 31 02:11:07 CEST 2010
Hi Don,
In R, the only thing I can think to do is parse the XML (using the R XML
package), creating a data frame that has the attribute labels as one
column and the human friendly text strings in another. You can then
merge this data frame with the SpatialLinesDataFrame containing the
edges.
Dan
On Tue, 2010-03-30 at 16:45 -0700, Don MacQueen wrote:
> 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
--
Dan Putler
Sauder School of Business
University of British Columbia
More information about the R-sig-Geo
mailing list