# map.make: Turn a set of polygons into a polyline database In adeckmyn/mapMaker: Create map databases from Natural Earth data

## Description

Turn a set of polygons (as returned by `map(...,fill=TRUE)` or `read.regions()`) into a polyline-based data set.

## Usage

 ```1 2 3 4 5 6 7``` ```map.gon2line(map, precision=1.E-8) map.make(map, precision=1.E-8) map.split(ww) map.dups(ww) map.shift.gon(ww,valence=NULL) map.merge.segments(ww,valence=NULL) map.LR(ww) ```

## Arguments

 `map` A list with components `x,y,names`, as output from `map(fill=TRUE)` or `read.region()`. `ww` A list with components `gon`, `line` and `names`, which is also the format of the output. See 'value' for details. `valence` A numeric vector (output from `map.valence`). If NULL, it is computed inside the function. As this may take some time (e.g. about 1 minute for a world database) but is needed in two functions, it is convenient to calculate it separately. `precision` Data from Natural Earth may have some numerical 'jitter': identical points on two polygons may differ by some numerically insignificant amount. But since the identification of polylines depends on identifying common points, we must first 'clean' the data by setting all points that differ by less than the given precision, to be exactly equal. Given that the final result is written as 32bit floats, 8 decimals seems appropriate.

## Details

This set of functions performs the various steps necessary to transform a set of polygons into a data set of polylines that may be used as input for `maps`. A necessary condition is that the polygons need to have exactly matching borders. If this is not the case, the result may be completely random.

See 'examples' for quick discussion of the various functions.

## Value

All these functions, except `map.valence`, return an indexed data set of a map. After every step, the details may be different but the format is the same:

• x,y: the actual lines, separated by NA's.

• names: the names of all the polygons.

• line: all the lines in the set, with indexes and some extra information:

• nline: the number of lines in the data set.

• begin, end: vectors of length `nline` pointing at the first and last point of every line in the data vectors `x,y`.

• length: vector of length `nline` containing the length of every vector

• left, right: vectors of length `nline` containing the number of the polygon at the left and right of the line. May be missing or incomplete at some intermediate stages.

• gon: description of all the polygons:

• ngon: the number of polygons.

• length: vector of length `ngon`. The number of lines that every polygon conists of.

• data: all the lines that constitute the polygons. Negative values mean the line is followed in reverse direction. There is no NA separating the different polygons, so you need exact begin and end points.

• begin, end: vectors of length `ngon`: the begin and end point in the data vector.

## See Also

`maps:map`, `read.region`, `map.valence`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19``` ```## Not run: # a typical transformation sequence: be <- read.admin1(countries="BE") # read provincial borders map(be) # you can use map() to see the result be1 <- map.make(be) # turn into an internal format be2 <- map.split(be1) # split the polylines into segments consisting of 2 points be3 <- map.dups(be2) # remove all dupplicate segments val <- map.valence(be3) # calculate the 'valence' of every point (number of segments it belongs to) be4 <- map.shift.gon(be3,val) # shift the lines forming a polygon, until the polygon starts at a vertex be5 <- map.merge.segments(be4,val) # merge all segments to polylines that begin and end at a vertex be6 <- map.LR(be5) # fix which polygons are at left and right of a line # All this may be done in 1 call: be6 <- map.gon2line(be) map.export.bin(be6,file=paste(MY_MAP_PATH,"belgium",sep="/")) # save as a binary database Sys.setenv("R_MY_MAP_PATH"=MY_MAP_PATH) # map() uses environment variables to find data files belgiumMapEnv <- "R_MY_MAP_PATH" map(database="belgium") # see the final result ## End(Not run) ```

adeckmyn/mapMaker documentation built on May 10, 2019, 5:52 a.m.