But where are these soil science researchers? R code for producing the  HTML and KML directory
4 pages
English

But where are these soil science researchers? R code for producing the HTML and KML directory

-

Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
4 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

But where are these soil science researchers?R code for producing the HTML and KMLdirectoryJulien MoeysSeptember 30, 2009Contents1 About this document 12 Files needed 23 Time needed 24 Set the directory and load R KML functions 25 Import and clean the data 26 Write the KML le 37 Write the HTML bookmark le 38 Compact the KML le into a KMZ le 41 About this documentThis document has been created by Julien MOEYS. See the my website formore information and contact details (especially the page But where are theseSoil Science researchers?).This document and the soil laboratory directory DATA are licensed under aCreative Commons Attribution-Share Alike 3.0 Unported or higher.The R code (functions that produce HTML and KML le from the CSV ta-ble of soil science laboratories) is licensed under a GNU General Public Licenseversion 3 or higher.Please feel free to contact the author (see website) if you have any questionor suggestion, but remember all this is provided with absolutely no garantee ofany kind.1ˆˆˆ''2 Files neededFor running this sample code, you need:The HTML and KML functions code in a le named FUNCTION KML.R;An export of the soil laboratories directory in the form of a CSV dataframe SOIL LABS.CSV;Eventually, 7zip program installed on your computer and executable fromthe command line (7z.exe)The code has been tested under Microsoft windows XP.3 Time neededOn my computer, running the whole script over 303 labs took 10 minutes ...

Informations

Publié par
Nombre de lectures 23
Langue English

Extrait

But where are these soil science researchers?
R code for producing the HTML and KML
directory
Julien Moeys
September 30, 2009
Contents
1 About this document 1
2 Files needed 2
3 Time needed 2
4 Set the directory and load R KML functions 2
5 Import and clean the data 2
6 Write the KML le 3
7 Write the HTML bookmark le 3
8 Compact the KML le into a KMZ le 4
1 About this document
This document has been created by Julien MOEYS. See the my website for
more information and contact details (especially the page But where are these
Soil Science researchers?).
This document and the soil laboratory directory DATA are licensed under a
Creative Commons Attribution-Share Alike 3.0 Unported or higher.
The R code (functions that produce HTML and KML le from the CSV ta-
ble of soil science laboratories) is licensed under a GNU General Public License
version 3 or higher.
Please feel free to contact the author (see website) if you have any question
or suggestion, but remember all this is provided with absolutely no garantee of
any kind.

ˆ
ˆ
'
'
2 Files needed
For running this sample code, you need:
The HTML and KML functions code in a le named FUNCTION KML.R;
An export of the soil laboratories directory in the form of a CSV data
frame SOIL LABS.CSV;
Eventually, 7zip program installed on your computer and executable from
the command line (7z.exe)
The code has been tested under Microsoft windows XP.
3 Time needed
On my computer, running the whole script over 303 labs took 10 minutes.
The code is optimised (with "lapply" & co), but some parts may need further
improvements.
4 Set the directory and load R KML functions
# Date of script START:
date()
[1] "Wed Sep 30 14:53:37 2009"
# Set the directory:
setwd("C:/_RTOOLS/SWEAVE_WORK/KML_SOIL_LABS")
# Import the functions:
eval( parse( file = "FUNCTION_KML.R" ) )
5 Import and clean the data
# Import the data
mydata <- read.table(
file = "SOIL_LABS.CSV",
header = TRUE,
sep = ",",
dec = ".",
stringsAsFactors = FALSE,
na.strings = "",
quote = " ,
encoding = "UTF-8"
) #
# Clean the data from eventual "missing data"
dim(mydata)
[1] 315 8
2mydata <- clean.dtf(mydata)
dim(mydata)
[1] 315 8
# Display columns names
colnames(mydata)
[1] "name" "wgs_lat" "wgs_long" "description"
[5] "name_url" "institution" "city" "country"
6 Write the KML le
write.point.kml(
data.s = mydata,
fileName = "SOIL_LABS.kml",
fileDir = getwd(),
lat = "wgs_lat",
long = "wgs_long",
folderCol = "country",
placeMCol = "city",
alt = NULL,
name = "name",
description = "description",
additional = "institution",
descUrl = "name_url",
iconUrl =
"http://maps.google.com/mapfiles/kml/shapes/poi.png",
iconScale = 1.0,
GMUrlZoom = 14,
encoding = "UTF-8"
) #
7 Write the HTML bookmark le
In the text below, change "Firstname FAMILYNAME" by your name if you
create yourself the directory le (and state somewhere that this is a derived
data from me (Julien MOEYS), in case you distribute the result of this script).
write.point.html(
data.s = mydata,
fileName = "SOIL_LABS_BOOKMARKS.HTML",
fileDir = getwd(),
lat = "wgs_lat",
long = "wgs_long",
folderCol = "country",
placeMCol = "city",
alt = NULL,
name = "name",
3description = "description",
additional = "institution",
descUrl = "name_url",
iconUrl = "http://maps.google.com/mapfiles/kml/shapes/poi.png",
iconScale = 1.0,
GMUrlZoom = 14,
encoding = "UTF-8",
doc.title = "World Soil Science Labs",
doc.author = "Firstname FAMILYNAME",
doc.C.own = "Firstname FAMILYNAME",
doc.licence = "Creative Commons Attribution-Share Alike 3.0",
doc.licence.url = "http://creativecommons.org/licenses/by-sa/3.0/",
doc.licence.txt = "Some rights reserved"
) #
8 Compact the KML le into a KMZ le
The sample code below require 7zip to be installed and available from the com-
mand line (7z.exe). It works under MS Windows. It is not necessary to compact
the KML

  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents