Description Usage Arguments Details Examples
View source: R/180707_SwissTopo.R
This function take as address information as arguements and retrieves the geocodes using the swiss topo API. The minimum information required is the postal code. When insufficient information is provided then the function returns the central point of all possible addresses with a precision metric. The presicion metric is the distance of the mid-point retrieved to the most remote address of this area. Precision 0 means precise geocode. If the precision is NA, swiss topo could not identify this address, implying a mistake in the impute, like spelling mistake in the street name or no correspondance between street and postal code. If the incorrect information cannot be identified, then one could omit the least reliable information and rerun the algorithm to get a centroid with some precision parameter. The unit of the precision is the same as the unit of the geocodes.
1 2 | SwissTopoGeocodes(street = "", number = "", postal = postal, city = "",
precision = F)
|
street |
the street name, if not given set to blank |
number |
the street number, if not given set to blank |
postal |
the postal code, the minimum requred information |
city |
the city, if not given set to blank |
precision |
if TRUE gives a measure about the precision of geocode returned |
The output of this function is a list with two elements. The first is the geocode and the second some additional information. Additional information is only provided when precition is requested and if the geocode is not of precision NA or 0. The additional infromation gives the alternative geocodes of the given address.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Mittelstrasse 43, 3012, Bern
street <- "Mittelstrasse"
number <- "43"
postal <- "3012"
city <- "Bern"
MittelstrasseGeo <-
SwissTopoGeocodes(
street = street,
number =number,
postal = postal,
city = city, precision = T
)
# when insufficient information is given
street <- "Mittelstrasse"
number <- ""
postal <- "3012"
city <- ""
MittelstrasseGeo <-
SwissTopoGeocodes(
street = street,
number =number,
postal = postal,
city = city, precision = T
)
plot(MittelstrasseGeo$addinfo$x, MittelstrasseGeo$addinfo$y)
points(MittelstrasseGeo$geocode$x, MittelstrasseGeo$geocode$y, col = "red", pch = 19)
SwissTopoGeocodes()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.