Learn R Programming

plotKML (version 0.4-2)

spMetadata-methods: Methods to generate spatial metadata

Description

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 ( tag). The read.metadata function can be used to read the formatted metadata (.xml), prepared following to the http://www.fgdc.gov/metadata/csdgm/{Federal Geographic Data Committee (FGDC) Content Standard for Digital Geospatial Metadata}, and convert them to a more readble format (data frame).

Usage

## S3 method for class 'RasterLayer':
spMetadata(obj, Target_variable, bounds, color, \dots )
## S3 method for class '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, Target_variable_descr = "NA", 
    Geosp_Data_Presentation_Form, Edition, Purpose, Abstract, 
    Supplinf, Publisher, Pub_Place, Temp_Ext,
    Update_Freq = c("Unknown", "Continually", "Daily", "Weekly", 
    "Monthly", "Annually", "As needed", "Irregular", "None planned"), 
    Stat_Progress = c("Complete", "In work", "Planned"), 
    Spatial_Represent_Type = c("Point", "Vector", "Raster"),
    Keyw_theme, Keyw_place )

Arguments

obj
some "Spatial" or "Raster" class object with "data" slot
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 bounds vector)
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 xmlSchemaValidate
Target_variable_descr
character; specifies target variable description for eainfo-node 'attrdef'
Geosp_Data_Presentation_Form
character; defines node 'geoform'
Edition
defines the version of the title
Purpose
defines the purpose of the given layer
Abstract
defines the abstract of the given layer
Supplinf
defines the supplemental information of the given layer
Publisher
defines publishing organization (or individual)
Pub_Place
defines publication place ('pubplace')
Temp_Ext
defines temporal extent start/end
Update_Freq
defines update frequency
Stat_Progress
defines progress status
Spatial_Represent_Type
defines direct node (direct spatial reference method)
Keyw_theme
defines node(s) 'themekey'
Keyw_place
defines node(s) 'placekey'
...
additional arguments to be passed

Details

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 http://plotkml.r-forge.r-project.org/FGDC.xml{FGDC.xml} template file; to enter the missing fields use e.g. the http://geology.usgs.gov/tools/metadata/tools/doc/tkme.html{Tkme} software: Another editor for formal metadata, by Peter N. Schweitzer (U.S. Geological Survey). Before commiting the metadata file, try also running a http://geo-nsdi.er.usgs.gov/validation/{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 thehttp://code.google.com/apis/maps/documentation/webservices/{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.

References

  • 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/)

See Also

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

Examples

Run this code
## 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)

Run the code above in your browser using DataLab