spMetadata-methods | 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 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, ...)
obj |
some |
xml.file |
character; optional input XML metadata file |
out.xml.file |
character; optional output XML metadata file |
md.type |
|
generate.missing |
logical; specifies whether to automatically generate missing fields |
GoogleGeocode |
logical; specifies whether the function should try to use GoogleGeocoding functionality to determine the location name |
signif.digit |
integer; the default number of significant digits (in the case of rounding) |
colour_scale |
the color scheme used to visualize this data |
color |
character; list of colors ( |
bounds |
numeric vector; upper and lower bounds used for visualization |
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 |
... |
additional arguments to be passed e.g. via the |
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 (https://mrdata.usgs.gov/validation/). 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):
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.
and for INSPIRE metadata:
metadata[["fileIdentifier"]][["CharacterString"]]
— Metadata file identifier (not mandatory for INSPIRE-compl.) created by UUIDgenerate from package UUID (version 4 UUID).
metadata[["dateStamp"]][["Date"]]
— Metadata date stamp created using Sys.Date().
metadata[["identificationInfo"]][["MD_DataIdentification"]]
[["extent"]][["EX_Extent"]][["geographicElement"]][["EX_GeographicBoundingBox"]]
— 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 Use_Constraints
argument.
Tomislav Hengl and Michael Blaschek
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/)
Tkme metadata editor (http://geology.usgs.gov/tools/metadata/tools/doc/tkme.html)
INSPIRE, INS MD, Commission Regulation (EC) No 1205/2008 of 3 December 2008 implementing Directive 2007/2/EC of the European Parliament and of the Council as regards metadata (Text with EEA relevance). See also Corrigendum to INSPIRE Metadata Regulation.
INSPIRE, INS MDTG, (2013) INSPIRE Metadata Implementing Rules: Technical Guidelines based on EN ISO 19115 and EN ISO 19119, v1.3
kml_metadata
, SpatialMetadata-class
, sp::Spatial
, kml_open
## Not run: library(sp) library(uuid) library(rjson) ## 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["SNDMHT_A"]) ## this generates some metadata automatically e.g.: xmlRoot(eberg.md@xml)[["eainfo"]][["detailed"]][["attr"]] ## 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"], md.type="INSPIRE", 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")) mdnames$field.names ## 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: library(rgdal) 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.