| spMetadata-methods {plotKML} | R Documentation |
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 can be used to read the formatted metadata (.xml), prepared following to the Federal Geographic Data Committee (FGDC) Content Standard for Digital Geospatial Metadata, and convert them to a more readble format (data frame).
## S4 method for signature 'RasterLayer'
spMetadata(obj, Target_variable, bounds, color, ... )
## S4 method for signature 'Spatial'
spMetadata(obj, xml.file, generate.missing = TRUE, Citation_title,
Target_variable, Attribute_Measurement_Resolution = 1, Attribute_Units_of_Measure = "NA",
Indirect_Spatial_Reference = "", GoogleGeocode = FALSE,
Enduser_license_URL = get("license_url", envir = plotKML.opts),
signif.digit = 3, colour_scale, bounds, legend_names, icons, validate.schema = FALSE)
obj |
some |
xml.file |
character; optional XML metadata file |
generate.missing |
logical; specifies whether to automatically generate missing fields |
Citation_title |
character; title of the bibliographic reference for this data set |
Target_variable |
character; target variable name |
Attribute_Measurement_Resolution |
numeric; detection limit i.e. measurement precision |
Attribute_Units_of_Measure |
character; measurement units |
Indirect_Spatial_Reference |
character; location name as on the topographic map |
GoogleGeocode |
logical; specifies whether the function should try to use GoogleGeocoding functionality to determine the location name |
Enduser_license_URL |
character; URL to the end user license |
signif.digit |
integer; the default number of significant digits (in the case of rounding) |
colour_scale |
the colour scheme used to visualize this data |
bounds |
numeric vector; upper and lower bounds used for visualization |
color |
character; colour legend (must match the |
legend_names |
character; legend names in the order of bounds |
icons |
character; file name or URL used for icons (if applicable) |
validate.schema |
logical; specifies whether to validate the schema using the |
... |
optional arguments |
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 (system.file("FGDC.xml", package="plotKML")). The FGDC.xml file contains 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 (specified via Target_variable). To prepare a metadata xml file for the layer of interest, consider using the FGDC.xml template file; to enter the missing fields use 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.
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.:
metadata[["idinfo"]][["native"]] — Session info e.g.: Produced using R version 2.12.2 (2011-02-25) running on Windows 7 x64.
metadata[["spdoinfo"]][["indspref"]] — Indirect spatial reference estimated using the Google Maps API Web Services.
metadata[["idinfo"]][["spdom"]][["bounding"]] — Bounding box in the WGS84 geographical coordinates estimated by reprojecting the original bounding box.
By default, plotKML uses the Creative Commons license, but this can be adjusted by setting the Enduser_license_URL argument above.
Tomislav Hengl
The Federal Geographic Data Committee, (2006) FGDC Don't Duck Metadata — A short reference guide for writing quality metadata. Vers. 1, http://www.fgdc.gov/metadata/documents/MetadataQuickGuide.pdf
Content Standard for Digital Geospatial Metadata (http://www.fgdc.gov/metadata/csdgm/)
Template metadata file (http://plotkml.r-forge.r-project.org/FGDC.xml)
Tkme metadata editor (http://geology.usgs.gov/tools/metadata/tools/doc/tkme.html)
Creative Commons licenses (http://creativecommons.org/licenses/)
kml_metadata, SpatialMetadata-class, spMetadata.Spatial, sp::Spatial, kml_open
## Not run: # read metadata from the system file:
x <- read.metadata(system.file("FGDC.xml", package="plotKML"))
str(x)
# generate missing metadata
data(eberg)
coordinates(eberg) <- ~X+Y
proj4string(eberg) <- CRS("+init=epsg:31467")
# no metadata file specified:
eberg.md <- spMetadata(eberg, Target_variable="SNDMHT_A")
# with localy prepared metadata file:
eberg.md <- spMetadata(eberg, xml.file=system.file("eberg.xml", package="plotKML"),
Target_variable="SNDMHT_A")
# print the results of validation (it needs to be able to connect to a URL with schema):
eberg.md <- spMetadata(eberg, Target_variable="SNDMHT_A", validate.schema = TRUE)
# write the metadata to a file:
saveXML(metadata(eberg.md), "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)