spMetadata-methods {plotKML}R Documentation

Methods to generate spatial metadata


The spMetadata function will try to generate missing metadata (bounding box, location info, session info, metadata creator info and similar) for any Spatial* object (from the sp package) or Raster* object (from the raster package). The resulting object of class SpatialMetadata-class can be used e.g. to generate a Layer description documents (<description> tag).
The read.metadata function reads the formatted metadata (.xml), prepared following e.g. the Federal Geographic Data Committee (FGDC) Content Standard for Digital Geospatial Metadata or INSPIRE standard, and converts them to a data frame.


## S4 method for signature 'RasterLayer'
spMetadata(obj, bounds, color, ... )
## S4 method for signature 'Spatial'
spMetadata(obj, xml.file, out.xml.file, 
    md.type = c("FGDC", "INSPIRE")[1],
    generate.missing = TRUE, GoogleGeocode = FALSE,
    signif.digit = 3, colour_scale, color = NULL, bounds,
    legend_names, icons, validate.schema = FALSE, ...)



some "Spatial" or "Raster" class object with "data" slot


character; optional input XML metadata file


character; optional output XML metadata file


character; metadata standard FGDC or INSPIRE


logical; specifies whether to automatically generate missing fields


logical; specifies whether the function should try to use GoogleGeocoding functionality to determine the location name


integer; the default number of significant digits (in the case of rounding)


the color scheme used to visualize this data


character; list of colors (rgb()) that can be passed instead of using the pallete


numeric vector; upper and lower bounds used for visualization


character; legend names in the order of bounds


character; file name or URL used for icons (if applicable)


logical; specifies whether to validate the schema using the xmlSchemaValidate


additional arguments to be passed e.g. via the metadata.env()


spMetadata tries to locate a metadata file in the working directory (it looks for a metadata file with the same name as the object name). If no .xml file exists, it will load the template xml file available in the system folder (e.g. system.file("FGDC.xml", package="plotKML") or system.file("INSPIRE_ISO19139.xml", package="plotKML")). The FGDC.xml/INSPIRE_ISO19139.xml files contain typical metadata entries with description and examples. For practical purposes, one metadata object in plotKML can be associated with only one variable i.e. one column in the "data" slot (the first column by default). To prepare a metadata xml file following the FGDC standard, consider using e.g. the Tkme software: Another editor for formal metadata, by Peter N. Schweitzer (U.S. Geological Survey). Before commiting the metadata file, try also running a validation test. Before committing the metadata file following the INSPIRE standard, try running the INSPIRE Geoportal Metadata Validator.
spMetadata tries to automatically generate the most usefull information, so that a user can easily find out about the input data and procedures followed to generate the visualization (KML). Typical metadata entries include e.g. (FGDC):

and for INSPIRE metadata:

By default, plotKML uses the Creative Commons license, but this can be adjusted by setting the Use_Constraints argument.


Tomislav Hengl and Michael Blaschek


See Also

kml_metadata, SpatialMetadata-class, sp::Spatial, kml_open


## Not run: 
## read metadata from the system file:
x <- read.metadata(system.file("FGDC.xml", package="plotKML"))
## generate missing metadata
coordinates(eberg) <- ~X+Y
proj4string(eberg) <- CRS("+init=epsg:31467")
## no metadata file specified:
eberg.md <- spMetadata(eberg["SNDMHT_A"])
## this generates some metadata automatically e.g.:
## combine with localy prepared metadata file:
eberg.md <- spMetadata(eberg["SNDMHT_A"], 
    xml.file=system.file("eberg.xml", package="plotKML"))
## Additional metadat entries can be added by using e.g.:
eberg.md <- spMetadata(eberg["SNDMHT_A"], 
  CI_Citation_title = 'Ebergotzen data set',
  CI_Online_resource_URL = 'http://geomorphometry.org/content/ebergotzen')
## the same using the FGDC template:
eberg.md <- spMetadata(eberg["SNDMHT_A"], 
  Citation_title = 'Ebergotzen data set',
  Citation_URL = 'http://geomorphometry.org/content/ebergotzen')
## Complete list of names:
mdnames <- read.csv(system.file("mdnames.csv", package="plotKML"))
## these can be assigned to the "metadata" environment by using:
metadata.env(CI_Citation_title = 'Ebergotzen data set')
get("CI_Citation_title", metadata)

## write data and metadata to a file:
writeOGR(eberg["SNDMHT_A"], "eberg_SAND.shp", ".", "ESRI Shapefile")
saveXML(eberg.md@xml, "eberg_SAND.xml")
## export to SLD format:
metadata2SLD(eberg.md, "eberg.sld")
## plot the layer with the metadata:
kml(eberg, file.name = "eberg_md.kml", colour = SNDMHT_A, metadata = eberg.md, kmz = TRUE)

## End(Not run)

[Package plotKML version 0.5-9 Index]