[r-cran-maptools] 11/20: Import Upstream version 0.8-23

Andreas Tille tille at debian.org
Sun Jan 15 18:55:44 UTC 2017


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository r-cran-maptools.

commit f8e0f3add092b874fd6373bd5bde48467f582481
Author: Andreas Tille <tille at debian.org>
Date:   Sun Jan 15 19:53:28 2017 +0100

    Import Upstream version 0.8-23
---
 ChangeLog                                | 1234 +++++++++++++---------
 DESCRIPTION                              |   58 +-
 INDEX                                    |   54 -
 MD5                                      |  149 +++
 NAMESPACE                                |   16 +-
 R/AAA.R                                  |   23 +-
 R/CCmaps.R                               |    5 +-
 R/DP.R                                   |   11 +-
 R/Rgshhs.R                               |  115 ++-
 R/SpatialLines-methods.R                 |    2 +-
 R/SpatialPolys-methods.R                 |    8 +-
 R/asciigrid.R                            |    2 +-
 R/checkHoles.R                           |  122 ++-
 R/dotsinpolys.R                          |    9 +-
 R/elide.R                                |   22 +-
 R/gc_dist.R                              |    4 +-
 R/getKMLcoordinates.R                    |    5 +
 R/kmlLine.R                              |    2 +-
 R/kmlPoints.R                            |   89 ++
 R/kmlPolygon.R                           |    6 +-
 R/lineLabel.R                            |  271 +++++
 R/maptools.R                             |   10 +-
 R/maptoolsChanges.R                      |   38 +-
 R/midpoint.R                             |   49 +
 R/nowrapRecenter.R                       |   36 +-
 R/{pointLabel.R => pointLabelBase.R}     |  436 ++++----
 R/pointLabelLattice.R                    |  302 ++++++
 R/point_line_distance.R                  |   64 ++
 R/readSplus.R                            |    4 +-
 R/shapelib.R                             |   20 +-
 R/sp2pbs.R                               |  374 +++----
 R/sp_tools.R                             |    4 +-
 R/spatstat1.R                            |   80 +-
 R/spmaps.R                               |  258 +++--
 R/subset.R                               |    2 +-
 R/sun-methods.R                          |   19 +-
 R/sun.R                                  |   28 +-
 R/union.R                                |   15 +-
 data/SplashDams.rda                      |  Bin 0 -> 8097 bytes
 data/gpcholes.rda                        |  Bin 354 -> 354 bytes
 data/state.vbm.rda                       |  Bin 0 -> 4397 bytes
 data/wrld_simpl.rda                      |  Bin 355060 -> 283324 bytes
 inst/ChangeLog                           | 1234 +++++++++++++---------
 inst/changes                             |   74 +-
 inst/old_man/Map2poly.Rd                 |   92 --
 inst/old_man/get.Pcent.Rd                |   26 -
 inst/old_man/maptools.Rd                 |   25 -
 inst/old_man/plot.Map.Rd                 |   58 --
 inst/old_man/plot.polylist.Rd            |   66 --
 inst/old_man/read.shape.Rd               |   43 -
 inst/old_man/subset.polylist.Rd          |   33 -
 inst/old_man/write.linelistShape.Rd      |   48 -
 inst/old_man/write.pointShape.Rd         |   48 -
 inst/old_man/write.polylistShape.Rd      |   50 -
 inst/share/gshhs_c.b                     |  Bin 184528 -> 182584 bytes
 inst/share/wdb_borders_c.b               |  Bin 84912 -> 85144 bytes
 man/Rgshhs.Rd                            |   33 +-
 man/SpatialLines2PolySet.Rd              |    5 +-
 man/SpatialLinesMidPoints.Rd             |   34 +
 man/SplashDams.Rd                        |   37 +
 man/as.ppp.Rd                            |   21 +-
 man/asciigrid.Rd                         |    2 +-
 man/checkPolygonsHoles.Rd                |   45 +-
 man/elide-methods.Rd                     |  170 +--
 man/gcDestination.Rd                     |    0
 man/getKMLcoordinates.Rd                 |    2 +-
 man/gzAzimuth.Rd                         |    2 +-
 man/kmlLine.Rd                           |    4 -
 man/kmlPoints.Rd                         |   64 ++
 man/kmlPolygon.Rd                        |    4 -
 man/lineLabel.Rd                         |  132 +++
 man/map2SpatialPolygons.Rd               |    3 +-
 man/nearestPointOnLine.Rd                |   36 +
 man/nearestPointOnSegment.Rd             |   42 +
 man/nowrapRecenter.Rd                    |   17 +-
 man/pal2SpatialPolygons.Rd               |   15 +-
 man/{pointLabel.Rd => pointLabelBase.Rd} |  206 ++--
 man/pointLabelLattice.Rd                 |  106 ++
 man/readShapeLines.Rd                    |    6 +-
 man/readShapePoints.Rd                   |    4 +-
 man/readShapePoly.Rd                     |    9 +-
 man/readShapeSpatial.Rd                  |    6 +-
 man/readSplus.Rd                         |    2 +-
 man/snapPointsToLines.Rd                 |   61 ++
 man/sp2WB.Rd                             |    2 +-
 man/state.vbm.Rd                         |   49 +
 man/sun-methods.Rd                       |   61 +-
 man/thinnedSpatialPoly.Rd                |    9 +-
 man/unionSpatialPolygons.Rd              |   14 +-
 maptools-Ex.R                            | 1654 ++++++++++++++++++++++++++++++
 src/Rgshhs.c                             |   28 +-
 src/Rgshhs.h                             |   29 +-
 src/Rshapeget.c                          |    2 +-
 src/Rshapewrite1.c                       |    4 +-
 src/shapefil.h                           |    2 +-
 src/shpopen.c                            |    7 +-
 src/shptree.c                            |    4 +-
 97 files changed, 6072 insertions(+), 2604 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 74327f2..645949f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,814 +1,1022 @@
-2010-09-08 18:36  rsbivand
+2013-02-10 13:58  rsbivand
 
-	* DESCRIPTION, R/SpatialLines-methods.R, man/readShapeLines.Rd,
-	  man/readShapePoly.Rd, man/readShapeSpatial.Rd: zero nParts for
-	  lines
+	* .Rbuildignore: don't ship old_man
 
-2010-08-28 12:34  rsbivand
+2013-02-09 10:22  rsbivand
 
-	* R/Rgshhs.R, R/maptools.R, R/shapelib.R, R/sp2pbs.R, R/sp_spat1.R,
-	  R/union.R, ChangeLog, inst/ChangeLog: as.double to storage.mode
+	* DESCRIPTION, src/Rgshhs.c, src/Rshapeget.c, src/Rshapewrite1.c: C
+	  code warning cleanup; new-style contribs
 
-2010-08-26 12:36  rsbivand
+2013-01-16 09:24  rsbivand
 
-	* ChangeLog, inst/ChangeLog: check Sys.which value
+	* ChangeLog, inst/ChangeLog: tidy
 
-2010-08-26 12:32  rsbivand
+2013-01-16 09:22  rsbivand
 
-	* DESCRIPTION, R/readGPS.R: check Sys.which value
+	* DESCRIPTION, R/AAA.R: move startup message to .onAttach
 
-2010-08-12 17:08  rsbivand
+2013-01-04 00:36  oscarperpi
 
-	* R/kmlLine.R, man/holepolys.Rd, DESCRIPTION, ChangeLog,
-	  inst/ChangeLog: data docs fix
+	* man/lineLabel.Rd: Fixed description in lineLabel.Rd
 
-2010-04-22 04:47  rsbivand
+2012-12-21 12:36  rsbivand
 
-	* DESCRIPTION, R/shapelib.R, ChangeLog, inst/ChangeLog: read.shape
-	  filen without extension
+	* ChangeLog, inst/ChangeLog: tidy
 
-2010-04-12 08:55  rsbivand
+2012-11-19 13:29  edzer
 
-	* DESCRIPTION, ChangeLog, inst/ChangeLog: tidy
+	* DESCRIPTION, R/dotsinpolys.R: version bump, added URL
+	  dotsinpolygons: renamed sample.Polygons to spsample, so we can
+	  retire sample.Xxx in sp
 
-2010-04-05 12:42  rsbivand
+2012-11-19 13:00  oscarperpi
 
-	* DESCRIPTION, man/checkPolygonsHoles.Rd,
-	  man/thinnedSpatialPoly.Rd, man/unionSpatialPolygons.Rd: comment
-	  out links to rgeos
+	* NAMESPACE: new method "label" for line labels
 
-2010-04-03 21:24  rsbivand
+2012-11-19 12:59  oscarperpi
 
-	* DESCRIPTION, R/DP.R, R/Rgshhs.R, R/checkHoles.R,
-	  R/nowrapRecenter.R, R/union.R, ChangeLog, inst/ChangeLog: hide
-	  rgeos
+	* man/lineLabel.Rd: new line labels examples added
 
-2010-04-03 18:22  rsbivand
+2012-11-19 12:59  oscarperpi
 
-	* R/shapelib.R, ChangeLog, inst/ChangeLog: DBF filename, GSHHS C
-	  code errors addressed
+	* R/lineLabel.R: line label algorithm improved
 
-2010-04-03 18:01  rsbivand
+2012-11-12 09:25  rsbivand
 
-	* DESCRIPTION, R/AAA.R, R/shapelib.R, R/union.R,
-	  man/readShapeLines.Rd, man/readShapePoints.Rd,
-	  man/readShapePoly.Rd, man/readShapeSpatial.Rd,
-	  man/unionSpatialPolygons.Rd, src/Rgshhs.c, src/Rgshhs.h,
-	  ChangeLog, inst/ChangeLog: DBF filename, GSHHS C code errors
-	  addressed
+	* ChangeLog, inst/ChangeLog: tidy
 
-2010-01-17 20:26  rsbivand
+2012-11-12 09:24  rsbivand
 
-	* R/AAA.R, R/sp_bind.R, man/spRbind-methods.Rd: change spRbind for
-	  SpatialPointsDataFrame objects
+	* ChangeLog, DESCRIPTION, R/CCmaps.R: fix bug in CCmaps
 
-2010-01-10 20:42  rsbivand
+2012-11-06 07:17  rsbivand
 
-	* ChangeLog, inst/ChangeLog: gshhs hole fix
+	* DESCRIPTION, NAMESPACE, man/lineLabel.Rd,
+	  man/pointLabelLattice.Rd: add drawDetails.labels to NAMESPACE
 
-2010-01-10 20:37  rsbivand
+2012-11-05 08:11  rsbivand
 
-	* R/Rgshhs.R: gshhs hole fix
+	* ChangeLog, inst/ChangeLog: tidy
 
-2010-01-08 10:46  rsbivand
+2012-11-05 08:11  rsbivand
 
-	* R/Rgshhs.R, ChangeLog, inst/ChangeLog: hole assignment in GSHHS
+	* DESCRIPTION, NAMESPACE, R/lineLabel.R, R/pointLabel.R,
+	  R/pointLabelBase.R, R/pointLabelLattice.R, man/lineLabel.Rd,
+	  man/pointLabel.Rd, man/pointLabelBase.Rd,
+	  man/pointLabelLattice.Rd, man/sp2WB.Rd: to UTF-8; adding lattice
+	  pointLabel
 
-2010-01-07 19:07  rsbivand
+2012-11-04 16:04  rsbivand
 
-	* ChangeLog, inst/ChangeLog: rgeos integration
+	* ChangeLog, inst/ChangeLog: tidy
 
-2010-01-07 19:03  rsbivand
+2012-10-29 14:39  rsbivand
 
-	* R/AAA.R, R/Rgshhs.R, man/Rgshhs.Rd: rgeos integration
+	* DESCRIPTION, R/spatstat1.R: branching in owin2Polygons on
+	  as.polygonal type
 
-2010-01-07 13:10  rsbivand
+2012-08-22 12:35  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/DP.R, R/Rgshhs.R, R/checkHoles.R,
-	  R/nowrapRecenter.R, R/union.R, R/zzz.R, man/Rgshhs.Rd,
-	  man/checkPolygonsHoles.Rd, man/nowrapRecenter.Rd,
-	  man/thinnedSpatialPoly.Rd, man/unionSpatialPolygons.Rd, R/AAA.R:
-	  rgeos integration
+	* man/SpatialLines2PolySet.Rd, man/map2SpatialPolygons.Rd,
+	  man/pal2SpatialPolygons.Rd: make suggests if(require())
+
+2012-08-09 12:58  rsbivand
+
+	* DESCRIPTION, R/Rgshhs.R, man/Rgshhs.Rd: Rgshhs SpatialCollections
+	  avoidance
+
+2012-07-22 13:10  rsbivand
+
+	* R/midpoint.R: correct midpoint data.frame
+
+2012-06-29 08:45  rsbivand
+
+	* ChangeLog, inst/ChangeLog: tidy
+
+2012-06-08 20:10  rsbivand
+
+	* ChangeLog, inst/ChangeLog: tidy
+
+2012-06-08 20:08  rsbivand
+
+	* DESCRIPTION, NAMESPACE, R/midpoint.R,
+	  man/SpatialLinesMidPoints.Rd: add line midpoint
+
+2012-05-09 08:12  rsbivand
+
+	* R/getKMLcoordinates.R: blanks in KML input
+
+2012-05-04 08:29  rsbivand
+
+	* R/elide.R: copy comment in elide
+
+2012-05-03 11:09  rsbivand
+
+	* DESCRIPTION, NAMESPACE, R/point_line_distance.R,
+	  man/nearestPointOnLine.Rd, man/nearestPointOnSegment.Rd,
+	  man/snapPointsToLines.Rd: adding functions for snapping points to
+	  lines by German Carrillo
+
+2012-02-06 09:13  rsbivand
 
-2009-12-21 13:39  rsbivand
+	* DESCRIPTION, man/Rgshhs.Rd: Rgshhs documentation
 
-	* ChangeLog, INDEX, inst/ChangeLog: adding CCmaps
+2012-01-27 12:29  rsbivand
 
-2009-12-21 13:35  rsbivand
+	* man/unionSpatialPolygons.Rd: fix documentation
 
-	* DESCRIPTION, NAMESPACE, R/CCmaps.R, man/CCmaps.Rd, src/Rgshhs.c:
-	  adding CCmaps
+2012-01-15 13:15  rsbivand
 
-2009-12-18 22:56  rsbivand
+	* ChangeLog, DESCRIPTION, inst/ChangeLog: tidy
 
-	* inst/share/gshhs_c.b, inst/share/wdb_borders_c.b, man/Rgshhs.Rd,
-	  man/spRbind-methods.Rd, src/Rgshhs.c, src/Rgshhs.h: GSHHS upgrade
-	  to 2.0
+2012-01-12 06:50  rsbivand
 
-2009-12-03 08:34  rsbivand
+	* man/SplashDams.Rd: updated source for splash dam data
 
-	* INDEX, ChangeLog, inst/ChangeLog: hole example format change
+2012-01-09 19:08  rsbivand
 
-2009-12-03 08:31  rsbivand
+	* DESCRIPTION, NAMESPACE, R/kmlPoints.R, data/SplashDams.rda,
+	  man/SplashDams.Rd, man/kmlPoints.Rd: adding kmlPoints
 
-	* ChangeLog, DESCRIPTION, data/gpcholes.rda, man/holepolys.Rd,
-	  inst/ChangeLog: hole example format change
+2012-01-02 18:14  rsbivand
 
-2009-11-23 12:49  rsbivand
+	* DESCRIPTION, data/state.vbm.rda, man/state.vbm.Rd: adding
+	  state.vbm
 
-	* man/getinfo.shape.Rd, ChangeLog, inst/ChangeLog: reinstate
-	  getinfo.shape
+2011-12-19 09:01  rsbivand
 
-2009-11-23 12:45  rsbivand
+	* ChangeLog, inst/ChangeLog: upgrade GSHHS to 2.2.0
 
-	* NAMESPACE: reinstate getinfo.shape
+2011-12-19 09:00  rsbivand
 
-2009-11-20 13:26  rsbivand
+	* DESCRIPTION, inst/share/gshhs_c.b, inst/share/wdb_borders_c.b,
+	  man/Rgshhs.Rd, src/Rgshhs.c, src/Rgshhs.h: upgrade GSHHS to 2.2.0
 
-	* DESCRIPTION, NAMESPACE, R/dotsinpolys.R,
-	  inst/old_man/Map2poly.Rd, inst/old_man/get.Pcent.Rd,
-	  inst/old_man/maptools.Rd, inst/old_man/plot.Map.Rd,
-	  inst/old_man/plot.polylist.Rd, inst/old_man/read.shape.Rd,
-	  inst/old_man/subset.polylist.Rd,
-	  inst/old_man/write.linelistShape.Rd,
-	  inst/old_man/write.pointShape.Rd,
-	  inst/old_man/write.polylistShape.Rd, man/Map2poly.Rd,
-	  man/dotsInPolys.Rd, man/get.Pcent.Rd, man/holepolys.Rd,
-	  man/maptools.Rd, man/plot.Map.Rd, man/plot.polylist.Rd,
-	  man/read.shape.Rd, man/readShapeLines.Rd, man/readShapePoints.Rd,
-	  man/readShapePoly.Rd, man/readShapeSpatial.Rd,
-	  man/subset.polylist.Rd, man/symbolsInPolys.Rd,
-	  man/write.linelistShape.Rd, man/write.pointShape.Rd,
-	  man/write.polylistShape.Rd, man/leglabs.Rd, ChangeLog,
-	  inst/ChangeLog: moving deprecated functions from namespace
+2011-11-17 08:19  rsbivand
 
-2009-11-19 21:11  rsbivand
+	* DESCRIPTION, NAMESPACE, R/spatstat1.R, man/as.ppp.Rd: adding
+	  as.SpatialLines.psp
 
-	* DESCRIPTION, NAMESPACE, R/DP.R, man/spCbind-methods.Rd,
-	  man/spRbind-methods.Rd, man/thinnedSpatialPoly.Rd, ChangeLog,
-	  inst/ChangeLog: adding thinnedSpatialPoly
+2011-11-14 21:35  rsbivand
 
-2009-11-05 17:26  edzer
+	* DESCRIPTION, R/checkHoles.R, R/pointLabel.R, R/sun.R,
+	  src/shpopen.c: complete partial argument matches
 
-	* R/sp_bind.R, man/spChFIDs-methods.Rd: moved spChFID method,
-	  functions and docs to package sp
+2011-08-08 18:52  rsbivand
 
-2009-09-17 10:22  rsbivand
+	* man/readShapeLines.Rd, man/readShapePoints.Rd,
+	  man/readShapePoly.Rd, man/readShapeSpatial.Rd: link to write.dbf
 
-	* DESCRIPTION, man/GE_SpatialGrid.Rd, man/Map2poly.Rd,
-	  man/SpatialLines2PolySet.Rd, man/asciigrid.Rd, man/kmlLine.Rd,
-	  man/kmlOverlay.Rd, man/nowrapRecenter.Rd, ChangeLog,
-	  inst/ChangeLog: fix documentation links
+2011-08-07 11:49  rsbivand
 
-2009-07-14 11:17  rsbivand
+	* ChangeLog, inst/ChangeLog: editing startup message
 
-	* man/: GE_SpatialGrid.Rd, kmlLine.Rd, kmlOverlay.Rd,
-	  kmlPolygon.Rd: KML WGS84 notes added
+2011-08-07 11:48  rsbivand
 
-2009-06-22 16:52  rsbivand
+	* R/AAA.R: editing startup message
 
-	* ChangeLog, DESCRIPTION, R/SpatialPolys-methods.R, inst/ChangeLog:
-	  changed all.equal to identical in closed ring forcing
+2011-08-07 11:33  rsbivand
 
-2009-06-10 16:33  rsbivand
+	* inst/ChangeLog: editing startup message
 
-	* ChangeLog, DESCRIPTION, R/SpatialPolys-methods.R, inst/ChangeLog:
-	  more NULL geometry trapping
+2011-08-07 11:32  rsbivand
 
-2009-05-26 12:22  rsbivand
+	* ChangeLog: editing startup message
 
-	* ChangeLog, DESCRIPTION, R/sp_spat1.R, R/spatstat1.R,
-	  inst/ChangeLog, man/as.ppp.Rd: coercion from owin/tess to
-	  SpatialPolygons
+2011-08-07 11:28  rsbivand
 
-2009-04-08 19:29  rsbivand
+	* NAMESPACE, man/Rgshhs.Rd, man/checkPolygonsHoles.Rd,
+	  man/nowrapRecenter.Rd, man/unionSpatialPolygons.Rd: editing
+	  startup message
 
-	* ChangeLog, DESCRIPTION, R/spatstat1.R, inst/ChangeLog:
-	  improvements to spatstat support - Adrian Baddeley
+2011-08-06 14:18  rsbivand
 
-2009-03-29 17:32  rsbivand
+	* DESCRIPTION, R/AAA.R, R/checkHoles.R: edited startup message
 
-	* ChangeLog, DESCRIPTION, inst/ChangeLog: drop=FALSE in reading
-	  line and polygon shapefiles
+2011-06-11 05:38  rsbivand
 
-2009-03-29 17:29  rsbivand
+	* ChangeLog, inst/ChangeLog: permit NA IDs in union
 
-	* LICENSE, R/SpatialLines-methods.R, R/SpatialPolys-methods.R,
-	  inst/LICENSE: drop=FALSE in reading line and polygon shapefiles
+2011-06-11 05:37  rsbivand
 
-2009-03-17 21:43  vir
+	* DESCRIPTION, R/union.R, man/unionSpatialPolygons.Rd: permit NA
+	  IDs in union
 
-	* R/readSplus.R: Minor fix to allow for a line with NA's just
-	  before the END.
+2011-06-10 08:03  rsbivand
 
-2009-03-10 18:23  rsbivand
+	* ChangeLog, inst/ChangeLog: documenting unionSpatialPolygons
+	  change
 
-	* INDEX, LICENSE, inst/LICENSE, ChangeLog, inst/ChangeLog: data web
-	  link
+2011-06-10 08:02  rsbivand
 
-2009-02-18 12:58  rsbivand
+	* DESCRIPTION: documenting unionSpatialPolygons change
 
-	* inst/shapes/fylk-val-ll.dbf, inst/shapes/fylk-val-ll.shp,
-	  inst/shapes/fylk-val-ll.shx, data/wrld_simpl.rda, ChangeLog,
-	  inst/ChangeLog: kml writing; GSHHS lines shift
+2011-06-10 08:00  rsbivand
 
-2009-02-18 12:55  rsbivand
+	* ChangeLog, inst/ChangeLog: documenting unionSpatialPolygons
+	  change
 
-	* ChangeLog, DESCRIPTION, INDEX, NAMESPACE, R/Rgshhs.R,
-	  inst/ChangeLog, inst/LICENSE, inst/share/gshhs_c.b,
-	  man/Rgshhs.Rd, R/getKMLcoordinates.R, R/kmlLine.R,
-	  R/kmlPolygon.R, man/getKMLcoordinates.Rd, man/kmlLine.Rd,
-	  man/kmlPolygon.Rd, man/wrld_simpl.Rd: kml writing; GSHHS lines
-	  shift
+2011-06-10 07:58  rsbivand
 
-2009-02-05 18:45  rsbivand
+	* man/unionSpatialPolygons.Rd: documenting unionSpatialPolygons
+	  change
 
-	* man/asciigrid.Rd: tidy
+2011-06-09 08:10  rsbivand
 
-2009-02-05 16:38  rsbivand
+	* DESCRIPTION, R/union.R, man/unionSpatialPolygons.Rd: added
+	  gUnaryUnion to unionSpatialPolygons
 
-	* R/readSplus.R, man/sp2WB.Rd, ChangeLog, inst/ChangeLog: adding
-	  features to readSplus
+2011-05-06 06:14  rsbivand
 
-2009-02-05 14:38  rsbivand
+	* ChangeLog, inst/ChangeLog: tidy
+
+2011-05-06 06:13  rsbivand
+
+	* DESCRIPTION, R/spatstat1.R, man/as.ppp.Rd: superimpose correction
+
+2011-04-29 06:29  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/readSplus.R, inst/share/Splus.map,
-	  man/readSplus.Rd, ChangeLog, inst/ChangeLog: adding readSplus for
-	  WinBUGS
+	* ChangeLog, inst/ChangeLog: change superimpose
 
-2009-01-20 15:38  rsbivand
+2011-04-29 06:28  rsbivand
 
-	* DESCRIPTION, R/sun-methods.R, ChangeLog, inst/ChangeLog: sun NULL
-	  tz
+	* DESCRIPTION, R/spatstat1.R: change superimpose
 
-2008-11-13 15:06  rsbivand
+2011-04-03 20:26  sluque
 
-	* ChangeLog, DESCRIPTION, R/readGPS.R, inst/ChangeLog,
-	  man/readGPS.Rd: ... for readGPS()
+	* R/sun-methods.R: Fix comments for proper outlining with allout.
 
-2008-11-12 15:55  rsbivand
+2011-04-01 06:57  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/SP2owin.R, R/sp_spat1.R, R/spatstat1.R,
-	  man/as.ppp.Rd, man/ppp.Rd: as.psp
+	* DESCRIPTION, R/spatstat1.R, man/as.ppp.Rd: marks fix for psp
 
-2008-10-02 16:46  rsbivand
+2011-03-30 14:48  rsbivand
 
-	* ChangeLog, inst/ChangeLog: changelog
+	* ChangeLog, inst/ChangeLog: more hole fixing
 
-2008-08-14 11:09  rsbivand
+2011-03-30 14:48  rsbivand
 
-	* DESCRIPTION, INDEX, R/spmaps.R: NULL bug in maps2SP
+	* R/checkHoles.R, man/checkPolygonsHoles.Rd: more hole fixing
 
-2008-06-27 10:15  rsbivand
+2011-03-29 12:45  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/SpatialLines-methods.R,
-	  R/SpatialPoints-methods.R, R/SpatialPolys-methods.R,
-	  R/maptools.R, R/pcent.R, R/readGPS.R, R/shapelib.R, R/subset.R,
-	  inst/changes, man/readShapePoly.Rd, R/Spatial-methods.R,
-	  man/readShapeSpatial.Rd, ChangeLog, inst/ChangeLog: readSpatial
-	  wrapper
+	* R/checkHoles.R: tree holes
 
-2008-06-19 07:56  rsbivand
+2011-03-29 08:24  rsbivand
 
-	* DESCRIPTION, R/sp2pbs.R: PolySet2SpatialLines UTM zone update
+	* R/checkHoles.R: STRtree in hole check
 
-2008-05-24 19:18  rsbivand
+2011-03-28 13:14  rsbivand
 
-	* ChangeLog, INDEX, inst/ChangeLog: GSHHS support to 1.10
+	* DESCRIPTION, R/checkHoles.R: try around gEquals in hole check
 
-2008-05-24 18:27  rsbivand
+2011-03-28 08:25  rsbivand
 
-	* DESCRIPTION, R/Rgshhs.R, R/sp2pbs.R, inst/share/gshhs_c.b,
-	  inst/share/wdb_borders_c.b, man/Rgshhs.Rd, src/Rgshhs.c,
-	  src/Rgshhs.h: GSHHS support to 1.10
+	* ChangeLog, inst/ChangeLog: add comments to wrld_simpl
 
-2008-04-14 22:49  rsbivand
+2011-03-28 08:24  rsbivand
 
-	* DESCRIPTION: tidy
+	* DESCRIPTION, data/wrld_simpl.rda: add comments to wrld_simpl
 
-2008-04-14 22:35  rsbivand
+2011-03-23 13:50  rsbivand
 
 	* ChangeLog, inst/ChangeLog: tidy
 
-2008-04-14 22:33  rsbivand
+2011-03-23 13:50  rsbivand
 
-	* DESCRIPTION: PolySet
+	* ChangeLog, DESCRIPTION, inst/ChangeLog: tidy
 
-2008-04-13 18:47  rsbivand
+2011-03-22 22:25  rsbivand
 
-	* DESCRIPTION, INDEX, R/sp2pbs.R: PBS to SP SID bug
+	* data/wrld_simpl.rda: resave rda files
 
-2008-04-10 16:07  rsbivand
+2011-03-22 22:23  rsbivand
 
-	* man/readShapePoly.Rd: tidy
+	* data/gpcholes.rda, data/wrld_simpl.rda: resave rda files
 
-2008-04-04 19:59  rsbivand
+2011-03-22 22:22  rsbivand
 
-	* DESCRIPTION, R/SpatialPolys-methods.R, man/readShapePoly.Rd: ABS
-	  nulls
+	* data/gpcholes.rda, data/wrld_simpl.rda: resave rda files
 
-2008-03-30 21:48  rsbivand
+2011-03-21 10:12  rsbivand
 
-	* DESCRIPTION, R/Rgshhs.R, man/Rgshhs.Rd: GSHHS clip
+	* ChangeLog, inst/ChangeLog: fix 2.13 Rd bugs
 
-2008-03-03 22:47  rsbivand
+2011-03-21 10:06  rsbivand
 
-	* ChangeLog, DESCRIPTION, R/GE_png.R, R/shapelib.R, inst/ChangeLog,
-	  man/GE_SpatialGrid.Rd, man/readShapeLines.Rd,
-	  man/readShapePoints.Rd, man/readShapePoly.Rd: makegrid
+	* DESCRIPTION, man/getKMLcoordinates.Rd, man/kmlLine.Rd,
+	  man/kmlPolygon.Rd: fix 2.13 Rd bugs
 
-2008-02-09 13:42  rsbivand
+2011-03-10 13:56  rsbivand
 
-	* DESCRIPTION, man/Rgshhs.Rd, man/SpatialLines2PolySet.Rd,
-	  man/checkPolygonsHoles.Rd, man/dotsInPolys.Rd,
-	  man/gcDestination.Rd, man/map2SpatialPolygons.Rd,
-	  man/nowrapRecenter.Rd, man/pal2SpatialPolygons.Rd,
-	  man/plot.polylist.Rd, man/pointLabel.Rd, man/readGPS.Rd,
-	  man/readShapeLines.Rd, man/readShapePoints.Rd,
-	  man/readShapePoly.Rd, man/sp2WB.Rd, man/sp2tmap.Rd,
-	  man/sun-methods.Rd, man/symbolsInPolys.Rd,
-	  man/unionSpatialPolygons.Rd, man/write.linelistShape.Rd,
-	  man/write.pointShape.Rd, man/write.polylistShape.Rd: line lengths
-	  in help
+	* R/sp2pbs.R, R/spmaps.R: PolySet2SpatialPolygons projection
+	  modification
 
-2008-01-30 21:53  rsbivand
+2011-02-24 14:29  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/GE_png.R, man/GE_SpatialGrid.Rd: SG
-	  creation
+	* R/CCmaps.R, R/DP.R, R/Rgshhs.R, R/SpatialLines-methods.R,
+	  R/SpatialPolys-methods.R, R/asciigrid.R, R/checkHoles.R,
+	  R/elide.R, R/gc_dist.R, R/kmlLine.R, R/kmlPolygon.R,
+	  R/maptools.R, R/readSplus.R, R/shapelib.R, R/sp2pbs.R,
+	  R/sp_tools.R, R/spmaps.R, R/subset.R: making length comparisons
+	  literal integers
 
-2008-01-30 09:26  rsbivand
+2011-02-11 09:42  rsbivand
 
-	* R/elide.R: ppp + getinfo
+	* R/Rgshhs.R: Rgshhs intersection
 
-2008-01-29 12:36  rsbivand
+2011-02-06 14:48  rsbivand
 
-	* R/elide.R: ppp + getinfo
+	* DESCRIPTION, R/AAA.R, src/shapefil.h, src/shpopen.c,
+	  src/shptree.c: suppress startup messages
 
-2008-01-29 12:00  rsbivand
+2011-01-02 14:25  rsbivand
 
-	* R/elide.R, man/elide-methods.Rd: ppp + getinfo
+	* R/Rgshhs.R, man/Rgshhs.Rd: GSHHS 2.1.0 update
 
-2008-01-29 11:37  rsbivand
+2010-12-31 15:43  rsbivand
 
-	* R/: sp_spat1.R, spatstat1.R: ppp + getinfo
+	* inst/share/gshhs_c.b: GSHHS 2.1.0 update
 
-2008-01-29 10:52  rsbivand
+2010-12-31 15:37  rsbivand
 
-	* R/shapelib.R, R/sp_spat1.R, src/Rshapeget.c, src/Rshapeinfo.c:
-	  ppp + getinfo
+	* R/checkHoles.R, man/Rgshhs.Rd, src/Rgshhs.c: GSHHS 2.1.0 update
 
-2008-01-29 10:03  rsbivand
+2010-12-16 10:46  rsbivand
 
-	* src/Rshapeinfo.c: ppp + getinfo
+	* man/as.ppp.Rd, man/gzAzimuth.Rd, man/pal2SpatialPolygons.Rd,
+	  man/readShapeLines.Rd, man/readShapePoly.Rd,
+	  man/readShapeSpatial.Rd, man/readSplus.Rd,
+	  man/unionSpatialPolygons.Rd: use rownames for retrieving FIDs
 
-2008-01-29 09:50  rsbivand
+2010-12-16 10:27  rsbivand
 
-	* ChangeLog, DESCRIPTION, R/shapelib.R, R/sp_spat1.R,
-	  R/spatstat1.R, src/Rshapeinfo.c: ppp + getinfo
+	* man/as.ppp.Rd, man/pal2SpatialPolygons.Rd, man/readShapePoly.Rd,
+	  man/readSplus.Rd, man/unionSpatialPolygons.Rd: use rownames for
+	  retrieving FIDs
 
-2008-01-20 16:08  rsbivand
+2010-11-30 17:37  rsbivand
 
-	* ChangeLog, DESCRIPTION, NAMESPACE, R/SpatialPolys-methods.R,
-	  R/sp2pbs.R, inst/ChangeLog, man/SpatialLines2PolySet.Rd: pbs to
-	  sp
+	* ChangeLog, inst/ChangeLog: tidy
 
-2007-12-13 18:32  rsbivand
+2010-11-30 00:10  edzer
 
-	* DESCRIPTION, R/elide.R: elide
+	* man/as.ppp.Rd, man/asciigrid.Rd: updated email address
 
-2007-12-09 19:03  rsbivand
+2010-11-24 13:40  rsbivand
 
-	* ChangeLog, DESCRIPTION, R/elide.R, inst/ChangeLog,
-	  man/elide-methods.Rd, src/Rgshhs.c, src/Rgshhs.h: elide shift
+	* R/union.R: preparing for rgeos release
 
-2007-11-21 23:37  rsbivand
+2010-11-24 12:32  rsbivand
 
-	* R/elide.R: elide bug
+	* R/union.R, man/unionSpatialPolygons.Rd: preparing for rgeos
+	  release
 
-2007-11-16 10:12  rsbivand
+2010-11-24 09:11  rsbivand
 
-	* DESCRIPTION, inst/changes, inst/share/gshhs_c.b, man/Rgshhs.Rd,
-	  src/Rgshhs.c, src/Rgshhs.h, src/shpopen.c: GSHHS to 1.5
+	* ChangeLog: preparing for rgeos release
 
-2007-11-10 14:17  rsbivand
+2010-11-24 09:09  rsbivand
 
-	* src/: shpopen.c, shptree.c: assert
+	* inst/ChangeLog: preparing for rgeos release
 
-2007-10-31 16:43  rsbivand
+2010-11-24 09:08  rsbivand
 
-	* ChangeLog, R/sp2WB.R, inst/ChangeLog: thingy to slot
+	* DESCRIPTION, R/AAA.R, R/DP.R, R/Rgshhs.R, R/checkHoles.R,
+	  R/nowrapRecenter.R, R/union.R, man/Rgshhs.Rd,
+	  man/checkPolygonsHoles.Rd, man/nowrapRecenter.Rd,
+	  man/thinnedSpatialPoly.Rd, man/unionSpatialPolygons.Rd: preparing
+	  for rgeos release
 
-2007-10-31 14:46  rsbivand
+2010-11-18 07:53  rsbivand
 
-	* ChangeLog, DESCRIPTION, R/SP2owin.R, R/SpatialLines-methods.R,
-	  R/SpatialPolys-methods.R, R/checkHoles.R, R/dotsinpolys.R,
-	  R/nowrapRecenter.R, R/sp2WB.R, R/sp2pbs.R, R/union.R,
-	  inst/ChangeLog, inst/changes, man/checkPolygonsHoles.Rd,
-	  man/dotsInPolys.Rd, man/gcDestination.Rd,
-	  man/map2SpatialPolygons.Rd, man/pal2SpatialPolygons.Rd,
-	  man/readShapePoly.Rd, man/symbolsInPolys.Rd,
-	  man/unionSpatialPolygons.Rd: thingy to slot
+	* .Rbuildignore: add .Rbuildignore
 
-2007-10-23 14:50  rsbivand
+2010-11-18 04:30  sluque
 
-	* DESCRIPTION, LICENSE, inst/LICENSE, inst/changes,
-	  man/Map2poly.Rd, man/as.ppp.Rd, man/readShapeLines.Rd,
-	  man/readShapePoints.Rd, man/readShapePoly.Rd: license
+	* R/sun-methods.R, R/sun.R, man/sun-methods.Rd: Use match.arg() in
+	  sun methods, so that defaults actually work.
+	  
+	  Minor improvements to documentation.
 
-2007-10-10 08:25  rsbivand
+2010-11-17 15:49  rsbivand
 
-	* ChangeLog, INDEX, inst/ChangeLog, inst/changes: tidy
+	* INDEX, svn2cl.xsl: initial clean
 
-2007-10-06 19:38  rsbivand
+2010-11-17 15:49  rsbivand
 
-	* man/gcDestination.Rd: elide first cut
+	* ChangeLog, oChangeLog: initial clean
 
-2007-10-06 12:05  rsbivand
+2010-11-17 15:45  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/elide.R, R/gc_dist.R,
-	  man/elide-methods.Rd: elide first cut
+	* inst/shapes, inst/shapes/baltim.dbf, inst/shapes/baltim.shp,
+	  inst/shapes/baltim.shx, inst/shapes/columbus.dbf,
+	  inst/shapes/columbus.shp, inst/shapes/columbus.shx,
+	  inst/shapes/fylk-val-ll.dbf, inst/shapes/fylk-val-ll.shp,
+	  inst/shapes/fylk-val-ll.shx, inst/shapes/fylk-val.dbf,
+	  inst/shapes/fylk-val.shp, inst/shapes/fylk-val.shx,
+	  inst/shapes/pointZ.dbf, inst/shapes/pointZ.prj,
+	  inst/shapes/pointZ.shp, inst/shapes/pointZ.shx,
+	  inst/shapes/sids.dbf, inst/shapes/sids.shp, inst/shapes/sids.shx:
+	  initial clean
 
-2007-09-29 18:37  rsbivand
+2010-11-17 15:44  rsbivand
 
-	* R/pointLabel.R: pointLabel update
+	* inst/shapes: initial clean
 
-2007-09-26 11:09  rsbivand
+2010-11-17 15:40  rsbivand
 
-	* R/asciigrid.R: Ascii Grid dec
+	* .: initial clean
 
-2007-09-18 10:19  rsbivand
+2010-11-13 15:55  rsbivand
 
-	* ChangeLog, inst/ChangeLog, inst/changes: tidy
+	* adding getRgshhsMap
 
-2007-09-18 10:15  rsbivand
+2010-10-17 18:29  rsbivand
 
-	* DESCRIPTION, R/maptools.R, R/sp2WB.R: tidy
+	* ppp marks as data.frame not vector
 
-2007-09-14 22:14  rsbivand
+2010-09-08 17:12  rsbivand
 
-	* R/sp2Mondrian.R, man/sp2Mondrian.Rd: Mondrian new format
+	* zero nParts for lines
 
-2007-09-14 08:58  rsbivand
+2010-09-08 16:36  rsbivand
 
-	* DESCRIPTION, R/SpatialLines-methods.R, R/SpatialPoints-methods.R,
-	  R/SpatialPolys-methods.R, R/shapelib.R, man/readShapeLines.Rd,
-	  man/readShapePoints.Rd, man/readShapePoly.Rd,
-	  man/write.linelistShape.Rd, man/write.pointShape.Rd,
-	  man/write.polylistShape.Rd: pass through max_nchar
+	* zero nParts for lines
 
-2007-09-05 18:07  rsbivand
+2010-08-28 10:35  rsbivand
 
-	* DESCRIPTION, R/spmaps.R, ChangeLog, inst/ChangeLog, inst/changes:
-	  double NA at end of map coords
+	* as.double to storage.mode
 
-2007-07-25 10:49  rsbivand
+2010-08-26 10:36  rsbivand
 
-	* man/write.polylistShape.Rd: 3D polylist, write line shape, owin
-	  poly
+	* check Sys.which value
 
-2007-07-19 21:33  rsbivand
+2010-08-12 15:09  rsbivand
 
-	* DESCRIPTION, R/SP2owin.R, R/maptools.R, R/shapelib.R,
-	  inst/changes, man/as.ppp.Rd, man/write.linelistShape.Rd,
-	  man/write.polylistShape.Rd, src/Rshapewrite1.c: 3D polylist
-	  writing
+	* data docs fix
 
-2007-06-11 10:05  rsbivand
+2010-04-22 02:48  rsbivand
 
-	* DESCRIPTION: encoding
+	* read.shape filen without extension
 
-2007-06-10 23:27  rsbivand
+2010-04-12 06:55  rsbivand
 
-	* ChangeLog, INDEX, inst/ChangeLog, inst/changes, man/Map2poly.Rd,
-	  man/sp2WB.Rd: encode
+	* tidy
 
-2007-06-10 22:47  rsbivand
+2010-04-05 10:42  rsbivand
 
-	* ChangeLog, DESCRIPTION, NAMESPACE, R/pointLabel.R,
-	  inst/ChangeLog, man/pointLabel.Rd: pointLabel
+	* comment out links to rgeos
 
-2007-06-05 15:31  rsbivand
+2010-04-03 19:25  rsbivand
 
-	* INDEX, R/readGPS.R: con correction
+	* hide rgeos
 
-2007-05-08 18:35  rsbivand
+2010-04-03 16:23  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/sp_spat1.R, man/as.ppp.Rd: revert
-	  spatstat coerce
+	* DBF filename, GSHHS C code errors addressed
 
-2007-05-07 10:55  rsbivand
+2010-04-03 16:02  rsbivand
 
-	* man/readGPS.Rd: tidy
+	* DBF filename, GSHHS C code errors addressed
 
-2007-04-28 21:41  rsbivand
+2010-01-17 19:27  rsbivand
 
-	* man/readShapePoints.Rd: doc error
+	* change spRbind for SpatialPointsDataFrame objects
 
-2007-04-27 18:37  rsbivand
+2010-01-10 19:42  rsbivand
 
-	* man/readGPS.Rd: resolve GPS conflict
+	* gshhs hole fix
 
-2007-04-21 06:27  rsbivand
+2010-01-10 19:37  rsbivand
 
-	* DESCRIPTION, INDEX, R/GE_png.R: GE dimnames
+	* gshhs hole fix
 
-2007-04-16 06:01  rsbivand
+2010-01-08 09:48  rsbivand
 
-	* man/readGPS.Rd: sp problem and gps
+	* hole assignment in GSHHS
 
-2007-04-16 04:40  rsbivand
+2010-01-07 18:07  rsbivand
 
-	* DESCRIPTION, R/readGPS.R, R/spmaps.R, man/readGPS.Rd: sp problem
-	  and gps
+	* rgeos integration
 
-2007-03-29 16:34  rsbivand
+2010-01-07 12:10  rsbivand
 
-	* inst/changes: tidy
+	* rgeos integration
 
-2007-03-23 18:50  rsbivand
+2009-12-21 12:39  rsbivand
 
-	* DESCRIPTION, INDEX, NAMESPACE, R/plot.Map.R, R/readGPS.R,
-	  man/readGPS.Rd: readGPS
+	* adding CCmaps
 
-2007-02-09 21:09  rsbivand
+2009-12-21 12:39  rsbivand
 
-	* R/SpatialPolys-methods.R, man/readShapePoly.Rd: force_ring in
-	  readShapePoly
+	* adding CCmaps
 
-2007-02-01 15:28  rsbivand
+2009-12-18 21:56  rsbivand
 
-	* DESCRIPTION, INDEX, R/sun-methods.R, man/plot.Map.Rd,
-	  man/plot.polylist.Rd, man/sun-methods.Rd: sun manual tidy
+	* GSHHS upgrade to 2.0
 
-2007-01-21 11:50  rsbivand
+2009-12-03 07:35  rsbivand
 
-	* man/: GE_SpatialGrid.Rd, kmlOverlay.Rd: GE_PNG additions
+	* hole example format change
 
-2007-01-20 22:35  rsbivand
+2009-12-03 07:35  rsbivand
 
-	* DESCRIPTION, NAMESPACE, inst/changes, R/GE_png.R,
-	  man/GE_SpatialGrid.Rd, man/kmlOverlay.Rd: GE_PNG additions
+	* hole example format change
 
-2007-01-16 10:39  rsbivand
+2009-12-03 07:34  rsbivand
 
-	* INDEX: im and sun-methods
+	* hole example format change
 
-2007-01-16 10:23  rsbivand
+2009-11-23 11:50  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/sp_spat1.R, inst/changes,
-	  man/as.ppp.Rd, man/crepuscule-methods.Rd, man/ppp.Rd,
-	  man/solarnoon-methods.Rd, man/solarpos-methods.Rd,
-	  man/sun-methods.Rd, man/sunriset-methods.Rd: im and sun-methods
+	* reinstate getinfo.shape
 
-2006-12-02 16:38  rsbivand
+2009-11-20 12:27  rsbivand
 
-	* DESCRIPTION, INDEX, man/solarnoon-methods.Rd: release
+	* moving deprecated functions from namespace
 
-2006-11-22 13:03  rsbivand
+2009-11-19 20:11  rsbivand
 
-	* R/Rgshhs.R: Rgshhs
+	* adding thinnedSpatialPoly
 
-2006-11-16 15:34  rsbivand
+2009-11-05 16:26  edzer
 
-	* R/sp_bind.R, inst/share/nc_xtra.dbf, man/spCbind-methods.Rd,
-	  man/spChFIDs-methods.Rd, man/spRbind-methods.Rd: bind
+	* moved spChFID method, functions and docs to package sp
 
-2006-11-16 15:31  rsbivand
+2009-09-17 08:22  rsbivand
 
-	* DESCRIPTION, INDEX, NAMESPACE, R/sp2pbs.R, man/Rgshhs.Rd,
-	  man/map2SpatialPolygons.Rd, man/plot.polylist.Rd,
-	  man/read.shape.Rd, man/subset.polylist.Rd, src/Rgshhs.c: bind
+	* fix documentation links
 
-2006-10-31 14:06  rsbivand
+2009-07-14 09:17  rsbivand
 
-	* NAMESPACE, R/SP2owin.R, R/sp_tools.R, R/sun.R, inst/changes,
-	  inst/share/co37_d90.e00, inst/share/gshhs_c.b, R/Rgshhs.R,
-	  R/checkHoles.R, R/nowrapRecenter.R, R/union.R, man/Rgshhs.Rd,
-	  man/checkPolygonsHoles.Rd, man/nowrapRecenter.Rd,
-	  man/pal2SpatialPolygons.Rd, man/unionSpatialPolygons.Rd,
-	  src/Rgshhs.c, src/Rgshhs.h: sun and r-spatial integration
+	* KML WGS84 notes added
 
-2006-10-31 09:29  rsbivand
+2009-06-22 14:53  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/sun.R, R/zzz.R, R/SP2owin.R,
-	  R/sp2pbs.R, R/sp_spat1.R, R/sp_tools.R, R/spatstat1.R,
-	  R/spmaps.R, R/sun-methods.R, man/ContourLines2SLDF.Rd,
-	  man/SpatialLines2PolySet.Rd, man/as.ppp.Rd,
-	  man/crepuscule-methods.Rd, man/map2SpatialPolygons.Rd,
-	  man/ppp.Rd, man/solarnoon-methods.Rd, man/solarpos-methods.Rd,
-	  man/sun.Rd, man/sunriset-methods.Rd: sun and r-spatial
-	  integration
+	* changed all.equal to identical in closed ring forcing
 
-2006-10-29 14:53  rsbivand
+2009-06-22 14:52  rsbivand
 
-	* R/sun.R: sun ephemerides
+	* changed all.equal to identical in closed ring forcing
 
-2006-10-28 21:56  rsbivand
+2009-06-10 14:34  rsbivand
 
-	* R/sun.R: sun ephemerides
+	* more NULL geometry trapping
 
-2006-10-28 19:23  rsbivand
+2009-05-26 10:22  rsbivand
 
-	* DESCRIPTION, INDEX, NAMESPACE, R/sun.R, inst/changes, man/sun.Rd:
-	  sun ephemerides
+	* coercion from owin/tess to SpatialPolygons
 
-2006-10-19 22:03  rsbivand
+2009-04-08 17:29  rsbivand
 
-	* DESCRIPTION, R/dotsinpolys.R, inst/changes: dostInPolys NULL
+	* improvements to spatstat support - Adrian Baddeley
 
-2006-09-21 21:42  rsbivand
+2009-03-29 15:32  rsbivand
 
-	* DESCRIPTION: R 2.4.0
+	* drop=FALSE in reading line and polygon shapefiles
 
-2006-08-30 16:50  rsbivand
+2009-03-17 20:43  vir
 
-	* DESCRIPTION, src/Rshapewrite1.c: pointZ
+	* Minor fix to allow for a line with NA's just before the END.
 
-2006-08-30 08:59  rsbivand
+2009-03-10 17:24  rsbivand
 
-	* DESCRIPTION, LICENSE, R/maptools.R, R/shapelib.R, inst/LICENSE,
-	  inst/changes, man/readShapePoints.Rd, src/Rshapewrite.c,
-	  inst/shapes/pointZ.dbf, inst/shapes/pointZ.prj,
-	  inst/shapes/pointZ.shp, inst/shapes/pointZ.shx: pointZ
+	* data web link
 
-2006-05-02 09:07  rsbivand
+2009-02-18 12:00  rsbivand
 
-	* DESCRIPTION, R/SpatialLines-methods.R, R/SpatialPoints-methods.R,
-	  R/SpatialPolys-methods.R, R/shapelib.R, inst/changes,
-	  man/read.shape.Rd, man/readShapeLines.Rd, man/readShapePoints.Rd,
-	  man/readShapePoly.Rd, src/Rshapeget.c: Geolytics bug
+	* kml writing; GSHHS lines shift
 
-2006-04-10 21:21  rsbivand
+2009-02-18 11:58  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/asciigrid.R, R/azimuth.R, R/sp2WB.R,
-	  inst/changes, man/asciigrid.Rd, man/dotsInPolys.Rd,
-	  man/gzAzimuth.Rd: fix to sp2WB, readAsciiGrid, writeAsciiGrid
+	* kml writing; GSHHS lines shift
 
-2006-03-20 09:32  rsbivand
+2009-02-05 17:45  rsbivand
 
-	* DESCRIPTION, R/sp2Mondrian.R, man/sp2Mondrian.Rd: Mondrian
+	* tidy
 
-2006-03-10 13:49  rsbivand
+2009-02-05 15:39  rsbivand
 
-	* DESCRIPTION, INDEX, NAMESPACE, R/asciigrid.R, R/sp2tmap.R,
-	  inst/changes, man/asciigrid.Rd, man/sp2WB.Rd, R/azimuth.R,
-	  R/sp2Mondrian.R, man/gzAzimuth.Rd, man/sp2Mondrian.Rd:
-	  sp2Mondrian
+	* adding features to readSplus
 
-2006-03-01 09:53  rsbivand
+2009-02-05 13:39  rsbivand
 
-	* DESCRIPTION, INDEX, R/SpatialPoints-methods.R,
-	  R/SpatialPolys-methods.R, R/plot.Map.R, R/shapelib.R,
-	  inst/changes, man/plot.Map.Rd, man/write.linelistShape.Rd,
-	  man/write.pointShape.Rd, man/write.polylistShape.Rd,
-	  src/Rshapeget.c: checks on polylists
+	* adding readSplus for WinBUGS
 
-2006-01-11 12:08  rsbivand
+2009-01-20 14:39  rsbivand
 
-	* R/sp2tmap.R, man/sp2tmap.Rd: tmap
+	* sun NULL tz
 
-2006-01-10 14:08  rsbivand
+2008-11-13 14:07  rsbivand
 
-	* R/sp2tmap.R, man/sp2tmap.Rd: tmap
+	* ... for readGPS()
 
-2006-01-09 14:33  rsbivand
+2008-11-13 14:06  rsbivand
 
-	* NAMESPACE, man/sp2tmap.Rd: sp2tmap
+	* ... for readGPS()
 
-2006-01-08 22:23  rsbivand
+2008-11-12 14:55  rsbivand
 
-	* man/sp2tmap.Rd: adding sp2tmap
+	* as.psp
 
-2006-01-08 19:34  rsbivand
+2008-10-02 14:46  rsbivand
 
-	* DESCRIPTION, R/sp2WB.R, R/sp2tmap.R, man/asciigrid.Rd,
-	  man/sp2tmap.Rd: adding sp2tmap
+	* changelog
 
-2005-12-15 16:00  rsbivand
+2008-08-14 09:09  rsbivand
 
-	* INDEX: to 5-4
+	* NULL bug in maps2SP
 
-2005-12-12 22:27  rsbivand
+2008-06-27 08:17  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/SpatialPoints-methods.R,
-	  R/SpatialPolys-methods.R, R/shapelib.R, R/sp2WB.R, inst/changes,
-	  man/readShapePoly.Rd, man/sp2WB.Rd, man/write.pointShape.Rd:
-	  sp2WB
+	* readSpatial wrapper
 
-2005-10-03 19:44  rsbivand
+2008-06-19 05:57  rsbivand
 
-	* DESCRIPTION, R/SpatialLines-methods.R, inst/changes: lines bugs
+	* PolySet2SpatialLines UTM zone update
 
-2005-09-14 23:08  rsbivand
+2008-05-24 17:18  rsbivand
 
-	* R/SpatialPolys-methods.R: as at 0.5-2
+	* GSHHS support to 1.10
 
-2005-09-13 19:24  rsbivand
+2008-05-24 16:27  rsbivand
 
-	* man/: dotsInPolys.Rd, symbolsInPolys.Rd: remove suggested splancs
+	* GSHHS support to 1.10
 
-2005-09-13 16:53  rsbivand
+2008-04-14 20:49  rsbivand
 
-	* DESCRIPTION, R/dotsinpolys.R, man/dotsInPolys.Rd,
-	  man/plot.Map.Rd, man/readShapePoly.Rd, man/symbolsInPolys.Rd:
-	  remove suggested splancs
+	* tidy
 
-2005-09-09 16:28  rsbivand
+2008-04-14 20:35  rsbivand
 
-	* R/plot.Map.R: ... in plot.Map
+	* tidy
 
-2005-09-08 22:28  rsbivand
+2008-04-14 20:33  rsbivand
 
-	* INDEX, R/SpatialPolys-methods.R, R/dotsinpolys.R,
-	  man/dotsInPolys.Rd: dotsinpolys begun
+	* PolySet
 
-2005-09-08 13:11  rsbivand
+2008-04-13 16:47  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/maptools.R, R/shapelib.R: codetools
+	* PBS to SP SID bug
 
-2005-09-05 14:54  rsbivand
+2008-04-10 14:07  rsbivand
 
-	* man/asciigrid.Rd: links
+	* tidy
 
-2005-09-05 11:00  rsbivand
+2008-04-04 17:59  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/SpatialLines-methods.R,
-	  R/SpatialPoints-methods.R, R/SpatialPolys-methods.R,
-	  R/asciigrid.R, man/asciigrid.Rd, man/readShapeLines.Rd,
-	  man/readShapePoints.Rd, man/readShapePoly.Rd,
-	  man/read_ShapeLines.Rd, man/read_ShapePoints.Rd,
-	  man/read_ShapePoly.Rd: removing _
+	* ABS nulls
 
-2005-09-03 18:19  rsbivand
+2008-04-04 17:59  rsbivand
 
-	* inst/changes, man/read_ShapeLines.Rd, man/read_ShapePoly.Rd:
-	  added ... to degAxis()
+	* ABS nulls
 
-2005-09-02 09:40  rsbivand
+2008-03-30 19:48  rsbivand
 
-	* NAMESPACE, R/asciigrid.R, man/asciigrid.Rd: more asciigrid
+	* GSHHS clip
 
-2005-09-01 20:26  rsbivand
+2008-03-03 21:47  rsbivand
 
-	* inst/: shapes/fylk-val.shp, shapes/fylk-val.shx, grids/simple.ag,
-	  shapes/sids.shp, shapes/sids.shx, grids/test.ag: Initial import.
+	* makegrid
 
-2005-09-01 20:26  rsbivand
+2008-02-09 12:42  rsbivand
 
-	* inst/: shapes/fylk-val.shp, shapes/fylk-val.shx, grids/simple.ag,
-	  shapes/sids.shp, shapes/sids.shx, grids/test.ag: Initial revision
+	* line lengths in help
 
-2005-09-01 20:21  rsbivand
+2008-01-30 20:53  rsbivand
 
-	* R/SpatialPolys-methods.R, man/Map2poly.Rd, man/dotsInPolys.Rd,
-	  man/get.Pcent.Rd, man/holepolys.Rd, man/maptools.Rd,
-	  man/plot.Map.Rd, man/plot.polylist.Rd, man/read.shape.Rd,
-	  man/read_ShapeLines.Rd, man/subset.polylist.Rd,
-	  man/symbolsInPolys.Rd, man/write.linelistShape.Rd,
-	  man/write.pointShape.Rd, man/asciigrid.Rd,
-	  man/read_ShapePoints.Rd, man/read_ShapePoly.Rd,
-	  man/write.polylistShape.Rd, src/Rcentroid.c, src/Rshapeget.c,
-	  src/Rshapeinfo.c, src/Rshapewrite.c, src/insiders.c,
-	  src/maptools.h, src/Rshapewrite1.c, src/shapefil.h,
-	  src/shpopen.c, src/shptree.c, data/gpcholes.rda, inst/LICENSE,
-	  inst/changes, inst/shapes/sids.dbf, src/pip.c,
-	  inst/shapes/baltim.dbf, inst/shapes/baltim.shp,
-	  inst/shapes/baltim.shx, inst/shapes/columbus.dbf,
-	  inst/shapes/fylk-val.dbf, inst/shapes/columbus.shp,
-	  inst/shapes/columbus.shx: Initial import.
-
-2005-09-01 20:21  rsbivand
-
-	* R/SpatialPolys-methods.R, man/Map2poly.Rd, man/dotsInPolys.Rd,
-	  man/get.Pcent.Rd, man/holepolys.Rd, man/maptools.Rd,
-	  man/plot.Map.Rd, man/plot.polylist.Rd, man/read.shape.Rd,
-	  man/read_ShapeLines.Rd, man/subset.polylist.Rd,
-	  man/symbolsInPolys.Rd, man/write.linelistShape.Rd,
-	  man/write.pointShape.Rd, man/asciigrid.Rd,
-	  man/read_ShapePoints.Rd, man/read_ShapePoly.Rd,
-	  man/write.polylistShape.Rd, src/Rcentroid.c, src/Rshapeget.c,
-	  src/Rshapeinfo.c, src/Rshapewrite.c, src/insiders.c,
-	  src/maptools.h, src/Rshapewrite1.c, src/shapefil.h,
-	  src/shpopen.c, src/shptree.c, data/gpcholes.rda, inst/LICENSE,
-	  inst/changes, inst/shapes/sids.dbf, src/pip.c,
-	  inst/shapes/baltim.dbf, inst/shapes/baltim.shp,
-	  inst/shapes/baltim.shx, inst/shapes/columbus.dbf,
-	  inst/shapes/fylk-val.dbf, inst/shapes/columbus.shp,
-	  inst/shapes/columbus.shx: Initial revision
+	* SG creation
+
+2008-01-30 08:26  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 11:36  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 11:00  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 10:37  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 09:52  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 09:03  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 08:50  rsbivand
+
+	* ppp + getinfo
+
+2008-01-20 15:08  rsbivand
+
+	* pbs to sp
+
+2007-12-13 17:32  rsbivand
+
+	* elide
+
+2007-12-09 18:03  rsbivand
+
+	* elide shift
+
+2007-11-21 22:37  rsbivand
+
+	* elide bug
+
+2007-11-16 09:12  rsbivand
+
+	* GSHHS to 1.5
+
+2007-11-10 13:17  rsbivand
+
+	* assert
+
+2007-10-31 15:43  rsbivand
+
+	* thingy to slot
+
+2007-10-31 13:46  rsbivand
+
+	* thingy to slot
+
+2007-10-23 12:50  rsbivand
+
+	* license
+
+2007-10-10 06:25  rsbivand
+
+	* tidy
+
+2007-10-06 17:38  rsbivand
+
+	* elide first cut
+
+2007-10-06 10:06  rsbivand
+
+	* elide first cut
+
+2007-09-29 16:37  rsbivand
+
+	* pointLabel update
+
+2007-09-26 09:09  rsbivand
+
+	* Ascii Grid dec
+
+2007-09-18 08:19  rsbivand
+
+	* tidy
+
+2007-09-14 20:14  rsbivand
+
+	* Mondrian new format
+
+2007-09-14 06:58  rsbivand
+
+	* pass through max_nchar
+
+2007-09-05 16:09  rsbivand
+
+	* double NA at end of map coords
+
+2007-07-25 08:49  rsbivand
+
+	* 3D polylist, write line shape, owin poly
+
+2007-07-19 19:33  rsbivand
+
+	* 3D polylist writing
+
+2007-06-11 08:05  rsbivand
+
+	* encoding
+
+2007-06-10 21:27  rsbivand
+
+	* encode
+
+2007-06-10 20:47  rsbivand
+
+	* pointLabel
+
+2007-06-05 13:31  rsbivand
+
+	* con correction
+
+2007-05-08 16:35  rsbivand
+
+	* revert spatstat coerce
+
+2007-05-07 08:55  rsbivand
+
+	* tidy
+
+2007-04-28 19:41  rsbivand
+
+	* doc error
+
+2007-04-27 16:37  rsbivand
+
+	* resolve GPS conflict
+
+2007-04-21 04:27  rsbivand
+
+	* GE dimnames
+
+2007-04-16 04:01  rsbivand
+
+	* sp problem and gps
+
+2007-04-16 02:40  rsbivand
+
+	* sp problem and gps
+
+2007-03-29 14:34  rsbivand
+
+	* tidy
+
+2007-03-23 17:50  rsbivand
+
+	* readGPS
+
+2007-02-09 20:09  rsbivand
+
+	* force_ring in readShapePoly
+
+2007-02-01 14:28  rsbivand
+
+	* sun manual tidy
+
+2007-01-21 10:50  rsbivand
+
+	* GE_PNG additions
+
+2007-01-20 21:36  rsbivand
+
+	* GE_PNG additions
+
+2007-01-16 09:39  rsbivand
+
+	* im and sun-methods
+
+2007-01-16 09:23  rsbivand
+
+	* im and sun-methods
+
+2006-12-02 15:38  rsbivand
+
+	* release
+
+2006-11-22 12:03  rsbivand
+
+	* Rgshhs
+
+2006-11-16 14:34  rsbivand
+
+	* bind
+
+2006-10-31 13:07  rsbivand
+
+	* sun and r-spatial integration
+
+2006-10-31 08:31  rsbivand
+
+	* sun and r-spatial integration
+
+2006-10-29 13:53  rsbivand
+
+	* sun ephemerides
+
+2006-10-28 19:56  rsbivand
+
+	* sun ephemerides
+
+2006-10-28 17:23  rsbivand
+
+	* sun ephemerides
+
+2006-10-19 20:03  rsbivand
+
+	* dostInPolys NULL
+
+2006-09-21 19:42  rsbivand
+
+	* R 2.4.0
+
+2006-08-30 14:50  rsbivand
+
+	* pointZ
+
+2006-08-30 07:00  rsbivand
+
+	* pointZ
+
+2006-05-02 07:07  rsbivand
+
+	* Geolytics bug
+
+2006-04-10 19:21  rsbivand
+
+	* fix to sp2WB, readAsciiGrid, writeAsciiGrid
+
+2006-03-20 08:32  rsbivand
+
+	* Mondrian
+
+2006-03-10 12:50  rsbivand
+
+	* sp2Mondrian
+
+2006-03-01 08:53  rsbivand
+
+	* checks on polylists
+
+2006-01-11 11:08  rsbivand
+
+	* tmap
+
+2006-01-10 13:08  rsbivand
+
+	* tmap
+
+2006-01-09 13:33  rsbivand
+
+	* sp2tmap
+
+2006-01-08 21:23  rsbivand
+
+	* adding sp2tmap
+
+2006-01-08 18:34  rsbivand
+
+	* adding sp2tmap
+
+2005-12-15 15:00  rsbivand
+
+	* to 5-4
+
+2005-12-12 21:27  rsbivand
+
+	* sp2WB
+
+2005-10-03 17:44  rsbivand
+
+	* lines bugs
+
+2005-09-14 21:08  rsbivand
+
+	* as at 0.5-2
+
+2005-09-13 17:24  rsbivand
+
+	* remove suggested splancs
+
+2005-09-13 14:53  rsbivand
+
+	* remove suggested splancs
+
+2005-09-09 14:28  rsbivand
+
+	* ... in plot.Map
+
+2005-09-08 20:28  rsbivand
+
+	* dotsinpolys begun
+
+2005-09-08 11:11  rsbivand
+
+	* codetools
+
+2005-09-05 12:54  rsbivand
+
+	* links
+
+2005-09-05 09:00  rsbivand
+
+	* removing _
+
+2005-09-03 16:19  rsbivand
+
+	* added ... to degAxis()
+
+2005-09-02 07:40  rsbivand
+
+	* more asciigrid
 
-2005-09-01 20:18  rsbivand
+2005-09-01 18:26  rsbivand
 
-	* DESCRIPTION, INDEX, LICENSE, NAMESPACE, R/shapelib.R,
-	  R/SpatialLines-methods.R, R/SpatialPoints-methods.R,
-	  R/asciigrid.R, R/colslegs.R, R/dotsinpolys.R, R/maptools.R,
-	  R/maptoolsChanges.R, R/pcent.R, R/plot.Map.R,
-	  R/point.in.polygon.R, R/subset.R, R/zzz.R: Initial import.
+	* Initial revision
 
-2005-09-01 20:18  rsbivand
+2005-09-01 18:26  
 
-	* DESCRIPTION, INDEX, LICENSE, NAMESPACE, R/shapelib.R,
-	  R/SpatialLines-methods.R, R/SpatialPoints-methods.R,
-	  R/asciigrid.R, R/colslegs.R, R/dotsinpolys.R, R/maptools.R,
-	  R/maptoolsChanges.R, R/pcent.R, R/plot.Map.R,
-	  R/point.in.polygon.R, R/subset.R, R/zzz.R: Initial revision
+	* New repository initialized by cvs2svn.
 
diff --git a/DESCRIPTION b/DESCRIPTION
index a8d5e8a..f74a377 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,17 +1,34 @@
 Package: maptools
-Version: 0.7-38
-Date: 2010-09-08
+Version: 0.8-23
+Date: 2013-02-09
 Title: Tools for reading and handling spatial objects
-Encoding: latin1
-Author: Nicholas J. Lewin-Koh and Roger Bivand, contributions by Edzer
-        J. Pebesma, Eric Archer, Adrian Baddeley, Hans-Jörg Bibiko,
-        Stéphane Dray, David Forrest, Michael Friendly, Patrick
-        Giraudoux, Duncan Golicher, Virgilio Gómez Rubio, Patrick
-        Hausmann, Thomas Jagger, Sebastian P. Luque, Don MacQueen,
-        Andrew Niccolai, Tom Short and Ben Stabler
-Maintainer: Roger Bivand <Roger.Bivand at nhh.no>
-Depends: R (>= 2.4), foreign (>= 0.8), sp (>= 0.9-47), methods, lattice
-Suggests: spatstat, PBSmapping, maps, gpclib, RArcInfo
+Authors at R: c( person("Roger", "Bivand", role = c("cre", "aut"), email =
+        "Roger.Bivand at nhh.no"), person("Nicholas", "Lewin-Koh", role =
+        "aut"), person("Edzer", "Pebesma", role = "ctb"),
+        person("Eric", "Archer", role = "ctb"), person("Adrian",
+        "Baddeley", role = "ctb"), person("Hans-Jörg", "Bibiko", role =
+        "ctb"), person("Jonathan", "Callahan", role = "ctb"),
+        person("German", "Carrillo", role = "ctb"), person("Stéphane",
+        "Dray", role = "ctb"), person("David", "Forrest", role =
+        "ctb"), person("Michael", "Friendly", role = "ctb"),
+        person("Patrick", "Giraudoux", role = "ctb"), person("Duncan",
+        "Golicher", role = "ctb"), person("Virgilio", "Gómez Rubio",
+        role = "ctb"), person("Patrick", "Hausmann", role = "ctb"),
+        person("Karl Ove", "Hufthammer", role = "ctb"),
+        person("Thomas", "Jagger", role = "ctb"), person("Sebastian",
+        "Luque", role = "ctb"), person("Don", "MacQueen", role =
+        "ctb"), person("Andrew", "Niccolai", role = "ctb"),
+        person("Oscar", "Perpiñán Lamigueiro", role = "ctb"),
+        person("Tom", "Short", role = "ctb"), person("Greg", "Snow",
+        role = "ctb"), person("Ben", "Stabler", role = "ctb"),
+        person("Murray", "Stokely", role = "ctb"), person("Rolf",
+        "Turner", role = "ctb"))
+Encoding: UTF-8
+Depends: R (>= 2.10), foreign (>= 0.8), sp (>= 0.9-47), methods, grid,
+        lattice, stats
+Suggests: rgeos (>= 0.1-8), spatstat (>= 1.18), PBSmapping,
+        RColorBrewer
+Enhances: maps, gpclib, RArcInfo
 Description: Set of tools for manipulating and reading geographic data,
         in particular ESRI shapefiles; C code used from shapelib. It
         includes binary access to GSHHS shoreline files. The package
@@ -19,6 +36,19 @@ Description: Set of tools for manipulating and reading geographic data,
         with packages such as PBSmapping, spatstat, maps, RArcInfo,
         Stata tmap, WinBUGS, Mondrian, and others.
 License: GPL (>= 2)
-Packaged: 2010-09-08 17:15:01 UTC; rsb
+URL: http://r-forge.r-project.org/projects/maptools/
+Packaged: 2013-02-10 14:01:59 UTC; rsb
+Author: Roger Bivand [cre, aut], Nicholas Lewin-Koh [aut], Edzer
+        Pebesma [ctb], Eric Archer [ctb], Adrian Baddeley [ctb],
+        Hans-Jörg Bibiko [ctb], Jonathan Callahan [ctb], German
+        Carrillo [ctb], Stéphane Dray [ctb], David Forrest [ctb],
+        Michael Friendly [ctb], Patrick Giraudoux [ctb], Duncan
+        Golicher [ctb], Virgilio Gómez Rubio [ctb], Patrick Hausmann
+        [ctb], Karl Ove Hufthammer [ctb], Thomas Jagger [ctb],
+        Sebastian Luque [ctb], Don MacQueen [ctb], Andrew Niccolai
+        [ctb], Oscar Perpiñán Lamigueiro [ctb], Tom Short [ctb], Greg
+        Snow [ctb], Ben Stabler [ctb], Murray Stokely [ctb], Rolf
+        Turner [ctb]
+Maintainer: Roger Bivand <Roger.Bivand at nhh.no>
 Repository: CRAN
-Date/Publication: 2010-09-09 11:04:35
+Date/Publication: 2013-02-10 15:42:31
diff --git a/INDEX b/INDEX
deleted file mode 100644
index c7a312d..0000000
--- a/INDEX
+++ /dev/null
@@ -1,54 +0,0 @@
-as.owin.SpatialGridDataFrame
-                        coercion between sp objects and spatstat
-                        objects
-CCmaps                  Conditioned choropleth maps
-checkPolygonsHoles      Check holes in Polygons objects
-ContourLines2SLDF       Converter functions to build
-                        SpatialLinesDataFrame objects
-crepuscule              Methods for sun ephemerides calculations
-dotsInPolys             Put dots in polygons
-elide-methods           Methods for Function elide in Package
-                        'maptools'
-gcDestination           Find destination in geographical coordinates
-GE_SpatialGrid          Create SpatialGrid for PNG output to GE
-getinfo.shape           Get shapefile header information
-getKMLcoordinates       Get a list of coordinates out of a KML file
-gpcholes                Hisaji Ono's lake/hole problem
-gzAzimuth               Find azimuth for geographical coordinates
-kmlLine                 Create and write a KML file on the basis of a
-                        given Lines object
-kmlOverlay              Create and write KML file for PNG image overlay
-kmlPolygon              Create and write a KML file on the basis of a
-                        given Polygons object
-leglabs                 Make legend labels
-map2SpatialPolygons     Convert map objects to sp classes
-nowrapRecenter          Break polygons at meridian for recentering
-pal2SpatialPolygons     Making SpatialPolygons objects from RArcInfo
-                        input
-pointLabel              Label placement for points to avoid overlaps
-ppp-class               Virtual class "ppp"
-readAsciiGrid           read/write to/from (ESRI) asciigrid format
-readGPS                 GPSbabel read interface
-readShapeLines          Read arc shape files into SpatialLinesDataFrame
-                        objects
-readShapePoints         Read points shape files into
-                        SpatialPointsDataFrame objects
-readShapePoly           Read polygon shape files into
-                        SpatialPolygonsDataFrame objects
-readShapeSpatial        Read shape files into Spatial*DataFrame objects
-readSplus               Read exported WinBUGS maps
-Rgshhs                  Read GSHHS data into sp object
-sp2Mondrian             write map data for Mondrian
-sp2tmap                 Convert SpatialPolygons object for Stata tmap
-                        command
-sp2WB                   Export SpatialPolygons object as S-Plus map for
-                        WinBUGS
-SpatialLines2PolySet    Convert sp line and polygon objects to
-                        PBSmapping PolySet objects
-spCbind-methods         cbind for spatial objects
-spRbind-methods         rbind for spatial objects
-symbolsInPolys          Place grids of points over polygons
-thinnedSpatialPoly      Douglas-Peuker line generalization for Spatial
-                        Polygons
-unionSpatialPolygons    Aggregate Polygons in a SpatialPolygons object
-wrld_simpl              Simplified world country polygons
diff --git a/MD5 b/MD5
new file mode 100644
index 0000000..aa5333c
--- /dev/null
+++ b/MD5
@@ -0,0 +1,149 @@
+deb3cd5576beffe473ad275db90eef0f *ChangeLog
+45fbef7199362cd0a12770414fbb4690 *DESCRIPTION
+f36f02b8e559e17e5d2e56210d8f8358 *LICENSE
+1fc46cd37ec81684e1c131b0b4722989 *NAMESPACE
+f3bbe96042fd513db79b9efe6f132187 *R/AAA.R
+1399d0064b46e6e6c90600b1b64a5e19 *R/CCmaps.R
+5848792717e41318276dbe13f75315b7 *R/DP.R
+b52e6bfd6272c6c26bec32d86332d830 *R/GE_png.R
+80b66cc8d070d4f7965b2eb0758f796d *R/Rgshhs.R
+929f90890eb062dd5b6038dd260c5af5 *R/SP2owin.R
+49cf181c899841812a2bb22c6ab79d36 *R/Spatial-methods.R
+a64d500aa81262fb0252d4b3aa1f7662 *R/SpatialLines-methods.R
+671d16e8dd8547271c36604b7fb7d97c *R/SpatialPoints-methods.R
+67df860fd2684398c6a29f53c1e1eb76 *R/SpatialPolys-methods.R
+b554d8957790bcf7444ab442fe57648c *R/asciigrid.R
+e29845deee219ec6442657468249b233 *R/azimuth.R
+c7ec880c721a64b9ffa9731f12d43f1d *R/checkHoles.R
+26a3fc11f1fca539879d3f115d2b444b *R/colslegs.R
+0aeb9b76c865d15b173bdb5ac052692a *R/dotsinpolys.R
+08fee92d40b987ffe9af7c4ec17c58ad *R/elide.R
+148df8cfbd7dadceba256df8d37d9ab0 *R/gc_dist.R
+a9f9233e0515d09b17d77d785f4d0312 *R/getKMLcoordinates.R
+3a28225f27e2c7a6531411d4fe27ac7f *R/kmlLine.R
+4f0724c5f0fd055529d99e1f3798bec3 *R/kmlPoints.R
+7686ded0d450e1b142ae99628284c1c9 *R/kmlPolygon.R
+b5aec75cdeab2607fc41d781cb80f1ca *R/lineLabel.R
+2af1dab97074d7202daee3f95d971191 *R/maptools.R
+e32451be693afaa6914ccb3a414ef9d2 *R/maptoolsChanges.R
+dec461da52968b8289e55fc84925c5fd *R/midpoint.R
+98c47f3636741a33836988bfdde7188d *R/nowrapRecenter.R
+6e337a6093b17b645e62e0abf773f975 *R/pcent.R
+d0e87ce6ba53ad5163677147d0a584a1 *R/plot.Map.R
+b1733b14cbc627504bd3564e87b6213b *R/point.in.polygon.R
+5bcacd845d507f477e7b960f82cc4f58 *R/pointLabelBase.R
+64bd10616719e5aff5cbe232a354e829 *R/pointLabelLattice.R
+8fa9f1f35d55c471b3c070e713ff14ab *R/point_line_distance.R
+3ea318f87d9fbe32693557d502f7dcee *R/readGPS.R
+4ce28933f9aaee54b7c0e2d718b2a2e5 *R/readSplus.R
+254297162508942d87ed1f7f0dd64a85 *R/shapelib.R
+27e9edece00045b78668d74107cd13b7 *R/sp2Mondrian.R
+2a3967d5eedb7198176c667d87866473 *R/sp2WB.R
+30ae94c4a694f983c4b710aaa80e4636 *R/sp2pbs.R
+293eab37398f4ea65b421b8091bd569e *R/sp2tmap.R
+1f59cf510bc07e7029d3161ec42b5de4 *R/sp_bind.R
+c9daa9fe1ac96fa85e2bcb86758d8f5c *R/sp_spat1.R
+e9943f26d6c56f3ba69d60ba6652e9e4 *R/sp_tools.R
+a1f3e3ac4a74a5e2848a5aa706c84d71 *R/spatstat1.R
+51749751c1f05788c2dda6369e19a203 *R/spmaps.R
+beb695c582d1c3aaa519cedd375e2c38 *R/subset.R
+4d3c2cab1f163eacf26bfd66161f0440 *R/sun-methods.R
+7149e328828e259e39b14f0a2bdf5c1b *R/sun.R
+9181ef13c0ad5e9830801464afb9ba33 *R/union.R
+89e84c8fec40a5e2d0482ae8642a5244 *R/zzz.R
+d0b8c2ac5cb2ac40fff68a7b329df381 *data/SplashDams.rda
+ad794d2bb004f79c29d6d20a9341a0ec *data/gpcholes.rda
+f58d7bbadb55463c773ef91b74f7e6cf *data/state.vbm.rda
+b11b2dc736e768c927211d6fce5ab7df *data/wrld_simpl.rda
+deb3cd5576beffe473ad275db90eef0f *inst/ChangeLog
+f36f02b8e559e17e5d2e56210d8f8358 *inst/LICENSE
+0d1e185186bdb70959760c0a63f7be4f *inst/changes
+ef247b6c335e75e48f81da7ef7554fa6 *inst/grids/simple.ag
+15c2101eb916ea116f400d560f73dd7c *inst/grids/test.ag
+be9a3966e14428c7c83c6a0fa745baaa *inst/shapes/baltim.dbf
+8ed6c81148522bb43464e0ea30489099 *inst/shapes/baltim.shp
+7f69b41aa1254188cd450efaaf4f6b8c *inst/shapes/baltim.shx
+a692f891aa504c8092a824e37f236475 *inst/shapes/columbus.dbf
+f5952cc1485ac06b60d6554664becf65 *inst/shapes/columbus.shp
+f55a38e1ffb1605a7895df9e790d24f0 *inst/shapes/columbus.shx
+fd1f7bf0d2229067bad7d1b683110702 *inst/shapes/fylk-val-ll.dbf
+55f31c8583bd7954fe759ea88a9c29cd *inst/shapes/fylk-val-ll.shp
+c934a856e9de765b9d505c3314228919 *inst/shapes/fylk-val-ll.shx
+2084a695bd4c1506e7715f1ddbd3edc3 *inst/shapes/fylk-val.dbf
+d9079745082fd71366f12a997a246d50 *inst/shapes/fylk-val.shp
+65ef512c20fb9faad7da709294943eba *inst/shapes/fylk-val.shx
+48feafd9a6ebb04331620fdeeb2139b2 *inst/shapes/pointZ.dbf
+f42287ef344d1258b3b6268be060d0b4 *inst/shapes/pointZ.prj
+1542c32529f84916de522d851f9f9ab7 *inst/shapes/pointZ.shp
+678d15a3bec59811646d004bb74d7235 *inst/shapes/pointZ.shx
+739845e11f7e69826b04ca22a7d45568 *inst/shapes/sids.dbf
+32ef63f29fdb9eca9733dc5feb3a707d *inst/shapes/sids.shp
+2085b2c4715f1f58c64bc410166371fd *inst/shapes/sids.shx
+c4f746f01e9671f40b124ffdcd47fca8 *inst/share/Splus.map
+29005b74a5acf1caac4aca8807a46933 *inst/share/co37_d90.e00
+542df698239a73e33ac7deb278089326 *inst/share/gshhs_c.b
+e3fb11232e6cb27770d15aaf4f632aa4 *inst/share/nc_xtra.dbf
+f6f195d5493396e97599ec596bd61b4c *inst/share/wdb_borders_c.b
+01780bffb2997b97141feb87540a3516 *man/CCmaps.Rd
+f85df7425d7f27dfc69832b69edd86f2 *man/ContourLines2SLDF.Rd
+5ad9bfb6296b6c8488c7d8644a3c1de1 *man/GE_SpatialGrid.Rd
+72db9fc93d5daea7ab2a7ebf77a314be *man/Rgshhs.Rd
+9c8d32a1a4db3e63600de7b91d0cff44 *man/SpatialLines2PolySet.Rd
+94cade77d4574f0150a68af47e86ca01 *man/SpatialLinesMidPoints.Rd
+5dd0471f34d8645c1a41916a4f7b6a31 *man/SplashDams.Rd
+f7e0c617483ff82aaa7436adf262d586 *man/as.ppp.Rd
+c67196d773b35e38abc31670b5481096 *man/asciigrid.Rd
+e4e87a89e1cc56a586d68960ba5bc4a1 *man/checkPolygonsHoles.Rd
+0ba43dbf573ef51669d7ad2922a1af3c *man/dotsInPolys.Rd
+9e39e06ce97aa7407879a00def515fc7 *man/elide-methods.Rd
+950743858326fd33e6c180a315cde063 *man/gcDestination.Rd
+341b579f66d63b3ffcfe73622588dc3d *man/getKMLcoordinates.Rd
+e455cbefaf6d3970b24081a7c02d8fa3 *man/getinfo.shape.Rd
+96c5eb42c51c44dfc1ce301a3df4347b *man/gzAzimuth.Rd
+5fa1da9264c3fcb8c7936e23b2514180 *man/holepolys.Rd
+8b8ecf1e0a835f24842c838b2ada0d91 *man/kmlLine.Rd
+21b39cbcb1d236065117a19ed9a320a9 *man/kmlOverlay.Rd
+6a8926d8c881588f4c7907711591c0cc *man/kmlPoints.Rd
+795ee68785451f2fc7623bcd003a43fd *man/kmlPolygon.Rd
+5aee594b0203b637510fe71e1ce2bda3 *man/leglabs.Rd
+c5f20bfb6b29271ed4868200d37d5b95 *man/lineLabel.Rd
+fc945c4eb6e1d7ad5e6c57671285a4c9 *man/map2SpatialPolygons.Rd
+faeaff841d01f23c46e359dcac2f95e0 *man/nearestPointOnLine.Rd
+4c4dfe73ec4e6c87be454a6f0cb53f0a *man/nearestPointOnSegment.Rd
+a5aa4380a95ebdc5511aa3c082cbc848 *man/nowrapRecenter.Rd
+e941e4c0fe856263cca3eeafd3a81c09 *man/pal2SpatialPolygons.Rd
+2192d5eded3e8cea9af4c39a6c90fb50 *man/pointLabelBase.Rd
+cafc82b341c3fa708b3c92f37881b6e9 *man/pointLabelLattice.Rd
+e54eef37d626acea8c6350db5fe2219d *man/ppp.Rd
+1d23bfed4495b2ed9526fe9d81b31b67 *man/readGPS.Rd
+5a5a29a3a575bb8b499954e53a7ee819 *man/readShapeLines.Rd
+e0c09bc46d251ecac95df41134b868ed *man/readShapePoints.Rd
+c4854a1684e89709b27f5335a05ece11 *man/readShapePoly.Rd
+ac2a0d238e65e9587660a0df4796fe9f *man/readShapeSpatial.Rd
+69007bb88fcfc1df500197b01f5b23fa *man/readSplus.Rd
+767c435212b466210e75bd07de3c889d *man/snapPointsToLines.Rd
+c8a374183fc3f7fb622485c5b7f36938 *man/sp2Mondrian.Rd
+20f2d2c2d1c070d7b2fefc9e1556cc5a *man/sp2WB.Rd
+5b5be2484b2a7bb15e6e4eaddc60c621 *man/sp2tmap.Rd
+ace8a20344f545f9e0faa30f8e7de2e9 *man/spCbind-methods.Rd
+38877ece5e77bf053bc5cc2031c7c2ad *man/spRbind-methods.Rd
+024209da5ee31a795eaa70cafa7743f8 *man/state.vbm.Rd
+0b0b2a46375b6c9e16f50e5046573092 *man/sun-methods.Rd
+82b7bf65f37a77094bc0eece339d5a67 *man/symbolsInPolys.Rd
+71a1b2f0e6652e19f21cc60fdf44d235 *man/thinnedSpatialPoly.Rd
+f7e8eda586323e58757d488d0aceb282 *man/unionSpatialPolygons.Rd
+07568c79ba78dfd739f910d93048aa07 *man/wrld_simpl.Rd
+81158e2282656234a0e579acd9b6bff6 *maptools-Ex.R
+1bf1a0abc70257b5b43e39184b67187a *src/Rcentroid.c
+66d2929d6a58ae93974ff266cfeb23ba *src/Rgshhs.c
+9509debecc4e83e39be501a04c003f11 *src/Rgshhs.h
+1124203648658a3692a1192c8c8891d7 *src/Rshapeget.c
+496830d11d266228fbf847eaab8abcad *src/Rshapeinfo.c
+154bc3269659778e5562b39fadc4a80f *src/Rshapewrite.c
+6d977f2d6b13d70d08789c544e4db90e *src/Rshapewrite1.c
+e73d96058ef7d9c6732a623eb41f9cb3 *src/insiders.c
+b44b2e8ded1a882d916425b5707186cc *src/maptools.h
+bbf80b23dc8a7c63da8d19faab5ee5fc *src/pip.c
+78350ce87574efc8c1a4c6a656f2a00d *src/shapefil.h
+0615c74261af16a4ae701f4043546bdf *src/shpopen.c
+5562d9d1068a3d2c54655f1226764b64 *src/shptree.c
diff --git a/NAMESPACE b/NAMESPACE
index cdb6811..45a6fd1 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -2,7 +2,9 @@ useDynLib(maptools)
 
 import(sp)
 import(foreign)
+import(grid)
 importFrom(lattice, strip.custom)
+importFrom(stats, smooth.spline)
 
 export(leglabs, dotsInPolys, symbolsInPolys, getinfo.shape, print.shapehead) 
         # plotpolys, shape2poly, shape2lines, 
@@ -37,13 +39,13 @@ export(SpatialPolygons2PolySet, SpatialLines2PolySet, PolySet2SpatialPolygons, P
 export(as.ppp.SpatialPoints, as.ppp.SpatialPointsDataFrame, as.SpatialPoints.ppp, as.SpatialPointsDataFrame.ppp, as.SpatialGridDataFrame.ppp)
 export(as.owin.SpatialGridDataFrame, as.owin.SpatialPixelsDataFrame, as.owin.SpatialPolygons, as.SpatialGridDataFrame.im, as.im.SpatialGridDataFrame)
 
-export(as.psp.SpatialLinesDataFrame, as.psp.SpatialLines, as.psp.Lines, as.psp.Line)
+export(as.psp.SpatialLinesDataFrame, as.psp.SpatialLines, as.psp.Lines, as.psp.Line, as.SpatialLines.psp)
 
-export(gpclibPermit, gpclibPermitStatus)
+export(gpclibPermit, gpclibPermitStatus, rgeosStatus)
 
 export(unionSpatialPolygons, nowrapSpatialPolygons, nowrapRecenter, checkPolygonsHoles)
 
-export(Rgshhs)
+export(Rgshhs, getRgshhsMap)
 
 export(CCmaps)
 
@@ -53,11 +55,17 @@ exportMethods(elide)
 
 export(GE_SpatialGrid, kmlOverlay, Sobj_SpatialGrid)
 
-export(kmlPolygon, kmlLine, getKMLcoordinates)
+export(kmlPolygon, kmlLine, getKMLcoordinates, kmlPoints)
 
 export(pointLabel, gcDestination)
 export(thinnedSpatialPoly)
 
+export(snapPointsToLines, nearestPointOnSegment, nearestPointOnLine, SpatialLinesMidPoints)
+
+export(panel.pointLabel, lineLabel)
+S3method("drawDetails", "labels")
+exportMethods(sp.pointLabel, sp.lineLabel, label)
+
 #S3method(plot, Map)
 #S3method(plot, polylist)
 #S3method(subset, polylist)
diff --git a/R/AAA.R b/R/AAA.R
index c7a31fd..28c4945 100644
--- a/R/AAA.R
+++ b/R/AAA.R
@@ -1,18 +1,19 @@
 .MAPTOOLS_CACHE <- new.env(FALSE, parent=globalenv())
 
 .onLoad <- function(lib, pkg) {
-    require(methods, quietly = TRUE, warn.conflicts = FALSE)
-    require("sp")
     assign("gpclib", FALSE, envir=.MAPTOOLS_CACHE)
-    cat(paste("\n\tNote: polygon geometry computations in maptools\n",
-              "\tdepend on the package gpclib, which has a\n",
-              "\trestricted licence. It is disabled by default;\n",
-              "\tto enable gpclib, type gpclibPermit()\n"))
-    cat("\nChecking rgeos availability as gpclib substitute:\n")
-#    rgeosI <- require(rgeos, quietly = TRUE, warn.conflicts = FALSE)
-    rgeosI <- FALSE
-    cat(rgeosI, "\n")
-    assign("rgeos", rgeosI, envir=.MAPTOOLS_CACHE)
+}
+
+.onAttach <- function(lib, pkg) {
+    Smess <- paste("Checking rgeos availability: ")
+    rgeosI <- setRgeosStatus()
+    Smess <- paste(Smess, rgeosI, "\n", sep="")
+    if (!rgeosI) Smess <- paste(Smess, 
+              "\tNote: when rgeos is not available, polygon geometry",
+              "\tcomputations in maptools depend on gpclib,\n",
+              "\twhich has a restricted licence. It is disabled by default;\n",
+              "\tto enable gpclib, type gpclibPermit()\n")
+    packageStartupMessage(Smess, appendLF = FALSE)
 }
 
 .onUnload <- function(libpath) {
diff --git a/R/CCmaps.R b/R/CCmaps.R
index 9b0ebe1..ac0387f 100644
--- a/R/CCmaps.R
+++ b/R/CCmaps.R
@@ -5,13 +5,14 @@ CCmaps <- function(obj, zcol=NULL, cvar=NULL, cvar.names=NULL,
 	stopifnot(is(obj, "SpatialPolygonsDataFrame")) 
 	stopifnot(!is.null(zcol), !is.null(cvar))
 	n <- length(slot(obj, "polygons"))
-	stopifnot(length(zcol) == 1)
+	stopifnot(length(zcol) == 1L)
 	ncc <- length(cvar)
 	stopifnot(ncc <= 2, ncc > 0)
 	if (is.null(cvar.names)) cvar.names <- names(cvar)
 	nlcc <- integer(ncc)
 	lcc <- vector(mode="list", length=ncc)
-	fcc <- logical(nlcc)
+#	fcc <- logical(nlcc)
+	fcc <- logical(ncc)
 	for (i in 1:ncc) {
 	    ccc <- class(cvar[[i]])
 	    stopifnot(ccc %in% c("factor", "shingle"))
diff --git a/R/DP.R b/R/DP.R
index 2f91220..f796d08 100644
--- a/R/DP.R
+++ b/R/DP.R
@@ -53,7 +53,7 @@ dp_func <- function(points, tolerance) {
  simplify <- function(start, end, tol=tolerance) {
 
   #Calculate intermediate point distances 
-  if (length(points$x[start:end]) > 2) {
+  if (length(points$x[start:end]) > 2L) {
 
  	#Avoid Inf slope
  	if( points$x[start] ==  points$x[end] )  
@@ -99,13 +99,12 @@ dp_func <- function(points, tolerance) {
 }
 
 
-thinnedSpatialPoly <- function(SP, tolerance, minarea=0) {
+thinnedSpatialPoly <- function(SP, tolerance, minarea=0, topologyPreserve=FALSE, avoidGEOS=FALSE) {
     stopifnot(inherits(SP, "SpatialPolygons"))
     rgeosI <- rgeosStatus()
-    if (rgeosI) {
-#        require(rgeos)
-#        res <- thinnedSpatialPolyGEOS(SP=SP, tolerance=tolerance,
-#            minarea=minarea)
+    if (rgeosI && !avoidGEOS) {
+        require(rgeos)
+        res <- gSimplify(spgeom=SP, tol=tolerance, topologyPreserve=topologyPreserve)
     } else {
       pls <- slot(SP, "polygons")
       pls_dp <- vector(mode="list", length=length(pls))
diff --git a/R/Rgshhs.R b/R/Rgshhs.R
index acdca1f..b201063 100644
--- a/R/Rgshhs.R
+++ b/R/Rgshhs.R
@@ -1,9 +1,10 @@
-# Copyright (c) 2005-2010 Roger Bivand
+# Copyright (c) 2005-2010 Roger Bivand and Karl Ove Hufthammer
 
 Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0, 
-	shift=FALSE, verbose=TRUE, no.clip = FALSE) {
+	shift=FALSE, verbose=TRUE, no.clip = FALSE, properly=FALSE,
+        avoidGEOS=FALSE, checkPolygons=FALSE) {
 	if (!is.character(fn)) stop("file name must be character string")
-	if (length(fn) != 1) stop("file name must be single character string")
+	if (length(fn) != 1L) stop("file name must be single character string")
 	dolim <- FALSE
 	dolim <- (!is.null(xlim) || !is.null(ylim))
 	if (!is.null(xlim)) lim <- xlim
@@ -25,8 +26,8 @@ Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0,
 		minarea, PACKAGE="maptools")
 	else clip <- NULL
         rgeosI <- rgeosStatus()
-        if (rgeosI) {
-#            require(rgeos)
+        if (rgeosI && !avoidGEOS) {
+            require(rgeos)
         } else {
             stopifnot(isTRUE(gpclibPermitStatus()))
 	    require("gpclib")
@@ -37,7 +38,7 @@ Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0,
 
 	Antarctica <- which(polydata$area[(chosen_0+1)] > 1.3e+07 & 
 		polydata$area[(chosen_0+1)] < 1.4e+07)
-	if (length(Antarctica) == 1) {
+	if (length(Antarctica) == 1L) {
 		if (verbose) cat("Polygon", which(chosen_0 == (Antarctica-1)), 
 			"is Antarctica\n")
 		if (verbose) cat("  area", polydata$area[Antarctica], "\n")
@@ -59,13 +60,20 @@ Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0,
 	    ic <- 1
 	    if (verbose) cat("Rgshhs: clipping", sum(clip), "of", 
 		length(polys), "polygons ...\n")
-            if (rgeosI) {
-		limgp <- Polygons(list(Polygon(limbb)), ID="0")
+            if (rgeosI && !avoidGEOS) {
+		limgp <- SpatialPolygons(list(Polygons(list(Polygon(limbb)),
+                    ID="0")))
 		for (i in seq(along=polys)) {
 		    if (clip[i] == 1) {
-                        tp <- Polygons(list(Polygon(polys[[i]])), ID="1")
+                        tp <- SpatialPolygons(list(Polygons(list(Polygon(
+                            polys[[i]])), ID="1")))
                         rp0 <- NULL
-#                        rp0 <- PolygonsIntersections(tp, limgp)
+                        gI <- gIntersection(tp, limgp)
+# bug reported 120809 r-sig-geo.20.trevva
+                        if (!is.null(gI) && is(gI, "SpatialCollections")) 
+                            gI <- slot(gI, "polyobj")
+                        if (!is.null(gI)) 
+                            rp0 <- slot(gI, "polygons")[[1]]
                         rp <- NULL
                         if (!is.null(rp0)) 
                             rp <- lapply(slot(rp0, "Polygons"), slot, "coords")
@@ -121,7 +129,7 @@ Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0,
 	chosen_1 <- chosen_0+1
 	if (line == 0) {
 	 levels <- polydata$level[chosen_1]
-         if (rgeosI) {
+         if (rgeosI && !avoidGEOS) {
           ids <- polydata$id[chosen_1]
           containers <- polydata$container[chosen_1]
           ancestors <- polydata$ancestor[chosen_1]
@@ -129,7 +137,7 @@ Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0,
           ntl <- as.integer(names(tl))
           mntl <- match(1:4, ntl)
           l1 <- which(levels == 1L)
-          if (length(l1) > 0) {
+          if (length(l1) > 0L) {
               c1 <- which(containers == -1L)
               if (any(l1 != c1)) warning("containers and levels not coherent")
               if (!is.na(mntl[4])) {
@@ -172,19 +180,26 @@ Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0,
 			}
 			if (shift) crds[,1] <- ifelse(crds[,1] > 180, 
 			    crds[,1] - 360, crds[,1])
-			jres <- list(Polygon(crds, hole=holes[this]))
+			if (checkPolygons) {
+                            jres <- list(Polygon(crds))
+                        } else {
+                            jres <- list(Polygon(crds, hole=holes[this]))
+                        }
 			srl <- c(srl, jres)
 		    }
 		}
                 pls0 <- Polygons(srl, ID=IDs[i])
-#		Srl[[i]] <- checkPolygonsGEOS(pls0)
-                Srl[[i]] <- pls0
+		if (checkPolygons) {
+                    Srl[[i]] <- checkPolygonsGEOS(pls0, properly=properly)
+                } else {
+                    Srl[[i]] <- pls0
+                }
 	  }
 	  res <- as.SpatialPolygons.PolygonsList(Srl, 
 		proj4string=CRS("+proj=longlat +datum=WGS84"))
+          polydata <- data.frame(polydata)[chosen_1,]
 
-	  list(polydata=data.frame(polydata)[chosen_1,], belongs=belongs,
-              SP=res)
+	  return(list(polydata=polydata, belongs=belongs, SP=res))
          } else {
 	  belongs <- matrix(1:length(chosen_1), ncol=1)
 #	  belonged_to <- as.numeric(rep(NA, length(chosen_1)))
@@ -203,8 +218,8 @@ Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0,
 	    for (il in mlevel:2) {
 		w_il <- which(levels == il)
 		w_il_1 <- which(levels == (il-1))
-		if (length(w_il) > 0) {
-			if (length(w_il_1) == 1) {
+		if (length(w_il) > 0L) {
+			if (length(w_il_1) == 1L) {
 			    belongs[w_il, (il-1)] <- w_il_1
 			    if (!first_time) {
 				prom <- which(!is.na(match(belongs[,il], w_il)))
@@ -217,7 +232,7 @@ Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0,
 			    for (i in 1:length(w_il_1)) {
 				ii <- w_il_1[i]
 				lp1 <- as(polys[[ii]][[1]], "gpc.poly")
-				if (length(polys[[ii]]) > 1) {
+				if (length(polys[[ii]]) > 1L) {
 				    for (j in 2:length(polys[[ii]])) {
 					lpj <- as(polys[[ii]][[j]], "gpc.poly")
 					lp1 <- append.poly(lp1, lpj)
@@ -228,7 +243,7 @@ Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0,
 			    for (i in 1:length(w_il)) {
 				ii <- w_il[i]
 				lp1 <- as(polys[[ii]][[1]], "gpc.poly")
-				if (length(polys[[ii]]) > 1) {
+				if (length(polys[[ii]]) > 1L) {
 				    for (j in 2:length(polys[[ii]])) {
 					lpj <- as(polys[[ii]][[j]], "gpc.poly")
 					lp1 <- append.poly(lp1, lpj)
@@ -236,7 +251,7 @@ Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0,
 				}
 				for (j in 1:length(l_1)) {
 				    tp <- gpclib:::intersect(l_1[[j]], lp1)
-				    if (length(tp at pts) > 0) {
+				    if (length(tp at pts) > 0L) {
 					belongs[w_il[i], (il-1)] <- w_il_1[j]
 			    		if (!first_time) {
 					    prom <- which(!is.na(match(
@@ -303,3 +318,59 @@ Rgshhs <- function(fn, xlim=NULL, ylim=NULL, level=4, minarea=0,
 	  list(SP=res)
 	}
 }
+
+# contributed 101018 by Karl Ove Hufthammer
+
+getRgshhsMap = function (fn = system.file("share/gshhs_c.b",
+ package = "maptools"), xlim, ylim, level = 1, shift = TRUE,
+ verbose = TRUE, no.clip = FALSE, properly=FALSE, avoidGEOS=FALSE, checkPolygons=FALSE) 
+{
+    # First try fetching the map directly, possibly with negative coordinates.
+    # Note that some polygons with longitude < 0 use negative coordinates 
+    # (e.g., Great Britain), and some use positve coordinates (e.g., Ireland).
+    #    
+    # (Must use 'try' here, because for example xlim=c(-40,-10)
+    # results in an error, while xlim=c(-40,-5) does not.)
+    map1 = try(Rgshhs(fn, xlim = xlim, ylim = ylim, shift = shift, 
+                    level = level, verbose=verbose, no.clip = no.clip,
+                    properly=properly, avoidGEOS=avoidGEOS,
+                    checkPolygons=checkPolygons)$SP)
+    
+    # Now try fetching the same area using positive coordinates.
+    xl.west = (xlim + 360)%%360
+    if (xl.west[2] < xl.west[1])
+        xl.west[2] = 360
+    map2 = Rgshhs(fn, xlim = xl.west, ylim = ylim, shift = shift, 
+            level = level, verbose=verbose, no.clip = no.clip,
+            properly=properly, avoidGEOS=avoidGEOS,
+            checkPolygons=checkPolygons)$SP
+    
+    # If there where no polygons with negative coordinates, just
+    # use the positive coordinates.
+    if (class(map1) == "try-error") 
+        map.union = map2 else { # Else merge the two maps into one.
+        
+        # First store the original polygon IDs in data frames.
+        df1 = data.frame(polyID = row.names(map1), stringsAsFactors=FALSE)
+        row.names(df1) = df1$polyID
+        map1.spdf = SpatialPolygonsDataFrame(map1, df1)
+        
+        df2 = data.frame(polyID = row.names(map2), stringsAsFactors=FALSE)
+        row.names(df2) = df2$polyID
+        map2.spdf = SpatialPolygonsDataFrame(map2, df2)
+        
+        # Generate new polygon IDs to avoid duplicate IDs when
+        # rbinding the two maps.
+        row.names(map1.spdf) = as.character(seq_along(map1 at polygons))
+        row.names(map2.spdf) = as.character(length(map1 at polygons) + 
+                        seq_along(map2 at polygons))
+        map.merged = rbind(map1.spdf, map2.spdf)
+        
+        # Finally, combine all the polygons, using the
+        # original polyon IDs.
+        map.union = unionSpatialPolygons(map.merged, map.merged$polyID)
+    }
+    map.union
+}
+
+
diff --git a/R/SpatialLines-methods.R b/R/SpatialLines-methods.R
index c96775c..2bf1dd7 100644
--- a/R/SpatialLines-methods.R
+++ b/R/SpatialLines-methods.R
@@ -26,7 +26,7 @@ writeLinesShape <- function(x, fn, factor2char = TRUE, max_nchar=254) {
         nullParts <- sapply(shp$Shapes, function(x) x$nParts) == 0
         if (delete_null_obj) {
 	    nullParts <- which(nullParts)
-	    if (length(nullParts) > 0) {
+	    if (length(nullParts) > 0L) {
 		for (i in length(nullParts):1)
 	            shp$Shapes[[nullParts[i]]] <- NULL
                 attr(shp$Shapes,'nshps') <- attr(shp$Shapes,'nshps') - 
diff --git a/R/SpatialPolys-methods.R b/R/SpatialPolys-methods.R
index e1b5e04..963eb5e 100644
--- a/R/SpatialPolys-methods.R
+++ b/R/SpatialPolys-methods.R
@@ -30,7 +30,7 @@ writePolyShape <- function(x, fn, factor2char = TRUE, max_nchar=254) {
         nullParts <- sapply(Map$Shapes, function(x) x$nParts) == 0
         if (delete_null_obj) {
 	    nullParts <- which(nullParts)
-	    if (length(nullParts) > 0) {
+	    if (length(nullParts) > 0L) {
               if (!retrieve_ABS_null) {
 		for (i in length(nullParts):1)
 	            Map$Shapes[[nullParts[i]]] <- NULL
@@ -112,9 +112,9 @@ writePolyShape <- function(x, fn, factor2char = TRUE, max_nchar=254) {
     x <- as.character(x)
     which.nas <- which(is.na(x))
     which.blanks <- which(x == "")
-    if (length(which.blanks) > 0) 
+    if (length(which.blanks) > 0L) 
         x[which.blanks] <- -Inf
-    if (length(which.nas) > 0) 
+    if (length(which.nas) > 0L) 
         x[which.nas] <- Inf
     delimited <- gsub("([+-]{0,1}[0-9.]+([eE][+-]{0,1}[0-9.]+){0,1})", 
         paste(delim, "\\1", delim, sep = ""), x)
@@ -136,7 +136,7 @@ writePolyShape <- function(x, fn, factor2char = TRUE, max_nchar=254) {
     rank.overall <- ifelse(is.na(rank.character), rank.numeric, 
         rank.character)
     order.frame <- as.data.frame(rank.overall)
-    if (length(which.nas) > 0) 
+    if (length(which.nas) > 0L) 
         order.frame[which.nas, ] <- Inf
     retval <- do.call("order", order.frame)
     return(retval)
diff --git a/R/asciigrid.R b/R/asciigrid.R
index 1041fb5..e52a3b9 100644
--- a/R/asciigrid.R
+++ b/R/asciigrid.R
@@ -77,7 +77,7 @@ writeAsciiGrid <- function(x, fname, attr = 1, na.value = -9999,
 		stop("can only write SpatialGridDataFrame objects to asciigrid")
 	x = as(x, "SpatialGridDataFrame")
 	gp = gridparameters(x)
-	if (length(gp$cells.dim) != 2)
+	if (length(gp$cells.dim) != 2L)
 		stop("asciigrid only supports 2D grids")
 #	if (gp$cellsize[1] != gp$cellsize[2])
 	if (diff(gp$cellsize) < .Machine$double.eps ^ 0.5)
diff --git a/R/checkHoles.R b/R/checkHoles.R
index 90e09f2..0354e0b 100644
--- a/R/checkHoles.R
+++ b/R/checkHoles.R
@@ -1,17 +1,34 @@
 gpclibPermit <- function() {
-    if (require("gpclib", quietly = TRUE, warn.conflicts = FALSE))
+    if ("gpclib" %in% .packages(all.available = TRUE))
         assign("gpclib", TRUE, envir=.MAPTOOLS_CACHE)
-    get("gpclib", envir=.MAPTOOLS_CACHE)
+    gpclibPermitStatus()
 }
 
 gpclibPermitStatus <- function() get("gpclib", envir=.MAPTOOLS_CACHE)
 
+setRgeosStatus <- function() {
+    rgeosI <- "rgeos" %in% .packages(all.available = TRUE)
+#    if (rgeosI) {
+#        ldNS <- loadedNamespaces()
+#        if (!("rgeos" %in% ldNS)) {
+#            oo <- try(loadNamespace("rgeos"), silent=TRUE)
+#            if (class(oo) == "try-error") rgeosI <- FALSE
+#            else unloadNamespace("rgeos")
+#        }
+#    }
+    assign("rgeos", rgeosI, envir=.MAPTOOLS_CACHE)
+}
+
 rgeosStatus <- function() get("rgeos", envir=.MAPTOOLS_CACHE)
 
-checkPolygonsHoles <- function(x) {
-    if (rgeosStatus()) {
-#        require(rgeos)
-#        return(checkPolygonsGEOS(x))
+checkPolygonsHoles <- function(x, properly=TRUE, avoidGEOS=FALSE,
+    useSTRtree=FALSE) {
+    if (rgeosStatus() && !avoidGEOS) {
+        require(rgeos)
+# version check rgeos
+        if (compareVersion(as.character(packageVersion("rgeos")), "0.1-4") < 0)
+            useSTRtree <- FALSE
+        return(checkPolygonsGEOS(x, properly=properly, useSTRtree=useSTRtree))
     } else {
         stopifnot(isTRUE(gpclibPermitStatus()))
 	require(gpclib)
@@ -83,3 +100,96 @@ checkPolygonsHoles <- function(x) {
    	else return(as.integer(-1))
 }
 
+
+checkPolygonsGEOS <- function(obj, properly=TRUE, force=TRUE, useSTRtree=FALSE) {
+    if (!is(obj, "Polygons")) 
+        stop("not a Polygons object")
+    comm <- try(createPolygonsComment(obj), silent=TRUE)
+#    isVal <- try(gIsValid(SpatialPolygons(list(obj))), silent=TRUE)
+#    if (class(isVal) == "try-error") isVal <- FALSE
+    if (class(comm) != "try-error" && !force) {
+        comment(obj) <- comm
+        return(obj)
+    }
+    pls <- slot(obj, "Polygons")
+    n <- length(pls)
+    if (n < 1) stop("Polygon list of zero length")
+    uniqs <- rep(TRUE, n)
+    if (n > 1) {
+      if (useSTRtree) tree1 <- gUnarySTRtreeQuery(obj)
+      SP <- SpatialPolygons(lapply(1:n, function(i) 
+        Polygons(list(pls[[i]]), ID=i)))
+      for (i in 1:(n-1)) {
+        if (useSTRtree) {
+            if (!is.null(tree1[[i]])) {
+                res <- try(gEquals(SP[i,], SP[tree1[[i]],], byid=TRUE),
+                    silent=TRUE)
+                if (class(res) == "try-error") {
+                    warning("Polygons object ", slot(obj, "ID"), ", Polygon ",
+                        i, ": ", res)
+                    next
+                }
+                if (any(res)) {
+                    uniqs[as.integer(rownames(res)[res])] <- FALSE
+                }
+            }
+        } else {
+            res <- try(gEquals(SP[i,], SP[uniqs,], byid=TRUE), silent=TRUE)
+            if (class(res) == "try-error") {
+                warning("Polygons object ", slot(obj, "ID"), ", Polygon ",
+                    i, ": ", res)
+                next
+            }
+            res[i] <- FALSE
+            if (any(res)) {
+                wres <- which(res)
+                uniqs[wres[wres > i]] <- FALSE
+            }
+        }
+      }
+    }
+    if (any(!uniqs)) warning(paste("Duplicate Polygon objects dropped:",
+        paste(wres, collapse=" ")))
+    pls <- pls[uniqs]
+    n <- length(pls)
+    if (n < 1) stop("Polygon list of zero length")
+    if (n == 1) {
+        oobj <- Polygons(pls, ID=slot(obj, "ID"))
+        comment(oobj) <- createPolygonsComment(oobj)
+        return(oobj)
+    }
+    areas <- sapply(pls, slot, "area")
+    pls <- pls[order(areas, decreasing=TRUE)]
+    oholes <- sapply(pls, function(x) slot(x, "hole"))
+    holes <- rep(FALSE, n)
+    SP <- SpatialPolygons(lapply(1:n, function(i) 
+        Polygons(list(pls[[i]]), ID=i)))
+    if (useSTRtree) tree2 <- gUnarySTRtreeQuery(SP)
+    for (i in 1:(n-1)) {
+        if (useSTRtree) {
+            if (!is.null(tree2[[i]])) {
+                if (properly) res <- gContainsProperly(SP[i,], SP[tree2[[i]],],
+                    byid=TRUE)
+                else res <- gContains(SP[i,], SP[tree2[[i]],], byid=TRUE)
+            } else {
+                res <- FALSE
+            }
+        } else {
+            if (properly) res <- gContainsProperly(SP[i,], SP[-(1:i),],
+                byid=TRUE)
+            else res <- gContains(SP[i,], SP[-(1:i),], byid=TRUE)
+        }
+        wres <- which(res)
+        if (length(wres) > 0L) {
+            nres <- as.integer(rownames(res))
+            holes[nres[wres]] <- ! holes[nres[wres]]
+        }
+    }
+    for (i in 1:n) {
+        if (oholes[i] != holes[i])
+        pls[[i]] <- Polygon(slot(pls[[i]], "coords"), hole=holes[i])
+    }
+    oobj <- Polygons(pls, ID=slot(obj, "ID"))
+    comment(oobj) <- createPolygonsComment(oobj)
+    oobj    
+}
diff --git a/R/dotsinpolys.R b/R/dotsinpolys.R
index b594af9..e6363b2 100644
--- a/R/dotsinpolys.R
+++ b/R/dotsinpolys.R
@@ -22,7 +22,9 @@ dotsInPolys <- function(pl, x, f="random", offset, compatible=FALSE) {
     }
     for (i in 1:n) {
         if (x[i] > 0) {
-	    ires <- sample.Polygons(pls[[i]], x[i], type=f, offset=offset)
+		#EJP: deprecate sample.Polygons
+	    #ires <- sample.Polygons(pls[[i]], x[i], type=f, offset=offset)
+	    ires <- spsample(pls[[i]], x[i], type=f, offset=offset)
 	    if (!is.null(ires)) res[[i]] <- ires
 	    if (!is.null(res[[i]])) ID_out <- c(ID_out, IDs[i])
 	}
@@ -75,8 +77,9 @@ symbolsInPolys <- function(pl, dens, symb="+", compatible=FALSE) {
     for (i in 1:n) {
 	px <- as.integer(sum(counts[[i]]))
         if (px > 0) {
-            ires <- sample.Polygons(pls[[i]], px, type="regular", 
-		offset=c(0.5,0.5))
+			#EJP: deprecate sample.Polygons:
+            #ires <- sample.Polygons(pls[[i]], px, type="regular", 
+            ires <- spsample(pls[[i]], px, type="regular", offset=c(0.5,0.5))
 	    if (!is.null(ires)) res[[i]] <- ires
 	    if (!is.null(res[[i]])) symb_out <- c(symb_out, symb[i])
 	}
diff --git a/R/elide.R b/R/elide.R
old mode 100755
new mode 100644
index eaeb3fc..d2766e4
--- a/R/elide.R
+++ b/R/elide.R
@@ -10,14 +10,14 @@ if (!isGeneric("elide")) {
 
 elide.points <- function(obj, bb=NULL, shift=c(0, 0), reflect=c(FALSE, FALSE),
   scale=NULL, flip=FALSE, rotate=0, center=NULL, unitsq=FALSE) {
-  if (length(shift) != 2)
+  if (length(shift) != 2L)
     stop("Two coordinate shift in input units required")
   if (!is.numeric(shift)) stop("shift not numeric")
   if (!is.logical(reflect)) stop("reflect must be logical")
-  if (length(reflect) != 2) stop("Two coordinate reflect required")
+  if (length(reflect) != 2L) stop("Two coordinate reflect required")
   if (!is.logical(flip)) stop("flip must be logical")
   if (!is.numeric(rotate)) stop("rotate not numeric")
-  if (!is.null(center) && length(center) != 2)
+  if (!is.null(center) && length(center) != 2L)
     stop("center must be numeric of length two")
   if (!is.logical(unitsq)) stop("unitsq must be logical")
   crds <- coordinates(obj)
@@ -100,14 +100,14 @@ elideCoords <- function(x, y, xr, yr, reflect, scale, rotate, center) {
 
 elide.lines <- function(obj, bb=NULL, shift=c(0, 0), reflect=c(FALSE, FALSE),
   scale=NULL, inverse=FALSE, flip=FALSE, rotate=0, center=NULL) {
-  if (length(shift) != 2)
+  if (length(shift) != 2L)
     stop("Two coordinate shift in input units required")
   if (!is.numeric(shift)) stop("shift not numeric")
   if (!is.logical(reflect)) stop("reflect must be logical")
-  if (length(reflect) != 2) stop("Two coordinate reflect required")
+  if (length(reflect) != 2L) stop("Two coordinate reflect required")
   if (!is.logical(flip)) stop("flip must be logical")
   if (!is.numeric(rotate)) stop("rotate not numeric")
-  if (!is.null(center) && length(center) != 2)
+  if (!is.null(center) && length(center) != 2L)
     stop("center must be numeric of length two")
   if (is.null(bb)) bb <- bbox(obj)
   if (rotate != 0 && is.null(center)) center <- bb[,1]
@@ -158,14 +158,14 @@ setMethod("elide", signature(obj="SpatialLinesDataFrame"), elide.linesdf)
 
 elide.polygons <- function(obj, bb=NULL, shift=c(0, 0), reflect=c(FALSE, FALSE),
   scale=NULL, inverse=FALSE, flip=FALSE, rotate=0, center=NULL) {
-  if (length(shift) != 2)
+  if (length(shift) != 2L)
     stop("Two coordinate shift in input units required")
   if (!is.numeric(shift)) stop("shift not numeric")
   if (!is.logical(reflect)) stop("reflect must be logical")
-  if (length(reflect) != 2) stop("Two coordinate reflect required")
+  if (length(reflect) != 2L) stop("Two coordinate reflect required")
   if (!is.logical(flip)) stop("flip must be logical")
   if (!is.numeric(rotate)) stop("rotate not numeric")
-  if (!is.null(center) && length(center) != 2)
+  if (!is.null(center) && length(center) != 2L)
     stop("center must be numeric of length two")
   if (is.null(bb)) bb <- bbox(obj)
   if (rotate != 0 && is.null(center)) center <- bb[,1]
@@ -193,7 +193,9 @@ elide.polygons <- function(obj, bb=NULL, shift=c(0, 0), reflect=c(FALSE, FALSE),
       new_crds <- elideCoords(x=xc, y=yc, xr=xr, yr=yr, 
         reflect=reflect, scale=scale)
       Polygon(new_crds)})
-    Polygons(new_Pls, ID=slot(x, "ID"))})
+    pres <- Polygons(new_Pls, ID=slot(x, "ID"))
+    if (!is.null(comment(x))) comment(pres) <- comment(x)
+    pres})
   res <- SpatialPolygons(new_pls)
   res
 }
diff --git a/R/gc_dist.R b/R/gc_dist.R
old mode 100755
new mode 100644
index 5ff4e18..8fc625a
--- a/R/gc_dist.R
+++ b/R/gc_dist.R
@@ -17,8 +17,8 @@ gcDestination <- function(lon, lat, bearing, dist, dist.units = "km",
     if (!is.numeric(dist)) stop("dist not numeric")
 
     if (length(lon) != length(lat)) stop("lon and lat differ in length")
-    if (length(bearing) > 1 && length(lon) > 1) stop("length mismatch")
-    if (length(bearing) > 1 && length(dist) > 1) stop("length mismatch")
+    if (length(bearing) > 1L && length(lon) > 1L) stop("length mismatch")
+    if (length(bearing) > 1L && length(dist) > 1L) stop("length mismatch")
 
     as.radians <- function(degrees) degrees * pi / 180
     as.degrees <- function(radians) radians * 180 / pi
diff --git a/R/getKMLcoordinates.R b/R/getKMLcoordinates.R
index a1cfa11..1f0f4d2 100644
--- a/R/getKMLcoordinates.R
+++ b/R/getKMLcoordinates.R
@@ -4,6 +4,11 @@ getKMLcoordinates <- function(kmlfile, ignoreAltitude = FALSE) {
         stop("kmlfile is missing")
     kml <- paste(readLines(kmlfile, encoding = "UTF-8"), 
         collapse = " ")
+    ## ++ new code Mike Sumner 120509
+    ## remove tabs first
+    kml <- gsub("[[:blank:]]+", " ", kml)
+    ##   
+
     re <- "<coordinates> *([^<]+?) *<\\/coordinates>"
     mtchs <- gregexpr(re, kml)[[1]]
     coords <- list()
diff --git a/R/kmlLine.R b/R/kmlLine.R
old mode 100755
new mode 100644
index 9be1031..e76007e
--- a/R/kmlLine.R
+++ b/R/kmlLine.R
@@ -12,7 +12,7 @@ kmlLine <- function(obj = NULL, kmlfile = NULL, name = "R Line",
     if (class(obj) != "Lines" && class(obj) != "SpatialLinesDataFrame") 
         stop("obj must be of class 'Lines' or 'SpatialLinesDataFrame' [package 'sp']")
     if (class(obj) == "SpatialLinesDataFrame") {
-        if (length(obj at lines) > 1) 
+        if (length(obj at lines) > 1L) 
             warning(paste("Only the first Lines object with the ID '", 
               obj at lines[[1]]@ID, "' is taken from 'obj'", 
               sep = ""))
diff --git a/R/kmlPoints.R b/R/kmlPoints.R
new file mode 100644
index 0000000..4a8ab49
--- /dev/null
+++ b/R/kmlPoints.R
@@ -0,0 +1,89 @@
+
+kmlPoints <- function (obj = NULL, kmlfile = NULL, kmlname = "", kmldescription = "",
+                       name = NULL, description = "", 
+                       icon = "http://google.com/mapfiles/kml/paddle/wht-diamond.png") {
+    # Handle null object
+    if (is.null(obj)) 
+        return(list(header = c("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", 
+            "<kml xmlns=\"http://earth.google.com/kml/2.2\">", 
+            "<Document>", paste("<name>", kmlname, "</name>", 
+                sep = ""), paste("<description><![CDATA[", kmldescription, 
+                "]]></description>", sep = "")), footer = c("</Document>", 
+            "</kml>")))
+
+    # Handle wrong data type
+    if (class(obj) != "SpatialPointsDataFrame") 
+        stop("obj must be of class 'SpatialPointsDataFrame' [package 'sp']")
+
+    # Handle null name
+    if (is.null(name)) {
+        name = c()
+        for (i in 1:nrow(obj))
+            name <- append(name, paste("site", i))
+    }
+
+    # Handle single value name, description and icon
+    if (length(name) < nrow(obj)) {
+        if (length(name) > 1)
+            warning("kmlPoints: length(name) does not match nrow(obj). The first name will be replicated.")
+        name <- rep(name,nrow(obj))
+    }
+    if (length(description) < nrow(obj)) {
+        if (length(description) > 1)
+            warning("kmlPoints: length(description) does not match nrow(obj). The first description will be replicated.")
+        description <- rep(description,nrow(obj))
+    }
+    if (length(icon) < nrow(obj)) {
+        if (length(icon) > 1)
+            warning("kmlPoints: length(icon) does not match nrow(obj). Only the first one will be used.")
+        icon <- icon[1]
+    }
+
+    # Set up defaults for different sections
+    kml <- kmlStyle <- ""
+    kmlHeader <- c("<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
+                   "<kml xmlns=\"http://earth.google.com/kml/2.2\">",
+                   "<Document>", 
+             paste("<name>", kmlname, "</name>", sep = ""),
+             paste("<description><![CDATA[", kmldescription, "]]></description>", sep = ""))
+    kmlFooter <- c("</Document>", "</kml>")
+
+    # Create a set of styles
+    # NOTE:  Available icons are at: http://sites.google.com/site/gmapsdevelopment/
+    # NOTE:  No checking is done to make sure the icon href actually exists.
+    for (i in 1:length(icon)) {
+        pt_icon_href = icon[i]
+        kmlStyle <- append(kmlStyle, paste("<Style id=\"style", i, "\">", sep = ""))
+        kmlStyle <- append(kmlStyle, "  <IconStyle>")
+        kmlStyle <- append(kmlStyle, "    <Icon>")
+        kmlStyle <- append(kmlStyle, paste("      <href>", pt_icon_href, "</href>", sep = ""))
+        kmlStyle <- append(kmlStyle, "    </Icon>")
+        kmlStyle <- append(kmlStyle, "  </IconStyle>")
+        kmlStyle <- append(kmlStyle, "</Style>")
+    }
+
+    # Create the sequential list of Placemarks
+    for (i in 1:nrow(obj)) {
+        point <- obj[i,]
+        pt_name = name[i]
+        pt_description = description[i]
+        pt_style <- paste("#style",ifelse(length(icon) == 1, 1, i),sep="")
+        kml <- append(kml, "<Placemark>")
+        kml <- append(kml, paste("  <name>", pt_name, "</name>", sep = ""))
+        kml <- append(kml, paste("  <description><![CDATA[", pt_description, "]]></description>", sep = ""))
+        kml <- append(kml, paste("  <styleUrl>", pt_style, "</styleUrl>", sep = ""))
+        kml <- append(kml, "  <Point>")
+        kml <- append(kml, "    <coordinates>")
+        kml <- append(kml, paste(point at coords[1], point at coords[2], sep = ","))
+        kml <- append(kml, "    </coordinates>")
+        kml <- append(kml, "  </Point>")
+        kml <- append(kml, "</Placemark>")
+    }
+    
+    # Write out the file or return the compontents
+    if (!is.null(kmlfile)) 
+        cat(paste(c(kmlHeader, kmlStyle, kml, kmlFooter), sep = "", 
+            collapse = "\n"), "\n", file = kmlfile, sep = "")
+    else list(style = kmlStyle, content = kml)
+}
+
diff --git a/R/kmlPolygon.R b/R/kmlPolygon.R
old mode 100755
new mode 100644
index 1932b7c..677b809
--- a/R/kmlPolygon.R
+++ b/R/kmlPolygon.R
@@ -12,7 +12,7 @@ kmlPolygon <- function(obj = NULL, kmlfile = NULL, name = "R Polygon",
     if (class(obj) != "Polygons" && class(obj) != "SpatialPolygonsDataFrame") 
         stop("obj must be of class 'Polygons' or 'SpatialPolygonsDataFrame' [package 'sp']")
     if (class(obj) == "SpatialPolygonsDataFrame") {
-        if (length(obj at polygons) > 1) 
+        if (length(obj at polygons) > 1L) 
             warning(paste("Only the first Polygons object with the ID '", 
               obj at polygons[[1]]@ID, "' is taken from 'obj'", 
               sep = ""))
@@ -79,8 +79,8 @@ kmlPolygon <- function(obj = NULL, kmlfile = NULL, name = "R Polygon",
         # which contains these holes regardingless plotOrder;
         # TODO: rearrange holes according to 'their' polygons automatically via
         # hole.in.which.polygon?
-        holeFlag <- ifelse((i + 1) <= length(obj at Polygons), 
-            obj at Polygons[[i + 1]]@hole, FALSE)
+        holeFlag <- ifelse((i + 1L) <= length(obj at Polygons), 
+            obj at Polygons[[i + 1L]]@hole, FALSE)
         if (!holeFlag) 
             kml <- append(kml, "</Polygon>")
     }
diff --git a/R/lineLabel.R b/R/lineLabel.R
new file mode 100644
index 0000000..00e3835
--- /dev/null
+++ b/R/lineLabel.R
@@ -0,0 +1,271 @@
+# Author: Oscar Perpinan Lamigueiro oscar.perpinan at gmail.com
+# Date :  October 2012
+# Version 0.10
+# Licence GPL v3
+
+lineLabel <- function(line, label,
+                      spar=.6, position = c('above', 'below'),
+                      textloc = 'constantSlope',
+                      col = add.text$col,
+                      alpha = add.text$alpha,
+                      cex = add.text$cex,
+                      lineheight = add.text$lineheight,
+                      font = add.text$font,
+                      fontfamily = add.text$fontfamily,
+                      fontface = add.text$fontface,
+                      lty = add.line$lty,
+                      lwd = add.line$lwd, 
+                      col.line = add.line$col,
+                      identifier = 'lineLabel',
+                     ...){
+  ## line is a list of Line objects
+  ## label and line must be of equal length
+  stopifnot(is.numeric(textloc) | is.character(textloc))
+  stopifnot(length(line) == length(label))
+  if (is.numeric(textloc)) stopifnot(length(line) == length(textloc))
+
+  add.text <- trellis.par.get("add.text")
+  add.line <- trellis.par.get("add.line")
+
+  position <- match.arg(position)
+
+  for (i in seq_along(line)) {
+    subline <- line[[i]]
+    lbl <- label[i]
+    
+    coords <- xy.coords(coordinates(subline))
+
+    llines(coords,
+           col = col.line, lty=lty, lwd=lwd,
+           identifier = paste(identifier, "line", ## add ID?
+             sep = "."))
+
+    if (lbl !='') { ## Only execute if label is not empty
+      ## Where the label is to be placed?
+      ## Method "mixed" from lattice::panel.levelplot
+      coords <- with(coords, data.frame(x, y))
+      slopes <- diff(coords$y) / diff(coords$x)
+      slopes[is.infinite(slopes)] <- NA
+ 
+      rx <- range(coords$x)
+      ry <- range(coords$y)
+
+      stopifnot(is.character(textloc) | is.numeric(textloc))
+      
+      if (is.character(textloc)){
+        textloc <- match.arg(textloc, c('minSlope', 'maxDepth', 'constantSlope'))
+
+        idxLoc <- switch(textloc,
+                          minSlope = which.min(abs(slopes)),
+                          maxDepth = {
+                            depth <- pmin(pmin(coords$x - rx[1], rx[2] - coords$x) / diff(rx), 
+                                          pmin(coords$y - ry[1], ry[2] - coords$y) / diff(ry))
+                            min(which.max(depth), length(slopes))
+                            },
+                          constantSlope = {
+                            slopeSign <- sign(slopes)
+                            zeros <- which(slopes==0)
+                            for (i in zeros) {
+                              i1 <- max(1, i-1)
+                              i2 <- min(length(slopes), i + 1)
+                              slopeSign[i] <- sign(sum(slopes[c(i1, i2)], na.rm=1))
+                              }
+                            rleSlopes <- rle(slopeSign)
+                            idxCS <- max(which.max(rleSlopes$lengths) - 1, 1)
+                            cumLengths <- cumsum(rleSlopes$lengths)
+                            idxLim <- c(cumLengths[idxCS] +1, cumLengths[idxCS + 1])
+                            idxLim[1]
+                            ## idx1 <- cumsum(rleSlopes$lengths)[idxCS] + 1
+                            ## idx2 <- idx1 + rleSlopes$lengths[idxCS + 1] - 1
+                            ## which(coords[,1] == min(coords[c(idx1, idx2), 1]))
+                            }
+                          )
+        } else {idxLoc <- textloc[i]}
+      
+      ## Label: number of characters, width and height
+      gp <- gpar(col = col,
+                 alpha = alpha,
+                 cex = cex,
+                 lineheight = lineheight,
+                 fontfamily = fontfamily,
+                 fontface = fontface)
+      chars <- strsplit(lbl, '')[[1]]
+      nchars <- length(chars)
+
+
+      chWidth <- sapply(chars, function(ch){
+        chGrob <- textGrob(ch, gp=gp)
+        gWidth <- grobWidth(chGrob)
+        convertWidth(gWidth, 'native', valueOnly=TRUE)
+      })
+
+      labLength <- sum(chWidth)
+
+      chHeight <- sapply(chars, function(ch){
+        chGrob <- textGrob(ch, gp=gp)
+        gHeight <- grobHeight(chGrob)
+        convertHeight(gHeight, 'native', valueOnly=TRUE)
+      })
+      labHeight <- max(chHeight)
+
+      ##------------------------------------------------------------------##
+      ## Starting at idxLoc, extract the segment of the line to be
+      ## followed. It must be long enough for the text
+      ##------------------------------------------------------------------##
+
+      lengths <- LineLength(subline, sum=FALSE, longlat=FALSE)
+      nParts <- length(lengths)
+      lengthsLoc <- cumsum(lengths[idxLoc:nParts])
+
+      if (labLength > lengthsLoc[nParts - idxLoc +1]) { ##The segment is not long enough for the label
+        idxLoc <- 1
+        segCoords <- apply(coords, 2, mean)
+        slopes <- mean(slopes, na.rm=TRUE)
+      } else {
+        idxLength <- min(which(lengthsLoc >= labLength))
+        segCoords <- coords[idxLoc:(idxLoc+idxLength),]
+        segment <- Line(segCoords)
+        lengthSeg <- LineLength(segment)
+      }
+
+      nX <- nrow(segCoords)
+      if (!is.null(nX) && nX >= 4) { ## smooth.spline needs at least four distinct x values
+
+        ##------------------------------------------------------------------##
+        ## Resample the segment to obtain a collection of short segments.
+        ##------------------------------------------------------------------##
+
+        n <- floor(lengthSeg/min(chWidth)) * 1e3
+
+        segSplineFun <- smooth.spline(segCoords, spar = spar) ## change spar to adjust the smooth level
+        rxSeg <- range(segCoords$x)
+        xsp <- seq(rxSeg[1], rxSeg[2], length=n) ## new x values to resample the segment
+        segSpline <- data.frame(predict(segSplineFun, xsp))
+
+        ## Each letter will be placed above a midpoint of this resampled segment
+        midPoints <- 1/2 * (segSpline[1:(n-1), ] + segSpline[2:n, ])
+        slopes <- diff(segSpline$y) / diff(segSpline$x)
+
+        ##------------------------------------------------------------------##
+        ## Parallel translation of the resampled segment. The distant is fixed
+        ## by the height of the label.
+        ##------------------------------------------------------------------##
+
+        ## Distance between segments
+        D <- labHeight
+        ## Unitary perpendicular vector
+        perp <- data.frame(x=-diff(segSpline$y), y=diff(segSpline$x))
+        len <- apply(perp, 1, FUN=function(v)sqrt(sum(v^2)))
+        perp <- perp/len
+
+        ## Points above (+) or below (-) line
+
+        if (position =='below') D <- abs(D) else D <- -abs(D)
+        segOffset <- sweep(midPoints, 2, D * colMeans(perp))
+        ##segOffset <- midPoints +  D*perp
+
+        segSplineLine <- Line(segOffset) ##Line(segSpline)
+        lengthSegSpline <- LineLength(segSplineLine, sum=FALSE)
+
+        ## sp.lines(segSplineLine, col='blue')
+
+        ##------------------------------------------------------------------##
+        ## A character is placed above a collection of segments whose total
+        ## length is higher than the character width. IDs is a vector of
+        ## indices to subset the parallel segment.
+        ##------------------------------------------------------------------##
+
+        id <- IDs <- 1
+        lengths <- lengthSegSpline
+        nSegs <- length(lengths)
+        for (i in 2:nchars){
+          D <- cumsum(lengths)
+          L <- 1/2*(chWidth[i-1] + chWidth[i])
+          id <- min(which(D>=L))
+          lengths <- lengths[(id+1):nSegs]
+          IDs <- c(IDs, id)
+        }
+        IDs <- cumsum(IDs)
+
+        pts <- SpatialPoints(segOffset)[IDs,] 
+        coordLabs <- coordinates(pts)
+        slopeLabs <- 180/pi * atan(slopes[IDs])
+
+        tg <- textGrob(chars, coordLabs[,1], coordLabs[,2],
+                       default.units='native',
+                       rot=slopeLabs,
+                       gp=gp)
+        grid.draw(tg)
+
+      } else { ## without 4 distinct x values
+        coordLabs <- coords[idxLoc,]
+        slopeLabs <- 180/pi * atan(slopes[idxLoc])
+        just <- if (position=='below') 'top' else 'bottom'
+
+        tg <- textGrob(lbl, coordLabs[,1], coordLabs[,2],
+                       just=just,
+                       default.units='native',
+                       rot=slopeLabs,
+                       gp=gp)
+        grid.draw(tg)
+
+
+
+      }
+      ## lapply(1:nchars, FUN=function(i){
+      ##   pg <- circleGrob(coordLabs[i,1], coordLabs[i,2], r=chWidth[i]/2,
+      ##                    default.units='native', gp=gpar(col='red'))
+      ##   grid.draw(pg)
+      ##  })
+    }}
+}
+
+setGeneric('sp.lineLabel', function(object, labels, byid=TRUE,...){standardGeneric('sp.lineLabel')})
+
+setMethod('sp.lineLabel',
+          signature=(object='Lines'),
+          definition=function(object, labels, byid=TRUE, ...){
+            if (missing(labels)) labels=object at ID
+            if (isTRUE(byid)){
+              lengths <- sapply(object at Lines, LineLength)
+              idxMax <- which.max(lengths)
+              labs <- rep('', length(object at Lines))
+              labs[idxMax] <- labels
+            } else {
+              labs <- rep(labels, length(object at Lines))
+            }
+            lineLabel(object at Lines, label=labs, ...)
+          }
+          )
+
+setMethod('sp.lineLabel',
+          signature=(object='SpatialLines'),
+          definition=function(object, labels, byid=TRUE,...){
+            if (missing(labels)){
+              ids <- sapply(object at lines, function(l)l at ID)
+              labels <- ids
+              names(labels) <- ids
+            }
+            for (i in seq_along(object)){
+              line <- object at lines[[i]]
+              idLabel <- match(line at ID, names(labels))
+              lbl <- if (is.na(idLabel)) '' else as.graphicsAnnot(labels[idLabel])
+              sp.lineLabel(line, lbl, byid=byid,...)
+            }
+          }
+          )
+
+
+setGeneric('label', function(object, text,...){standardGeneric('label')})
+
+setMethod('label', signature=(object='SpatialLines'),
+          definition=function(object, text,...){
+            text <- as.character(text)
+            nfeatures <- length(object)
+            if (!identical(nfeatures, length(text))){
+              stop('Number of labels must equal number of features.')
+            }
+            ids <- sapply(object at lines, function(l)l at ID)
+            names(text) <- ids
+            text
+          })
diff --git a/R/maptools.R b/R/maptools.R
index f12407a..1bce628 100644
--- a/R/maptools.R
+++ b/R/maptools.R
@@ -28,7 +28,7 @@ plot.polylist <- function(x, col, border=par("fg"), add=FALSE,
 		}
 	}
 	pO <- attr(x, "plotOrder")
-	if (length(x) < 1) stop("zero length polylist")
+	if (length(x) < 1L) stop("zero length polylist")
 	if (is.null(pO) || length(x) != length(pO)) pO <- 1:length(x)
 	pO <- as.integer(pO)
 	if (length(pO) != length(unique(pO))) stop("malformed plot order")
@@ -350,7 +350,7 @@ Map2poly <- function(Map, region.id=NULL, quiet=TRUE) {
 	attr(res, "plotOrder") <- pO
 
     	nD <- unique(sapply(res, function(x) dim(x)[2]))
-    	if (length(nD) > 1) stop("multiple dimension polylist components")
+    	if (length(nD) > 1L) stop("multiple dimension polylist components")
     	nD <- as.integer(nD)
     	attr(res, "nDims") <- nD
 
@@ -448,7 +448,7 @@ Map2poly1 <- function(Map, region.id=NULL, raw=TRUE) {
 
 			}
 			rj <- ri[int]
-			if (length(rj) > 0) {
+			if (length(rj) > 0L) {
 				res1[[i]] <- as.integer(rj)
 			}
 		}
@@ -509,7 +509,7 @@ Map2poly1 <- function(Map, region.id=NULL, raw=TRUE) {
 				jj <- x[[i]][j]
 				hits[j] <- (i %in% x[[jj]])
 			}
-			if (length(which(hits)) > 1) stop("multiple circulars")
+			if (length(which(hits)) > 1L) stop("multiple circulars")
 			pair <- c(i, x[[i]][hits])
 			res <- rbind(res, pair)
 		}			
@@ -566,7 +566,7 @@ Map2poly1 <- function(Map, region.id=NULL, raw=TRUE) {
 # the gone vector is used to avoid multiple assignments to the plot
 # order list that can happen with circularity
 
-		if (length(ihits) > 0) {
+		if (length(ihits) > 0L) {
 			tihits <- ids[ihits]
 			rtihits <- rle(ids[ids %in%tihits])
 			o <- order(rtihits$lengths)
diff --git a/R/maptoolsChanges.R b/R/maptoolsChanges.R
index d7a5ee0..a5e468a 100644
--- a/R/maptoolsChanges.R
+++ b/R/maptoolsChanges.R
@@ -1,19 +1,19 @@
-maptools <- function(changes=FALSE) {
-	.DESC <- packageDescription("maptools")
-	cat(.DESC[["Package"]], ", version ", .DESC[["Version"]],
-	 	", ", .DESC[["Date"]], "\n", sep="")
-	.CH <- NULL
-	if (changes) {
-		cat("\n")
-		file <- system.file("changes", package = "maptools")
-		.CH <- scan(file, list(version="character", 
-			changes="character"), sep="\t", quiet=TRUE)
-		for (i in length(.CH$changes):1) {
-			cat(unlist(strsplit(.CH$changes[i], " ")), fill=TRUE, 
-				labels=.CH$version[i])
-			cat("\n")
-		}
-	}
-	invisible(.CH)
-}
-
+maptools <- function(changes=FALSE) {
+	.DESC <- packageDescription("maptools")
+	cat(.DESC[["Package"]], ", version ", .DESC[["Version"]],
+	 	", ", .DESC[["Date"]], "\n", sep="")
+	.CH <- NULL
+	if (changes) {
+		cat("\n")
+		file <- system.file("changes", package = "maptools")
+		.CH <- scan(file, list(version="character", 
+			changes="character"), sep="\t", quiet=TRUE)
+		for (i in length(.CH$changes):1) {
+			cat(unlist(strsplit(.CH$changes[i], " ")), fill=TRUE, 
+				labels=.CH$version[i])
+			cat("\n")
+		}
+	}
+	invisible(.CH)
+}
+
diff --git a/R/midpoint.R b/R/midpoint.R
new file mode 100644
index 0000000..9d7efb7
--- /dev/null
+++ b/R/midpoint.R
@@ -0,0 +1,49 @@
+################################################################################
+# Converts SpatialLinesDataFrame to SpatialPointsDataFrame with points at
+# the midpoints of the line segments (Jonathan Callahan).
+SpatialLinesMidPoints <- function(sldf) {
+  stopifnot(is.projected(sldf))
+# define a function to get the midpoint of each Line object in each Lines
+# object in slot(sldf, "lines"), copying out repeated roed of the data slot
+  Lns <- slot(sldf, "lines")
+  hash_lns <- sapply(Lns, function(x) length(slot(x, "Lines")))
+  N <- sum(hash_lns)
+  midpoints <- matrix(NA, ncol=2, nrow=N)
+  Ind <- integer(length=N)
+  ii <- 1
+  for (i in 1:length(Lns)) {
+    Lnsi <- slot(Lns[[i]], "Lines")
+    for(j in 1:hash_lns[i]) {
+      Ind[ii] <- i
+      midpoints[ii,] <- getMidpoint(slot(Lnsi[[j]], "coords"))
+      ii <- ii+1
+    }
+  }
+  if (is(sldf, "SpatialLinesDataFrame")) {
+    df0 <- slot(sldf, "data")[Ind,]
+    df <- as.data.frame(cbind(df0, Ind))
+  } else df <- data.frame(Ind=Ind)
+# create a SpatialPointsDataFrame
+  spdf <- SpatialPointsDataFrame(midpoints, data=df,
+    proj4string=CRS(proj4string(sldf)))
+  return(spdf)
+}
+
+getMidpoint <- function(coords) {
+# calculate distances between points
+  dist <- sqrt( (diff(coords[,1])^2 + (diff(coords[,2]))^2 ) )
+# midpoint distance
+  dist_mid <- sum(dist) / 2.0
+# cumulative distances, starting with the first point
+  dist_cum <- c(0,cumsum(dist))
+# index of coordinates on either side of dist_mid
+  end_index <- which(dist_cum > dist_mid)[1]
+  start_index <- end_index-1
+# calculate exact midpoint
+  start <- coords[start_index,]
+  end <- coords[end_index,]
+  dist_remaining <- dist_mid - dist_cum[start_index]
+  mid <- start + (end - start) * (dist_remaining / dist[start_index])
+  return(mid)
+}
+
diff --git a/R/nowrapRecenter.R b/R/nowrapRecenter.R
index d70b1f7..d1065a8 100644
--- a/R/nowrapRecenter.R
+++ b/R/nowrapRecenter.R
@@ -1,7 +1,7 @@
-nowrapSpatialPolygons <- function(obj, offset=0, eps=rep(.Machine$double.eps, 2)) {
+nowrapSpatialPolygons <- function(obj, offset=0, eps=rep(.Machine$double.eps^(1/2), 2), avoidGEOS=FALSE) {
     rgeosI <- rgeosStatus()
     if (rgeosI) {
-#        require(rgeos)
+        require(rgeos)
     } else {
         stopifnot(isTRUE(gpclibPermitStatus()))
 	require(gpclib)
@@ -15,7 +15,7 @@ nowrapSpatialPolygons <- function(obj, offset=0, eps=rep(.Machine$double.eps, 2)
 	if (inout) {
 		pls <- slot(obj, "polygons")
 		Srl <- lapply(pls, .nowrapPolygons, offset=offset, eps=eps,
-                    rgeosI=rgeosI)
+                    rgeosI=rgeosI, avoidGEOS=avoidGEOS)
 		res <- as.SpatialPolygons.PolygonsList(Srl,
 			proj4string=CRS(proj4string(obj)))
 	} else res <- obj
@@ -23,12 +23,20 @@ nowrapSpatialPolygons <- function(obj, offset=0, eps=rep(.Machine$double.eps, 2)
 }
 
 .nowrapPolygons <- function(obj, offset=0, eps=rep(.Machine$double.eps, 2),
-     rgeosI) {
+     rgeosI, avoidGEOS=FALSE) {
 	if (!is(obj, "Polygons")) stop("not an Polygons object")
 	bbo <- bbox(obj)
 	inout <- bbo[1,1] < offset && bbo[1,2] >= offset
 	if (inout) {
-            if (rgeosI) {
+            if (rgeosI && !avoidGEOS) {
+                 comm <- try(createPolygonsComment(obj), silent=TRUE)
+                 isV <- try(gIsValid(SpatialPolygons(list(obj))), silent=TRUE)
+                 if (class(comm) != "try-error" && class(isV) != "try-error" 
+                     && isV) {
+                     comment(obj) <- comm
+                 } else {
+                     stop(paste("invalid Polygons object:", slot(obj, "ID")))
+                 }
                  bb <- bbox(obj)
                  bb <- list(x=bb[1,], y=bb[2,])
                  bbmatW <- matrix(c(rep(bb$x[1], 2), rep(offset-eps[1], 2), 
@@ -37,12 +45,14 @@ nowrapSpatialPolygons <- function(obj, offset=0, eps=rep(.Machine$double.eps, 2)
                  bbmatE <- matrix(c(rep(offset+eps[2], 2), rep(bb$x[2], 2), 
                      offset+eps[2], bb$y[1], rep(bb$y[2], 2), 
                      rep(bb$y[1], 2)), ncol=2)
-#                 resW <- PolygonsIntersections(obj,
-#                     Polygons(list(Polygon(bbmatW)), ID="W"))
-#                 resE <- PolygonsIntersections(obj,
-#                     Polygons(list(Polygon(bbmatE)), ID="E"))
-#                 res <- Polygons(c(slot(resW, "Polygons"),
-#                     slot(resE, "Polygons")), ID=slot(obj, "ID"))
+                 SPobj <- SpatialPolygons(list(obj))
+                 resW <- gIntersection(SPobj, SpatialPolygons(list(Polygons(
+                     list(Polygon(bbmatW)), ID="W"))))
+                 resE <- gIntersection(SPobj, SpatialPolygons(list(Polygons(
+                     list(Polygon(bbmatE)), ID="E"))))
+                 cparts <- c(slot(slot(resW, "polygons")[[1]], "Polygons"),
+                     slot(slot(resE, "polygons")[[1]], "Polygons"))
+                 res <- Polygons(cparts, ID=slot(obj, "ID"))
             } else {
 		pls <- slot(obj, "Polygons")
 		nParts <- length(pls)
@@ -79,7 +89,7 @@ nowrapSpatialPolygons <- function(obj, offset=0, eps=rep(.Machine$double.eps, 2)
 	res
 }
 
-nowrapRecenter <- function(obj, offset=0, eps=rep(.Machine$double.eps, 2)) {
-	res <- recenter(nowrapSpatialPolygons(obj, offset=offset, eps=eps))
+nowrapRecenter <- function(obj, offset=0, eps=rep(.Machine$double.eps^(1/2), 2), avoidGEOS=FALSE) {
+	res <- recenter(nowrapSpatialPolygons(obj, offset=offset, eps=eps, avoidGEOS=avoidGEOS))
 	res
 }
diff --git a/R/pointLabel.R b/R/pointLabelBase.R
similarity index 95%
rename from R/pointLabel.R
rename to R/pointLabelBase.R
index c7602c2..4a504d4 100644
--- a/R/pointLabel.R
+++ b/R/pointLabelBase.R
@@ -1,218 +1,218 @@
-pointLabel <- function(x, y = NULL, labels = seq(along = x), cex = 1,
-                       method = c("SANN", "GA"),
-                       allowSmallOverlap = FALSE,
-                       trace = FALSE,
-                       doPlot = TRUE,
-                       ...)
-{
-  if (!missing(y) && (is.character(y) || is.expression(y))) {
-    labels <- y
-    y <- NULL
-  }
-  labels <- as.graphicsAnnot(labels)
-  boundary <- par()$usr
-  xyAspect <- par()$pin[1] / par()$pin[2] # width / height
-  # scale to a unit area from 0 to 1
-  toUnityCoords <- function(xy) {
-    list(x = (xy$x - boundary[1]) / (boundary[2] - boundary[1]) * xyAspect,
-         y = (xy$y - boundary[3]) / (boundary[4] - boundary[3]) / xyAspect)
-  }
-  toUserCoords <- function(xy) {
-    list(x = boundary[1] + xy$x / xyAspect * (boundary[2] - boundary[1]), 
-         y = boundary[3] + xy$y * xyAspect * (boundary[4] - boundary[3])) 
-  }
-  z <- xy.coords(x, y, recycle = TRUE)
-  z <- toUnityCoords(z)
-  x <- z$x
-  y <- z$y
-  if (length(labels) < length(x)) 
-    labels <- rep(labels, length(x))
-  method <- match.arg(method)
-    
-  if (allowSmallOverlap) 
-      nudgeFactor <- 0.02 
-  n_labels <- length(x)
-  # There are eight possible alignment codes, corresponding to the 
-  # corners and side mid-points of the rectangle
-  # Codes are 1:8
-  # Code 7 (top right) is the most preferred
-  width <- (strwidth(labels, units = "figure", cex = cex) + 0.015) * xyAspect
-  height <- (strheight(labels, units = "figure", cex = cex) + 0.015) / xyAspect 
-
-  gen_offset <- function(code)
-         c(-1,  -1,  -1,  0,  0,   1,  1,   1)[code] * (width/2) +
-    1i * c(-1,   0,   1, -1,  1,  -1,  0,   1)[code] * (height/2)
-  
-  
-  # Finds intersection area of two rectangles
-  rect_intersect <- function(xy1, offset1, xy2, offset2) {
-    w <- pmin(Re(xy1+offset1/2), Re(xy2+offset2/2)) - pmax(Re(xy1-offset1/2), Re(xy2-offset2/2))   
-    h <- pmin(Im(xy1+offset1/2), Im(xy2+offset2/2)) - pmax(Im(xy1-offset1/2), Im(xy2-offset2/2))   
-    w[w <= 0] <- 0
-    h[h <= 0] <- 0
-    w*h
-  }
-  
-  nudge <- function(offset) {
-    # Nudge the labels slightly if they overlap:
-    doesIntersect <- rect_intersect(xy[rectidx1] + offset[rectidx1], rectv[rectidx1],
-                                    xy[rectidx2] + offset[rectidx2], rectv[rectidx2]) > 0
-  
-    pyth <- abs(xy[rectidx1] + offset[rectidx1] - xy[rectidx2] - offset[rectidx2]) / nudgeFactor
-    eps <- 1.0e-10
-
-    for (i in which(doesIntersect & pyth > eps)) {
-      idx1 <- rectidx1[i]
-      idx2 <- rectidx2[i]
-      vect <- (xy[idx1] + offset[idx1] - xy[idx2] - offset[idx2]) / pyth[idx1]
-      offset[idx1] <- offset[idx1] + vect
-      offset[idx2] <- offset[idx2] - vect
-    }
-    offset
-  }
-  
-  objective <- function(gene) {
-    offset <- gen_offset(gene)
-
-    # Allow for "bending" the labels a bit
-    if (allowSmallOverlap) offset <- nudge(offset)
-
-    if (!is.null(rectidx1))
-      area <- sum(rect_intersect(xy[rectidx1] + offset[rectidx1], rectv[rectidx1],
-                                 xy[rectidx2] + offset[rectidx2], rectv[rectidx2]))
-    else
-      area <- 0
-      
-    # Penalize labels which go outside the image area
-    # Count points outside of the image
-    n_outside <- sum(Re(xy + offset - rectv/2) < 0 | Re(xy + offset + rectv/2) > xyAspect |
-                     Im(xy + offset - rectv/2) < 0 | Im(xy + offset + rectv/2) > 1/xyAspect)
-    res <- 1000 * area + n_outside
-    #cat(n_outside,"\n")
-    res
-  }
-   
-  # Make a list of label rectangles in their reference positions,
-  # centered over the map feature; the real labels are displaced
-  # from these positions so as not to overlap
-  # Note that some labels can be bigger than others
-  xy <- x + 1i * y
-  rectv <- width + 1i * height
-
-  rectidx1 <- rectidx2 <- array(0, (length(x)^2 - length(x)) / 2)
-  k <- 0
-  for (i in 1:length(x))
-    for (j in seq(len=(i-1))) {
-      k <- k + 1
-      rectidx1[k] <- i
-      rectidx2[k] <- j
-    }
-  canIntersect <- rect_intersect(xy[rectidx1], 2 * rectv[rectidx1],
-                                 xy[rectidx2], 2 * rectv[rectidx2]) > 0
-  rectidx1 <- rectidx1[canIntersect]
-  rectidx2 <- rectidx2[canIntersect]
-  if (trace) cat("possible intersects =", length(rectidx1), "\n")
-
-  if (trace) cat("portion covered =", sum(rect_intersect(xy, rectv,xy,rectv)),"\n")
-
-  GA <- function() {
-    # Make some starting genes
-    n_startgenes <- 1000     # size of starting gene pool 
-    n_bestgenes <- 30       # genes selected for cross-breeding
-    prob <- 0.2
-
-    # Mutation function: O(n^2) time
-    mutate <- function(gene) {
-      offset <- gen_offset(gene)
-      # Directed mutation where two rectangles intersect
-      doesIntersect <- rect_intersect(xy[rectidx1] + offset[rectidx1], rectv[rectidx1],
-                                      xy[rectidx2] + offset[rectidx2], rectv[rectidx2]) > 0
-    
-      for (i in which(doesIntersect)) {
-        gene[rectidx1[i]] <- sample(1:8, 1)
-      }
-      # And a bit of random mutation, too
-      for (i in seq(along=gene))
-        if (runif(1) <= prob)
-          gene[i] <- sample(1:8, 1)
-      gene
-    }
-    
-    # Crossbreed two genes, then mutate at "hot spots" where intersections remain
-    crossbreed <- function(g1, g2)
-      ifelse(sample(c(0,1), length(g1), repl = TRUE) > .5, g1, g2)
-
-
-    genes <- matrix(sample(1:8, n_labels * n_startgenes, repl = TRUE), n_startgenes, n_labels)
-    
-    for (i in 1:10) {
-      scores <- array(0., NROW(genes))
-      for (j in 1:NROW(genes))
-        scores[j] <- objective(genes[j,])
-      rankings <- order(scores)
-      genes <- genes[rankings,]
-      bestgenes <- genes[1:n_bestgenes,]
-      bestscore <- scores[rankings][1]
-      if (bestscore == 0) {
-        if (trace) cat("overlap area =", bestscore, "\n")
-        break
-      }
-      # At each stage, we breed the best genes with one another
-      genes <- matrix(0, n_bestgenes^2, n_labels)
-      for (j in 1:n_bestgenes)
-        for (k in 1:n_bestgenes)
-          genes[n_bestgenes*(j-1) + k,] <- mutate(crossbreed(bestgenes[j,], bestgenes[k,]))
-      
-      genes <- rbind(bestgenes, genes)
-      if (trace) cat("overlap area =", bestscore, "\n")
-    }
-    nx <- Re(xy + gen_offset(bestgenes[1,]))
-    ny <- Im(xy + gen_offset(bestgenes[1,]))
-    list(x = nx, y = ny)
-  }
-  SANN <- function() {
-    # Make some starting "genes"
-    #gene <- sample(1:8, n_labels, repl = TRUE)
-    gene <- rep(8, n_labels)
-    score <- objective(gene)
-    bestgene <- gene
-    bestscore <- score
-    T <- 2.5
-    for (i in 1:50) {
-      k <- 1
-      for (j in 1:50) {
-        newgene <- gene
-        newgene[sample(1:n_labels, 1)] <- sample(1:8,1)
-        newscore <- objective(newgene)
-        if (newscore <= score || runif(1) < exp((score - newscore) / T)) {
-          # keep the new set if it has the same or better score or
-          # if it's worse randomly based on the annealing criteria
-          k <- k + 1
-          score <- newscore
-          gene <- newgene
-        }
-        if (score <= bestscore) {
-          bestscore <- score
-          bestgene <- gene
-        }
-        if (bestscore == 0 || k == 10) break
-      }
-      if (bestscore == 0) break
-      if (trace) cat("overlap area =", bestscore, "\n")
-      T <- 0.9 * T
-    }
-    
-    if (trace) cat("overlap area =", bestscore, "\n")
-    nx <- Re(xy + gen_offset(bestgene))
-    ny <- Im(xy + gen_offset(bestgene))
-    list(x = nx, y = ny)
-  }
-  if (method == "SANN")
-    xy <- SANN()
-  else
-    xy <- GA()
-  xy <- toUserCoords(xy)
-  if (doPlot)
-    text(xy, labels, cex = cex, ...)
-  invisible(xy)
-}
+pointLabel <- function(x, y = NULL, labels = seq(along = x), cex = 1,
+                       method = c("SANN", "GA"),
+                       allowSmallOverlap = FALSE,
+                       trace = FALSE,
+                       doPlot = TRUE,
+                       ...)
+{
+  if (!missing(y) && (is.character(y) || is.expression(y))) {
+    labels <- y
+    y <- NULL
+  }
+  labels <- as.graphicsAnnot(labels)
+  boundary <- par()$usr
+  xyAspect <- par()$pin[1] / par()$pin[2] # width / height
+  # scale to a unit area from 0 to 1
+  toUnityCoords <- function(xy) {
+    list(x = (xy$x - boundary[1]) / (boundary[2] - boundary[1]) * xyAspect,
+         y = (xy$y - boundary[3]) / (boundary[4] - boundary[3]) / xyAspect)
+  }
+  toUserCoords <- function(xy) {
+    list(x = boundary[1] + xy$x / xyAspect * (boundary[2] - boundary[1]), 
+         y = boundary[3] + xy$y * xyAspect * (boundary[4] - boundary[3])) 
+  }
+  z <- xy.coords(x, y, recycle = TRUE)
+  z <- toUnityCoords(z)
+  x <- z$x
+  y <- z$y
+  if (length(labels) < length(x)) 
+    labels <- rep(labels, length(x))
+  method <- match.arg(method)
+    
+  if (allowSmallOverlap) 
+      nudgeFactor <- 0.02 
+  n_labels <- length(x)
+  # There are eight possible alignment codes, corresponding to the 
+  # corners and side mid-points of the rectangle
+  # Codes are 1:8
+  # Code 7 (top right) is the most preferred
+  width <- (strwidth(labels, units = "figure", cex = cex) + 0.015) * xyAspect
+  height <- (strheight(labels, units = "figure", cex = cex) + 0.015) / xyAspect 
+
+  gen_offset <- function(code)
+         c(-1,  -1,  -1,  0,  0,   1,  1,   1)[code] * (width/2) +
+    1i * c(-1,   0,   1, -1,  1,  -1,  0,   1)[code] * (height/2)
+  
+  
+  # Finds intersection area of two rectangles
+  rect_intersect <- function(xy1, offset1, xy2, offset2) {
+    w <- pmin(Re(xy1+offset1/2), Re(xy2+offset2/2)) - pmax(Re(xy1-offset1/2), Re(xy2-offset2/2))   
+    h <- pmin(Im(xy1+offset1/2), Im(xy2+offset2/2)) - pmax(Im(xy1-offset1/2), Im(xy2-offset2/2))   
+    w[w <= 0] <- 0
+    h[h <= 0] <- 0
+    w*h
+  }
+  
+  nudge <- function(offset) {
+    # Nudge the labels slightly if they overlap:
+    doesIntersect <- rect_intersect(xy[rectidx1] + offset[rectidx1], rectv[rectidx1],
+                                    xy[rectidx2] + offset[rectidx2], rectv[rectidx2]) > 0
+  
+    pyth <- abs(xy[rectidx1] + offset[rectidx1] - xy[rectidx2] - offset[rectidx2]) / nudgeFactor
+    eps <- 1.0e-10
+
+    for (i in which(doesIntersect & pyth > eps)) {
+      idx1 <- rectidx1[i]
+      idx2 <- rectidx2[i]
+      vect <- (xy[idx1] + offset[idx1] - xy[idx2] - offset[idx2]) / pyth[idx1]
+      offset[idx1] <- offset[idx1] + vect
+      offset[idx2] <- offset[idx2] - vect
+    }
+    offset
+  }
+  
+  objective <- function(gene) {
+    offset <- gen_offset(gene)
+
+    # Allow for "bending" the labels a bit
+    if (allowSmallOverlap) offset <- nudge(offset)
+
+    if (!is.null(rectidx1))
+      area <- sum(rect_intersect(xy[rectidx1] + offset[rectidx1], rectv[rectidx1],
+                                 xy[rectidx2] + offset[rectidx2], rectv[rectidx2]))
+    else
+      area <- 0
+      
+    # Penalize labels which go outside the image area
+    # Count points outside of the image
+    n_outside <- sum(Re(xy + offset - rectv/2) < 0 | Re(xy + offset + rectv/2) > xyAspect |
+                     Im(xy + offset - rectv/2) < 0 | Im(xy + offset + rectv/2) > 1/xyAspect)
+    res <- 1000 * area + n_outside
+    #cat(n_outside,"\n")
+    res
+  }
+   
+  # Make a list of label rectangles in their reference positions,
+  # centered over the map feature; the real labels are displaced
+  # from these positions so as not to overlap
+  # Note that some labels can be bigger than others
+  xy <- x + 1i * y
+  rectv <- width + 1i * height
+
+  rectidx1 <- rectidx2 <- array(0, (length(x)^2 - length(x)) / 2)
+  k <- 0
+  for (i in 1:length(x))
+    for (j in seq(len=(i-1))) {
+      k <- k + 1
+      rectidx1[k] <- i
+      rectidx2[k] <- j
+    }
+  canIntersect <- rect_intersect(xy[rectidx1], 2 * rectv[rectidx1],
+                                 xy[rectidx2], 2 * rectv[rectidx2]) > 0
+  rectidx1 <- rectidx1[canIntersect]
+  rectidx2 <- rectidx2[canIntersect]
+  if (trace) cat("possible intersects =", length(rectidx1), "\n")
+
+  if (trace) cat("portion covered =", sum(rect_intersect(xy, rectv,xy,rectv)),"\n")
+
+  GA <- function() {
+    # Make some starting genes
+    n_startgenes <- 1000     # size of starting gene pool 
+    n_bestgenes <- 30       # genes selected for cross-breeding
+    prob <- 0.2
+
+    # Mutation function: O(n^2) time
+    mutate <- function(gene) {
+      offset <- gen_offset(gene)
+      # Directed mutation where two rectangles intersect
+      doesIntersect <- rect_intersect(xy[rectidx1] + offset[rectidx1], rectv[rectidx1],
+                                      xy[rectidx2] + offset[rectidx2], rectv[rectidx2]) > 0
+    
+      for (i in which(doesIntersect)) {
+        gene[rectidx1[i]] <- sample(1:8, 1)
+      }
+      # And a bit of random mutation, too
+      for (i in seq(along=gene))
+        if (runif(1) <= prob)
+          gene[i] <- sample(1:8, 1)
+      gene
+    }
+    
+    # Crossbreed two genes, then mutate at "hot spots" where intersections remain
+    crossbreed <- function(g1, g2)
+      ifelse(sample(c(0,1), length(g1), replace = TRUE) > .5, g1, g2)
+
+
+    genes <- matrix(sample(1:8, n_labels * n_startgenes, replace = TRUE), n_startgenes, n_labels)
+    
+    for (i in 1:10) {
+      scores <- array(0., NROW(genes))
+      for (j in 1:NROW(genes))
+        scores[j] <- objective(genes[j,])
+      rankings <- order(scores)
+      genes <- genes[rankings,]
+      bestgenes <- genes[1:n_bestgenes,]
+      bestscore <- scores[rankings][1]
+      if (bestscore == 0) {
+        if (trace) cat("overlap area =", bestscore, "\n")
+        break
+      }
+      # At each stage, we breed the best genes with one another
+      genes <- matrix(0, n_bestgenes^2, n_labels)
+      for (j in 1:n_bestgenes)
+        for (k in 1:n_bestgenes)
+          genes[n_bestgenes*(j-1) + k,] <- mutate(crossbreed(bestgenes[j,], bestgenes[k,]))
+      
+      genes <- rbind(bestgenes, genes)
+      if (trace) cat("overlap area =", bestscore, "\n")
+    }
+    nx <- Re(xy + gen_offset(bestgenes[1,]))
+    ny <- Im(xy + gen_offset(bestgenes[1,]))
+    list(x = nx, y = ny)
+  }
+  SANN <- function() {
+    # Make some starting "genes"
+    #gene <- sample(1:8, n_labels, repl = TRUE)
+    gene <- rep(8, n_labels)
+    score <- objective(gene)
+    bestgene <- gene
+    bestscore <- score
+    T <- 2.5
+    for (i in 1:50) {
+      k <- 1
+      for (j in 1:50) {
+        newgene <- gene
+        newgene[sample(1:n_labels, 1)] <- sample(1:8,1)
+        newscore <- objective(newgene)
+        if (newscore <= score || runif(1) < exp((score - newscore) / T)) {
+          # keep the new set if it has the same or better score or
+          # if it's worse randomly based on the annealing criteria
+          k <- k + 1
+          score <- newscore
+          gene <- newgene
+        }
+        if (score <= bestscore) {
+          bestscore <- score
+          bestgene <- gene
+        }
+        if (bestscore == 0 || k == 10) break
+      }
+      if (bestscore == 0) break
+      if (trace) cat("overlap area =", bestscore, "\n")
+      T <- 0.9 * T
+    }
+    
+    if (trace) cat("overlap area =", bestscore, "\n")
+    nx <- Re(xy + gen_offset(bestgene))
+    ny <- Im(xy + gen_offset(bestgene))
+    list(x = nx, y = ny)
+  }
+  if (method == "SANN")
+    xy <- SANN()
+  else
+    xy <- GA()
+  xy <- toUserCoords(xy)
+  if (doPlot)
+    text(xy, labels, cex = cex, ...)
+  invisible(xy)
+}
diff --git a/R/pointLabelLattice.R b/R/pointLabelLattice.R
new file mode 100644
index 0000000..2feeaa4
--- /dev/null
+++ b/R/pointLabelLattice.R
@@ -0,0 +1,302 @@
+# Author: Oscar Perpinan Lamigueiro (oscar.perpinan at gmail.com)
+# using original code from maptools::pointLabel
+# Date :  October 2012
+# Version 0.10
+# Licence GPL v3
+
+
+drawDetails.labels <- function(x, ..., recording) {
+
+  ##------------------------------------------------------------------##
+  ## Functions SANN, GA and auxiliars (extracted from maptools::pointLabel)
+  ##------------------------------------------------------------------##
+
+  gen_offset <- function(code) c(-1, -1, -1, 0, 0, 1, 1, 1)[code] *
+    (width/2) + (0+1i) * c(-1, 0, 1, -1, 1, -1, 0, 1)[code] *
+      (height/2)
+
+  rect_intersect <- function(xy1, offset1, xy2, offset2) {
+    w <- pmin(Re(xy1 + offset1/2), Re(xy2 + offset2/2)) - 
+      pmax(Re(xy1 - offset1/2), Re(xy2 - offset2/2))
+    h <- pmin(Im(xy1 + offset1/2), Im(xy2 + offset2/2)) - 
+      pmax(Im(xy1 - offset1/2), Im(xy2 - offset2/2))
+    w[w <= 0] <- 0
+    h[h <= 0] <- 0
+    w * h
+  }
+
+  nudge <- function(offset) {
+    doesIntersect <- rect_intersect(xy[rectidx1] + offset[rectidx1], 
+                                    rectv[rectidx1], xy[rectidx2] + offset[rectidx2], 
+                                    rectv[rectidx2]) > 0
+    pyth <- abs(xy[rectidx1] + offset[rectidx1] - xy[rectidx2] - 
+                offset[rectidx2])/nudgeFactor
+    eps <- 1e-10
+    for (i in which(doesIntersect & pyth > eps)) {
+      idx1 <- rectidx1[i]
+      idx2 <- rectidx2[i]
+      vect <- (xy[idx1] + offset[idx1] - xy[idx2] - offset[idx2])/pyth[idx1]
+      offset[idx1] <- offset[idx1] + vect
+      offset[idx2] <- offset[idx2] - vect
+    }
+    offset
+  }
+
+  objective <- function(gene) {
+    offset <- gen_offset(gene)
+    if (allowSmallOverlap) offset <- nudge(offset)
+    if (!is.null(rectidx1)) 
+      area <- sum(rect_intersect(xy[rectidx1] + offset[rectidx1], 
+                                 rectv[rectidx1], xy[rectidx2] + offset[rectidx2], 
+                                 rectv[rectidx2]))
+    else area <- 0
+    n_outside <- sum(Re(xy + offset - rectv/2) < 0 |
+                     Re(xy + offset + rectv/2) > xyAspect |
+                     Im(xy + offset - rectv/2) < 0 |
+                     Im(xy + offset + rectv/2) > 1/xyAspect)
+    res <- 1000 * area + n_outside
+    res
+  }
+
+  GA <- function() {
+    n_startgenes <- 1000
+    n_bestgenes <- 30
+    prob <- 0.2
+    mutate <- function(gene) {
+      offset <- gen_offset(gene)
+      doesIntersect <- rect_intersect(xy[rectidx1] + offset[rectidx1], 
+                                      rectv[rectidx1], xy[rectidx2] + offset[rectidx2], 
+                                      rectv[rectidx2]) > 0
+      for (i in which(doesIntersect)) {
+        gene[rectidx1[i]] <- sample(1:8, 1)
+      }
+      for (i in seq(along = gene)) if (runif(1) <= prob) 
+        gene[i] <- sample(1:8, 1)
+      gene
+    }
+    crossbreed <- function(g1, g2) ifelse(sample(c(0, 1), 
+                                                 length(g1), replace = TRUE) > 0.5, g1, g2)
+    genes <- matrix(sample(1:8, n_labels * n_startgenes, 
+                           replace = TRUE), n_startgenes, n_labels)
+    for (i in 1:10) {
+      scores <- array(0, NROW(genes))
+      for (j in 1:NROW(genes)) scores[j] <- objective(genes[j, 
+                                                            ])
+      rankings <- order(scores)
+      genes <- genes[rankings, ]
+      bestgenes <- genes[1:n_bestgenes, ]
+      bestscore <- scores[rankings][1]
+      if (bestscore == 0) {
+        ## if (trace) 
+        ##   cat("overlap area =", bestscore, "\n")
+        break
+      }
+      genes <- matrix(0, n_bestgenes^2, n_labels)
+      for (j in 1:n_bestgenes) {
+        for (k in 1:n_bestgenes) {
+          genes[n_bestgenes * (j - 1) + k, ] <-
+            mutate(crossbreed(bestgenes[j,], bestgenes[k, ]))
+        }}
+      genes <- rbind(bestgenes, genes)
+      ## if (trace) 
+      ##   cat("overlap area =", bestscore, "\n")
+    }
+    nx <- Re(xy + gen_offset(bestgenes[1, ]))
+    ny <- Im(xy + gen_offset(bestgenes[1, ]))
+    list(x = nx, y = ny)
+  }
+
+  SANN <- function() {
+    gene <- rep(8, n_labels)
+    score <- objective(gene)
+    bestgene <- gene
+    bestscore <- score
+    T <- 2.5
+    for (i in 1:50) {
+      k <- 1
+      for (j in 1:50) {
+        newgene <- gene
+        newgene[sample(1:n_labels, 1)] <- sample(1:8, 
+                                                 1)
+        newscore <- objective(newgene)
+        if (newscore <= score || runif(1) < exp((score - 
+              newscore)/T)) {
+          k <- k + 1
+          score <- newscore
+          gene <- newgene
+        }
+        if (score <= bestscore) {
+          bestscore <- score
+          bestgene <- gene
+        }
+        if (bestscore == 0 || k == 10) 
+          break
+      }
+      if (bestscore == 0) 
+        break
+      ## if (trace) 
+      ##   cat("overlap area =", bestscore, "\n")
+      T <- 0.9 * T
+    }
+    ## if (trace) 
+    ##   cat("overlap area =", bestscore, "\n")
+    nx <- Re(xy + gen_offset(bestgene))
+    ny <- Im(xy + gen_offset(bestgene))
+    list(x = nx, y = ny)
+  }
+
+  ## ------------------------------------------------------------------ ##
+  ## Extraction of information from the supplied grob (x)
+  gl <- x
+  x <- gl$x
+  y <- gl$y
+  labels <- gl$labels
+  
+  gp <- gl$gp
+
+  allowSmallOverlap <- gl$allowSmallOverlap
+  if (allowSmallOverlap) 
+    nudgeFactor <- 0.02
+
+  method <- gl$method
+
+  ## ------------------------------------------------------------------ ##
+  ## Coordinates, labels and graphical parameters
+  z <- xy.coords(x, y, recycle = TRUE)
+  x <- convertX(unit(z$x, 'native'), 'npc', valueOnly=TRUE)
+  y <- convertY(unit(z$y, 'native'), 'npc', valueOnly=TRUE)
+
+  if (length(labels) < length(x)) 
+    labels <- rep(labels, length(x))
+  n_labels <- length(x)
+
+  vp <- current.vpTree()$parent
+  windowWidth <- convertWidth(vp$width, 'cm', valueOnly=TRUE)
+  windowHeight <- convertHeight(vp$height, 'cm', valueOnly=TRUE)
+  xyAspect <- windowWidth/windowHeight ##windowHeight/windowWidth
+  
+  ## widthOriginal <- convertX(stringWidth(labels), 'npc',
+  ##                           valueOnly=TRUE)
+  ## heightOriginal <- convertX(stringHeight(labels), 'npc',
+  ##                            valueOnly=TRUE)
+
+  widthOriginal <-  sapply(labels, function(s){
+    tg <- textGrob(s, gp=gp)
+    gw <- grobWidth(tg);
+    convertX(gw, 'npc', valueOnly=TRUE)
+  })
+
+  heightOriginal <-  sapply(labels, function(s){
+    tg <- textGrob(s, gp=gp)
+    gh <- grobHeight(tg);
+    convertY(gh, 'npc', valueOnly=TRUE)
+  })
+  
+  width <- widthOriginal + 0.015 ##xyAspect * widthOriginal  ## en pointLabel agregan 0.015
+  height <- heightOriginal + 0.015 ##1/xyAspect * (heightOriginal + 1e-2)
+  
+  ## ------------------------------------------------------------------ ##
+
+  xy <- x + (0+1i) * y
+  rectv <- width + (0+1i) * height
+  rectidx1 <- rectidx2 <- array(0, (length(x)^2 - length(x))/2)
+  k <- 0
+  for (i in 1:length(x)) {
+    for (j in seq(len = (i - 1))) {
+      k <- k + 1
+      rectidx1[k] <- i
+      rectidx2[k] <- j
+    }}
+    
+  canIntersect <- rect_intersect(xy[rectidx1], 2 * rectv[rectidx1], 
+                                 xy[rectidx2], 2 * rectv[rectidx2]) > 0
+  rectidx1 <- rectidx1[canIntersect]
+  rectidx2 <- rectidx2[canIntersect]
+
+  ## if (trace) 
+  ##   cat("possible intersects =", length(rectidx1), "\n")
+  ## if (trace) 
+  ##   cat("portion covered =", sum(rect_intersect(xy, rectv, 
+  ##                                               xy, rectv)), "\n")
+  if (method == "SANN") 
+    xy <- SANN()
+  else xy <- GA()
+
+  ## ------------------------------------------------------------------ ##
+  dots = list(...)
+#  if (hasArg(group.number)) {
+  if (!is.null(dots$group.number)) {
+    group <- dots$group.number
+  } else group <- 0
+
+  idRect <- trellis.grobname('rect', type='panel', group=group)
+  
+  rg <- rectGrob(x=xy$x, y=xy$y,
+                 width=widthOriginal, height=heightOriginal,
+                 gp=gpar(fill=gp$fill, col='transparent', alpha=gp$alpha),
+                 name=idRect)
+  grid.draw(rg)
+  
+  idLabel <- trellis.grobname('label', type='panel', group=group)
+  tg <- textGrob(x=xy$x, y=xy$y, label=labels,
+                 gp=gp,
+                 name=idLabel)
+  grid.draw(tg)
+}
+
+panel.pointLabel <- function (x, y = NULL,
+                              labels = seq(along = x),
+                              method = c("SANN", "GA"),
+                              allowSmallOverlap = FALSE,
+                              col = add.text$col,
+                              alpha = add.text$alpha,
+                              cex = add.text$cex,
+                              lineheight = add.text$lineheight,
+                              font = add.text$font,
+                              fontfamily = add.text$fontfamily,
+                              fontface = add.text$fontface,
+                              fill='transparent',
+                              ...){
+
+  add.text <- trellis.par.get("add.text")
+  
+  if (!missing(y) && (is.character(y) || is.expression(y))) {
+    labels <- y
+    y <- NULL
+  }
+
+  labels <- as.graphicsAnnot(labels)
+  ## if (length(labels) < length(x)) 
+  ##   labels <- rep(labels, length(x))
+
+  method <- match.arg(method)
+   
+  labelGrob <- grob(x=x, y=y,
+                    labels=labels,
+                    gp=gpar(col = col,
+                      alpha = alpha,
+                      cex = cex,
+                      lineheight = lineheight,
+                      ##font = add.text$font,
+                      fontfamily = fontfamily,
+                      fontface = fontface,
+                      fill = fill), ##rectangle color
+                    method=method,
+                    allowSmallOverlap=allowSmallOverlap,
+                    cl='labels')
+  grid.draw(labelGrob)
+}
+
+setGeneric('sp.pointLabel', function(object, labels, ...){standardGeneric('sp.pointLabel')})
+
+setMethod('sp.pointLabel',
+          signature=(object='SpatialPoints'),
+          definition=function(object, labels, ...){
+            xy = coordinates(object)
+            if (missing(labels)) labels <- row.names(object)
+            panel.pointLabel(xy[,1], xy[,2], labels, ...)
+          })
+
+
+
+
diff --git a/R/point_line_distance.R b/R/point_line_distance.R
new file mode 100644
index 0000000..8f87daa
--- /dev/null
+++ b/R/point_line_distance.R
@@ -0,0 +1,64 @@
+nearestPointOnSegment = function(s, p){
+    # Adapted from http://pastebin.com/n9rUuGRh
+    ap = c(p[1] - s[1,1], p[2] - s[1,2])
+    ab = c(s[2,1] - s[1,1], s[2,2] - s[1,2])
+    t = sum(ap*ab) / sum(ab*ab)
+    t = ifelse(t<0,0,ifelse(t>1,1,t))
+    x = s[1,1] + ab[1] * t 
+    y = s[1,2] + ab[2] * t
+    result = c(x, y, sqrt((x-p[1])^2 + (y-p[2])^2))  # Return nearest point and distance
+    names(result) = c("X","Y","distance")    
+    result
+}
+
+nearestPointOnLine = function(coordsLine, coordsPoint){
+    nearest_points = vapply(2:nrow(coordsLine), 
+        function(x) 
+            nearestPointOnSegment(coordsLine[(x-1):x,], coordsPoint),
+                FUN.VALUE=c(0,0,0))
+
+    # Return coordinates of the nearest point on this line  
+    nearest_points[1:2, which.min(nearest_points[3,])]  
+}
+
+snapPointsToLines <- function( points, lines, maxDist=NA, withAttrs=TRUE) {
+
+    require("rgeos")
+
+    if (is(points, 'SpatialPoints') && missing(withAttrs))
+        withAttrs = FALSE
+
+    if (is(points, 'SpatialPoints') && withAttrs==TRUE)
+        stop("A SpatialPoints object has no attributes! Set withAttrs as FALSE.")
+
+    if (!is.na(maxDist)) {
+        w = gWithinDistance(points, lines, dist=maxDist, byid=TRUE)
+        validPoints = apply(w,2,any)
+        validLines = apply(w,1,any)
+        points = points[validPoints,]
+        lines =  lines[validLines,]
+    }
+
+    d = gDistance(points, lines, byid=TRUE) 
+    nearest_line_index = apply(d, 2, which.min) # Position of each nearest line in lines object 
+
+    coordsLines = coordinates(lines)  
+    coordsPoints = coordinates(points)  
+
+    # Get coordinates of nearest points lying on nearest lines
+    mNewCoords = vapply(1:length(points), 
+        function(x) 
+            nearestPointOnLine(coordsLines[[nearest_line_index[x]]][[1]], 
+                coordsPoints[x,]), FUN.VALUE=c(0,0))
+
+    # Recover lines' Ids (Ids and index differ if maxDist is given)
+    if (!is.na(maxDist)) nearest_line_id = as.numeric(rownames(d)[nearest_line_index])+1 
+    else nearest_line_id = nearest_line_index 
+
+    # Create data frame and sp points
+    if (withAttrs) df = cbind(points at data, nearest_line_id) 
+    else df = data.frame(nearest_line_id, row.names=names(nearest_line_index))
+
+    SpatialPointsDataFrame(coords=t(mNewCoords), data=df, 
+        proj4string=CRS(proj4string(points)))
+}
diff --git a/R/readSplus.R b/R/readSplus.R
index c6cd02a..3ca6450 100644
--- a/R/readSplus.R
+++ b/R/readSplus.R
@@ -14,8 +14,8 @@ readSplus<-function(file, proj4string=CRS(as.character(NA)) )
         xscale <- 1
         yscale <- 1
         scales <- grep("cale", lns[(offset+1):(offset+2)])
-	if (length(scales) > 0) {
-            if (length(scales) < 2) 
+	if (length(scales) > 0L) {
+            if (length(scales) < 2L) 
                 stop("Only one scale given")
             xsc <- grep("x|X", lns[(offset+1):(offset+2)])
             ysc <- grep("y|Y", lns[(offset+1):(offset+2)])
diff --git a/R/shapelib.R b/R/shapelib.R
index 9a16131..a809f91 100644
--- a/R/shapelib.R
+++ b/R/shapelib.R
@@ -7,7 +7,7 @@
 read.shape <- function(filen, dbf.data=TRUE, verbose=TRUE, repair=FALSE) {
   filen <- path.expand(filen)
   .Deprecated("", package="maptools", msg="use readShapeSpatial:\nobjects other than Spatial objects defined in the sp package are deprecated")
-  if (length(grep("\\.shp$", tolower(filen))) == 0)
+  if (length(grep("\\.shp$", tolower(filen))) == 0L)
     filen <- paste(filen, "shp", sep=".")
   shinfo <- getinfo.shape(filen)
   if (dbf.data) {
@@ -20,9 +20,9 @@ read.shape <- function(filen, dbf.data=TRUE, verbose=TRUE, repair=FALSE) {
     lsbn <- length(sbn)
     if (lsbn > 1 && tolower(sbn[lsbn]) == "shp") sbn[lsbn] <- "dbf"
     filen1 <- paste(sbn, collapse=".")
-    if (length(grep("\\.dbf$", filen1)) == 0)
+    if (length(grep("\\.dbf$", filen1)) == 0L)
         filen1 <- paste(filen1, "dbf", sep=".")
-    if (length(dn) > 0) {
+    if (length(dn) > 0L) {
         filen1 <- paste(dn, filen1, sep=.Platform$file.sep)
     }
     df <- read.dbf(filen1)
@@ -100,7 +100,7 @@ write.pointShape <- function(coordinates, df, file, factor2char=TRUE,
 .isValidPolylist <- function(polylist, verbose=FALSE) {
   if (!inherits(polylist, "polylist")) stop("not a polylist object")
   res <- TRUE
-  if (length(polylist) < 1) {
+  if (length(polylist) < 1L) {
     if (verbose) cat("zero length polylist\n")
     res <- FALSE
   }
@@ -164,13 +164,13 @@ write.pointShape <- function(coordinates, df, file, factor2char=TRUE,
 
 .makePolylistValid <- function(polylist) {
   if (!inherits(polylist, "polylist")) stop("not a polylist object")
-  if (length(polylist) < 1) stop("zero length polylist")
+  if (length(polylist) < 1L) stop("zero length polylist")
   n <- length(polylist)
   if (is.null(attr(polylist, "nDims")) || 
     !is.integer(attr(polylist, "nDims")) || 
     (attr(polylist, "nDims") < 2 || attr(polylist, "nDims") > 3)) {
     nD <- unique(sapply(polylist, function(x) dim(x)[2]))
-    if (length(nD) > 1) stop("multiple dimension polylist components")
+    if (length(nD) > 1L) stop("multiple dimension polylist components")
     nD <- as.integer(nD)
     attr(polylist, "nDims") <- nD
   }
@@ -187,7 +187,7 @@ write.pointShape <- function(coordinates, df, file, factor2char=TRUE,
       if (any(is.na(c(polylist[[i]])))) {
 	xy <- polylist[[i]]
         NAs <- unclass(attr(na.omit(xy), "na.action"))
-	nParts <- length(NAs) + 1
+	nParts <- length(NAs) + 1L
 	from <- integer(nParts)
 	to <- integer(nParts)
 	from[1] <- 1
@@ -229,7 +229,7 @@ write.pointShape <- function(coordinates, df, file, factor2char=TRUE,
       if (any(is.na(c(polylist[[i]])))) {
 	xy <- polylist[[i]]
         NAs <- unclass(attr(na.omit(xy), "na.action"))
-	nParts <- length(NAs) + 1
+	nParts <- length(NAs) + 1L
 	from <- integer(nParts)
 	to <- integer(nParts)
 	from[1] <- 1
@@ -286,7 +286,7 @@ write.polylistShape <- function(polylist, df, file, factor2char=TRUE,
   if (strictFilename && nchar(basename(file)) > 8) 
     stop("shapefile names must conform to the 8.3 format")
   if (!inherits(polylist, "polylist")) stop("not a polylist object")
-  if (length(polylist) < 1) stop("zero length polylist")
+  if (length(polylist) < 1L) stop("zero length polylist")
   if (nrow(df) != length(polylist))
     stop("different number of rows in polylist and data frame")
   if (!.isValidPolylist(polylist)) {
@@ -314,7 +314,7 @@ write.linelistShape <- function(linelist, df, file, factor2char=TRUE,
   file <- paste(dirnm, bnm, sep=.Platform$file.sep)
   if (strictFilename && nchar(basename(file)) > 8) 
     stop("shapefile names must conform to the 8.3 format")
-  if (length(linelist) < 1) stop("zero length linelist")
+  if (length(linelist) < 1L) stop("zero length linelist")
   if (nrow(df) != length(linelist))
     stop("different number of rows in linelist and data frame")
   if (!any(sapply(linelist, function(x) is.integer(attr(x, "nParts"))))) {
diff --git a/R/sp2pbs.R b/R/sp2pbs.R
index 6208f79..69e3435 100644
--- a/R/sp2pbs.R
+++ b/R/sp2pbs.R
@@ -1,183 +1,191 @@
-# PBSmapping utilities
-
-SpatialPolygons2PolySet <- function(SpP) {
-	require(PBSmapping)
-	pls <- slot(SpP, "polygons")
-	n <- length(pls)
-	PID <- NULL
-	SID <- NULL
-	POS <- NULL
-	X <- NULL
-	Y <- NULL
-	for (i in 1:n) {
-		srs <- slot(pls[[i]], "Polygons")
-		m <- length(srs)
-		for (j in 1:m) {
-			crds <- slot(srs[[j]], "coords")
-			k <- nrow(crds)
-			PID <- c(PID, rep(i, k))
-			SID <- c(SID, rep(j, k))
-			POS <- c(POS, 1:k)
-			X <- c(X, crds[,1])
-			Y <- c(Y, crds[,2])
-		}
-	}
-	PID <- as.integer(PID)
-	SID <- as.integer(SID)
-	POS <- as.integer(POS)
-        storage.mode(X) <- "double"
-        storage.mode(Y) <- "double"
-	require(PBSmapping)
-	pj <- .pbsproj(SpP)
-	zn <- NULL
-	if (pj == "UTM") {
-		zn <- attr(pj, "zone")
-		attr(pj, "zone") <- NULL
-	}
-	res <- as.PolySet(data.frame(PID=PID, SID=SID, POS=POS, X=X, Y=Y),
-		projection=pj, zone=zn)
-	res
-}
-
-SpatialLines2PolySet <- function(SL) {
-#	require(maps)
-	pls <- slot(SL, "lines")
-	n <- length(pls)
-	PID <- NULL
-	SID <- NULL
-	POS <- NULL
-	X <- NULL
-	Y <- NULL
-	for (i in 1:n) {
-		srs <- slot(pls[[i]], "Lines")
-		m <- length(srs)
-		for (j in 1:m) {
-			crds <- coordinates(srs[[j]])
-			k <- nrow(crds)
-			PID <- c(PID, rep(i, k))
-			SID <- c(SID, rep(j, k))
-			POS <- c(POS, 1:k)
-			X <- c(X, crds[,1])
-			Y <- c(Y, crds[,2])
-		}
-	}
-	PID <- as.integer(PID)
-	SID <- as.integer(SID)
-	POS <- as.integer(POS)
-        storage.mode(X) <- "double"
-        storage.mode(Y) <- "double"
-	require(PBSmapping)
-	pj <- .pbsproj(SL)
-	zn <- NULL
-	if (pj == "UTM") {
-		zn <- attr(pj, "zone")
-		attr(pj, "zone") <- NULL
-	}
-	res <- as.PolySet(data.frame(PID=PID, SID=SID, POS=POS, X=X, Y=Y),
-		projection=pj, zone=zn)
-	res
-}
-
-.pbsproj <- function(Sobj) {
-	p4str <- proj4string(Sobj)
-	if (is.na(p4str)) return("1")
-	res <- grep("longlat", p4str, fixed=TRUE)
-	if (length(res) > 0) return("LL")
-	res <- regexpr("utm", p4str, fixed=TRUE)
-	if (res > 0) {
-		val <- "UTM"
-		res <- regexpr("+zone=", p4str, fixed=TRUE)
-		sres <- substring(p4str, res+attr(res, "match.length"))
-		zn0 <- regexpr("[[:digit:]]+", sres)
-		attr(val, "zone") <- as.integer(substring(sres, zn0, 
-			zn0+attr(zn0, "match.length")))
-	} else val <- "1"
-	val
-}
-
-PolySet2SpatialPolygons <- function(PS, close_polys=TRUE) {
-    if (!inherits(PS, "PolySet")) stop("not a PolySet object")
-    prj <- attr(PS, "projection")
-    if (is.null(prj)) stop("unknown coordinate reference system")
-    if (prj == "LL") p4s <- "+proj=longlat"
-    else if (prj == "UTM") {
-# apparent change in PBS object attributes
-        zn <- attr(prj, "zone")
-        if (is.null(zn)) zn <- attr(PS, "zone")
-        if (is.null(zn)) stop("no valid zone attribute")
-	p4s <- paste("+proj=utm +zone=", zn, sep="")
-    } else stop("unknown coordinate reference system")
-    hasPID <- "PID" %in% names(PS)
-    if (!hasPID) stop("object does not have PID column")
-    res0 <- split(PS, PS$PID)
-    hasSID <- "SID" %in% names(PS)
-    outPolygons <- vector(mode="list", length=length(res0)) 
-    if (hasSID) {
-        res1 <- lapply(res0, function(x) split(x, x$SID))
-        if (close_polys) res1 <- lapply(res1, 
-            function(i) lapply(i, function(x) {
-                n <- nrow(x)
-                if (!isTRUE(identical(x$X[1], x$X[n])) ||
-                    !isTRUE(identical(x$Y[1], x$Y[n]))) rbind(x, x[1,])
-                else x
-            })
-        )
-# extra level added to fix bug found by A Lobos 080413
-        for (i in seq(along=outPolygons)) {
-            outPolygons[[i]] <- Polygons(lapply(res1[[i]], function(x) 
-                Polygon(cbind(x$X, x$Y))), ID=names(res1)[i])
-        }
-# PIDs added as IDs 080413
-    } else {
-        if (close_polys) res0 <- lapply(res0, function(x) {
-            n <- nrow(x)
-            if (!isTRUE(identical(x$X[1], x$X[n])) ||
-                !isTRUE(identical(x$Y[1], x$Y[n]))) rbind(x, x[1,])
-            else x
-        })
-        for (i in seq(along=outPolygons)) {
-            outPolygons[[i]] <- Polygons(list(Polygon(cbind(res0[[i]]$X,
-                res0[[i]]$Y))), ID=as.character(i))
-        }
-    }
-    outSP <- SpatialPolygons(outPolygons, proj4string=CRS(p4s))
-    outSP
-}
-
-PolySet2SpatialLines <- function(PS) {
-    if (!inherits(PS, "PolySet")) stop("not a PolySet object")
-    prj <- attr(PS, "projection")
-    prj <- attr(PS, "projection")
-    if (is.null(prj)) stop("unknown coordinate reference system")
-    if (prj == "LL") p4s <- "+proj=longlat"
-    else if (prj == "UTM") {
-# apparent change in PBS object attributes
-        zn <- attr(prj, "zone")
-        if (is.null(zn)) zn <- attr(PS, "zone")
-        if (is.null(zn)) stop("no valid zone attribute")
-	p4s <- paste("+proj=utm +zone=", zn, sep="")
-    } else stop("unknown coordinate reference system")
-    hasPID <- "PID" %in% names(PS)
-    if (!hasPID) stop("object does not have PID column")
-    res0 <- split(PS, PS$PID)
-    hasSID <- "SID" %in% names(PS)
-    outLines <- vector(mode="list", length=length(res0)) 
-    if (hasSID) {
-        res1 <- lapply(res0, function(x) split(x, x$SID))
-        for (i in seq(along=outLines)) {
-            outLines[[i]] <- Lines(lapply(res1[[i]], function(x) 
-                Line(cbind(x$X, x$Y))), ID=as.character(i))
-        }
-    } else {
-        for (i in seq(along=outLines)) {
-            outLines[[i]] <- Lines(lapply(res0[[i]], function(x)
-                Line(cbind(res0[[i]]$X, res0[[i]]$Y))), ID=as.character(i))
-        }
-    }
-    outSP <- SpatialLines(outLines, proj4string=CRS(p4s))
-    outSP
-    
-
-}
-
-
+# PBSmapping utilities
+
+SpatialPolygons2PolySet <- function(SpP) {
+	require(PBSmapping)
+	pls <- slot(SpP, "polygons")
+	n <- length(pls)
+	PID <- NULL
+	SID <- NULL
+	POS <- NULL
+	X <- NULL
+	Y <- NULL
+	for (i in 1:n) {
+		srs <- slot(pls[[i]], "Polygons")
+		m <- length(srs)
+		for (j in 1:m) {
+			crds <- slot(srs[[j]], "coords")
+			k <- nrow(crds)
+			PID <- c(PID, rep(i, k))
+			SID <- c(SID, rep(j, k))
+			POS <- c(POS, 1:k)
+			X <- c(X, crds[,1])
+			Y <- c(Y, crds[,2])
+		}
+	}
+	PID <- as.integer(PID)
+	SID <- as.integer(SID)
+	POS <- as.integer(POS)
+        storage.mode(X) <- "double"
+        storage.mode(Y) <- "double"
+	require(PBSmapping)
+	pj <- .pbsproj(SpP)
+	zn <- NULL
+	if (pj == "UTM") {
+		zn <- attr(pj, "zone")
+		attr(pj, "zone") <- NULL
+	}
+	res <- as.PolySet(data.frame(PID=PID, SID=SID, POS=POS, X=X, Y=Y),
+		projection=pj, zone=zn)
+	res
+}
+
+SpatialLines2PolySet <- function(SL) {
+#	require(maps)
+	pls <- slot(SL, "lines")
+	n <- length(pls)
+	PID <- NULL
+	SID <- NULL
+	POS <- NULL
+	X <- NULL
+	Y <- NULL
+	for (i in 1:n) {
+		srs <- slot(pls[[i]], "Lines")
+		m <- length(srs)
+		for (j in 1:m) {
+			crds <- coordinates(srs[[j]])
+			k <- nrow(crds)
+			PID <- c(PID, rep(i, k))
+			SID <- c(SID, rep(j, k))
+			POS <- c(POS, 1:k)
+			X <- c(X, crds[,1])
+			Y <- c(Y, crds[,2])
+		}
+	}
+	PID <- as.integer(PID)
+	SID <- as.integer(SID)
+	POS <- as.integer(POS)
+        storage.mode(X) <- "double"
+        storage.mode(Y) <- "double"
+	require(PBSmapping)
+	pj <- .pbsproj(SL)
+	zn <- NULL
+	if (pj == "UTM") {
+		zn <- attr(pj, "zone")
+		attr(pj, "zone") <- NULL
+	}
+	res <- as.PolySet(data.frame(PID=PID, SID=SID, POS=POS, X=X, Y=Y),
+		projection=pj, zone=zn)
+	res
+}
+
+.pbsproj <- function(Sobj) {
+	p4str <- proj4string(Sobj)
+	if (is.na(p4str)) return("1")
+	res <- grep("longlat", p4str, fixed=TRUE)
+	if (length(res) > 0L) return("LL")
+	res <- regexpr("utm", p4str, fixed=TRUE)
+	if (res > 0) {
+		val <- "UTM"
+		res <- regexpr("+zone=", p4str, fixed=TRUE)
+		sres <- substring(p4str, res+attr(res, "match.length"))
+		zn0 <- regexpr("[[:digit:]]+", sres)
+		attr(val, "zone") <- as.integer(substring(sres, zn0, 
+			zn0+attr(zn0, "match.length")))
+	} else val <- "1"
+	val
+}
+
+PolySet2SpatialPolygons <- function(PS, close_polys=TRUE) {
+    if (!inherits(PS, "PolySet")) stop("not a PolySet object")
+    prj <- attr(PS, "projection")
+    if (is.null(prj)) stop("unknown coordinate reference system")
+    if (prj == "LL") p4s <- "+proj=longlat"
+    else if (prj == "UTM") {
+# apparent change in PBS object attributes
+        zn <- attr(prj, "zone")
+        if (is.null(zn)) zn <- attr(PS, "zone")
+        if (is.null(zn)) stop("no valid zone attribute")
+	p4s <- paste("+proj=utm +zone=", zn, sep="")
+    } else {
+       p4s <- as.character(NA)
+       warning("unknown coordinate reference system")
+    }
+# stop("unknown coordinate reference system") 110310
+    hasPID <- "PID" %in% names(PS)
+    if (!hasPID) stop("object does not have PID column")
+    res0 <- split(PS, PS$PID)
+    hasSID <- "SID" %in% names(PS)
+    outPolygons <- vector(mode="list", length=length(res0)) 
+    if (hasSID) {
+        res1 <- lapply(res0, function(x) split(x, x$SID))
+        if (close_polys) res1 <- lapply(res1, 
+            function(i) lapply(i, function(x) {
+                n <- nrow(x)
+                if (!isTRUE(identical(x$X[1], x$X[n])) ||
+                    !isTRUE(identical(x$Y[1], x$Y[n]))) rbind(x, x[1,])
+                else x
+            })
+        )
+# extra level added to fix bug found by A Lobos 080413
+        for (i in seq(along=outPolygons)) {
+            outPolygons[[i]] <- Polygons(lapply(res1[[i]], function(x) 
+                Polygon(cbind(x$X, x$Y))), ID=names(res1)[i])
+        }
+# PIDs added as IDs 080413
+    } else {
+        if (close_polys) res0 <- lapply(res0, function(x) {
+            n <- nrow(x)
+            if (!isTRUE(identical(x$X[1], x$X[n])) ||
+                !isTRUE(identical(x$Y[1], x$Y[n]))) rbind(x, x[1,])
+            else x
+        })
+        for (i in seq(along=outPolygons)) {
+            outPolygons[[i]] <- Polygons(list(Polygon(cbind(res0[[i]]$X,
+                res0[[i]]$Y))), ID=as.character(i))
+        }
+    }
+    outSP <- SpatialPolygons(outPolygons, proj4string=CRS(p4s))
+    outSP
+}
+
+PolySet2SpatialLines <- function(PS) {
+    if (!inherits(PS, "PolySet")) stop("not a PolySet object")
+    prj <- attr(PS, "projection")
+    prj <- attr(PS, "projection")
+    if (is.null(prj)) stop("unknown coordinate reference system")
+    if (prj == "LL") p4s <- "+proj=longlat"
+    else if (prj == "UTM") {
+# apparent change in PBS object attributes
+        zn <- attr(prj, "zone")
+        if (is.null(zn)) zn <- attr(PS, "zone")
+        if (is.null(zn)) stop("no valid zone attribute")
+	p4s <- paste("+proj=utm +zone=", zn, sep="")
+    } else {
+       p4s <- as.character(NA)
+       warning("unknown coordinate reference system")
+    }
+# stop("unknown coordinate reference system") 110310
+    hasPID <- "PID" %in% names(PS)
+    if (!hasPID) stop("object does not have PID column")
+    res0 <- split(PS, PS$PID)
+    hasSID <- "SID" %in% names(PS)
+    outLines <- vector(mode="list", length=length(res0)) 
+    if (hasSID) {
+        res1 <- lapply(res0, function(x) split(x, x$SID))
+        for (i in seq(along=outLines)) {
+            outLines[[i]] <- Lines(lapply(res1[[i]], function(x) 
+                Line(cbind(x$X, x$Y))), ID=as.character(i))
+        }
+    } else {
+        for (i in seq(along=outLines)) {
+            outLines[[i]] <- Lines(lapply(res0[[i]], function(x)
+                Line(cbind(res0[[i]]$X, res0[[i]]$Y))), ID=as.character(i))
+        }
+    }
+    outSP <- SpatialLines(outLines, proj4string=CRS(p4s))
+    outSP
+    
+
+}
+
+
diff --git a/R/sp_tools.R b/R/sp_tools.R
index 7e70124..b236f1c 100644
--- a/R/sp_tools.R
+++ b/R/sp_tools.R
@@ -2,7 +2,7 @@ MapGen2SL <- function(file, proj4string=CRS(as.character(NA))) {
 	con <- file(file, "r")
 	hold <- readLines(con)
 	close(con)
-	if (length(hold) == 500000) warning("500,000 point limit reached")
+	if (length(hold) == 500000L) warning("500,000 point limit reached")
 	starts <- which(hold == "# -b")
 	n <- length(starts)
 	if (n < 1) stop("Not a Mapgen format file")
@@ -43,7 +43,7 @@ ArcObj2SLDF <- function(arc, proj4string=CRS(as.character(NA)), IDs) {
 }
 
 ContourLines2SLDF <- function(cL, proj4string=CRS(as.character(NA))) {
-	if (length(cL) < 1) stop("cL too short")
+	if (length(cL) < 1L) stop("cL too short")
 	cLstack <- tapply(1:length(cL), sapply(cL, function(x) x[[1]]), 
 		function(x) x, simplify=FALSE)
 	df <- data.frame(level=names(cLstack))
diff --git a/R/spatstat1.R b/R/spatstat1.R
index cc0b4d6..89ba086 100644
--- a/R/spatstat1.R
+++ b/R/spatstat1.R
@@ -11,15 +11,16 @@ as.ppp.SpatialPoints = function(X) {
 
 setAs("SpatialPoints", "ppp", function(from) as.ppp.SpatialPoints(from))
 
+# Mike Sumner 20101011
 as.ppp.SpatialPointsDataFrame = function(X) {
 	require(spatstat)
 	bb <- bbox(X)
         colnames(bb) <- NULL
 	W  <- owin(bb[1,], bb[2,])
 	nc <- ncol(X)
-        marks <- if(nc == 0) NULL else X[[1]]
-        if(nc > 1)
-          warning(paste(nc-1, "columns of data frame discarded"))
+        marks <- if(nc == 0) NULL else slot(X, "data")
+#        if(nc > 1)
+#          warning(paste(nc-1, "columns of data frame discarded"))
 	cc <- coordinates(X)
 	return(ppp(cc[,1], cc[,2], window = W, marks = marks, check=FALSE))
 }
@@ -58,24 +59,37 @@ setAs("SpatialPolygons", "owin", function(from) as.owin.SpatialPolygons(from))
 # methods for coercion to Spatial Polygons by Adrian Baddeley
 
 owin2Polygons <- function(x, id="1") {
+	require(spatstat)
   stopifnot(is.owin(x))
   x <- as.polygonal(x)
   closering <- function(df) { df[c(seq(nrow(df)), 1), ] }
-  pieces <- lapply(x$bdry,
+  if (x$type == "polygonal") {
+      pieces <- lapply(x$bdry,
                    function(p) {
                      Polygon(coords=closering(cbind(p$x,p$y)),
                              hole=is.hole.xypolygon(p))  })
+  } else if (x$type == "rectangle") {
+      rectCrds <- cbind(x$xrange[c(1,1,2,2,1)], x$yrange[c(1,2,2,1,1)])
+      pieces <- list(Polygon(rectCrds, hole=FALSE))
+  } else stop("owin2Polygons: unknown type:", x$type)
   z <- Polygons(pieces, id)
   return(z)
 }
 
 as.SpatialPolygons.tess <- function(x) {
+	require(spatstat)
   stopifnot(is.tess(x))
   y <- tiles(x)
   nam <- names(y)
   z <- list()
-  for(i in seq(y))
-    z[[i]] <- owin2Polygons(y[[i]], nam[i])
+  for(i in seq(y)) {
+    zi <- try(owin2Polygons(y[[i]], nam[i]), silent=TRUE)
+    if (class(zi) == "try-error") {
+      warning(paste("tile", i, "defective\n", as.character(zi)))
+    } else {
+      z[[i]] <- zi
+    }
+  }
   return(SpatialPolygons(z))
 }
 
@@ -83,6 +97,7 @@ setAs("tess", "SpatialPolygons", function(from) as.SpatialPolygons.tess(from))
 
 
 as.SpatialPolygons.owin <- function(x) {
+	require(spatstat)
   stopifnot(is.owin(x))
   y <- owin2Polygons(x)
   z <- SpatialPolygons(list(y))
@@ -96,7 +111,8 @@ setAs("owin", "SpatialPolygons", function(from) as.SpatialPolygons.owin(from))
 # methods for 'as.psp' for sp classes by Adrian Baddeley
 
 as.psp.Line <- function(from, ..., window=NULL, marks=NULL, fatal) {
-  xy <- from at coords
+	require(spatstat)
+  xy <- slot(from, "coords")
   df <- as.data.frame(cbind(xy[-nrow(xy), , drop=FALSE], xy[-1, ,
 drop=FALSE]))
   if(is.null(window)) {
@@ -110,8 +126,14 @@ drop=FALSE]))
 setAs("Line", "psp", function(from) as.psp.Line(from))
   
 as.psp.Lines <- function(from, ..., window=NULL, marks=NULL, fatal) {
-  y <- lapply(from at Lines, as.psp.Line, window=window)
-  z <- superimposePSP(y, window=window)
+	require(spatstat)
+  y <- lapply(slot(from, "Lines"), as.psp.Line, window=window)
+  if (as.character(packageVersion("spatstat")) < "1.22.0") {
+    z <- superimposePSP(y, window=window)
+  } else {
+    z <- do.call(superimpose,c(y,list(W=window)))
+#    z <- superimpose(y, window=window)
+  }
   if(!is.null(marks))
     marks(z) <- marks
   return(z)
@@ -119,18 +141,28 @@ as.psp.Lines <- function(from, ..., window=NULL, marks=NULL, fatal) {
 
 setAs("Lines", "psp", function(from) as.psp.Lines(from))
 
-as.psp.SpatialLines <- function(from, ..., window=NULL, marks=NULL, fatal) {
+as.psp.SpatialLines <- function(from, ..., window=NULL, marks=NULL,
+                                 characterMarks=FALSE, fatal) {
+	require(spatstat)
   if(is.null(window)) {
-    w <- from at bbox
+    w <- slot(from, "bbox")
     window <- owin(w[1,], w[2,])
   }
-  lin <- from at lines
+  lin <- slot(from, "lines")
   y <- lapply(lin, as.psp.Lines, window=window)
-  id <- unlist(lapply(lin, function(s) { s at ID }))
+  id <- row.names(from)
   if(is.null(marks))
-    for(i in seq(y)) 
-      marks(y[[i]]) <- id[i]
-  z <- do.call("superimposePSP", list(y, window=window))
+    for (i in seq(y)) 
+      marks(y[[i]]) <- if(characterMarks) id[i] else factor(id[i])
+# modified 110401 Rolf Turner
+#    for(i in seq(y)) 
+#      marks(y[[i]]) <- id[i]
+  if (as.character(packageVersion("spatstat")) < "1.22.0") {
+    z <- do.call("superimposePSP", list(y, window=window))
+  } else {
+#    z <- do.call("superimpose", list(y, window=window))
+    z <- do.call("superimpose", c(y, list(W = window)))
+  }
   if(!is.null(marks))
     marks(z) <- marks
   return(z)
@@ -139,6 +171,7 @@ as.psp.SpatialLines <- function(from, ..., window=NULL, marks=NULL, fatal) {
 setAs("SpatialLines", "psp", function(from) as.psp.SpatialLines(from))
 
 as.psp.SpatialLinesDataFrame <- function(from, ..., window=NULL, marks=NULL, fatal) {
+	require(spatstat)
   y <- as(from, "SpatialLines")
   z <- as.psp(y, window=window, marks=marks)
   if(is.null(marks)) {
@@ -159,4 +192,19 @@ as.psp.SpatialLinesDataFrame <- function(from, ..., window=NULL, marks=NULL, fat
 
 setAs("SpatialLinesDataFrame", "psp", function(from) as.psp.SpatialLinesDataFrame(from))
 
+# 111117 from psp to SpatialLines, Rolf Turner, Adrian Baddeley, Mathieu Rajerison
+
+as.SpatialLines.psp <- function(from) {
+
+     ends2line <- function(x) Line(matrix(x, ncol=2, byrow=TRUE))
+     munch <- function(z) { Lines(ends2line(as.numeric(z[1:4])), ID=z[5]) }
+  
+     ends <- as.data.frame(from)[,1:4]
+     ends[,5] <- row.names(ends)
+     y <- apply(ends, 1, munch)
+     SpatialLines(y)
+}
+
+setAs("psp", "SpatialLines", function(from) as.SpatialLines.psp(from))
+
 
diff --git a/R/spmaps.R b/R/spmaps.R
index 2c26746..fbf1ed9 100644
--- a/R/spmaps.R
+++ b/R/spmaps.R
@@ -1,107 +1,151 @@
-.NAmat2xyList <- function(xy) {
-	NAs <- unclass(attr(na.omit(xy), "na.action"))
-	if ((length(NAs) == 1) && (NAs == nrow(xy))) {
-		xy <- xy[-nrow(xy)]
-		NAs <- NULL
-	}
-# NA problem found by Edzer Pebesma, 24/8-06
-	diffNAs <- diff(NAs)
-	if (any(diffNAs == 1)) {
-		xy <- xy[-(NAs[which(diffNAs == 1)] + 1), ]
-		NAs <- unclass(attr(na.omit(xy), "na.action"))
-	}
-	nParts <- length(NAs) + 1
-# two NAs at end of file 070905 RSB
-# no NAs at all RSB 080814
-	if (!is.null(NAs) && nrow(xy) == NAs[length(NAs)])
-            nParts <- nParts - 1
-	res <- vector(mode="list", length=nParts)
-	from <- integer(nParts)
-	to <- integer(nParts)
-	from[1] <- 1
-	to[nParts] <- nrow(xy)
-# two NAs at end of file 070905 RSB
-# no NAs at all RSB 080814
-	if (!is.null(NAs) && nrow(xy) == NAs[length(NAs)])
-            to[nParts] <- to[nParts] - 1
-	if (nParts > 1) {
-		for (i in 2:nParts) {
-			to[(i-1)] <- NAs[(i-1)]-1
-			from[i] <- NAs[(i-1)]+1
-		}
-	}
-	for (i in 1:nParts) res[[i]] <- xy[from[i]:to[i],, drop = FALSE]
-	res
-}
-
-map2SpatialLines <- function(map, IDs=NULL, proj4string=CRS(as.character(NA))) {
-	require(maps)
-	xyList <- .NAmat2xyList(cbind(map$x, map$y))
-	if (is.null(IDs)) IDs <- as.character(1:length(xyList))
-
-	if (length(xyList) != length(IDs)) stop("map and IDs differ in length")
-	tab <- table(factor(IDs))
-	n <- length(tab)
-	IDss <- names(tab)
-	reg <- match(IDs, IDss)
-	belongs <- lapply(1:n, function(x) which(x == reg))
-# assemble the list of Lines
-	Srl <- vector(mode="list", length=n)
-	for (i in 1:n) {
-		nParts <- length(belongs[[i]])
-		srl <- vector(mode="list", length=nParts)
-		for (j in 1:nParts) {
-			crds <- xyList[[belongs[[i]][j]]]
-			if (nrow(crds) > 1) srl[[j]] <- Line(coords=crds)
-			else srl[[j]] <- Line(coords=rbind(crds, crds))
-		}
-		Srl[[i]] <- Lines(srl, ID=IDss[i])
-	}
-	res <- SpatialLines(Srl, proj4string=proj4string)
-	res
-}
-
-pruneMap <- function(map, xlim=NULL, ylim=NULL) {
-	candx <- NULL
-	if (!is.null(xlim)) {
-		if (length(xlim) != 2) stop("xlim must be of length 2")
-		candx <- which(map$x < xlim[1] | map$x > xlim[2])
-	}
-	candy <- NULL
-	if (!is.null(ylim)) {
-		if (length(ylim) != 2) stop("ylim must be of length 2")
-		candy <- which(map$y < ylim[1] | map$y > ylim[2])
-	}
-	if (is.null(candx) && is.null(candy)) return(map)
-	cand <- unique(sort(c(candx, candy)))
-	map$x <- map$x[-cand]
-	map$y <- map$y[-cand]
-	map
-}
-
-# to be moved to glue with maps:
-
-map2SpatialPolygons <- function(map, IDs, proj4string=CRS(as.character(NA))) {
-	require(maps)
-	if (missing(IDs)) stop("IDs required")
-	xyList <- .NAmat2xyList(cbind(map$x, map$y))
-	if (length(xyList) != length(IDs)) stop("map and IDs differ in length")
-	tab <- table(factor(IDs))
-	n <- length(tab)
-	IDss <- names(tab)
-	reg <- match(IDs, IDss)
-	belongs <- lapply(1:n, function(x) which(x == reg))
-# assemble the list of Srings
-	Srl <- vector(mode="list", length=n)
-	for (i in 1:n) {
-		nParts <- length(belongs[[i]])
-		srl <- vector(mode="list", length=nParts)
-		for (j in 1:nParts) {
-			srl[[j]] <- Polygon(coords=xyList[[belongs[[i]][j]]])
-		}
-		Srl[[i]] <- Polygons(srl, ID=IDss[i])
-	}
-	res <- as.SpatialPolygons.PolygonsList(Srl, proj4string=proj4string)
-	res
-}
-
+.NAmat2xyList <- function(xy) {
+	NAs <- unclass(attr(na.omit(xy), "na.action"))
+	if ((length(NAs) == 1L) && (NAs == nrow(xy))) {
+		xy <- xy[-nrow(xy)]
+		NAs <- NULL
+	}
+# NA problem found by Edzer Pebesma, 24/8-06
+	diffNAs <- diff(NAs)
+	if (any(diffNAs == 1)) {
+		xy <- xy[-(NAs[which(diffNAs == 1)] + 1), ]
+		NAs <- unclass(attr(na.omit(xy), "na.action"))
+	}
+	nParts <- length(NAs) + 1L
+# two NAs at end of file 070905 RSB
+# no NAs at all RSB 080814
+	if (!is.null(NAs) && nrow(xy) == NAs[length(NAs)])
+            nParts <- nParts - 1
+	res <- vector(mode="list", length=nParts)
+	from <- integer(nParts)
+	to <- integer(nParts)
+	from[1] <- 1
+	to[nParts] <- nrow(xy)
+# two NAs at end of file 070905 RSB
+# no NAs at all RSB 080814
+	if (!is.null(NAs) && nrow(xy) == NAs[length(NAs)])
+            to[nParts] <- to[nParts] - 1
+	if (nParts > 1) {
+		for (i in 2:nParts) {
+			to[(i-1)] <- NAs[(i-1)]-1
+			from[i] <- NAs[(i-1)]+1
+		}
+	}
+	for (i in 1:nParts) res[[i]] <- xy[from[i]:to[i],, drop = FALSE]
+	res
+}
+
+map2SpatialLines <- function(map, IDs=NULL, proj4string=CRS(as.character(NA))) {
+	require(maps)
+	xyList <- .NAmat2xyList(cbind(map$x, map$y))
+	if (is.null(IDs)) IDs <- as.character(1:length(xyList))
+
+	if (length(xyList) != length(IDs)) stop("map and IDs differ in length")
+	tab <- table(factor(IDs))
+	n <- length(tab)
+	IDss <- names(tab)
+	reg <- match(IDs, IDss)
+	belongs <- lapply(1:n, function(x) which(x == reg))
+# assemble the list of Lines
+	Srl <- vector(mode="list", length=n)
+	for (i in 1:n) {
+		nParts <- length(belongs[[i]])
+		srl <- vector(mode="list", length=nParts)
+		for (j in 1:nParts) {
+			crds <- xyList[[belongs[[i]][j]]]
+			if (nrow(crds) > 1) srl[[j]] <- Line(coords=crds)
+			else srl[[j]] <- Line(coords=rbind(crds, crds))
+		}
+		Srl[[i]] <- Lines(srl, ID=IDss[i])
+	}
+	res <- SpatialLines(Srl, proj4string=proj4string)
+	res
+}
+
+pruneMap <- function(map, xlim=NULL, ylim=NULL) {
+	candx <- NULL
+	if (!is.null(xlim)) {
+		if (length(xlim) != 2L) stop("xlim must be of length 2")
+		candx <- which(map$x < xlim[1] | map$x > xlim[2])
+	}
+	candy <- NULL
+	if (!is.null(ylim)) {
+		if (length(ylim) != 2L) stop("ylim must be of length 2")
+		candy <- which(map$y < ylim[1] | map$y > ylim[2])
+	}
+	if (is.null(candx) && is.null(candy)) return(map)
+	cand <- unique(sort(c(candx, candy)))
+	map$x <- map$x[-cand]
+	map$y <- map$y[-cand]
+	map
+}
+
+# to be moved to glue with maps:
+
+map2SpatialPolygons <- function(map, IDs, proj4string=CRS(as.character(NA))) {
+	require(maps)
+	if (missing(IDs)) stop("IDs required")
+	xyList <- .NAmat2xyList(cbind(map$x, map$y))
+	if (length(xyList) != length(IDs)) stop("map and IDs differ in length")
+	tab <- table(factor(IDs))
+	n <- length(tab)
+	IDss <- names(tab)
+	reg <- match(IDs, IDss)
+	belongs <- lapply(1:n, function(x) which(x == reg))
+# assemble the list of Srings
+	Srl <- vector(mode="list", length=n)
+	for (i in 1:n) {
+		nParts <- length(belongs[[i]])
+		srl <- vector(mode="list", length=nParts)
+		for (j in 1:nParts) {
+                        crds <- xyList[[belongs[[i]][j]]]
+                        if (nrow(crds) == 3) crds <- rbind(crds, crds[1,])
+			srl[[j]] <- Polygon(coords=crds)
+		}
+		Srl[[i]] <- Polygons(srl, ID=IDss[i])
+	}
+	res <- as.SpatialPolygons.PolygonsList(Srl, proj4string=proj4string)
+	res
+}
+
+SpatialPolygons2map <- function(spol) {
+    stopifnot(inherits(spol, "SpatialPolygons"))
+    p4str <- proj4string(spol)
+    if (is.na(p4str)) {
+        warning("no coordinate reference system")
+    } else {
+        if (is.projected(spol)) warning("projected coordinates")
+    }
+    pls <- slot(spol, "polygons")
+    n <- length(pls)
+    names <- NULL
+    range <- c(t(bbox(spol)))
+    x <- NULL
+    y <- NULL
+    for (i in 1:n) {
+        nm <- slot(pls[[i]], "ID")
+        Pls <- slot(pls[[i]], "Polygons")
+        ni <- length(Pls)
+        for (j in 1:ni) {
+            if (ni == 1) {
+                names <- c(names, nm)
+            } else {
+                names <- c(names, paste(nm, j, sep=":"))
+            }
+            crds <- slot(Pls[[j]], "coords")
+            x <- c(x, crds[,1])
+            y <- c(y, crds[,2])
+            if (j < ni) {
+                x <- c(x, as.numeric(NA))
+                y <- c(y, as.numeric(NA))
+            }
+        }
+        if (i < n) {
+            x <- c(x, as.numeric(NA))
+            y <- c(y, as.numeric(NA))
+        }
+    }
+    res <- list(x=x, y=y, range=range, names=names)
+    class(res) <- "map"
+    res
+}
+
diff --git a/R/subset.R b/R/subset.R
index 9ae4dba..e113172 100644
--- a/R/subset.R
+++ b/R/subset.R
@@ -4,7 +4,7 @@ subset.polylist <- function(x, subset, fit.bbox=TRUE, ...) {
 	.Deprecated("", package="maptools", msg="objects other than Spatial objects defined in the sp package are deprecated")
 	if (!inherits(x, "polylist")) stop("x not a polylist object")
 	if (!is.logical(subset)) stop("subset not a logical vector")
-	if (length(x) < 1) stop("zero length polylist")
+	if (length(x) < 1L) stop("zero length polylist")
 	if (length(x) != length(subset)) stop("x and subset different lengths")
 	res <- subset.default(x, subset)
 	attr(res, "region.id") <- subset.default(attr(x, "region.id"), subset)
diff --git a/R/sun-methods.R b/R/sun-methods.R
index e3ec5e1..03ceee4 100644
--- a/R/sun-methods.R
+++ b/R/sun-methods.R
@@ -20,7 +20,7 @@
     list(crds=crds, dateTime=dateTime)
 }
 
-###_ crepuscule methods
+###_ + crepuscule methods
 if (!isGeneric("crepuscule")) {
     setGeneric("crepuscule", function(crds, dateTime, ...) {
         standardGeneric("crepuscule")
@@ -40,6 +40,7 @@ setMethod("crepuscule",
               time.ll <- .timeData(eq.ll$dateTime)
               lon <- eq.ll$crds[, 1]
               lat <- eq.ll$crds[, 2]
+              direction <- match.arg(direction)
               res <- .crepuscule(lon=lon, lat=lat, year=time.ll$year,
                                  month=time.ll$month, day=time.ll$day,
                                  timezone=time.ll$timezone,
@@ -61,11 +62,12 @@ setMethod("crepuscule", signature(crds="matrix", dateTime="POSIXct"),
                    proj4string=CRS("+proj=longlat +datum=WGS84"), solarDep,
                    direction=c("dawn", "dusk"), POSIXct.out=FALSE) {
               crds.sp <- SpatialPoints(crds, proj4string=proj4string)
+              direction <- match.arg(direction)
               crepuscule(crds.sp, dateTime=dateTime, solarDep=solarDep,
                          direction=direction, POSIXct.out=POSIXct.out)
           })
 
-###_ sunriset methods
+###_ + sunriset methods
 if (!isGeneric("sunriset")) {
     setGeneric("sunriset", function(crds, dateTime, ...) {
         standardGeneric("sunriset")
@@ -83,6 +85,7 @@ setMethod("sunriset", signature(crds="SpatialPoints", dateTime="POSIXct"),
               time.ll <- .timeData(eq.ll$dateTime)
               lon <- eq.ll$crds[, 1]
               lat <- eq.ll$crds[, 2]
+              direction <- match.arg(direction)
               res <- .sunriset(lon=lon, lat=lat, year=time.ll$year,
                                month=time.ll$month, day=time.ll$day,
                                timezone=time.ll$timezone,
@@ -104,11 +107,12 @@ setMethod("sunriset", signature(crds="matrix", dateTime="POSIXct"),
                    proj4string=CRS("+proj=longlat +datum=WGS84"),
                    direction=c("sunrise", "sunset"), POSIXct.out=FALSE) {
               crds.sp <- SpatialPoints(crds, proj4string=proj4string)
+              direction <- match.arg(direction)
               sunriset(crds.sp, dateTime=dateTime,
                        direction=direction, POSIXct.out=POSIXct.out)
           })
 
-###_ solarnoon methods
+###_ + solarnoon methods
 if (!isGeneric("solarnoon")) {
     setGeneric("solarnoon", function(crds, dateTime, ...) {
         standardGeneric("solarnoon")
@@ -149,7 +153,7 @@ setMethod("solarnoon", signature(crds="matrix", dateTime="POSIXct"),
                         POSIXct.out=POSIXct.out)
           })
 
-###_ solarpos methods
+###_ + solarpos methods
 if (!isGeneric("solarpos")) {
     setGeneric("solarpos", function(crds, dateTime, ...) {
         standardGeneric("solarpos")
@@ -171,7 +175,7 @@ setMethod("solarpos", signature(crds="SpatialPoints", dateTime="POSIXct"),
                                hours=time.ll$hour, minutes=time.ll$min,
                                seconds=time.ll$sec, timezone=time.ll$timezone,
                                dlstime=time.ll$dlstime)
-              matrix(c(azimuth=res[,1], elevation=res[,2]), ncol=2)
+              matrix(c(azimuth=res[, 1], elevation=res[, 2]), ncol=2)
           })
 
 setMethod("solarpos", signature(crds="matrix", dateTime="POSIXct"),
@@ -182,8 +186,7 @@ setMethod("solarpos", signature(crds="matrix", dateTime="POSIXct"),
           })
 
 
-###_* Emacs local variables.
+###_ * Emacs local variables.
 ## Local variables:
-## allout-widgets-mode-inhibit: t
-## allout-layout: (-2 : 0)
+## allout-layout: (+ : 0)
 ## End:
diff --git a/R/sun.R b/R/sun.R
index 0c6ebd5..f1e8e46 100644
--- a/R/sun.R
+++ b/R/sun.R
@@ -267,8 +267,8 @@
     eqtime <- .eqTime(jc)
     solarDec <- .sunDeclination(jc)
     switch(direction,
-           dawn = hourangle <- .hangleSunriset(lat, solarDec, dir="sunrise"),
-           dusk = hourangle <- .hangleSunriset(lat, solarDec, dir="sunset"))
+           dawn = hourangle <- .hangleSunriset(lat, solarDec, direction="sunrise"),
+           dusk = hourangle <- .hangleSunriset(lat, solarDec, direction="sunset"))
     d <- lon - .deg(hourangle)
     tdiff <- 4 * d
     timeUTC <- 720 + tdiff - eqtime
@@ -278,10 +278,10 @@
     switch(direction,
            dawn = {
                hourangle <- .hangleCrepuscule(lat, solarDec, solarDep,
-                                              dir="dawn")},
+                                              direction="dawn")},
            dusk = {
                hourangle <- .hangleCrepuscule(lat, solarDec, solarDep,
-                                              dir="dusk")})
+                                              direction="dusk")})
     d <- lon - .deg(hourangle)
     tdiff <- 4 * d
     720 + tdiff - eqtime
@@ -304,8 +304,8 @@
     eqtime <- .eqTime(jc)
     solarDec <- .sunDeclination(jc)
     switch(direction,
-           sunrise = hourangle <- .hangleSunriset(lat, solarDec, dir="sunrise"),
-           sunset = hourangle <- .hangleSunriset(lat, solarDec, dir="sunset"))
+           sunrise = hourangle <- .hangleSunriset(lat, solarDec, direction="sunrise"),
+           sunset = hourangle <- .hangleSunriset(lat, solarDec, direction="sunset"))
     d <- lon - .deg(hourangle)
     tdiff <- 4 * d
     timeUTC <- 720 + tdiff - eqtime
@@ -313,8 +313,8 @@
     eqtime <- .eqTime(newt)
     solarDec <- .sunDeclination(newt)
     switch(direction,
-           sunrise = hourangle <- .hangleSunriset(lat, solarDec, dir="sunrise"),
-           sunset = hourangle <- .hangleSunriset(lat, solarDec, dir="sunset"))
+           sunrise = hourangle <- .hangleSunriset(lat, solarDec, direction="sunrise"),
+           sunset = hourangle <- .hangleSunriset(lat, solarDec, direction="sunset"))
     d <- lon - .deg(hourangle)
     tdiff <- 4 * d
     720 + tdiff - eqtime
@@ -379,10 +379,10 @@
     switch(direction,
            dawn = {
                risetTimeGMT <- .crepusculeUTC(jd, ll[, 1], ll[, 2], solarDep,
-                                              dir="dawn")},
+                                              direction="dawn")},
            dusk = {
                risetTimeGMT <- .crepusculeUTC(jd, ll[, 1], ll[, 2], solarDep,
-                                              dir="dusk")})
+                                              direction="dusk")})
     risetTimeLST <- risetTimeGMT + (60 * timezone) + (dlstime * 60)
     risetTimeLST / 1440
 }
@@ -406,10 +406,10 @@
     switch(direction,
            sunrise = {
                risetTimeGMT <- .sunrisetUTC(jd, ll[, 1], ll[, 2],
-                                            dir="sunrise")},
+                                            direction="sunrise")},
            sunset = {
                risetTimeGMT <- .sunrisetUTC(jd, ll[, 1], ll[, 2],
-                                            dir="sunset")})
+                                            direction="sunset")})
     risetTimeLST <- risetTimeGMT + (60 * timezone) + (dlstime * 60)
     risetTimeLST / 1440
 }
@@ -431,7 +431,7 @@
     jc <- .cent2000JD(jd)
     newt <- .cent2000JD(.julianD2000(jc) + 0.5 + ll[, 1] / 360)
     eqtime <- .eqTime(newt)
-#    solarNoonDec <- .sunDeclination(newt)
+    ## solarNoonDec <- .sunDeclination(newt)
     solNoonUTC <- 720 + (ll[, 1] * 4) - eqtime
     solarnoon <- solNoonUTC + (60 * timezone) + (dlstime * 60)
     solarnoon / 1440
@@ -457,7 +457,7 @@
     timenow <- hh + minutes / 60 + seconds / 3600 + zone
     jd <- .julianD(year, month, day)
     jc <- .cent2000JD(jd + timenow / 24)
-#    earthRadVec <- r <- .sunRadVec(jc)
+    ## earthRadVec <- r <- .sunRadVec(jc)
     solarDec <- .sunDeclination(jc)
     eqtime <- .eqTime(jc)
     solarTimefix <- eqtime - 4 * ll[, 1] + 60 * zone
diff --git a/R/union.R b/R/union.R
index 449df2e..43fd333 100644
--- a/R/union.R
+++ b/R/union.R
@@ -1,17 +1,22 @@
-unionSpatialPolygons <- function(SpP, IDs, threshold=NULL, avoidGEOS=FALSE) {
+unionSpatialPolygons <- function(SpP, IDs, threshold=NULL, avoidGEOS=FALSE, avoidUnaryUnion=FALSE) {
     if (!is(SpP, "SpatialPolygons")) stop("not a SpatialPolygons object")
+    if (storage.mode(IDs) != "character") IDs <- as.character(IDs)
+    if (missing(IDs)) stop("IDs required")
+    if (length(slot(SpP, "polygons")) != length(IDs))
+        stop("input lengths differ")
     rgeosI <- rgeosStatus()
     if (rgeosI && !avoidGEOS) {
-#        require(rgeos)
-#        res <- gUnionCascaded(SpP=SpP, IDs=IDs)
+        require(rgeos)
+        if (avoidUnaryUnion || version_GEOS0() < "3.3.0")
+            res <- gUnionCascaded(spgeom=SpP, id=IDs)
+        else
+            res <- gUnaryUnion(spgeom=SpP, id=IDs)
     } else {
         stopifnot(isTRUE(gpclibPermitStatus()))
 	require(gpclib)
 	pl <- slot(SpP, "polygons")
 	proj4CRS <- CRS(proj4string(SpP))
 	SrnParts <- sapply(pl, function(x) length(slot(x, "Polygons")))
-	if (missing(IDs)) stop("IDs required")
-	if (length(pl) != length(IDs)) stop("input lengths differ")
 	tab <- table(factor(IDs))
 	n <- length(tab)
 	IDss <- names(tab)
diff --git a/data/SplashDams.rda b/data/SplashDams.rda
new file mode 100644
index 0000000..93ec0a4
Binary files /dev/null and b/data/SplashDams.rda differ
diff --git a/data/gpcholes.rda b/data/gpcholes.rda
index 28d1d34..47fbe3a 100644
Binary files a/data/gpcholes.rda and b/data/gpcholes.rda differ
diff --git a/data/state.vbm.rda b/data/state.vbm.rda
new file mode 100644
index 0000000..144994f
Binary files /dev/null and b/data/state.vbm.rda differ
diff --git a/data/wrld_simpl.rda b/data/wrld_simpl.rda
index 3314ca6..c59ac24 100644
Binary files a/data/wrld_simpl.rda and b/data/wrld_simpl.rda differ
diff --git a/inst/ChangeLog b/inst/ChangeLog
index 74327f2..645949f 100644
--- a/inst/ChangeLog
+++ b/inst/ChangeLog
@@ -1,814 +1,1022 @@
-2010-09-08 18:36  rsbivand
+2013-02-10 13:58  rsbivand
 
-	* DESCRIPTION, R/SpatialLines-methods.R, man/readShapeLines.Rd,
-	  man/readShapePoly.Rd, man/readShapeSpatial.Rd: zero nParts for
-	  lines
+	* .Rbuildignore: don't ship old_man
 
-2010-08-28 12:34  rsbivand
+2013-02-09 10:22  rsbivand
 
-	* R/Rgshhs.R, R/maptools.R, R/shapelib.R, R/sp2pbs.R, R/sp_spat1.R,
-	  R/union.R, ChangeLog, inst/ChangeLog: as.double to storage.mode
+	* DESCRIPTION, src/Rgshhs.c, src/Rshapeget.c, src/Rshapewrite1.c: C
+	  code warning cleanup; new-style contribs
 
-2010-08-26 12:36  rsbivand
+2013-01-16 09:24  rsbivand
 
-	* ChangeLog, inst/ChangeLog: check Sys.which value
+	* ChangeLog, inst/ChangeLog: tidy
 
-2010-08-26 12:32  rsbivand
+2013-01-16 09:22  rsbivand
 
-	* DESCRIPTION, R/readGPS.R: check Sys.which value
+	* DESCRIPTION, R/AAA.R: move startup message to .onAttach
 
-2010-08-12 17:08  rsbivand
+2013-01-04 00:36  oscarperpi
 
-	* R/kmlLine.R, man/holepolys.Rd, DESCRIPTION, ChangeLog,
-	  inst/ChangeLog: data docs fix
+	* man/lineLabel.Rd: Fixed description in lineLabel.Rd
 
-2010-04-22 04:47  rsbivand
+2012-12-21 12:36  rsbivand
 
-	* DESCRIPTION, R/shapelib.R, ChangeLog, inst/ChangeLog: read.shape
-	  filen without extension
+	* ChangeLog, inst/ChangeLog: tidy
 
-2010-04-12 08:55  rsbivand
+2012-11-19 13:29  edzer
 
-	* DESCRIPTION, ChangeLog, inst/ChangeLog: tidy
+	* DESCRIPTION, R/dotsinpolys.R: version bump, added URL
+	  dotsinpolygons: renamed sample.Polygons to spsample, so we can
+	  retire sample.Xxx in sp
 
-2010-04-05 12:42  rsbivand
+2012-11-19 13:00  oscarperpi
 
-	* DESCRIPTION, man/checkPolygonsHoles.Rd,
-	  man/thinnedSpatialPoly.Rd, man/unionSpatialPolygons.Rd: comment
-	  out links to rgeos
+	* NAMESPACE: new method "label" for line labels
 
-2010-04-03 21:24  rsbivand
+2012-11-19 12:59  oscarperpi
 
-	* DESCRIPTION, R/DP.R, R/Rgshhs.R, R/checkHoles.R,
-	  R/nowrapRecenter.R, R/union.R, ChangeLog, inst/ChangeLog: hide
-	  rgeos
+	* man/lineLabel.Rd: new line labels examples added
 
-2010-04-03 18:22  rsbivand
+2012-11-19 12:59  oscarperpi
 
-	* R/shapelib.R, ChangeLog, inst/ChangeLog: DBF filename, GSHHS C
-	  code errors addressed
+	* R/lineLabel.R: line label algorithm improved
 
-2010-04-03 18:01  rsbivand
+2012-11-12 09:25  rsbivand
 
-	* DESCRIPTION, R/AAA.R, R/shapelib.R, R/union.R,
-	  man/readShapeLines.Rd, man/readShapePoints.Rd,
-	  man/readShapePoly.Rd, man/readShapeSpatial.Rd,
-	  man/unionSpatialPolygons.Rd, src/Rgshhs.c, src/Rgshhs.h,
-	  ChangeLog, inst/ChangeLog: DBF filename, GSHHS C code errors
-	  addressed
+	* ChangeLog, inst/ChangeLog: tidy
 
-2010-01-17 20:26  rsbivand
+2012-11-12 09:24  rsbivand
 
-	* R/AAA.R, R/sp_bind.R, man/spRbind-methods.Rd: change spRbind for
-	  SpatialPointsDataFrame objects
+	* ChangeLog, DESCRIPTION, R/CCmaps.R: fix bug in CCmaps
 
-2010-01-10 20:42  rsbivand
+2012-11-06 07:17  rsbivand
 
-	* ChangeLog, inst/ChangeLog: gshhs hole fix
+	* DESCRIPTION, NAMESPACE, man/lineLabel.Rd,
+	  man/pointLabelLattice.Rd: add drawDetails.labels to NAMESPACE
 
-2010-01-10 20:37  rsbivand
+2012-11-05 08:11  rsbivand
 
-	* R/Rgshhs.R: gshhs hole fix
+	* ChangeLog, inst/ChangeLog: tidy
 
-2010-01-08 10:46  rsbivand
+2012-11-05 08:11  rsbivand
 
-	* R/Rgshhs.R, ChangeLog, inst/ChangeLog: hole assignment in GSHHS
+	* DESCRIPTION, NAMESPACE, R/lineLabel.R, R/pointLabel.R,
+	  R/pointLabelBase.R, R/pointLabelLattice.R, man/lineLabel.Rd,
+	  man/pointLabel.Rd, man/pointLabelBase.Rd,
+	  man/pointLabelLattice.Rd, man/sp2WB.Rd: to UTF-8; adding lattice
+	  pointLabel
 
-2010-01-07 19:07  rsbivand
+2012-11-04 16:04  rsbivand
 
-	* ChangeLog, inst/ChangeLog: rgeos integration
+	* ChangeLog, inst/ChangeLog: tidy
 
-2010-01-07 19:03  rsbivand
+2012-10-29 14:39  rsbivand
 
-	* R/AAA.R, R/Rgshhs.R, man/Rgshhs.Rd: rgeos integration
+	* DESCRIPTION, R/spatstat1.R: branching in owin2Polygons on
+	  as.polygonal type
 
-2010-01-07 13:10  rsbivand
+2012-08-22 12:35  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/DP.R, R/Rgshhs.R, R/checkHoles.R,
-	  R/nowrapRecenter.R, R/union.R, R/zzz.R, man/Rgshhs.Rd,
-	  man/checkPolygonsHoles.Rd, man/nowrapRecenter.Rd,
-	  man/thinnedSpatialPoly.Rd, man/unionSpatialPolygons.Rd, R/AAA.R:
-	  rgeos integration
+	* man/SpatialLines2PolySet.Rd, man/map2SpatialPolygons.Rd,
+	  man/pal2SpatialPolygons.Rd: make suggests if(require())
+
+2012-08-09 12:58  rsbivand
+
+	* DESCRIPTION, R/Rgshhs.R, man/Rgshhs.Rd: Rgshhs SpatialCollections
+	  avoidance
+
+2012-07-22 13:10  rsbivand
+
+	* R/midpoint.R: correct midpoint data.frame
+
+2012-06-29 08:45  rsbivand
+
+	* ChangeLog, inst/ChangeLog: tidy
+
+2012-06-08 20:10  rsbivand
+
+	* ChangeLog, inst/ChangeLog: tidy
+
+2012-06-08 20:08  rsbivand
+
+	* DESCRIPTION, NAMESPACE, R/midpoint.R,
+	  man/SpatialLinesMidPoints.Rd: add line midpoint
+
+2012-05-09 08:12  rsbivand
+
+	* R/getKMLcoordinates.R: blanks in KML input
+
+2012-05-04 08:29  rsbivand
+
+	* R/elide.R: copy comment in elide
+
+2012-05-03 11:09  rsbivand
+
+	* DESCRIPTION, NAMESPACE, R/point_line_distance.R,
+	  man/nearestPointOnLine.Rd, man/nearestPointOnSegment.Rd,
+	  man/snapPointsToLines.Rd: adding functions for snapping points to
+	  lines by German Carrillo
+
+2012-02-06 09:13  rsbivand
 
-2009-12-21 13:39  rsbivand
+	* DESCRIPTION, man/Rgshhs.Rd: Rgshhs documentation
 
-	* ChangeLog, INDEX, inst/ChangeLog: adding CCmaps
+2012-01-27 12:29  rsbivand
 
-2009-12-21 13:35  rsbivand
+	* man/unionSpatialPolygons.Rd: fix documentation
 
-	* DESCRIPTION, NAMESPACE, R/CCmaps.R, man/CCmaps.Rd, src/Rgshhs.c:
-	  adding CCmaps
+2012-01-15 13:15  rsbivand
 
-2009-12-18 22:56  rsbivand
+	* ChangeLog, DESCRIPTION, inst/ChangeLog: tidy
 
-	* inst/share/gshhs_c.b, inst/share/wdb_borders_c.b, man/Rgshhs.Rd,
-	  man/spRbind-methods.Rd, src/Rgshhs.c, src/Rgshhs.h: GSHHS upgrade
-	  to 2.0
+2012-01-12 06:50  rsbivand
 
-2009-12-03 08:34  rsbivand
+	* man/SplashDams.Rd: updated source for splash dam data
 
-	* INDEX, ChangeLog, inst/ChangeLog: hole example format change
+2012-01-09 19:08  rsbivand
 
-2009-12-03 08:31  rsbivand
+	* DESCRIPTION, NAMESPACE, R/kmlPoints.R, data/SplashDams.rda,
+	  man/SplashDams.Rd, man/kmlPoints.Rd: adding kmlPoints
 
-	* ChangeLog, DESCRIPTION, data/gpcholes.rda, man/holepolys.Rd,
-	  inst/ChangeLog: hole example format change
+2012-01-02 18:14  rsbivand
 
-2009-11-23 12:49  rsbivand
+	* DESCRIPTION, data/state.vbm.rda, man/state.vbm.Rd: adding
+	  state.vbm
 
-	* man/getinfo.shape.Rd, ChangeLog, inst/ChangeLog: reinstate
-	  getinfo.shape
+2011-12-19 09:01  rsbivand
 
-2009-11-23 12:45  rsbivand
+	* ChangeLog, inst/ChangeLog: upgrade GSHHS to 2.2.0
 
-	* NAMESPACE: reinstate getinfo.shape
+2011-12-19 09:00  rsbivand
 
-2009-11-20 13:26  rsbivand
+	* DESCRIPTION, inst/share/gshhs_c.b, inst/share/wdb_borders_c.b,
+	  man/Rgshhs.Rd, src/Rgshhs.c, src/Rgshhs.h: upgrade GSHHS to 2.2.0
 
-	* DESCRIPTION, NAMESPACE, R/dotsinpolys.R,
-	  inst/old_man/Map2poly.Rd, inst/old_man/get.Pcent.Rd,
-	  inst/old_man/maptools.Rd, inst/old_man/plot.Map.Rd,
-	  inst/old_man/plot.polylist.Rd, inst/old_man/read.shape.Rd,
-	  inst/old_man/subset.polylist.Rd,
-	  inst/old_man/write.linelistShape.Rd,
-	  inst/old_man/write.pointShape.Rd,
-	  inst/old_man/write.polylistShape.Rd, man/Map2poly.Rd,
-	  man/dotsInPolys.Rd, man/get.Pcent.Rd, man/holepolys.Rd,
-	  man/maptools.Rd, man/plot.Map.Rd, man/plot.polylist.Rd,
-	  man/read.shape.Rd, man/readShapeLines.Rd, man/readShapePoints.Rd,
-	  man/readShapePoly.Rd, man/readShapeSpatial.Rd,
-	  man/subset.polylist.Rd, man/symbolsInPolys.Rd,
-	  man/write.linelistShape.Rd, man/write.pointShape.Rd,
-	  man/write.polylistShape.Rd, man/leglabs.Rd, ChangeLog,
-	  inst/ChangeLog: moving deprecated functions from namespace
+2011-11-17 08:19  rsbivand
 
-2009-11-19 21:11  rsbivand
+	* DESCRIPTION, NAMESPACE, R/spatstat1.R, man/as.ppp.Rd: adding
+	  as.SpatialLines.psp
 
-	* DESCRIPTION, NAMESPACE, R/DP.R, man/spCbind-methods.Rd,
-	  man/spRbind-methods.Rd, man/thinnedSpatialPoly.Rd, ChangeLog,
-	  inst/ChangeLog: adding thinnedSpatialPoly
+2011-11-14 21:35  rsbivand
 
-2009-11-05 17:26  edzer
+	* DESCRIPTION, R/checkHoles.R, R/pointLabel.R, R/sun.R,
+	  src/shpopen.c: complete partial argument matches
 
-	* R/sp_bind.R, man/spChFIDs-methods.Rd: moved spChFID method,
-	  functions and docs to package sp
+2011-08-08 18:52  rsbivand
 
-2009-09-17 10:22  rsbivand
+	* man/readShapeLines.Rd, man/readShapePoints.Rd,
+	  man/readShapePoly.Rd, man/readShapeSpatial.Rd: link to write.dbf
 
-	* DESCRIPTION, man/GE_SpatialGrid.Rd, man/Map2poly.Rd,
-	  man/SpatialLines2PolySet.Rd, man/asciigrid.Rd, man/kmlLine.Rd,
-	  man/kmlOverlay.Rd, man/nowrapRecenter.Rd, ChangeLog,
-	  inst/ChangeLog: fix documentation links
+2011-08-07 11:49  rsbivand
 
-2009-07-14 11:17  rsbivand
+	* ChangeLog, inst/ChangeLog: editing startup message
 
-	* man/: GE_SpatialGrid.Rd, kmlLine.Rd, kmlOverlay.Rd,
-	  kmlPolygon.Rd: KML WGS84 notes added
+2011-08-07 11:48  rsbivand
 
-2009-06-22 16:52  rsbivand
+	* R/AAA.R: editing startup message
 
-	* ChangeLog, DESCRIPTION, R/SpatialPolys-methods.R, inst/ChangeLog:
-	  changed all.equal to identical in closed ring forcing
+2011-08-07 11:33  rsbivand
 
-2009-06-10 16:33  rsbivand
+	* inst/ChangeLog: editing startup message
 
-	* ChangeLog, DESCRIPTION, R/SpatialPolys-methods.R, inst/ChangeLog:
-	  more NULL geometry trapping
+2011-08-07 11:32  rsbivand
 
-2009-05-26 12:22  rsbivand
+	* ChangeLog: editing startup message
 
-	* ChangeLog, DESCRIPTION, R/sp_spat1.R, R/spatstat1.R,
-	  inst/ChangeLog, man/as.ppp.Rd: coercion from owin/tess to
-	  SpatialPolygons
+2011-08-07 11:28  rsbivand
 
-2009-04-08 19:29  rsbivand
+	* NAMESPACE, man/Rgshhs.Rd, man/checkPolygonsHoles.Rd,
+	  man/nowrapRecenter.Rd, man/unionSpatialPolygons.Rd: editing
+	  startup message
 
-	* ChangeLog, DESCRIPTION, R/spatstat1.R, inst/ChangeLog:
-	  improvements to spatstat support - Adrian Baddeley
+2011-08-06 14:18  rsbivand
 
-2009-03-29 17:32  rsbivand
+	* DESCRIPTION, R/AAA.R, R/checkHoles.R: edited startup message
 
-	* ChangeLog, DESCRIPTION, inst/ChangeLog: drop=FALSE in reading
-	  line and polygon shapefiles
+2011-06-11 05:38  rsbivand
 
-2009-03-29 17:29  rsbivand
+	* ChangeLog, inst/ChangeLog: permit NA IDs in union
 
-	* LICENSE, R/SpatialLines-methods.R, R/SpatialPolys-methods.R,
-	  inst/LICENSE: drop=FALSE in reading line and polygon shapefiles
+2011-06-11 05:37  rsbivand
 
-2009-03-17 21:43  vir
+	* DESCRIPTION, R/union.R, man/unionSpatialPolygons.Rd: permit NA
+	  IDs in union
 
-	* R/readSplus.R: Minor fix to allow for a line with NA's just
-	  before the END.
+2011-06-10 08:03  rsbivand
 
-2009-03-10 18:23  rsbivand
+	* ChangeLog, inst/ChangeLog: documenting unionSpatialPolygons
+	  change
 
-	* INDEX, LICENSE, inst/LICENSE, ChangeLog, inst/ChangeLog: data web
-	  link
+2011-06-10 08:02  rsbivand
 
-2009-02-18 12:58  rsbivand
+	* DESCRIPTION: documenting unionSpatialPolygons change
 
-	* inst/shapes/fylk-val-ll.dbf, inst/shapes/fylk-val-ll.shp,
-	  inst/shapes/fylk-val-ll.shx, data/wrld_simpl.rda, ChangeLog,
-	  inst/ChangeLog: kml writing; GSHHS lines shift
+2011-06-10 08:00  rsbivand
 
-2009-02-18 12:55  rsbivand
+	* ChangeLog, inst/ChangeLog: documenting unionSpatialPolygons
+	  change
 
-	* ChangeLog, DESCRIPTION, INDEX, NAMESPACE, R/Rgshhs.R,
-	  inst/ChangeLog, inst/LICENSE, inst/share/gshhs_c.b,
-	  man/Rgshhs.Rd, R/getKMLcoordinates.R, R/kmlLine.R,
-	  R/kmlPolygon.R, man/getKMLcoordinates.Rd, man/kmlLine.Rd,
-	  man/kmlPolygon.Rd, man/wrld_simpl.Rd: kml writing; GSHHS lines
-	  shift
+2011-06-10 07:58  rsbivand
 
-2009-02-05 18:45  rsbivand
+	* man/unionSpatialPolygons.Rd: documenting unionSpatialPolygons
+	  change
 
-	* man/asciigrid.Rd: tidy
+2011-06-09 08:10  rsbivand
 
-2009-02-05 16:38  rsbivand
+	* DESCRIPTION, R/union.R, man/unionSpatialPolygons.Rd: added
+	  gUnaryUnion to unionSpatialPolygons
 
-	* R/readSplus.R, man/sp2WB.Rd, ChangeLog, inst/ChangeLog: adding
-	  features to readSplus
+2011-05-06 06:14  rsbivand
 
-2009-02-05 14:38  rsbivand
+	* ChangeLog, inst/ChangeLog: tidy
+
+2011-05-06 06:13  rsbivand
+
+	* DESCRIPTION, R/spatstat1.R, man/as.ppp.Rd: superimpose correction
+
+2011-04-29 06:29  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/readSplus.R, inst/share/Splus.map,
-	  man/readSplus.Rd, ChangeLog, inst/ChangeLog: adding readSplus for
-	  WinBUGS
+	* ChangeLog, inst/ChangeLog: change superimpose
 
-2009-01-20 15:38  rsbivand
+2011-04-29 06:28  rsbivand
 
-	* DESCRIPTION, R/sun-methods.R, ChangeLog, inst/ChangeLog: sun NULL
-	  tz
+	* DESCRIPTION, R/spatstat1.R: change superimpose
 
-2008-11-13 15:06  rsbivand
+2011-04-03 20:26  sluque
 
-	* ChangeLog, DESCRIPTION, R/readGPS.R, inst/ChangeLog,
-	  man/readGPS.Rd: ... for readGPS()
+	* R/sun-methods.R: Fix comments for proper outlining with allout.
 
-2008-11-12 15:55  rsbivand
+2011-04-01 06:57  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/SP2owin.R, R/sp_spat1.R, R/spatstat1.R,
-	  man/as.ppp.Rd, man/ppp.Rd: as.psp
+	* DESCRIPTION, R/spatstat1.R, man/as.ppp.Rd: marks fix for psp
 
-2008-10-02 16:46  rsbivand
+2011-03-30 14:48  rsbivand
 
-	* ChangeLog, inst/ChangeLog: changelog
+	* ChangeLog, inst/ChangeLog: more hole fixing
 
-2008-08-14 11:09  rsbivand
+2011-03-30 14:48  rsbivand
 
-	* DESCRIPTION, INDEX, R/spmaps.R: NULL bug in maps2SP
+	* R/checkHoles.R, man/checkPolygonsHoles.Rd: more hole fixing
 
-2008-06-27 10:15  rsbivand
+2011-03-29 12:45  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/SpatialLines-methods.R,
-	  R/SpatialPoints-methods.R, R/SpatialPolys-methods.R,
-	  R/maptools.R, R/pcent.R, R/readGPS.R, R/shapelib.R, R/subset.R,
-	  inst/changes, man/readShapePoly.Rd, R/Spatial-methods.R,
-	  man/readShapeSpatial.Rd, ChangeLog, inst/ChangeLog: readSpatial
-	  wrapper
+	* R/checkHoles.R: tree holes
 
-2008-06-19 07:56  rsbivand
+2011-03-29 08:24  rsbivand
 
-	* DESCRIPTION, R/sp2pbs.R: PolySet2SpatialLines UTM zone update
+	* R/checkHoles.R: STRtree in hole check
 
-2008-05-24 19:18  rsbivand
+2011-03-28 13:14  rsbivand
 
-	* ChangeLog, INDEX, inst/ChangeLog: GSHHS support to 1.10
+	* DESCRIPTION, R/checkHoles.R: try around gEquals in hole check
 
-2008-05-24 18:27  rsbivand
+2011-03-28 08:25  rsbivand
 
-	* DESCRIPTION, R/Rgshhs.R, R/sp2pbs.R, inst/share/gshhs_c.b,
-	  inst/share/wdb_borders_c.b, man/Rgshhs.Rd, src/Rgshhs.c,
-	  src/Rgshhs.h: GSHHS support to 1.10
+	* ChangeLog, inst/ChangeLog: add comments to wrld_simpl
 
-2008-04-14 22:49  rsbivand
+2011-03-28 08:24  rsbivand
 
-	* DESCRIPTION: tidy
+	* DESCRIPTION, data/wrld_simpl.rda: add comments to wrld_simpl
 
-2008-04-14 22:35  rsbivand
+2011-03-23 13:50  rsbivand
 
 	* ChangeLog, inst/ChangeLog: tidy
 
-2008-04-14 22:33  rsbivand
+2011-03-23 13:50  rsbivand
 
-	* DESCRIPTION: PolySet
+	* ChangeLog, DESCRIPTION, inst/ChangeLog: tidy
 
-2008-04-13 18:47  rsbivand
+2011-03-22 22:25  rsbivand
 
-	* DESCRIPTION, INDEX, R/sp2pbs.R: PBS to SP SID bug
+	* data/wrld_simpl.rda: resave rda files
 
-2008-04-10 16:07  rsbivand
+2011-03-22 22:23  rsbivand
 
-	* man/readShapePoly.Rd: tidy
+	* data/gpcholes.rda, data/wrld_simpl.rda: resave rda files
 
-2008-04-04 19:59  rsbivand
+2011-03-22 22:22  rsbivand
 
-	* DESCRIPTION, R/SpatialPolys-methods.R, man/readShapePoly.Rd: ABS
-	  nulls
+	* data/gpcholes.rda, data/wrld_simpl.rda: resave rda files
 
-2008-03-30 21:48  rsbivand
+2011-03-21 10:12  rsbivand
 
-	* DESCRIPTION, R/Rgshhs.R, man/Rgshhs.Rd: GSHHS clip
+	* ChangeLog, inst/ChangeLog: fix 2.13 Rd bugs
 
-2008-03-03 22:47  rsbivand
+2011-03-21 10:06  rsbivand
 
-	* ChangeLog, DESCRIPTION, R/GE_png.R, R/shapelib.R, inst/ChangeLog,
-	  man/GE_SpatialGrid.Rd, man/readShapeLines.Rd,
-	  man/readShapePoints.Rd, man/readShapePoly.Rd: makegrid
+	* DESCRIPTION, man/getKMLcoordinates.Rd, man/kmlLine.Rd,
+	  man/kmlPolygon.Rd: fix 2.13 Rd bugs
 
-2008-02-09 13:42  rsbivand
+2011-03-10 13:56  rsbivand
 
-	* DESCRIPTION, man/Rgshhs.Rd, man/SpatialLines2PolySet.Rd,
-	  man/checkPolygonsHoles.Rd, man/dotsInPolys.Rd,
-	  man/gcDestination.Rd, man/map2SpatialPolygons.Rd,
-	  man/nowrapRecenter.Rd, man/pal2SpatialPolygons.Rd,
-	  man/plot.polylist.Rd, man/pointLabel.Rd, man/readGPS.Rd,
-	  man/readShapeLines.Rd, man/readShapePoints.Rd,
-	  man/readShapePoly.Rd, man/sp2WB.Rd, man/sp2tmap.Rd,
-	  man/sun-methods.Rd, man/symbolsInPolys.Rd,
-	  man/unionSpatialPolygons.Rd, man/write.linelistShape.Rd,
-	  man/write.pointShape.Rd, man/write.polylistShape.Rd: line lengths
-	  in help
+	* R/sp2pbs.R, R/spmaps.R: PolySet2SpatialPolygons projection
+	  modification
 
-2008-01-30 21:53  rsbivand
+2011-02-24 14:29  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/GE_png.R, man/GE_SpatialGrid.Rd: SG
-	  creation
+	* R/CCmaps.R, R/DP.R, R/Rgshhs.R, R/SpatialLines-methods.R,
+	  R/SpatialPolys-methods.R, R/asciigrid.R, R/checkHoles.R,
+	  R/elide.R, R/gc_dist.R, R/kmlLine.R, R/kmlPolygon.R,
+	  R/maptools.R, R/readSplus.R, R/shapelib.R, R/sp2pbs.R,
+	  R/sp_tools.R, R/spmaps.R, R/subset.R: making length comparisons
+	  literal integers
 
-2008-01-30 09:26  rsbivand
+2011-02-11 09:42  rsbivand
 
-	* R/elide.R: ppp + getinfo
+	* R/Rgshhs.R: Rgshhs intersection
 
-2008-01-29 12:36  rsbivand
+2011-02-06 14:48  rsbivand
 
-	* R/elide.R: ppp + getinfo
+	* DESCRIPTION, R/AAA.R, src/shapefil.h, src/shpopen.c,
+	  src/shptree.c: suppress startup messages
 
-2008-01-29 12:00  rsbivand
+2011-01-02 14:25  rsbivand
 
-	* R/elide.R, man/elide-methods.Rd: ppp + getinfo
+	* R/Rgshhs.R, man/Rgshhs.Rd: GSHHS 2.1.0 update
 
-2008-01-29 11:37  rsbivand
+2010-12-31 15:43  rsbivand
 
-	* R/: sp_spat1.R, spatstat1.R: ppp + getinfo
+	* inst/share/gshhs_c.b: GSHHS 2.1.0 update
 
-2008-01-29 10:52  rsbivand
+2010-12-31 15:37  rsbivand
 
-	* R/shapelib.R, R/sp_spat1.R, src/Rshapeget.c, src/Rshapeinfo.c:
-	  ppp + getinfo
+	* R/checkHoles.R, man/Rgshhs.Rd, src/Rgshhs.c: GSHHS 2.1.0 update
 
-2008-01-29 10:03  rsbivand
+2010-12-16 10:46  rsbivand
 
-	* src/Rshapeinfo.c: ppp + getinfo
+	* man/as.ppp.Rd, man/gzAzimuth.Rd, man/pal2SpatialPolygons.Rd,
+	  man/readShapeLines.Rd, man/readShapePoly.Rd,
+	  man/readShapeSpatial.Rd, man/readSplus.Rd,
+	  man/unionSpatialPolygons.Rd: use rownames for retrieving FIDs
 
-2008-01-29 09:50  rsbivand
+2010-12-16 10:27  rsbivand
 
-	* ChangeLog, DESCRIPTION, R/shapelib.R, R/sp_spat1.R,
-	  R/spatstat1.R, src/Rshapeinfo.c: ppp + getinfo
+	* man/as.ppp.Rd, man/pal2SpatialPolygons.Rd, man/readShapePoly.Rd,
+	  man/readSplus.Rd, man/unionSpatialPolygons.Rd: use rownames for
+	  retrieving FIDs
 
-2008-01-20 16:08  rsbivand
+2010-11-30 17:37  rsbivand
 
-	* ChangeLog, DESCRIPTION, NAMESPACE, R/SpatialPolys-methods.R,
-	  R/sp2pbs.R, inst/ChangeLog, man/SpatialLines2PolySet.Rd: pbs to
-	  sp
+	* ChangeLog, inst/ChangeLog: tidy
 
-2007-12-13 18:32  rsbivand
+2010-11-30 00:10  edzer
 
-	* DESCRIPTION, R/elide.R: elide
+	* man/as.ppp.Rd, man/asciigrid.Rd: updated email address
 
-2007-12-09 19:03  rsbivand
+2010-11-24 13:40  rsbivand
 
-	* ChangeLog, DESCRIPTION, R/elide.R, inst/ChangeLog,
-	  man/elide-methods.Rd, src/Rgshhs.c, src/Rgshhs.h: elide shift
+	* R/union.R: preparing for rgeos release
 
-2007-11-21 23:37  rsbivand
+2010-11-24 12:32  rsbivand
 
-	* R/elide.R: elide bug
+	* R/union.R, man/unionSpatialPolygons.Rd: preparing for rgeos
+	  release
 
-2007-11-16 10:12  rsbivand
+2010-11-24 09:11  rsbivand
 
-	* DESCRIPTION, inst/changes, inst/share/gshhs_c.b, man/Rgshhs.Rd,
-	  src/Rgshhs.c, src/Rgshhs.h, src/shpopen.c: GSHHS to 1.5
+	* ChangeLog: preparing for rgeos release
 
-2007-11-10 14:17  rsbivand
+2010-11-24 09:09  rsbivand
 
-	* src/: shpopen.c, shptree.c: assert
+	* inst/ChangeLog: preparing for rgeos release
 
-2007-10-31 16:43  rsbivand
+2010-11-24 09:08  rsbivand
 
-	* ChangeLog, R/sp2WB.R, inst/ChangeLog: thingy to slot
+	* DESCRIPTION, R/AAA.R, R/DP.R, R/Rgshhs.R, R/checkHoles.R,
+	  R/nowrapRecenter.R, R/union.R, man/Rgshhs.Rd,
+	  man/checkPolygonsHoles.Rd, man/nowrapRecenter.Rd,
+	  man/thinnedSpatialPoly.Rd, man/unionSpatialPolygons.Rd: preparing
+	  for rgeos release
 
-2007-10-31 14:46  rsbivand
+2010-11-18 07:53  rsbivand
 
-	* ChangeLog, DESCRIPTION, R/SP2owin.R, R/SpatialLines-methods.R,
-	  R/SpatialPolys-methods.R, R/checkHoles.R, R/dotsinpolys.R,
-	  R/nowrapRecenter.R, R/sp2WB.R, R/sp2pbs.R, R/union.R,
-	  inst/ChangeLog, inst/changes, man/checkPolygonsHoles.Rd,
-	  man/dotsInPolys.Rd, man/gcDestination.Rd,
-	  man/map2SpatialPolygons.Rd, man/pal2SpatialPolygons.Rd,
-	  man/readShapePoly.Rd, man/symbolsInPolys.Rd,
-	  man/unionSpatialPolygons.Rd: thingy to slot
+	* .Rbuildignore: add .Rbuildignore
 
-2007-10-23 14:50  rsbivand
+2010-11-18 04:30  sluque
 
-	* DESCRIPTION, LICENSE, inst/LICENSE, inst/changes,
-	  man/Map2poly.Rd, man/as.ppp.Rd, man/readShapeLines.Rd,
-	  man/readShapePoints.Rd, man/readShapePoly.Rd: license
+	* R/sun-methods.R, R/sun.R, man/sun-methods.Rd: Use match.arg() in
+	  sun methods, so that defaults actually work.
+	  
+	  Minor improvements to documentation.
 
-2007-10-10 08:25  rsbivand
+2010-11-17 15:49  rsbivand
 
-	* ChangeLog, INDEX, inst/ChangeLog, inst/changes: tidy
+	* INDEX, svn2cl.xsl: initial clean
 
-2007-10-06 19:38  rsbivand
+2010-11-17 15:49  rsbivand
 
-	* man/gcDestination.Rd: elide first cut
+	* ChangeLog, oChangeLog: initial clean
 
-2007-10-06 12:05  rsbivand
+2010-11-17 15:45  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/elide.R, R/gc_dist.R,
-	  man/elide-methods.Rd: elide first cut
+	* inst/shapes, inst/shapes/baltim.dbf, inst/shapes/baltim.shp,
+	  inst/shapes/baltim.shx, inst/shapes/columbus.dbf,
+	  inst/shapes/columbus.shp, inst/shapes/columbus.shx,
+	  inst/shapes/fylk-val-ll.dbf, inst/shapes/fylk-val-ll.shp,
+	  inst/shapes/fylk-val-ll.shx, inst/shapes/fylk-val.dbf,
+	  inst/shapes/fylk-val.shp, inst/shapes/fylk-val.shx,
+	  inst/shapes/pointZ.dbf, inst/shapes/pointZ.prj,
+	  inst/shapes/pointZ.shp, inst/shapes/pointZ.shx,
+	  inst/shapes/sids.dbf, inst/shapes/sids.shp, inst/shapes/sids.shx:
+	  initial clean
 
-2007-09-29 18:37  rsbivand
+2010-11-17 15:44  rsbivand
 
-	* R/pointLabel.R: pointLabel update
+	* inst/shapes: initial clean
 
-2007-09-26 11:09  rsbivand
+2010-11-17 15:40  rsbivand
 
-	* R/asciigrid.R: Ascii Grid dec
+	* .: initial clean
 
-2007-09-18 10:19  rsbivand
+2010-11-13 15:55  rsbivand
 
-	* ChangeLog, inst/ChangeLog, inst/changes: tidy
+	* adding getRgshhsMap
 
-2007-09-18 10:15  rsbivand
+2010-10-17 18:29  rsbivand
 
-	* DESCRIPTION, R/maptools.R, R/sp2WB.R: tidy
+	* ppp marks as data.frame not vector
 
-2007-09-14 22:14  rsbivand
+2010-09-08 17:12  rsbivand
 
-	* R/sp2Mondrian.R, man/sp2Mondrian.Rd: Mondrian new format
+	* zero nParts for lines
 
-2007-09-14 08:58  rsbivand
+2010-09-08 16:36  rsbivand
 
-	* DESCRIPTION, R/SpatialLines-methods.R, R/SpatialPoints-methods.R,
-	  R/SpatialPolys-methods.R, R/shapelib.R, man/readShapeLines.Rd,
-	  man/readShapePoints.Rd, man/readShapePoly.Rd,
-	  man/write.linelistShape.Rd, man/write.pointShape.Rd,
-	  man/write.polylistShape.Rd: pass through max_nchar
+	* zero nParts for lines
 
-2007-09-05 18:07  rsbivand
+2010-08-28 10:35  rsbivand
 
-	* DESCRIPTION, R/spmaps.R, ChangeLog, inst/ChangeLog, inst/changes:
-	  double NA at end of map coords
+	* as.double to storage.mode
 
-2007-07-25 10:49  rsbivand
+2010-08-26 10:36  rsbivand
 
-	* man/write.polylistShape.Rd: 3D polylist, write line shape, owin
-	  poly
+	* check Sys.which value
 
-2007-07-19 21:33  rsbivand
+2010-08-12 15:09  rsbivand
 
-	* DESCRIPTION, R/SP2owin.R, R/maptools.R, R/shapelib.R,
-	  inst/changes, man/as.ppp.Rd, man/write.linelistShape.Rd,
-	  man/write.polylistShape.Rd, src/Rshapewrite1.c: 3D polylist
-	  writing
+	* data docs fix
 
-2007-06-11 10:05  rsbivand
+2010-04-22 02:48  rsbivand
 
-	* DESCRIPTION: encoding
+	* read.shape filen without extension
 
-2007-06-10 23:27  rsbivand
+2010-04-12 06:55  rsbivand
 
-	* ChangeLog, INDEX, inst/ChangeLog, inst/changes, man/Map2poly.Rd,
-	  man/sp2WB.Rd: encode
+	* tidy
 
-2007-06-10 22:47  rsbivand
+2010-04-05 10:42  rsbivand
 
-	* ChangeLog, DESCRIPTION, NAMESPACE, R/pointLabel.R,
-	  inst/ChangeLog, man/pointLabel.Rd: pointLabel
+	* comment out links to rgeos
 
-2007-06-05 15:31  rsbivand
+2010-04-03 19:25  rsbivand
 
-	* INDEX, R/readGPS.R: con correction
+	* hide rgeos
 
-2007-05-08 18:35  rsbivand
+2010-04-03 16:23  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/sp_spat1.R, man/as.ppp.Rd: revert
-	  spatstat coerce
+	* DBF filename, GSHHS C code errors addressed
 
-2007-05-07 10:55  rsbivand
+2010-04-03 16:02  rsbivand
 
-	* man/readGPS.Rd: tidy
+	* DBF filename, GSHHS C code errors addressed
 
-2007-04-28 21:41  rsbivand
+2010-01-17 19:27  rsbivand
 
-	* man/readShapePoints.Rd: doc error
+	* change spRbind for SpatialPointsDataFrame objects
 
-2007-04-27 18:37  rsbivand
+2010-01-10 19:42  rsbivand
 
-	* man/readGPS.Rd: resolve GPS conflict
+	* gshhs hole fix
 
-2007-04-21 06:27  rsbivand
+2010-01-10 19:37  rsbivand
 
-	* DESCRIPTION, INDEX, R/GE_png.R: GE dimnames
+	* gshhs hole fix
 
-2007-04-16 06:01  rsbivand
+2010-01-08 09:48  rsbivand
 
-	* man/readGPS.Rd: sp problem and gps
+	* hole assignment in GSHHS
 
-2007-04-16 04:40  rsbivand
+2010-01-07 18:07  rsbivand
 
-	* DESCRIPTION, R/readGPS.R, R/spmaps.R, man/readGPS.Rd: sp problem
-	  and gps
+	* rgeos integration
 
-2007-03-29 16:34  rsbivand
+2010-01-07 12:10  rsbivand
 
-	* inst/changes: tidy
+	* rgeos integration
 
-2007-03-23 18:50  rsbivand
+2009-12-21 12:39  rsbivand
 
-	* DESCRIPTION, INDEX, NAMESPACE, R/plot.Map.R, R/readGPS.R,
-	  man/readGPS.Rd: readGPS
+	* adding CCmaps
 
-2007-02-09 21:09  rsbivand
+2009-12-21 12:39  rsbivand
 
-	* R/SpatialPolys-methods.R, man/readShapePoly.Rd: force_ring in
-	  readShapePoly
+	* adding CCmaps
 
-2007-02-01 15:28  rsbivand
+2009-12-18 21:56  rsbivand
 
-	* DESCRIPTION, INDEX, R/sun-methods.R, man/plot.Map.Rd,
-	  man/plot.polylist.Rd, man/sun-methods.Rd: sun manual tidy
+	* GSHHS upgrade to 2.0
 
-2007-01-21 11:50  rsbivand
+2009-12-03 07:35  rsbivand
 
-	* man/: GE_SpatialGrid.Rd, kmlOverlay.Rd: GE_PNG additions
+	* hole example format change
 
-2007-01-20 22:35  rsbivand
+2009-12-03 07:35  rsbivand
 
-	* DESCRIPTION, NAMESPACE, inst/changes, R/GE_png.R,
-	  man/GE_SpatialGrid.Rd, man/kmlOverlay.Rd: GE_PNG additions
+	* hole example format change
 
-2007-01-16 10:39  rsbivand
+2009-12-03 07:34  rsbivand
 
-	* INDEX: im and sun-methods
+	* hole example format change
 
-2007-01-16 10:23  rsbivand
+2009-11-23 11:50  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/sp_spat1.R, inst/changes,
-	  man/as.ppp.Rd, man/crepuscule-methods.Rd, man/ppp.Rd,
-	  man/solarnoon-methods.Rd, man/solarpos-methods.Rd,
-	  man/sun-methods.Rd, man/sunriset-methods.Rd: im and sun-methods
+	* reinstate getinfo.shape
 
-2006-12-02 16:38  rsbivand
+2009-11-20 12:27  rsbivand
 
-	* DESCRIPTION, INDEX, man/solarnoon-methods.Rd: release
+	* moving deprecated functions from namespace
 
-2006-11-22 13:03  rsbivand
+2009-11-19 20:11  rsbivand
 
-	* R/Rgshhs.R: Rgshhs
+	* adding thinnedSpatialPoly
 
-2006-11-16 15:34  rsbivand
+2009-11-05 16:26  edzer
 
-	* R/sp_bind.R, inst/share/nc_xtra.dbf, man/spCbind-methods.Rd,
-	  man/spChFIDs-methods.Rd, man/spRbind-methods.Rd: bind
+	* moved spChFID method, functions and docs to package sp
 
-2006-11-16 15:31  rsbivand
+2009-09-17 08:22  rsbivand
 
-	* DESCRIPTION, INDEX, NAMESPACE, R/sp2pbs.R, man/Rgshhs.Rd,
-	  man/map2SpatialPolygons.Rd, man/plot.polylist.Rd,
-	  man/read.shape.Rd, man/subset.polylist.Rd, src/Rgshhs.c: bind
+	* fix documentation links
 
-2006-10-31 14:06  rsbivand
+2009-07-14 09:17  rsbivand
 
-	* NAMESPACE, R/SP2owin.R, R/sp_tools.R, R/sun.R, inst/changes,
-	  inst/share/co37_d90.e00, inst/share/gshhs_c.b, R/Rgshhs.R,
-	  R/checkHoles.R, R/nowrapRecenter.R, R/union.R, man/Rgshhs.Rd,
-	  man/checkPolygonsHoles.Rd, man/nowrapRecenter.Rd,
-	  man/pal2SpatialPolygons.Rd, man/unionSpatialPolygons.Rd,
-	  src/Rgshhs.c, src/Rgshhs.h: sun and r-spatial integration
+	* KML WGS84 notes added
 
-2006-10-31 09:29  rsbivand
+2009-06-22 14:53  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/sun.R, R/zzz.R, R/SP2owin.R,
-	  R/sp2pbs.R, R/sp_spat1.R, R/sp_tools.R, R/spatstat1.R,
-	  R/spmaps.R, R/sun-methods.R, man/ContourLines2SLDF.Rd,
-	  man/SpatialLines2PolySet.Rd, man/as.ppp.Rd,
-	  man/crepuscule-methods.Rd, man/map2SpatialPolygons.Rd,
-	  man/ppp.Rd, man/solarnoon-methods.Rd, man/solarpos-methods.Rd,
-	  man/sun.Rd, man/sunriset-methods.Rd: sun and r-spatial
-	  integration
+	* changed all.equal to identical in closed ring forcing
 
-2006-10-29 14:53  rsbivand
+2009-06-22 14:52  rsbivand
 
-	* R/sun.R: sun ephemerides
+	* changed all.equal to identical in closed ring forcing
 
-2006-10-28 21:56  rsbivand
+2009-06-10 14:34  rsbivand
 
-	* R/sun.R: sun ephemerides
+	* more NULL geometry trapping
 
-2006-10-28 19:23  rsbivand
+2009-05-26 10:22  rsbivand
 
-	* DESCRIPTION, INDEX, NAMESPACE, R/sun.R, inst/changes, man/sun.Rd:
-	  sun ephemerides
+	* coercion from owin/tess to SpatialPolygons
 
-2006-10-19 22:03  rsbivand
+2009-04-08 17:29  rsbivand
 
-	* DESCRIPTION, R/dotsinpolys.R, inst/changes: dostInPolys NULL
+	* improvements to spatstat support - Adrian Baddeley
 
-2006-09-21 21:42  rsbivand
+2009-03-29 15:32  rsbivand
 
-	* DESCRIPTION: R 2.4.0
+	* drop=FALSE in reading line and polygon shapefiles
 
-2006-08-30 16:50  rsbivand
+2009-03-17 20:43  vir
 
-	* DESCRIPTION, src/Rshapewrite1.c: pointZ
+	* Minor fix to allow for a line with NA's just before the END.
 
-2006-08-30 08:59  rsbivand
+2009-03-10 17:24  rsbivand
 
-	* DESCRIPTION, LICENSE, R/maptools.R, R/shapelib.R, inst/LICENSE,
-	  inst/changes, man/readShapePoints.Rd, src/Rshapewrite.c,
-	  inst/shapes/pointZ.dbf, inst/shapes/pointZ.prj,
-	  inst/shapes/pointZ.shp, inst/shapes/pointZ.shx: pointZ
+	* data web link
 
-2006-05-02 09:07  rsbivand
+2009-02-18 12:00  rsbivand
 
-	* DESCRIPTION, R/SpatialLines-methods.R, R/SpatialPoints-methods.R,
-	  R/SpatialPolys-methods.R, R/shapelib.R, inst/changes,
-	  man/read.shape.Rd, man/readShapeLines.Rd, man/readShapePoints.Rd,
-	  man/readShapePoly.Rd, src/Rshapeget.c: Geolytics bug
+	* kml writing; GSHHS lines shift
 
-2006-04-10 21:21  rsbivand
+2009-02-18 11:58  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/asciigrid.R, R/azimuth.R, R/sp2WB.R,
-	  inst/changes, man/asciigrid.Rd, man/dotsInPolys.Rd,
-	  man/gzAzimuth.Rd: fix to sp2WB, readAsciiGrid, writeAsciiGrid
+	* kml writing; GSHHS lines shift
 
-2006-03-20 09:32  rsbivand
+2009-02-05 17:45  rsbivand
 
-	* DESCRIPTION, R/sp2Mondrian.R, man/sp2Mondrian.Rd: Mondrian
+	* tidy
 
-2006-03-10 13:49  rsbivand
+2009-02-05 15:39  rsbivand
 
-	* DESCRIPTION, INDEX, NAMESPACE, R/asciigrid.R, R/sp2tmap.R,
-	  inst/changes, man/asciigrid.Rd, man/sp2WB.Rd, R/azimuth.R,
-	  R/sp2Mondrian.R, man/gzAzimuth.Rd, man/sp2Mondrian.Rd:
-	  sp2Mondrian
+	* adding features to readSplus
 
-2006-03-01 09:53  rsbivand
+2009-02-05 13:39  rsbivand
 
-	* DESCRIPTION, INDEX, R/SpatialPoints-methods.R,
-	  R/SpatialPolys-methods.R, R/plot.Map.R, R/shapelib.R,
-	  inst/changes, man/plot.Map.Rd, man/write.linelistShape.Rd,
-	  man/write.pointShape.Rd, man/write.polylistShape.Rd,
-	  src/Rshapeget.c: checks on polylists
+	* adding readSplus for WinBUGS
 
-2006-01-11 12:08  rsbivand
+2009-01-20 14:39  rsbivand
 
-	* R/sp2tmap.R, man/sp2tmap.Rd: tmap
+	* sun NULL tz
 
-2006-01-10 14:08  rsbivand
+2008-11-13 14:07  rsbivand
 
-	* R/sp2tmap.R, man/sp2tmap.Rd: tmap
+	* ... for readGPS()
 
-2006-01-09 14:33  rsbivand
+2008-11-13 14:06  rsbivand
 
-	* NAMESPACE, man/sp2tmap.Rd: sp2tmap
+	* ... for readGPS()
 
-2006-01-08 22:23  rsbivand
+2008-11-12 14:55  rsbivand
 
-	* man/sp2tmap.Rd: adding sp2tmap
+	* as.psp
 
-2006-01-08 19:34  rsbivand
+2008-10-02 14:46  rsbivand
 
-	* DESCRIPTION, R/sp2WB.R, R/sp2tmap.R, man/asciigrid.Rd,
-	  man/sp2tmap.Rd: adding sp2tmap
+	* changelog
 
-2005-12-15 16:00  rsbivand
+2008-08-14 09:09  rsbivand
 
-	* INDEX: to 5-4
+	* NULL bug in maps2SP
 
-2005-12-12 22:27  rsbivand
+2008-06-27 08:17  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/SpatialPoints-methods.R,
-	  R/SpatialPolys-methods.R, R/shapelib.R, R/sp2WB.R, inst/changes,
-	  man/readShapePoly.Rd, man/sp2WB.Rd, man/write.pointShape.Rd:
-	  sp2WB
+	* readSpatial wrapper
 
-2005-10-03 19:44  rsbivand
+2008-06-19 05:57  rsbivand
 
-	* DESCRIPTION, R/SpatialLines-methods.R, inst/changes: lines bugs
+	* PolySet2SpatialLines UTM zone update
 
-2005-09-14 23:08  rsbivand
+2008-05-24 17:18  rsbivand
 
-	* R/SpatialPolys-methods.R: as at 0.5-2
+	* GSHHS support to 1.10
 
-2005-09-13 19:24  rsbivand
+2008-05-24 16:27  rsbivand
 
-	* man/: dotsInPolys.Rd, symbolsInPolys.Rd: remove suggested splancs
+	* GSHHS support to 1.10
 
-2005-09-13 16:53  rsbivand
+2008-04-14 20:49  rsbivand
 
-	* DESCRIPTION, R/dotsinpolys.R, man/dotsInPolys.Rd,
-	  man/plot.Map.Rd, man/readShapePoly.Rd, man/symbolsInPolys.Rd:
-	  remove suggested splancs
+	* tidy
 
-2005-09-09 16:28  rsbivand
+2008-04-14 20:35  rsbivand
 
-	* R/plot.Map.R: ... in plot.Map
+	* tidy
 
-2005-09-08 22:28  rsbivand
+2008-04-14 20:33  rsbivand
 
-	* INDEX, R/SpatialPolys-methods.R, R/dotsinpolys.R,
-	  man/dotsInPolys.Rd: dotsinpolys begun
+	* PolySet
 
-2005-09-08 13:11  rsbivand
+2008-04-13 16:47  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/maptools.R, R/shapelib.R: codetools
+	* PBS to SP SID bug
 
-2005-09-05 14:54  rsbivand
+2008-04-10 14:07  rsbivand
 
-	* man/asciigrid.Rd: links
+	* tidy
 
-2005-09-05 11:00  rsbivand
+2008-04-04 17:59  rsbivand
 
-	* DESCRIPTION, NAMESPACE, R/SpatialLines-methods.R,
-	  R/SpatialPoints-methods.R, R/SpatialPolys-methods.R,
-	  R/asciigrid.R, man/asciigrid.Rd, man/readShapeLines.Rd,
-	  man/readShapePoints.Rd, man/readShapePoly.Rd,
-	  man/read_ShapeLines.Rd, man/read_ShapePoints.Rd,
-	  man/read_ShapePoly.Rd: removing _
+	* ABS nulls
 
-2005-09-03 18:19  rsbivand
+2008-04-04 17:59  rsbivand
 
-	* inst/changes, man/read_ShapeLines.Rd, man/read_ShapePoly.Rd:
-	  added ... to degAxis()
+	* ABS nulls
 
-2005-09-02 09:40  rsbivand
+2008-03-30 19:48  rsbivand
 
-	* NAMESPACE, R/asciigrid.R, man/asciigrid.Rd: more asciigrid
+	* GSHHS clip
 
-2005-09-01 20:26  rsbivand
+2008-03-03 21:47  rsbivand
 
-	* inst/: shapes/fylk-val.shp, shapes/fylk-val.shx, grids/simple.ag,
-	  shapes/sids.shp, shapes/sids.shx, grids/test.ag: Initial import.
+	* makegrid
 
-2005-09-01 20:26  rsbivand
+2008-02-09 12:42  rsbivand
 
-	* inst/: shapes/fylk-val.shp, shapes/fylk-val.shx, grids/simple.ag,
-	  shapes/sids.shp, shapes/sids.shx, grids/test.ag: Initial revision
+	* line lengths in help
 
-2005-09-01 20:21  rsbivand
+2008-01-30 20:53  rsbivand
 
-	* R/SpatialPolys-methods.R, man/Map2poly.Rd, man/dotsInPolys.Rd,
-	  man/get.Pcent.Rd, man/holepolys.Rd, man/maptools.Rd,
-	  man/plot.Map.Rd, man/plot.polylist.Rd, man/read.shape.Rd,
-	  man/read_ShapeLines.Rd, man/subset.polylist.Rd,
-	  man/symbolsInPolys.Rd, man/write.linelistShape.Rd,
-	  man/write.pointShape.Rd, man/asciigrid.Rd,
-	  man/read_ShapePoints.Rd, man/read_ShapePoly.Rd,
-	  man/write.polylistShape.Rd, src/Rcentroid.c, src/Rshapeget.c,
-	  src/Rshapeinfo.c, src/Rshapewrite.c, src/insiders.c,
-	  src/maptools.h, src/Rshapewrite1.c, src/shapefil.h,
-	  src/shpopen.c, src/shptree.c, data/gpcholes.rda, inst/LICENSE,
-	  inst/changes, inst/shapes/sids.dbf, src/pip.c,
-	  inst/shapes/baltim.dbf, inst/shapes/baltim.shp,
-	  inst/shapes/baltim.shx, inst/shapes/columbus.dbf,
-	  inst/shapes/fylk-val.dbf, inst/shapes/columbus.shp,
-	  inst/shapes/columbus.shx: Initial import.
-
-2005-09-01 20:21  rsbivand
-
-	* R/SpatialPolys-methods.R, man/Map2poly.Rd, man/dotsInPolys.Rd,
-	  man/get.Pcent.Rd, man/holepolys.Rd, man/maptools.Rd,
-	  man/plot.Map.Rd, man/plot.polylist.Rd, man/read.shape.Rd,
-	  man/read_ShapeLines.Rd, man/subset.polylist.Rd,
-	  man/symbolsInPolys.Rd, man/write.linelistShape.Rd,
-	  man/write.pointShape.Rd, man/asciigrid.Rd,
-	  man/read_ShapePoints.Rd, man/read_ShapePoly.Rd,
-	  man/write.polylistShape.Rd, src/Rcentroid.c, src/Rshapeget.c,
-	  src/Rshapeinfo.c, src/Rshapewrite.c, src/insiders.c,
-	  src/maptools.h, src/Rshapewrite1.c, src/shapefil.h,
-	  src/shpopen.c, src/shptree.c, data/gpcholes.rda, inst/LICENSE,
-	  inst/changes, inst/shapes/sids.dbf, src/pip.c,
-	  inst/shapes/baltim.dbf, inst/shapes/baltim.shp,
-	  inst/shapes/baltim.shx, inst/shapes/columbus.dbf,
-	  inst/shapes/fylk-val.dbf, inst/shapes/columbus.shp,
-	  inst/shapes/columbus.shx: Initial revision
+	* SG creation
+
+2008-01-30 08:26  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 11:36  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 11:00  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 10:37  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 09:52  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 09:03  rsbivand
+
+	* ppp + getinfo
+
+2008-01-29 08:50  rsbivand
+
+	* ppp + getinfo
+
+2008-01-20 15:08  rsbivand
+
+	* pbs to sp
+
+2007-12-13 17:32  rsbivand
+
+	* elide
+
+2007-12-09 18:03  rsbivand
+
+	* elide shift
+
+2007-11-21 22:37  rsbivand
+
+	* elide bug
+
+2007-11-16 09:12  rsbivand
+
+	* GSHHS to 1.5
+
+2007-11-10 13:17  rsbivand
+
+	* assert
+
+2007-10-31 15:43  rsbivand
+
+	* thingy to slot
+
+2007-10-31 13:46  rsbivand
+
+	* thingy to slot
+
+2007-10-23 12:50  rsbivand
+
+	* license
+
+2007-10-10 06:25  rsbivand
+
+	* tidy
+
+2007-10-06 17:38  rsbivand
+
+	* elide first cut
+
+2007-10-06 10:06  rsbivand
+
+	* elide first cut
+
+2007-09-29 16:37  rsbivand
+
+	* pointLabel update
+
+2007-09-26 09:09  rsbivand
+
+	* Ascii Grid dec
+
+2007-09-18 08:19  rsbivand
+
+	* tidy
+
+2007-09-14 20:14  rsbivand
+
+	* Mondrian new format
+
+2007-09-14 06:58  rsbivand
+
+	* pass through max_nchar
+
+2007-09-05 16:09  rsbivand
+
+	* double NA at end of map coords
+
+2007-07-25 08:49  rsbivand
+
+	* 3D polylist, write line shape, owin poly
+
+2007-07-19 19:33  rsbivand
+
+	* 3D polylist writing
+
+2007-06-11 08:05  rsbivand
+
+	* encoding
+
+2007-06-10 21:27  rsbivand
+
+	* encode
+
+2007-06-10 20:47  rsbivand
+
+	* pointLabel
+
+2007-06-05 13:31  rsbivand
+
+	* con correction
+
+2007-05-08 16:35  rsbivand
+
+	* revert spatstat coerce
+
+2007-05-07 08:55  rsbivand
+
+	* tidy
+
+2007-04-28 19:41  rsbivand
+
+	* doc error
+
+2007-04-27 16:37  rsbivand
+
+	* resolve GPS conflict
+
+2007-04-21 04:27  rsbivand
+
+	* GE dimnames
+
+2007-04-16 04:01  rsbivand
+
+	* sp problem and gps
+
+2007-04-16 02:40  rsbivand
+
+	* sp problem and gps
+
+2007-03-29 14:34  rsbivand
+
+	* tidy
+
+2007-03-23 17:50  rsbivand
+
+	* readGPS
+
+2007-02-09 20:09  rsbivand
+
+	* force_ring in readShapePoly
+
+2007-02-01 14:28  rsbivand
+
+	* sun manual tidy
+
+2007-01-21 10:50  rsbivand
+
+	* GE_PNG additions
+
+2007-01-20 21:36  rsbivand
+
+	* GE_PNG additions
+
+2007-01-16 09:39  rsbivand
+
+	* im and sun-methods
+
+2007-01-16 09:23  rsbivand
+
+	* im and sun-methods
+
+2006-12-02 15:38  rsbivand
+
+	* release
+
+2006-11-22 12:03  rsbivand
+
+	* Rgshhs
+
+2006-11-16 14:34  rsbivand
+
+	* bind
+
+2006-10-31 13:07  rsbivand
+
+	* sun and r-spatial integration
+
+2006-10-31 08:31  rsbivand
+
+	* sun and r-spatial integration
+
+2006-10-29 13:53  rsbivand
+
+	* sun ephemerides
+
+2006-10-28 19:56  rsbivand
+
+	* sun ephemerides
+
+2006-10-28 17:23  rsbivand
+
+	* sun ephemerides
+
+2006-10-19 20:03  rsbivand
+
+	* dostInPolys NULL
+
+2006-09-21 19:42  rsbivand
+
+	* R 2.4.0
+
+2006-08-30 14:50  rsbivand
+
+	* pointZ
+
+2006-08-30 07:00  rsbivand
+
+	* pointZ
+
+2006-05-02 07:07  rsbivand
+
+	* Geolytics bug
+
+2006-04-10 19:21  rsbivand
+
+	* fix to sp2WB, readAsciiGrid, writeAsciiGrid
+
+2006-03-20 08:32  rsbivand
+
+	* Mondrian
+
+2006-03-10 12:50  rsbivand
+
+	* sp2Mondrian
+
+2006-03-01 08:53  rsbivand
+
+	* checks on polylists
+
+2006-01-11 11:08  rsbivand
+
+	* tmap
+
+2006-01-10 13:08  rsbivand
+
+	* tmap
+
+2006-01-09 13:33  rsbivand
+
+	* sp2tmap
+
+2006-01-08 21:23  rsbivand
+
+	* adding sp2tmap
+
+2006-01-08 18:34  rsbivand
+
+	* adding sp2tmap
+
+2005-12-15 15:00  rsbivand
+
+	* to 5-4
+
+2005-12-12 21:27  rsbivand
+
+	* sp2WB
+
+2005-10-03 17:44  rsbivand
+
+	* lines bugs
+
+2005-09-14 21:08  rsbivand
+
+	* as at 0.5-2
+
+2005-09-13 17:24  rsbivand
+
+	* remove suggested splancs
+
+2005-09-13 14:53  rsbivand
+
+	* remove suggested splancs
+
+2005-09-09 14:28  rsbivand
+
+	* ... in plot.Map
+
+2005-09-08 20:28  rsbivand
+
+	* dotsinpolys begun
+
+2005-09-08 11:11  rsbivand
+
+	* codetools
+
+2005-09-05 12:54  rsbivand
+
+	* links
+
+2005-09-05 09:00  rsbivand
+
+	* removing _
+
+2005-09-03 16:19  rsbivand
+
+	* added ... to degAxis()
+
+2005-09-02 07:40  rsbivand
+
+	* more asciigrid
 
-2005-09-01 20:18  rsbivand
+2005-09-01 18:26  rsbivand
 
-	* DESCRIPTION, INDEX, LICENSE, NAMESPACE, R/shapelib.R,
-	  R/SpatialLines-methods.R, R/SpatialPoints-methods.R,
-	  R/asciigrid.R, R/colslegs.R, R/dotsinpolys.R, R/maptools.R,
-	  R/maptoolsChanges.R, R/pcent.R, R/plot.Map.R,
-	  R/point.in.polygon.R, R/subset.R, R/zzz.R: Initial import.
+	* Initial revision
 
-2005-09-01 20:18  rsbivand
+2005-09-01 18:26  
 
-	* DESCRIPTION, INDEX, LICENSE, NAMESPACE, R/shapelib.R,
-	  R/SpatialLines-methods.R, R/SpatialPoints-methods.R,
-	  R/asciigrid.R, R/colslegs.R, R/dotsinpolys.R, R/maptools.R,
-	  R/maptoolsChanges.R, R/pcent.R, R/plot.Map.R,
-	  R/point.in.polygon.R, R/subset.R, R/zzz.R: Initial revision
+	* New repository initialized by cvs2svn.
 
diff --git a/inst/changes b/inst/changes
index 5401b65..d16e9d0 100644
--- a/inst/changes
+++ b/inst/changes
@@ -1,37 +1,37 @@
-0.7-14	(see ChangeLog for more details) Depecating direct access to Map objectswhich will be removed from the namespace very soon. Started on merging readShape* and write*Shape functions
-0.7-1	GSHHS binary file reading support changed from release 1.3 to 1.5 and shipped coarse shorelines changed to 1.5, released 3 April 2007
-0.6-19	changed sp access to *apply and slot
-0.6-18	Change shapelib license from MIT to LGPL
-0.6-17	Added gcDestination based on contributions from Eric Archer and a list thread for finding a longlat destination given a longlat starting point and bearing, and elide methods to re-scale, reflect, translate and shift coordinates, permitting their relative positions to be retained but their actual locations to be (moderately) masked; a new version of pointLabel from Tom Short is also included
-0.6-16	pass through max_nchar to write.dbf() - thanks to Don MacQueen, updated sp2Mondrian to new format polygon files (with argument to use old format)
-0.6-15	map2* error when the final two coordintes in the input object are NAs - gambia.borders
-0.6-14	added .spatstat_check hack to "SpatialPolygons" to "owin" coercion, and corrected erroneous code for writing line shapefiles (multiple line segments not handled at all until now); write.polylistShape(..., force=TRUE) now default to set nDims attribute on polylist for passing to 3D polygon shapefile.
-0.6-13	Added pointLabel function contributed by Tom Short
-0.6-9	Added skeleton readGPS function using external gpsbabel through system, thanks to Patrick Giraudoux.
-0.6-7	Added GE_SpatialGrid and kmlOverlay preparation of PNG image overlays for Google Earth made by plotting out using the PNG graphics device, suggested by Duncan Golicher and David Forrest.
-0.6-6	Added im object exchange with spatstat, changed sun ephemerides documentation to single page ?"sun-methods".
-0.6-1	Added sun ephemerides by Sebastian P. Luque. In addition, code from off-CRAN packages on the r-spatial sourceforge repository has been added to maptools. This code includes reading GSHHS shoreline data, importing maps package line and polygon objects to Spatial* formats, importing ArcInfo vector data through the RArcInfo package into Spatial* formats, exporting Spatial* objects tp PBSmapping format, exchanging window and point objects with the spatstat package, and using the gpclib [...]
-0.5-16	Fixed bug in dotsInPolys() for returned NULL point objects.
-0.5-13	Passing through 3rd dimension in reading POINTZ shapefiles (bug report thanks to Michael Toews), POINTZ are also now written for 3D point coordinates.
-0.5-12	Added repair= argument to read.shape(), readShape*() functions, and bug fixes to prevent problems caused by shapefiles with malformed *.shx files; the repair= argument is FALSE by default, equivalent to function behaviour until now, but when TRUE, it tries to repair malformed *.shx files typically found in data provided by Geolytics Inc. Bug report thanks to Jon Wakefield.
-0.5-11	sp2WB now no longer emits 1e5 style coordinates, which WinBUGS cannot read; readAsciiGrid and writeAsciiGrid now have dec= arguments to cater for unusual locale handling in ArcGIS 9 (ArcGIS 8 and ArcView 3.2 read "." even in "," decimal mark locales, ArcGIS 9 is not as predictable); trackAzimuth is a wrapper for gzAzimuth to give directions along a track.
-0.5-9	Added azimuth-finding function, a function to output polygon maps for Mondrian, and made plot.Map deprecated; a fuzz factor has been added to writeAsciiGrid() to force cell resolution to equality if the difference is less than the square root of machine precision.
-0.5-6	Added guard functionality and traps for malformed polylist objects and force= argument to write.polylistShape(), thanks to excellent bug report from Marian Eriksson.
-0.5-5	Added function sp2tmap to create a data frame for export to Stata's tmap function from SpatialPolygons objects
-0.5-4	Added function sp2WB() to write SpatialPolygons objects to file for reading in SPlus format by WinBUGS, added argument to readShapePoly() to insert polygon IDs from DBF file column.
-0.5-2	The suggested dependency on splancs has been removed, and the dotsInPolys() and symbolsInPolys() function have been re-written to use sample.Polygons() from sp. Because sp respects holes, users may find that if polygon rings are taken (wrongly) to be holes, they will not receive any dots/symbols. The examples on the help pages show how to use wrapper package spgpc from the r-spatial repository to remedy this. Also the lwd= argument is now passed through in plot.Map().
-0.5-1	Moved functions from off-CRAN spmaptools to maptools, and introduced dependency on the sp package. The functions reading shapefiles directly into sp class objects will become the principal way of getting vector spatial data into R. Helper functions letting this happen step-by-step are not currently exposed in the maptools namespace, but may be if needed. Simple functions to read and write Arc ASCII grid files have also been added.
-0.4-15	Now using C code for ring direction, area and centroids; following a suggestion by Rick Reeves, read.shapes() now reads type 15 (POLYGONZ) shapefiles - confirmed, and should read types 11 POINTZ and 13 ARCZ. For types 13 and 15, it silently drops the third dimension, for type 11, the returned point has three dimensions.
-0.4-14	relieved 8 character file basename limit on writing shapefiles
-0.4-13	subset.polylist() now accepts both old and new polylists (without and with an area attribute)
-0.4-12	Changed condition in tests from 0-4.9 from any() to all(); the plotting order heuristic in Map2poly is replaced with plotting only in strict decreasing order of top-level (multi)polygon area (thanks to Paul Bivand for reporting a malformed plot order from the previous heuristic, involving one polygon disappearing). In multipolygons, the components are plotted in decreasing area order. The multpolygons themselves are assigned their area sum for plotting order. Ring directions are a [...]
-0.4-11	Adding checks for length() being zero
-0.4-10	Function write.linelistShape() added to output a list of lines to a shapefile, as suggested by Patrick Giraudoux.
-0.4-9	A bug in write.polylistShape() found by Greg Snow, provoked by not checking that numeric attributes were integer, has been resolved - they are now set to the required types.
-0.4-8	Functions dbf.read() and dbf.write() replaced by read.dbf() and write.dbf() in the foreign >= 0.8 package; references now made to those functions and package dependency on foreign (which is a recommended package and so not a problem in the course of time). This version of foreign is new, and so will take time to diffuse.
-0.4-7	The dbf.read() and dbf.write() functions have been revised and added to the user-visible namespace. New functions write.pointShape() and write.polylistShape() using dbf.write() has been added to let data.frames be written as point-type shapefiles, or as polygon-type shapefiles with an S3 polylist object, respectively - all these functions should be treated as alpha-quality until they have been in use for some time; reports on software that reads ESRI-generated shapefiles but does n [...]
-0.4-6	Allow axis labels to be passed through plot.polylist() (thanks to Lukas Meier)
-0.4-5	Corrected C code underlying the reading of DBF files to allow character fields to be arbitrarily wide (bug report Trondheim diamonds with fields over 200 characters wide - buffer overflow from unchecked max width 49); Added access to CHANGELOG through maptools() function.
-0.4-4	Corrected C code for reading SHP/SHX files to reduce danger of mismatched PROTECT/UNPROTECT pairs, and hopefully resolve issues with crashes on Windows platforms in some cases.
-0.4-3	Back out of a too-aggressive heuristic for guessing ring-directions and plot-ordering
-0.4-2	Introduced changes including warnings in Map2poly() and plot.polylist() with regard to rind-direction and plot-order heuristics - Map2poly() tries to determine which polygons and sub-polygons are wholly contained within each other, to note the order in which they should be plotted in plot.polygon() to avoid over-plotting when painting polygons, and, if the raw= argument is FALSE, to correct possible wrong ring directions (lakes are not usually found in the sea etc.). plot.polylist( [...]
+0.7-14	(see ChangeLog for more details) Depecating direct access to Map objectswhich will be removed from the namespace very soon. Started on merging readShape* and write*Shape functions
+0.7-1	GSHHS binary file reading support changed from release 1.3 to 1.5 and shipped coarse shorelines changed to 1.5, released 3 April 2007
+0.6-19	changed sp access to *apply and slot
+0.6-18	Change shapelib license from MIT to LGPL
+0.6-17	Added gcDestination based on contributions from Eric Archer and a list thread for finding a longlat destination given a longlat starting point and bearing, and elide methods to re-scale, reflect, translate and shift coordinates, permitting their relative positions to be retained but their actual locations to be (moderately) masked; a new version of pointLabel from Tom Short is also included
+0.6-16	pass through max_nchar to write.dbf() - thanks to Don MacQueen, updated sp2Mondrian to new format polygon files (with argument to use old format)
+0.6-15	map2* error when the final two coordintes in the input object are NAs - gambia.borders
+0.6-14	added .spatstat_check hack to "SpatialPolygons" to "owin" coercion, and corrected erroneous code for writing line shapefiles (multiple line segments not handled at all until now); write.polylistShape(..., force=TRUE) now default to set nDims attribute on polylist for passing to 3D polygon shapefile.
+0.6-13	Added pointLabel function contributed by Tom Short
+0.6-9	Added skeleton readGPS function using external gpsbabel through system, thanks to Patrick Giraudoux.
+0.6-7	Added GE_SpatialGrid and kmlOverlay preparation of PNG image overlays for Google Earth made by plotting out using the PNG graphics device, suggested by Duncan Golicher and David Forrest.
+0.6-6	Added im object exchange with spatstat, changed sun ephemerides documentation to single page ?"sun-methods".
+0.6-1	Added sun ephemerides by Sebastian P. Luque. In addition, code from off-CRAN packages on the r-spatial sourceforge repository has been added to maptools. This code includes reading GSHHS shoreline data, importing maps package line and polygon objects to Spatial* formats, importing ArcInfo vector data through the RArcInfo package into Spatial* formats, exporting Spatial* objects tp PBSmapping format, exchanging window and point objects with the spatstat package, and using the gpclib [...]
+0.5-16	Fixed bug in dotsInPolys() for returned NULL point objects.
+0.5-13	Passing through 3rd dimension in reading POINTZ shapefiles (bug report thanks to Michael Toews), POINTZ are also now written for 3D point coordinates.
+0.5-12	Added repair= argument to read.shape(), readShape*() functions, and bug fixes to prevent problems caused by shapefiles with malformed *.shx files; the repair= argument is FALSE by default, equivalent to function behaviour until now, but when TRUE, it tries to repair malformed *.shx files typically found in data provided by Geolytics Inc. Bug report thanks to Jon Wakefield.
+0.5-11	sp2WB now no longer emits 1e5 style coordinates, which WinBUGS cannot read; readAsciiGrid and writeAsciiGrid now have dec= arguments to cater for unusual locale handling in ArcGIS 9 (ArcGIS 8 and ArcView 3.2 read "." even in "," decimal mark locales, ArcGIS 9 is not as predictable); trackAzimuth is a wrapper for gzAzimuth to give directions along a track.
+0.5-9	Added azimuth-finding function, a function to output polygon maps for Mondrian, and made plot.Map deprecated; a fuzz factor has been added to writeAsciiGrid() to force cell resolution to equality if the difference is less than the square root of machine precision.
+0.5-6	Added guard functionality and traps for malformed polylist objects and force= argument to write.polylistShape(), thanks to excellent bug report from Marian Eriksson.
+0.5-5	Added function sp2tmap to create a data frame for export to Stata's tmap function from SpatialPolygons objects
+0.5-4	Added function sp2WB() to write SpatialPolygons objects to file for reading in SPlus format by WinBUGS, added argument to readShapePoly() to insert polygon IDs from DBF file column.
+0.5-2	The suggested dependency on splancs has been removed, and the dotsInPolys() and symbolsInPolys() function have been re-written to use sample.Polygons() from sp. Because sp respects holes, users may find that if polygon rings are taken (wrongly) to be holes, they will not receive any dots/symbols. The examples on the help pages show how to use wrapper package spgpc from the r-spatial repository to remedy this. Also the lwd= argument is now passed through in plot.Map().
+0.5-1	Moved functions from off-CRAN spmaptools to maptools, and introduced dependency on the sp package. The functions reading shapefiles directly into sp class objects will become the principal way of getting vector spatial data into R. Helper functions letting this happen step-by-step are not currently exposed in the maptools namespace, but may be if needed. Simple functions to read and write Arc ASCII grid files have also been added.
+0.4-15	Now using C code for ring direction, area and centroids; following a suggestion by Rick Reeves, read.shapes() now reads type 15 (POLYGONZ) shapefiles - confirmed, and should read types 11 POINTZ and 13 ARCZ. For types 13 and 15, it silently drops the third dimension, for type 11, the returned point has three dimensions.
+0.4-14	relieved 8 character file basename limit on writing shapefiles
+0.4-13	subset.polylist() now accepts both old and new polylists (without and with an area attribute)
+0.4-12	Changed condition in tests from 0-4.9 from any() to all(); the plotting order heuristic in Map2poly is replaced with plotting only in strict decreasing order of top-level (multi)polygon area (thanks to Paul Bivand for reporting a malformed plot order from the previous heuristic, involving one polygon disappearing). In multipolygons, the components are plotted in decreasing area order. The multpolygons themselves are assigned their area sum for plotting order. Ring directions are a [...]
+0.4-11	Adding checks for length() being zero
+0.4-10	Function write.linelistShape() added to output a list of lines to a shapefile, as suggested by Patrick Giraudoux.
+0.4-9	A bug in write.polylistShape() found by Greg Snow, provoked by not checking that numeric attributes were integer, has been resolved - they are now set to the required types.
+0.4-8	Functions dbf.read() and dbf.write() replaced by read.dbf() and write.dbf() in the foreign >= 0.8 package; references now made to those functions and package dependency on foreign (which is a recommended package and so not a problem in the course of time). This version of foreign is new, and so will take time to diffuse.
+0.4-7	The dbf.read() and dbf.write() functions have been revised and added to the user-visible namespace. New functions write.pointShape() and write.polylistShape() using dbf.write() has been added to let data.frames be written as point-type shapefiles, or as polygon-type shapefiles with an S3 polylist object, respectively - all these functions should be treated as alpha-quality until they have been in use for some time; reports on software that reads ESRI-generated shapefiles but does n [...]
+0.4-6	Allow axis labels to be passed through plot.polylist() (thanks to Lukas Meier)
+0.4-5	Corrected C code underlying the reading of DBF files to allow character fields to be arbitrarily wide (bug report Trondheim diamonds with fields over 200 characters wide - buffer overflow from unchecked max width 49); Added access to CHANGELOG through maptools() function.
+0.4-4	Corrected C code for reading SHP/SHX files to reduce danger of mismatched PROTECT/UNPROTECT pairs, and hopefully resolve issues with crashes on Windows platforms in some cases.
+0.4-3	Back out of a too-aggressive heuristic for guessing ring-directions and plot-ordering
+0.4-2	Introduced changes including warnings in Map2poly() and plot.polylist() with regard to rind-direction and plot-order heuristics - Map2poly() tries to determine which polygons and sub-polygons are wholly contained within each other, to note the order in which they should be plotted in plot.polygon() to avoid over-plotting when painting polygons, and, if the raw= argument is FALSE, to correct possible wrong ring directions (lakes are not usually found in the sea etc.). plot.polylist( [...]
diff --git a/inst/old_man/Map2poly.Rd b/inst/old_man/Map2poly.Rd
deleted file mode 100644
index 8d4289e..0000000
--- a/inst/old_man/Map2poly.Rd
+++ /dev/null
@@ -1,92 +0,0 @@
-% Copyright 2003 by Roger S. Bivand
-\encoding{latin1}
-\name{Map2poly}
-\alias{Map2poly}
-\alias{Map2poly1}
-\alias{Map2lines}
-\alias{Map2points}
-%\alias{Map2maplim}
-\alias{Map2bbs}
-\alias{MapShapeIds}
-\alias{shape2poly}
-\alias{shape2lines}
-\alias{shape2points}
-%\alias{shp2maplim}
-\alias{shape2bbs}
-\alias{convert.pl}
-%\alias{ringDir}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{Create polygon lists and bounding boxes from imported shapefiles}
-\description{
-  Map2poly() is a function to make imported GIS vector polygons into a "polylist" object from a "Map" object. Map2bbs() retrieves polygon bounding boxes; analogous functions for the "shapefiles" package are shape2poly() and shape2bbs() (thanks to St�phane Dray for his contribution); convert.pl() serves to convert the deprecated "multipart" "polylist" format to an NA-separated format now used by plot() for polylist objects and poly2nb(). 
-%\code{ringDir()} attempts to find out whether polygon ring 
-%coordinates run clockwise (external boundary of polygon object), or 
-%anti-clockwise (internal boundary - hole). 
-\code{*2lines()} and \code{*2points()} do the same as \code{*2poly()} for shapefiles of types 3=lines and 1=points; polygons are type=5.
-}
-\usage{
-Map2poly1(Map, region.id = NULL, raw=TRUE)
-Map2poly(Map, region.id = NULL, quiet=TRUE)
-Map2lines(Map)
-Map2points(Map)
-%Map2maplim(Map)
-Map2bbs(Map)
-MapShapeIds(Map)
-shape2poly(shape, region.id = NULL)
-shape2lines(shape)
-shape2points(shape)
-%shp2maplim(shape)
-shape2bbs(shape)
-convert.pl(pl)
-%ringDir(xy, ring)
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{Map}{object of class \code{"Map"}, imported from a GIS polygon vector file}
-  \item{shape}{list returned by \code{read.shapefile()}, imported from a GIS polygon vector file using the package "shapefiles"}
-  \item{region.id}{character vector of region ids to be added to the neighbours list as attribute \code{region.id}}
-  \item{raw}{default TRUE \emph{until next release}, if TRUE, do not run sanity check for ring directions implying holes in no surrounding polygon}
-  \item{quiet}{if TRUE, suppress reports of ring direction changes}
-  \item{pl}{list of old-style multipart polygons of class \code{polylist}}
-%  \item{xy}{the coordinate object for a single member of a polygon list}
-%  \item{ring}{the ring (one of \code{1:attr(xy, "nParts"))} index number}
-}
-\details{
-  From release 0.4-12, \code{Map2poly} replaces the plotting order heuristic with plotting only in strict decreasing order of top-level (multi)polygon area. In multipolygons, the components are plotted in decreasing area order. The multpolygons themselves are assigned their area sum for plotting order. Ring directions are all set to clockwise - very many shapefiles have been observed with quite unrealistic ring orders, so respecting input ring orders seems worse than imposing uniformity. [...]
-  From release 0.4-1, \code{Map2poly} tries to determine a plotting order for multiple parts of a single polygon object, and for lists of polygon objects to avoid overplotting. It also tries to respect the ESRI-stipulated rule that lakes are anti-clockwise and islands are clockwise: \url{http://shapelib.maptools.org/dl/shapefile.pdf}: "The order of vertices or orientation for a ring indicates which side of the ring is the interior of the polygon. The neighborhood to the right of an obser [...]
-}
-
-\value{
-  \code{Map2poly}, \code{shape2poly}, \code{convert.pl} return polylist objects, lists of polygon boundary coordinates (divided by NA where the polygon object is represented by more than one polygon) with many attributes;
-  \code{Map2lines}, \code{shape2lines} return lineslist objects;
-  \code{Map2points}, \code{shape2points} return (n x 2) matrices; and
-  \code{Map2bbs}, \code{shape2bbs} return bounding box matrixes, c(x1, y1, x2, y2) with coordinates for the lower left corner and upper right corner.
-}
-
-\author{Roger Bivand and St�phane Dray, \email{Roger.Bivand at nhh.no}}
- 
-\seealso{\code{\link{read.shape}}, \code{\link[shapefiles]{shapefiles}}}
-
-
-\examples{
-try2 <- read.shape(system.file("shapes/columbus.shp", package="maptools")[1])
-mappolys <- Map2poly(try2, as.character(try2$att.data$NEIGNO), quiet=FALSE)
-plot(mappolys)
-title(main="Polygons for Columbus OH from maptools package")
-mappolys <- Map2poly1(try2, as.character(try2$att.data$NEIGNO), raw=FALSE)
-plot(mappolys)
-title(main="Polygons for Columbus OH from maptools package")
-try3 <- read.shape(system.file("shapes/baltim.shp", package="maptools")[1])
-baltpts <- Map2points(try3)
-xylims <- attr(baltpts, "maplim")
-plot(xylims$x, xylims$y, asp=1, type='n', xlab="", ylab="")
-points(baltpts)
-title(main="Baltimore points from maptools package")
-try4 <- read.shape(system.file("shapes/fylk-val.shp", package="maptools")[1])
-fylk.val <- Map2lines(try4)
-xylims <- attr(fylk.val, "maplim")
-plot(xylims$x, xylims$y, asp=1, type='n', xlab="", ylab="")
-for (i in 1:length(fylk.val)) lines(fylk.val[[i]])
-title(main="Norwegian river centrelines from maptools package")
-}
-\keyword{spatial}
diff --git a/inst/old_man/get.Pcent.Rd b/inst/old_man/get.Pcent.Rd
deleted file mode 100644
index 12fc920..0000000
--- a/inst/old_man/get.Pcent.Rd
+++ /dev/null
@@ -1,26 +0,0 @@
-\name{get.Pcent}
-\alias{get.Pcent}
-\title{Polygon centroids}
-\description{
-  return the centroids of a map of polygons
-}
-\usage{
-get.Pcent(theMap)
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{theMap}{a Map object returned by read.shape()}
-}
-
-\value{
- a matrix of centroids.
-}
-
-\author{Nicholas J. Lewin-Koh, modified by Roger Bivand \email{Roger.Bivand at nhh.no}}
-
-\examples{
-x <- read.shape(system.file("shapes/sids.shp", package="maptools")[1])
-get.Pcent(x)
-}
-\keyword{spatial}
-
diff --git a/inst/old_man/maptools.Rd b/inst/old_man/maptools.Rd
deleted file mode 100644
index 1294ee9..0000000
--- a/inst/old_man/maptools.Rd
+++ /dev/null
@@ -1,25 +0,0 @@
-\name{maptools}
-\alias{maptools}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{Report version information and changes}
-\description{
-  Access version information and changes
-}
-\usage{
-maptools(changes = FALSE)
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{changes}{If TRUE, reports changes, most recent last}
-}
-
-\value{
-  Invisibly returns the change list, with members version and changes
-  
-}
-\author{Roger Bivand}
-
-\examples{
-maptools(changes=TRUE)
-}
-\keyword{spatial}
diff --git a/inst/old_man/plot.Map.Rd b/inst/old_man/plot.Map.Rd
deleted file mode 100644
index bbfdf62..0000000
--- a/inst/old_man/plot.Map.Rd
+++ /dev/null
@@ -1,58 +0,0 @@
-\name{plot.Map}
-\alias{plot.Map}
-%\alias{color.ramp}
-
-\title{Plot a Map object (deprecated)}
-\description{
-  This function is deprecated. It is difficult to maintain and there are several alternatives, either by converting Map objects to sp class objects or polylist etc. objects. (The function plots a map object directly from the imported shapefile data).
-}
-\usage{
-\method{plot}{Map}(x, recs, auxvar = NULL, add = FALSE, fg = "gray", ol = "black", 
-  prbg = NULL, glyph = 16, color='red', type = "q", nclass = 5, \dots)
-%color.ramp(nclass, color='red', nvec=NULL, type='q')
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{x}{a Map object returned by read.shape()}
-  \item{recs}{a vector with the shapes to plot, if missing defaults to all shapes; if fg is not equal to the length of recs, all fg are set to fg[1]}
-  \item{auxvar}{if the Map has polygon shapes, a variable from which to derive polygon fill colours using the computed class intervals, must be same length as number of shapes}
-  \item{add}{default FALSE, if TRUE add to existing plot}
-  \item{fg}{foreground colour, can be used to pass through point and polygon colours, permitting the built-in class interval calculation to be avoided; if fg is not equal to the length of recs, all fg are set to fg[1]}
-  \item{ol}{line/boundary colour; boundaries may be removed by setting to NA oe "transparent"}
-  \item{prbg}{if not NULL, draw a rectangle around the plot in this colour}
-  \item{glyph}{points plotted as this pch code}
-  \item{color}{base colour for color.ramp(); default "red"}
-  \item{type}{default "q" for quantile classes for color.ramp(), can also be "e" for equal intervals}
-  \item{nclass}{number of classes for class intervals}
-  \item{\dots}{passed through to plotting functions}
-%  \item{color}{default "red"}
-%  \item{nvec}{data vector to convert to class intervals}
-}
-
-\value{
-  If the \code{auxvar} variable is not used, the function returns NULL, otherwise it returns the list constructed by \code{maptools:::color.ramp()} with components:
-  \item{ramp}{vector of colours}
-  \item{col.class}{vector of classes}
-  \item{breaks}{class intervals given as argument to cut}
-}
-
-\author{Nicholas J. Lewin-Koh, modified by Roger Bivand \email{Roger.Bivand at nhh.no}}
-
-\seealso{\code{\link{read.shape}}, \code{\link{readShapePoly}}, \code{\link{readShapeLines}}, \code{\link{readShapePoints}}, \code{\link{getinfo.shape}}}
-\examples{
-\dontrun{
-x <- read.shape(system.file("shapes/sids.shp", package="maptools")[1])
-plot(x)
-nParts <- sapply(x$Shapes, function(x) attr(x, "nPart"))
-table(nParts)
-cols <- c("azure", "blue", "orange")
-fgs <- cols[nParts]
-plot(x, fg=fgs)
-res <- plot(x, auxvar=x$att.data$BIR74)
-str(res)
-res <- plot(x, auxvar=x$att.data$BIR74, type="e")
-str(res)
-}
-}
-\keyword{spatial}
-
diff --git a/inst/old_man/plot.polylist.Rd b/inst/old_man/plot.polylist.Rd
deleted file mode 100644
index adda96b..0000000
--- a/inst/old_man/plot.polylist.Rd
+++ /dev/null
@@ -1,66 +0,0 @@
-% Copyright 2001-4 by Roger S. Bivand
-\name{plot.polylist}
-\alias{plotpolys}
-\alias{plot.polylist}
-\alias{leglabs}
-\title{Plot polygons}
-\description{
-A helper function for plotting polygons in a global bounding box, attempts to handle overplotting internally, holes should be coded by coordinates ordered anti-clockwise. Earlier behaviour requires forcefill=TRUE; this is now default, but will cease to be so from next release. Changes caused by some imported shapefiles data leading to erroneously plotting lakes/islands, and R polygon() overplotting internal polygons. 
-\code{leglabs} makes character strings from the same break points. The \code{plot.polylist()} function may be used as a generic S3 method. NOTE! \code{plotpolys()} DEPRECATED: use generic plot() for polylist objects function instead.
-}
-\usage{
-\method{plot}{polylist}(x, col, border = par("fg"), add = FALSE, xlim=NULL,
- ylim=NULL, xlab = "", ylab = "", xpd = NULL, density = NULL, angle = 45, 
- pbg=NULL, forcefill=TRUE, ...)
-leglabs(vec, under="under", over="over", between="-")
-plotpolys(pl, bb, col = NA, border = par("fg"), add = FALSE, xlim=NULL,
- ylim=NULL, ...)
-}
-
-\arguments{
-  \item{pl, x}{list of polygons of class \code{polylist}}
-  \item{bb}{matrix of polygon bounding boxes - columns are LL(x), LL(y), UR(x), UR(y); note that this argument may be omitted if the polygon list object has an "maplim" attribute, or if both xlim and ylim arguments are given}
-  \item{col}{colurs to use for filling the polygons}
-  \item{border}{the color to draw the border}
-  \item{add}{add to existing plot}
-  \item{xlim, ylim}{numeric of length 2, giving the x and y coordinates ranges}
-  \item{xlab, ylab}{x and y axis labels, default no label}
-  \item{xpd}{(where) should clipping take place?}
-  \item{density}{the density of shading lines, in lines per inch}
-  \item{angle}{the slope of shading lines, given as an angle in degrees (counter-clockwise)}
-  \item{pbg}{colour to be used for hole and background fill, by default NULL (note that par("bg") may be "transparent")}
-  \item{forcefill}{default TRUE \emph{until next release} - fill anyway, if FALSE: believe ring direction as indication of holes/lakes}
-  \item{...}{other arguments passed to plot to set the plot window - not passed to polygon}
-  \item{vec}{vector of break values}
-  \item{under}{character value for under}
-  \item{over}{character value for over}
-  \item{between}{character value for between}
-%  \item{y}{numeric vector to be broken into class intervals}
-%  \item{rightmost.closed}{as in findInterval()}
-%  \item{all.inside}{as in findInterval()}
-}
-\author{Roger Bivand \email{Roger.Bivand at nhh.no}}
-
-\seealso{\code{\link{Map2poly}}, \code{\link{findInterval}}}
-
-\examples{
-try2 <- read.shape(system.file("shapes/columbus.shp", package="maptools")[1])
-mappolys <- Map2poly(try2, as.character(try2$att.data$NEIGNO))
-brks <- round(quantile(try2$att.data$CRIME, probs=seq(0,1,0.2)), digits=2)
-colours <- c("salmon1", "salmon2", "red3", "brown", "black")
-plot(mappolys, col=colours[findInterval(try2$att.data$CRIME, brks,
- all.inside=TRUE)], forcefill=FALSE)
-legend(x=c(5.8, 7.1), y=c(13, 14.5), legend=leglabs(brks),
-  fill=colours, bty="n")
-invisible(title(main=paste("Columbus OH: residential burglaries and vehicle",
- "thefts per thousand households, 1980", sep="\n")))
-try3 <- read.shape(system.file("shapes/sids.shp", package="maptools")[1])
-mappolys <- Map2poly(try3, as.character(try3$att.data$FIPSNO))
-cols <- c("pink", "orange", "red")
-np <- sapply(mappolys, function(x) attr(x, "nParts"))
-plot(mappolys, col=cols[np], forcefill=FALSE)
-invisible(title(main="White: one part, orange: two part, red: three part polygons"))
-plot(mappolys, density=c(10, 20, 30)[np], angle=c(-45, 0, 45)[np],
- axes=FALSE, forcefill=FALSE)
-}
-\keyword{spatial}
diff --git a/inst/old_man/read.shape.Rd b/inst/old_man/read.shape.Rd
deleted file mode 100644
index 214dc08..0000000
--- a/inst/old_man/read.shape.Rd
+++ /dev/null
@@ -1,43 +0,0 @@
-\name{read.shape}
-\alias{read.shape}
-\alias{getinfo.shape}
-\alias{print.shapehead}
-
-\title{Read shapefile into Map object}
-\description{
-  Read shapefile into Map object; the file should be given including its ".shp" extension, and the function will reconstruct the names of the database (dbf) file and the index (shx) file from these.
-}
-\usage{
-read.shape(filen, dbf.data = TRUE, verbose=TRUE, repair=FALSE)
-getinfo.shape(filen)
-\method{print}{shapehead}(x, ...)
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{filen}{name of file with *.shp extension}
-  \item{dbf.data}{read DBF data together with shapes, default TRUE}
-  \item{verbose}{default TRUE --- report type of shapefile and number of shapes}
-  \item{repair}{default FALSE: some shapefiles provided by Geolytics Inc. have values of object sizes stored in the *.shx index file that are eight bytes too large, leading the function to try to read past the end of file. If repair=TRUE, an attempt is made to repair the internal values, permitting such files to be read.}
-  \item{x}{a shapehead list as returned by getinfo.shape}
-  \item{...}{other arguments passed to print}
-}
-\details{
-  The function calls code from shapelib to read shapefiles, a file format used by ESRI GIS software among others
-}
-\value{
-read.shape() returns either a list of shapes of class ShapeList, or if dbf.data = TRUE a Map object with:
-  \item{Shapes}{a list of shapes of class ShapeList; both the individual shapes and the list have attributes}
-  \item{att.data}{a data frame of data from the associated DBF file; note that the field names are adjusted to use in R using \code{make.names()}, and so will permit the underscore character from R release 1.9.0.}
-}
-\references{\url{http://shapelib.maptools.org/}}
-\author{Nicholas J. Lewin-Koh, modified by Roger Bivand \email{Roger.Bivand at nhh.no}; shapelib by Frank Warmerdam}
-
-\seealso{\code{\link{plot.Map}}, \code{\link[foreign]{read.dbf}}}
-\examples{
-x <- read.shape(system.file("shapes/sids.shp", package="maptools")[1])
-length(x$Shapes)
-unlist(lapply(x$att.data, class))
-str(getinfo.shape(system.file("shapes/fylk-val.shp", package="maptools")[1]))
-}
-\keyword{spatial}
-
diff --git a/inst/old_man/subset.polylist.Rd b/inst/old_man/subset.polylist.Rd
deleted file mode 100644
index 6982bee..0000000
--- a/inst/old_man/subset.polylist.Rd
+++ /dev/null
@@ -1,33 +0,0 @@
-% Copyright 2003 by Roger S. Bivand
-\name{subset.polylist}
-\alias{subset.polylist}
-\title{Subset polygon list objects}
-\description{
-  The function subsets a polygon list object, also subsetting region ID attributes and also map limits if required.
-}
-\usage{
-\method{subset}{polylist}(x, subset, fit.bbox = TRUE, ...)
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{x}{a polylist object}
-  \item{subset}{a logical vector valued TRUE if the element is to be retained}
-  \item{fit.bbox}{if TRUE (default) modifies the maplim attribute to bound the subset}
-  \item{...}{other arguments passed through}
-}
-
-\value{
-  returns a polylist object, lists of polygon boundary coordinates (divided by NA where the polygon object is represented by more than one polygon);
-}
-
-\author{Roger Bivand \email{Roger.Bivand at nhh.no}}
-
-\examples{
-nc <- read.shape(system.file("shapes/sids.shp", package = "maptools")[1])
-mappolys <- Map2poly(nc, as.character(nc$att.data$FIPSNO))
-submap <- subset(mappolys, nc$att.data$SID74 > 0)
-plot(mappolys, col="orange")
-plot(submap, add=TRUE, col="lightpink", forcefill=TRUE)
-}
-\keyword{spatial}
-
diff --git a/inst/old_man/write.linelistShape.Rd b/inst/old_man/write.linelistShape.Rd
deleted file mode 100644
index dccd172..0000000
--- a/inst/old_man/write.linelistShape.Rd
+++ /dev/null
@@ -1,48 +0,0 @@
-\name{write.linelistShape}
-\alias{write.linelistShape}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{Write a arc-type shapefile}
-\description{
-  The function calls code from shapelib to write an arc-type shapefile from a list of matrices of line coordinates with no NAs.
-}
-\usage{
-write.linelistShape(linelist, df, file, factor2char = TRUE,
- strictFilename=FALSE, max_nchar=254)
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{linelist}{a list of matrices of line coordinates}
-  \item{df}{a data frame object}
-  \item{file}{a file name of maximum 8 chararacters, numbers or the underscore symbol to be written, omitting the extensions *.shp, *.shx and *.dbf, which are added in the function}
-  \item{factor2char}{logical, default TRUE, convert factor columns to character}
-  \item{strictFilename}{if TRUE, impose file basename length limit of 8 characters}
-  \item{max_nchar}{default 254, may be set to a higher limit and passed through to the DBF writer, please see Details in \code{\link[foreign]{write.dbf}}}
-}
-\details{
-  The function calls code from shapelib to write an arc-type shapefile (both the geometry file with a *.shp extension, the index file with a *.shx extension, and the database file with a *.dbf extension - see \code{\link[foreign]{write.dbf}} for details of the data frame export within this function.
-}
-\value{
-  no return value.
-}
-\references{\url{http://shapelib.maptools.org/}}
-\author{Nicholas J. Lewin-Koh, modified by Roger Bivand; shapelib by Frank Warmerdam}
-\note{From maptools 0.4-10, this function is placed in the user-visible namespace on a trial basis, and reports of any malfunction should be sent to the package maintainer, Roger Bivand \email{Roger.Bivand at nhh.no}. It is likely that this function and its arguments will be changed.}
-
-\seealso{\code{\link{write.pointShape}}, \code{\link[foreign]{write.dbf}}}
-\examples{
-x <- 10 * 1:nrow(volcano)
-y <- 10 * 1:ncol(volcano)
-line.list <- contourLines(x, y, volcano)
-vol.levels <- data.frame(alt=sapply(line.list, function(x) x[[1]]))
-vol.ll <- lapply(line.list, function(x) cbind(x$x, x$y))
-for (i in seq(along=vol.ll)) {
-  attr(vol.ll[[i]], "nParts") <- as.integer(1)
-  attr(vol.ll[[i]], "pstart") <- list(as.integer(1),
-    as.integer(nrow(vol.ll[[i]])))
-}
-tmpshp <- paste(tempdir(), "volcano", sep="/")
-write.linelistShape(vol.ll, vol.levels, file=tmpshp)
-try1 <- readShapeLines(tmpshp)
-plot(try1)
-}
-\keyword{spatial}
diff --git a/inst/old_man/write.pointShape.Rd b/inst/old_man/write.pointShape.Rd
deleted file mode 100644
index 42df421..0000000
--- a/inst/old_man/write.pointShape.Rd
+++ /dev/null
@@ -1,48 +0,0 @@
-\name{write.pointShape}
-\alias{write.pointShape}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{Write a point-type shapefile}
-\description{
-  The function calls code from shapelib to write a point-type shapefile.
-}
-\usage{
-write.pointShape(coordinates, df, file, factor2char = TRUE,
- strictFilename=FALSE, max_nchar=254)
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{coordinates}{a 2-column numeric matrix of coordinates}
-  \item{df}{a data frame object}
-  \item{file}{a file name of maximum 8 chararacters, numbers or the underscore symbol to be written, omitting the extensions *.shp, *.shx and *.dbf, which are added in the function}
-  \item{factor2char}{logical, default TRUE, convert factor columns to character}
-  \item{strictFilename}{if TRUE, impose file basename length limit of 8 characters}
-  \item{max_nchar}{default 254, may be set to a higher limit and passed through to the DBF writer, please see Details in \code{\link[foreign]{write.dbf}}}
-}
-
-\details{
-  The function calls code from shapelib to write a point-type shapefile (both the geometry file with a *.shp extension, the index file with a *.shx extension, and the database file with a *.dbf extension - see \code{\link[foreign]{write.dbf}} for details of the data frame export within this function.
-}
-\value{
-  no return value.
-}
-
-\references{\url{http://shapelib.maptools.org/}}
-
-\author{Nicholas J. Lewin-Koh, modified by Roger Bivand; shapelib by Frank Warmerdam}
-
-\note{From maptools 0.4-7, this function is placed in the user-visible namespace on a trial basis, and reports of any malfunction should be sent to the package maintainer, Roger Bivand \email{Roger.Bivand at nhh.no}. It is likely that this function and its arguments will be changed.}
-
-\seealso{\code{\link[foreign]{write.dbf}}}
-\examples{
-balt_orig <- readShapePoints(system.file("shapes/baltim.shp", package="maptools")[1])
-plot(balt_orig)
-balt_cheap <- balt_orig[balt_orig$PRICE < 40,]
-file <- tempfile("")
-write.pointShape(coordinates=coordinates(balt_cheap),
- df=as(balt_cheap, "data.frame"), file)
-getinfo.shape(paste(file, ".shp", sep=""))
-balt_new <- readShapePoints(paste(file, ".shp", sep=""))
-plot(balt_new, col="red", pch=16, add=TRUE)
-}
-\keyword{spatial}
-
diff --git a/inst/old_man/write.polylistShape.Rd b/inst/old_man/write.polylistShape.Rd
deleted file mode 100644
index 2b123a5..0000000
--- a/inst/old_man/write.polylistShape.Rd
+++ /dev/null
@@ -1,50 +0,0 @@
-\name{write.polylistShape}
-\alias{write.polylistShape}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{Write a polygon-type shapefile}
-\description{
-  The function calls code from shapelib to write a polygon-type shapefile from an S3 polylist object.
-}
-\usage{
-write.polylistShape(polylist, df, file, factor2char = TRUE,
- strictFilename=FALSE, force = TRUE, max_nchar=254)
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{polylist}{list of polygons of class \code{polylist}}
-  \item{df}{a data frame object}
-  \item{file}{a file name of maximum 8 chararacters, numbers or the underscore symbol to be written, omitting the extensions *.shp, *.shx and *.dbf, which are added in the function}
-  \item{factor2char}{logical, default TRUE, convert factor columns to character}
-  \item{strictFilename}{if TRUE, impose file basename length limit of 8 characters}
-  \item{force}{default TRUE, to try to force malformed polylist objects to some reasonable form that will not cause both maptools and R to crash. Because polylist objects are old-style rather than new-style classes, it is possible to crash R by trying to write malformed objects. Attempts are made to check for known problems, but using polylist objects rather than sp SpatialPolygons objects is known to be more risky. From release 0.6-14, polylist objects will be given an nDims attribute a [...]
-  \item{max_nchar}{default 254, may be set to a higher limit and passed through to the DBF writer, please see Details in \code{\link[foreign]{write.dbf}}}
-}
-\details{
-  The function calls code from shapelib to write a polygon-type shapefile (both the geometry file with a *.shp extension, the index file with a *.shx extension, and the database file with a *.dbf extension - see \code{\link[foreign]{write.dbf}} for details of the data frame export within this function.
-}
-\value{
-  no return value.
-}
-\references{\url{http://shapelib.maptools.org/}}
-
-\author{Nicholas J. Lewin-Koh, modified by Roger Bivand; shapelib by Frank Warmerdam}
-
-\note{From maptools 0.4-7, this function is placed in the user-visible namespace on a trial basis, and reports of any malfunction should be sent to the package maintainer, Roger Bivand \email{Roger.Bivand at nhh.no}. It is likely that this function and its arguments will be changed.}
-
-\seealso{\code{\link{write.pointShape}}, \code{\link[foreign]{write.dbf}}}
-\examples{
-col_orig <- read.shape(system.file("shapes/columbus.shp", package="maptools")[1])
-mappolys <- Map2poly(col_orig, as.character(col_orig$att.data$NEIGNO))
-plot(mappolys)
-col_df <- col_orig$att.data
-col_cheap <- subset(mappolys, col_df$HOVAL < 34)
-col_df_cheap <- subset(col_df, col_df$HOVAL < 34)
-file <- tempfile("")
-write.polylistShape(col_cheap, col_df_cheap, file)
-getinfo.shape(paste(file, ".shp", sep=""))
-col_new <- read.shape(paste(file, ".shp", sep=""))
-mappolys <- Map2poly(col_new, as.character(col_new$att.data$NEIGNO))
-plot(mappolys, border="red", add=TRUE)
-}
-\keyword{spatial}
-
diff --git a/inst/share/gshhs_c.b b/inst/share/gshhs_c.b
index bf2c031..20a17bb 100644
Binary files a/inst/share/gshhs_c.b and b/inst/share/gshhs_c.b differ
diff --git a/inst/share/wdb_borders_c.b b/inst/share/wdb_borders_c.b
index c535c8d..3c05f58 100644
Binary files a/inst/share/wdb_borders_c.b and b/inst/share/wdb_borders_c.b differ
diff --git a/man/Rgshhs.Rd b/man/Rgshhs.Rd
index abe6705..7eb6839 100644
--- a/man/Rgshhs.Rd
+++ b/man/Rgshhs.Rd
@@ -1,17 +1,26 @@
 \name{Rgshhs}
 \alias{Rgshhs}
+\alias{getRgshhsMap}
 %- Also NEED an '\alias' for EACH other topic documented here.
 \title{Read GSHHS data into sp object}
 \description{
-  If the data are polygon data, the function will read GSHHS polygons into SpatialPolygons object for a chosen region, using binary shorelines from Global Self-consistant Hierarchical High-resolution Shorelines, release 2.0 of July 15, 2009 (\url{ftp://ftp.soest.hawaii.edu/pwessel/gshhs/gshhs_2.0.zip}). If the data are line data, the borders or river lines will be read into a SpatialLines object. The data are provided in integer form as millionths of decimal degrees. Reading of much earl [...]
+  If the data are polygon data, the function will read GSHHS polygons into SpatialPolygons object for a chosen region, using binary shorelines from Global Self-consistant Hierarchical High-resolution Shorelines, release 2.2.0 of July 15, 2011 (\url{ftp://ftp.soest.hawaii.edu/pwessel/gshhs/gshhs+wdbii_2.2.0.tbz}). 
+
+The \code{getRgshhsMap} function calls \code{Rgshhs} internally to simplify the interface by returning only a SpatialPolygons object rather than a more complex list, and by calling \code{Rgshhs} twice either side of longitude 0 degrees for values of \dQuote{xlim} straddling 0, then merging the polygons retrieved.
+
+If the data are line data, the borders or river lines will be read into a SpatialLines object. The data are provided in integer form as millionths of decimal degrees. Reading of much earlier versions of the GSHHS binary files will fail with an error message. The netCDF GSHHS files distributed with GMT >= 4.2 cannot be read as they are in a very different format.
 }
 \usage{
-Rgshhs(fn, xlim = NULL, ylim = NULL, level = 4, minarea = 0, shift=FALSE, 
-verbose = TRUE, no.clip = FALSE)
+Rgshhs(fn, xlim = NULL, ylim = NULL, level = 4, minarea = 0, shift = FALSE, 
+verbose = TRUE, no.clip = FALSE, properly=FALSE, avoidGEOS=FALSE, 
+checkPolygons=FALSE)
+getRgshhsMap(fn = system.file("share/gshhs_c.b", package= "maptools"),
+ xlim, ylim, level = 1, shift = TRUE, verbose = TRUE, no.clip = FALSE,
+ properly=FALSE, avoidGEOS=FALSE, checkPolygons=FALSE)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
-  \item{fn}{filename or full path to GSHHS 2.0 file to be read}
+  \item{fn}{filename or full path to GSHHS 2.2.0 file to be read}
   \item{xlim}{longitude limits within 0-360 in most cases, negative longitudes are also found east of the Atlantic, but the Americas are recorded as positive values}
   \item{ylim}{latitude limits}
   \item{level}{maximum GSHHS level to include, defaults to 4 (everything), setting 1 will only retrieve land, no lakes}
@@ -19,6 +28,9 @@ verbose = TRUE, no.clip = FALSE)
   \item{shift}{default FALSE, can be used to shift longitudes > 180 degrees to below zero, beware of artefacts involving unhandled polygon splitting at 180 degrees}
   \item{verbose}{default TRUE, print progress reports}
   \item{no.clip}{default FALSE, if TRUE, do not clip output polygons to bounding box}
+  \item{properly}{default FALSE, if TRUE use \code{\link[rgeos]{gContainsProperly}} rather than \code{\link[rgeos]{gContains}}, here FALSE because clip rectangle touches clipped objects, so they are not properly contained}
+  \item{avoidGEOS}{default FALSE; if TRUE force use of \pkg{gpclib} even when \pkg{rgeos} is available}
+  \item{checkPolygons}{default FALSE, if TRUE, check using GEOS, which may re-order the member Polygon objects with respect to the returned polydata data frame rows}
 }
 
 \details{
@@ -31,10 +43,11 @@ verbose = TRUE, no.clip = FALSE)
   \item{belongs}{a matrix showing which polygon belongs to (is included in) which polygon, going from the highest level among the selected polygons down to 1 (land); levels are: 1 land, 2 lake, 3 island\_in\_lake, 4 pond\_in\_island\_in\_lake.}
   \item{new_belongs}{a ragged list of polygon inclusion used for making SP}
   \item{SP}{a SpatialPolygons object; this is the principal output object, and will become the only output object as the package matures}
+  the \code{getRgshhsMap} returns only a SpatialPolygons object;
   for line data, a list with the following component:
   \item{SP}{a SpatialLines object}
 }
-\references{\url{http://www.soest.hawaii.edu/pwessel/gshhs/index.html}, \url{ftp://ftp.soest.hawaii.edu/pwessel/gshhs/gshhs_2.0.zip}; Wessel, P., and W. H. F. Smith, A Global Self-consistent, Hierarchical, High-resolution Shoreline Database, J. Geophys. Res., 101, 8741-8743, 1996.}
+\references{\url{http://www.soest.hawaii.edu/pwessel/gshhs/index.html}, \url{ftp://ftp.soest.hawaii.edu/pwessel/gshhs/gshhs+wdbii_2.2.0.tbz}; Wessel, P., and W. H. F. Smith, A Global Self-consistent, Hierarchical, High-resolution Shoreline Database, J. Geophys. Res., 101, 8741-8743, 1996.}
 \author{Roger Bivand}
 
 \note{
@@ -45,9 +58,12 @@ By default, if the rgeos package is available, it is used for topology operation
 }
 
 \examples{
-gpclibPermit()
-require(gpclib)
+if (!rgeosStatus()) gpclibPermit()
 gshhs.c.b <- system.file("share/gshhs_c.b", package="maptools")
+WEx <- c(-12, 3)
+WEy <- c(48, 59)
+WE <- getRgshhsMap(gshhs.c.b, xlim=WEx, ylim=WEy)
+plot(WE, col="khaki", xlim=WEx, ylim=WEy, xaxs="i", yaxs="i", axes=TRUE)
 NZx <- c(160,180)
 NZy <- c(-50,-30)
 NZ <- Rgshhs(gshhs.c.b, xlim=NZx, ylim=NZy)
@@ -63,6 +79,9 @@ BNLp <- Rgshhs(gshhs.c.b, xlim=BNLx, ylim=BNLy)
 BNLl <- Rgshhs(wdb_lines, xlim=BNLx, ylim=BNLy)
 plot(BNLp$SP, col="khaki", pbg="azure2", xlim=BNLx, ylim=BNLy, xaxs="i", yaxs="i", axes=TRUE)
 lines(BNLl$SP)
+xlims <- c(0,360)
+ylims <- c(-90,90)
+world <- Rgshhs(gshhs.c.b, xlim=xlims, ylim=ylims, level=1, checkPolygons=TRUE)
 }
 \keyword{spatial}
 
diff --git a/man/SpatialLines2PolySet.Rd b/man/SpatialLines2PolySet.Rd
index 41741fd..8de5473 100644
--- a/man/SpatialLines2PolySet.Rd
+++ b/man/SpatialLines2PolySet.Rd
@@ -32,8 +32,8 @@ PolySet2SpatialPolygons(PS, close_polys=TRUE)
 \seealso{\code{\link[PBSmapping]{PolySet}}, \code{\link{MapGen2SL}}}
 
 \examples{
-library(PBSmapping)
-library(maps)
+if(require(PBSmapping)) {
+if(require(maps)) {
 nor_coast_lines <- map("world", interior=FALSE, plot=FALSE, xlim=c(4,32),
  ylim=c(58,72))
 nor_coast_lines <- pruneMap(nor_coast_lines, xlim=c(4,32), ylim=c(58,72))
@@ -54,6 +54,7 @@ summary(nor_coast_poly_PS)
 plotPolys(nor_coast_poly_PS)
 o1 <- PolySet2SpatialPolygons(nor_coast_poly_PS)
 plot(o1, axes=TRUE)
+}}
 }
 \keyword{spatial}
 
diff --git a/man/SpatialLinesMidPoints.Rd b/man/SpatialLinesMidPoints.Rd
new file mode 100644
index 0000000..57e2606
--- /dev/null
+++ b/man/SpatialLinesMidPoints.Rd
@@ -0,0 +1,34 @@
+\name{SpatialLinesMidPoints}
+\alias{SpatialLinesMidPoints}
+%- Also NEED an '\alias' for EACH other topic documented here.
+\title{Line midpoints}
+\description{
+The function onverts SpatialLinesDataFrame to SpatialPointsDataFrame with points at the midpoints of the line segments.
+}
+\usage{
+SpatialLinesMidPoints(sldf)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+  \item{sldf}{A SpatialLines or SpatialLinesDataFrame object}
+}
+\details{
+The function builds a SpatialPointsDataFrame from the midpoints of Line objects belonging to Lines objects in an object inheriting from a Spatial Lines object. The output data slot contains an index variable showing which Lines object the midpoints belong to.
+}
+
+\value{
+  A SpatialPointsDataFrame object created from the input object.
+}
+
+\author{Jonathan Callahan, modified by Roger Bivand}
+
+\examples{
+xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1],
+ proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
+plot(xx, col="blue")
+spdf <- SpatialLinesMidPoints(xx)
+plot(spdf, col="orange", add=TRUE)
+}
+
+\keyword{spatial}
+
diff --git a/man/SplashDams.Rd b/man/SplashDams.Rd
new file mode 100644
index 0000000..745c64c
--- /dev/null
+++ b/man/SplashDams.Rd
@@ -0,0 +1,37 @@
+\name{SplashDams}
+\alias{SplashDams}
+\docType{data}
+\title{Data for Splash Dams in western Oregon}
+\description{
+Data for Splash Dams in western Oregon
+}
+\usage{data(SplashDams)}
+\format{
+  The format is:
+Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
+  ..@ data       :'data.frame':	232 obs. of  6 variables:
+  .. ..$ streamName  : Factor w/ 104 levels "Abiqua Creek",..: 12 12 60 60 60 49 49 9 9 18 ...
+  .. ..$ locationCode: Factor w/ 3 levels "h","l","m": 1 1 1 1 1 1 1 1 1 1 ...
+  .. ..$ height      : int [1:232] 4 4 NA NA NA NA 10 NA NA NA ...
+  .. ..$ lastDate    : int [1:232] 1956 1956 1957 1936 1936 1929 1909 1919 1919 1919 ...
+  .. ..$ owner       : Factor w/ 106 levels "A. Stefani","A.H. Blakesley",..: 42 42 42 84 84 24 24 25 25 25 ...
+  .. ..$ datesUsed   : Factor w/ 118 levels "?-1870s-1899-?",..: 92 92 93 91 91 72 61 94 94 94 ...
+  ..@ coords.nrs : num(0) 
+  ..@ coords     : num [1:232, 1:3] -124 -124 -124 -124 -124 ...
+  .. ..- attr(*, "dimnames")=List of 2
+  .. .. ..$ : NULL
+  .. .. ..$ : chr [1:3] "coords.x1" "coords.x2" "coords.x3"
+  ..@ bbox       : num [1:3, 1:2] -124.2 42.9 0 -122.4 46.2 ...
+  .. ..- attr(*, "dimnames")=List of 2
+  .. .. ..$ : chr [1:3] "coords.x1" "coords.x2" "coords.x3"
+  .. .. ..$ : chr [1:2] "min" "max"
+  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
+  .. .. ..@ projargs: chr " +proj=longlat +ellps=WGS84"
+}
+\source{R. R. Miller (2010) Is the Past Present? Historical Splash-dam Mapping and Stream Disturbance Detection in the Oregon Coastal Province. MSc. thesis, Oregon State University; packaged by Jonathan Callahan}
+\references{\url{http://www.fs.fed.us/pnw/lwm/aem/docs/burnett/miller_rebecca_r2010rev.pdf}}
+\examples{
+data(SplashDams)
+plot(SplashDams, axes=TRUE)
+}
+\keyword{datasets}
diff --git a/man/as.ppp.Rd b/man/as.ppp.Rd
index f3f565e..11e92f1 100644
--- a/man/as.ppp.Rd
+++ b/man/as.ppp.Rd
@@ -24,6 +24,8 @@
 \alias{coerce,Lines,psp-method}
 \alias{coerce,SpatialLines,psp-method}
 \alias{coerce,SpatialLinesDataFrame,psp-method}
+\alias{as.SpatialLines.psp}
+\alias{coerce,psp,SpatialLines-method}
 \alias{coerce,im,SpatialGridDataFrame-method}
 \alias{coerce,ppp,SpatialGridDataFrame-method}
 \alias{coerce,ppp,SpatialPointsDataFrame-method}
@@ -45,6 +47,7 @@ S4-style as() coercion works between objects of S4 sp classes to spatstat S3 cla
 \item{coerce}{\code{signature(from = "Lines", to = "psp")}}
 \item{coerce}{\code{signature(from = "SpatialLines", to = "psp")}}
 \item{coerce}{\code{signature(from = "SpatialLinesDataFrame", to = "psp")}}
+\item{coerce}{\code{signature(from = "psp", to = "SpatialLines")}}
 \item{coerce}{\code{signature(from = "SpatialGridDataFrame", to = "ppp")}}
 \item{coerce}{\code{signature(from = "SpatialPolygons", to = "owin")}}
 \item{coerce}{\code{signature(from = "SpatialPixelsDataFrame", to = "owin")}}
@@ -66,8 +69,10 @@ as.SpatialGridDataFrame.ppp(from)
 as.SpatialGridDataFrame.im(from)
 as.psp.Line(from, ..., window=NULL, marks=NULL, fatal)
 as.psp.Lines(from, ..., window=NULL, marks=NULL, fatal)
-as.psp.SpatialLines(from, ..., window=NULL, marks=NULL, fatal)
+as.psp.SpatialLines(from, ..., window=NULL, marks=NULL, characterMarks
+                 = FALSE, fatal)
 as.psp.SpatialLinesDataFrame(from, ..., window=NULL, marks=NULL, fatal)
+as.SpatialLines.psp(from)
 as.SpatialPolygons.tess(x)
 as.SpatialPolygons.owin(x)
 }
@@ -76,6 +81,7 @@ as.SpatialPolygons.owin(x)
   \item{...}{other arguments to be passed through}
   \item{window}{window as defined in the spatstat package}
   \item{marks}{marks as defined in the spatstat package}
+  \item{characterMarks}{default FALSE, if TRUE, do not convert NULL narks to factor from character}
   \item{fatal}{formal coercion argument}
 }
 \note{When coercing a SpatialPolygons object to an owin object, full 
@@ -83,7 +89,7 @@ topology checking is enabled by default. To avoid checking, set
 \code{spatstat.options(checkpolygons=FALSE)} (from spatstat (1.14-6)). 
 To perform the checking later, \code{owinpolycheck(W, verbose=TRUE)}.}
 
-\author{Edzer Pebesma \email{e.pebesma at geo.uu.nl}, Roger Bivand}
+\author{Edzer Pebesma \email{edzer.pebesma at uni-muenster.de}, Roger Bivand}
 \examples{
 library(spatstat)
 data(meuse)
@@ -109,6 +115,15 @@ mr <- Line(meuse.riv)
 mr_psp <- as(mr, "psp")
 mr_psp
 plot(mr_psp)
+xx_back <- as(mr_psp, "SpatialLines")
+plot(xx_back)
+xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1],
+ proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
+xx_psp <- as(xx, "psp")
+xx_psp
+plot(xx_psp)
+xx_back <- as(xx_psp, "SpatialLines")
+plot(xx_back)
 mg_owin <- as(as(meuse.grid["ffreq"], "SpatialPixelsDataFrame"), "owin")
 mg_owin
 ho_sp <- SpatialPolygons(list(Polygons(list(Polygon(cbind(c(0,1,1,0,0),
@@ -127,7 +142,7 @@ all.equal(ho_sp, ho_sp1, check.attributes=FALSE)
 A <- tess(xgrid=0:4,ygrid=0:4)
 A_sp <- as(A, "SpatialPolygons")
 plot(A_sp)
-text(coordinates(A_sp), sapply(slot(A_sp, "polygons"), slot, "ID"), cex=0.6)
+text(coordinates(A_sp), labels=row.names(A_sp), cex=0.6)
 mg_dist <- meuse.grid["dist"]
 fullgrid(mg_dist) <- TRUE
 image(mg_dist, axes=TRUE)
diff --git a/man/asciigrid.Rd b/man/asciigrid.Rd
index a8283f2..6407430 100644
--- a/man/asciigrid.Rd
+++ b/man/asciigrid.Rd
@@ -34,7 +34,7 @@ to write the numeric data }
 }
 \note{In ArcGIS 8, it was not in general necessary to set the \code{dec} argument; it is not necessary in a mixed environment with ArcView 3.2 (R writes and ArcView reads "."), but inter-operation with ArcGIS 9 requires care because the defaults used by ArcGIS seem to be misleading, and it may be necessary to override what appear to be platform defaults by setting the argument.}
 \seealso{ \code{\link[sp]{image}}, \code{\link[graphics]{image}} }
-\author{Edzer J.\ Pebesma, e.pebesma at geo.uu.nl}
+\author{Edzer Pebesma, edzer.pebesma at uni-muenster.de}
 \examples{
 x <- readAsciiGrid(system.file("grids/test.ag", package="maptools")[1])
 summary(x)
diff --git a/man/checkPolygonsHoles.Rd b/man/checkPolygonsHoles.Rd
index d4ad60e..1507ae2 100644
--- a/man/checkPolygonsHoles.Rd
+++ b/man/checkPolygonsHoles.Rd
@@ -9,7 +9,7 @@
   The function checks holes in Polygons objects. Use of the rgeos package functions is prefered, and if rgeos is available, they will be used automatically. In this case, member Polygon objects are checked against each other for containment, and the returned Polygons object has component hole slots set appropriately. In addition, the output Polygons object may be provided with a comment string, encoding the external and internal rings. For gpclib use, see details below.
 }
 \usage{
-checkPolygonsHoles(x)
+checkPolygonsHoles(x, properly=TRUE, avoidGEOS=FALSE, useSTRtree=FALSE)
 gpclibPermitStatus()
 gpclibPermit()
 rgeosStatus()
@@ -17,6 +17,9 @@ rgeosStatus()
 %- maybe also 'usage' for other objects documented here.
 \arguments{
   \item{x}{An Polygons object as defined in package sp}
+  \item{properly}{default TRUE, use \code{\link[rgeos]{gContainsProperly}} rather than \code{\link[rgeos]{gContains}}}
+  \item{avoidGEOS}{default FALSE; if TRUE force use of \pkg{gpclib} even when \pkg{rgeos} is available}
+  \item{useSTRtree}{default FALSE, if TRUE, use \pkg{rgeos} STRtree in checking holes, which is much faster, but uses a lot of memory and does not release it on completion (work in progress)}
 }
 \details{
 If the gpclib package is used, an intersection between a gpc.poly object with one or more polygon contours and its bounding box is used to set the hole flag. The function will set single polygon contours to hole=FALSE, and if multiple polygon contours are holes, will set them TRUE. The \code{gpclibPermit} function is used to choose to permit the use of gpclib if installed, and \code{gpclibPermitStatus} reports its status. The licence for gpclib is not Free or Open Source and explicitly f [...]
@@ -26,9 +29,9 @@ If the gpclib package is used, an intersection between a gpc.poly object with on
 }
 
 \author{Roger Bivand}
-%\seealso{\code{\link[rgeos]{checkPolygonsGEOS}}}
+%\seealso{\code{\link[rgeos]{createPolygonsComment}}, \code{\link[rgeos]{gIsValid}}, \code{\link[rgeos]{gEquals}}, \code{\link[rgeos]{gContainsProperly}}}
 \examples{
-gpclibPermit()
+if (!rgeosStatus()) gpclibPermit()
 nc1 <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
  proj4string=CRS("+proj=longlat +ellps=clrk66"))
 pl <- slot(nc1, "polygons")
@@ -53,15 +56,47 @@ sapply(slot(res, "Polygons"), function(x) slot(x, "hole"))
 opar <- par(mfrow=c(1,2))
 SPx <- SpatialPolygons(list(x))
 plot(SPx)
-text(coordinates(SPx),
+text(t(sapply(slot(x, "Polygons"), function(i) slot(i, "labpt"))),
  labels=sapply(slot(x, "Polygons"), function(i) slot(i, "hole")), cex=0.6)
 title(xlab="Hole slot values before checking")
 SPres <- SpatialPolygons(list(res))
 plot(SPres)
-text(coordinates(SPres),
+text(t(sapply(slot(res, "Polygons"), function(i) slot(i, "labpt"))),
  labels=sapply(slot(res, "Polygons"), function(i) slot(i, "hole")), cex=0.6)
 title(xlab="Hole slot values after checking")
 par(opar)
+p1 <- Polygon(cbind(x=c(0, 0, 10, 10, 0), y=c(0, 10, 10, 0, 0))) # I
+p2 <- Polygon(cbind(x=c(3, 3, 7, 7, 3), y=c(3, 7, 7, 3, 3))) # H
+p8 <- Polygon(cbind(x=c(1, 1, 2, 2, 1), y=c(1, 2, 2, 1, 1))) # H
+p9 <- Polygon(cbind(x=c(1, 1, 2, 2, 1), y=c(5, 6, 6, 5, 5))) # H
+p3 <- Polygon(cbind(x=c(20, 20, 30, 30, 20), y=c(20, 30, 30, 20, 20))) # I
+p4 <- Polygon(cbind(x=c(21, 21, 29, 29, 21), y=c(21, 29, 29, 21, 21))) # H
+p14 <- Polygon(cbind(x=c(21, 21, 29, 29, 21), y=c(21, 29, 29, 21, 21))) # H
+p5 <- Polygon(cbind(x=c(22, 22, 28, 28, 22), y=c(22, 28, 28, 22, 22))) # I
+p15 <- Polygon(cbind(x=c(22, 22, 28, 28, 22), y=c(22, 28, 28, 22, 22))) # I
+p6 <- Polygon(cbind(x=c(23, 23, 27, 27, 23), y=c(23, 27, 27, 23, 23))) # H
+p7 <- Polygon(cbind(x=c(13, 13, 17, 17, 13), y=c(13, 17, 17, 13, 13))) # I
+p10 <- Polygon(cbind(x=c(24, 24, 26, 26, 24), y=c(24, 26, 26, 24, 24))) # I
+p11 <- Polygon(cbind(x=c(24.25, 24.25, 25.75, 25.75, 24.25),
+ y=c(24.25, 25.75, 25.75, 24.25, 24.25))) # H
+p12 <- Polygon(cbind(x=c(24.5, 24.5, 25.5, 25.5, 24.5),
+ y=c(24.5, 25.5, 25.5, 24.5, 24.5))) # I
+p13 <- Polygon(cbind(x=c(24.75, 24.75, 25.25, 25.25, 24.75),
+ y=c(24.75, 25.25, 25.25, 24.75, 24.75))) # H
+lp <- list(p1, p2, p13, p7, p6, p5, p4, p3, p8, p11, p12, p9, p10, p14, p15)
+#           1   2    3   4   5   6   7   8   9   10   11  12   13   14   15
+#           0   1   11   0   6   0   8   0   1   13    0   1    0  (7)  (6)
+#           I   H    H   I   H   I   H   I   H    H    I   H    I   ?    ?
+pls <- Polygons(lp, ID="1")
+comment(pls)
+pls1 <- checkPolygonsHoles(pls)
+comment(pls1)
+opar <- par(mfrow=c(1,2))
+plot(SpatialPolygons(list(pls)), col="magenta", pbg="cyan", usePolypath=FALSE)
+title(xlab="Hole slot values before checking")
+plot(SpatialPolygons(list(pls1)), col="magenta", pbg="cyan", usePolypath=FALSE)
+title(xlab="Hole slot values after checking")
+par(opar)
 }
 }
 \keyword{spatial}
diff --git a/man/elide-methods.Rd b/man/elide-methods.Rd
old mode 100755
new mode 100644
index cbf172d..6e79701
--- a/man/elide-methods.Rd
+++ b/man/elide-methods.Rd
@@ -1,85 +1,85 @@
-\name{elide-methods}
-\docType{methods}
-\alias{elide-methods}
-\alias{elide,SpatialPoints-method}
-\alias{elide,SpatialPointsDataFrame-method}
-\alias{elide,SpatialLines-method}
-\alias{elide,SpatialLinesDataFrame-method}
-\alias{elide,SpatialPolygons-method}
-\alias{elide,SpatialPolygonsDataFrame-method}
-\alias{elide}
-\title{Methods for Function elide in Package `maptools'}
-\description{
- Methods for function \code{elide} to translate and disguise coordinate placing in the real world. 
-}
-\section{Methods}{
-\describe{
-
-\item{obj = "SpatialPoints"}{elides object}
-
-\item{obj = "SpatialPointsDataFrame"}{elides object}
-
-\item{obj = "SpatialLines"}{elides object}
-
-\item{obj = "SpatialLinesDataFrame"}{elides object}
-
-\item{obj = "SpatialPolygons"}{elides object}
-
-\item{obj = "SpatialPolygonsDataFrame"}{elides object}
-}}
-
-\usage{
-elide(obj, ...)
-% (obj, bb=NULL, shift=c(0, 0), reflect=c(FALSE, FALSE), scale=NULL, flip=FALSE)
-}
-
-\arguments{
-  \item{obj}{object to be elided}
-  \item{...}{other arguments:
-  \describe{
-    \item{bb}{if NULL, uses bounding box of object, otherwise the given bounding box}
-    \item{shift}{values to shift the coordinates of the input object; this is made ineffective by the scale argument}
-    \item{reflect}{reverse coordinate axes}
-    \item{scale}{if NULL, coordinates not scaled; if TRUE, the longer dimension is scaled to lie within [0,1] and aspect maintained; if a scalar, the output range of [0,1] is multiplied by scale}
-    \item{flip}{translate coordinates on the main diagonal}
-    \item{rotate}{default 0, rotate angle degrees clockwise around center}
-    \item{center}{default NULL, if not NULL, the rotation center, numeric of length two}
-    \item{unitsq}{logical, default FALSE, if TRUE and scale TRUE, impose unit square bounding box (currently only points)}
-}}
-}
-
-\value{
-The methods return objects of the input class object with elided coordinates; the coordinate reference system is not set. Note that if the input coordinates or centroids are in the data slot data.frame of the input object, they should be removed before the use of these methods, otherwise they will betray the input positions.
-}
-\note{Rotation code kindly contributed by Don MacQueen}
-
-\examples{
-data(meuse)
-coordinates(meuse) <- c("x", "y")
-proj4string(meuse) <- CRS("+init=epsg:28992")
-data(meuse.riv)
-river_polygon <- Polygons(list(Polygon(meuse.riv)), ID="meuse")
-rivers <- SpatialPolygons(list(river_polygon))
-proj4string(rivers) <- CRS("+init=epsg:28992")
-rivers1 <- elide(rivers, reflect=c(TRUE, TRUE), scale=TRUE)
-meuse1 <- elide(meuse, bb=bbox(rivers), reflect=c(TRUE, TRUE), scale=TRUE)
-opar <- par(mfrow=c(1,2))
-plot(rivers, axes=TRUE)
-plot(meuse, add=TRUE)
-plot(rivers1, axes=TRUE)
-plot(meuse1, add=TRUE)
-par(opar)
-meuse1 <- elide(meuse, shift=c(10000, -10000))
-bbox(meuse)
-bbox(meuse1)
-rivers1 <- elide(rivers, shift=c(10000, -10000))
-bbox(rivers)
-bbox(rivers1)
-meuse1 <- elide(meuse, rotate=-30, center=apply(bbox(meuse), 1, mean))
-bbox(meuse)
-bbox(meuse1)
-plot(meuse1, axes=TRUE)
-}
-
-\keyword{methods}
-\keyword{spatial}
+\name{elide-methods}
+\docType{methods}
+\alias{elide-methods}
+\alias{elide,SpatialPoints-method}
+\alias{elide,SpatialPointsDataFrame-method}
+\alias{elide,SpatialLines-method}
+\alias{elide,SpatialLinesDataFrame-method}
+\alias{elide,SpatialPolygons-method}
+\alias{elide,SpatialPolygonsDataFrame-method}
+\alias{elide}
+\title{Methods for Function elide in Package `maptools'}
+\description{
+ Methods for function \code{elide} to translate and disguise coordinate placing in the real world. 
+}
+\section{Methods}{
+\describe{
+
+\item{obj = "SpatialPoints"}{elides object}
+
+\item{obj = "SpatialPointsDataFrame"}{elides object}
+
+\item{obj = "SpatialLines"}{elides object}
+
+\item{obj = "SpatialLinesDataFrame"}{elides object}
+
+\item{obj = "SpatialPolygons"}{elides object}
+
+\item{obj = "SpatialPolygonsDataFrame"}{elides object}
+}}
+
+\usage{
+elide(obj, ...)
+% (obj, bb=NULL, shift=c(0, 0), reflect=c(FALSE, FALSE), scale=NULL, flip=FALSE)
+}
+
+\arguments{
+  \item{obj}{object to be elided}
+  \item{...}{other arguments:
+  \describe{
+    \item{bb}{if NULL, uses bounding box of object, otherwise the given bounding box}
+    \item{shift}{values to shift the coordinates of the input object; this is made ineffective by the scale argument}
+    \item{reflect}{reverse coordinate axes}
+    \item{scale}{if NULL, coordinates not scaled; if TRUE, the longer dimension is scaled to lie within [0,1] and aspect maintained; if a scalar, the output range of [0,1] is multiplied by scale}
+    \item{flip}{translate coordinates on the main diagonal}
+    \item{rotate}{default 0, rotate angle degrees clockwise around center}
+    \item{center}{default NULL, if not NULL, the rotation center, numeric of length two}
+    \item{unitsq}{logical, default FALSE, if TRUE and scale TRUE, impose unit square bounding box (currently only points)}
+}}
+}
+
+\value{
+The methods return objects of the input class object with elided coordinates; the coordinate reference system is not set. Note that if the input coordinates or centroids are in the data slot data.frame of the input object, they should be removed before the use of these methods, otherwise they will betray the input positions.
+}
+\note{Rotation code kindly contributed by Don MacQueen}
+
+\examples{
+data(meuse)
+coordinates(meuse) <- c("x", "y")
+proj4string(meuse) <- CRS("+init=epsg:28992")
+data(meuse.riv)
+river_polygon <- Polygons(list(Polygon(meuse.riv)), ID="meuse")
+rivers <- SpatialPolygons(list(river_polygon))
+proj4string(rivers) <- CRS("+init=epsg:28992")
+rivers1 <- elide(rivers, reflect=c(TRUE, TRUE), scale=TRUE)
+meuse1 <- elide(meuse, bb=bbox(rivers), reflect=c(TRUE, TRUE), scale=TRUE)
+opar <- par(mfrow=c(1,2))
+plot(rivers, axes=TRUE)
+plot(meuse, add=TRUE)
+plot(rivers1, axes=TRUE)
+plot(meuse1, add=TRUE)
+par(opar)
+meuse1 <- elide(meuse, shift=c(10000, -10000))
+bbox(meuse)
+bbox(meuse1)
+rivers1 <- elide(rivers, shift=c(10000, -10000))
+bbox(rivers)
+bbox(rivers1)
+meuse1 <- elide(meuse, rotate=-30, center=apply(bbox(meuse), 1, mean))
+bbox(meuse)
+bbox(meuse1)
+plot(meuse1, axes=TRUE)
+}
+
+\keyword{methods}
+\keyword{spatial}
diff --git a/man/gcDestination.Rd b/man/gcDestination.Rd
old mode 100755
new mode 100644
diff --git a/man/getKMLcoordinates.Rd b/man/getKMLcoordinates.Rd
index 77da526..00cceae 100644
--- a/man/getKMLcoordinates.Rd
+++ b/man/getKMLcoordinates.Rd
@@ -8,7 +8,7 @@
 }
 
 \usage{
-coords <- getKMLcoordinates(kmlfile, ignoreAltitude=FALSE)
+getKMLcoordinates(kmlfile, ignoreAltitude=FALSE)
 }
 
 \arguments{
diff --git a/man/gzAzimuth.Rd b/man/gzAzimuth.Rd
index 6d650a1..136a0f5 100644
--- a/man/gzAzimuth.Rd
+++ b/man/gzAzimuth.Rd
@@ -31,7 +31,7 @@ name <- c("Mecca", "Anchorage", "Washington")
 long <- c(39.823333, -149.883333, -77.0166667)
 lat <- c(21.423333, 61.2166667, 38.9)
 x <- cbind(long, lat)
-rownames(x) <- name
+row.names(x) <- name
 crib <- c(-9.098363, 56.575960)
 r1 <- gzAzimuth(x[2:3,], x[1,])
 r1
diff --git a/man/kmlLine.Rd b/man/kmlLine.Rd
index 56b3998..5f7f38d 100644
--- a/man/kmlLine.Rd
+++ b/man/kmlLine.Rd
@@ -9,10 +9,6 @@
 kmlLine(obj=NULL, kmlfile=NULL, 
     name="R Line", description="", col=NULL, visibility=1, lwd=1,
     kmlname="", kmldescription="")
-x <- kmlLine(obj=NULL,
-    name="R Line", description="", col=NULL, visibility=1, lwd=1,
-    kmlname="", kmldescription="")
-y <- kmlLine(kmlname="", kmldescription="")
 }
 
 \arguments{
diff --git a/man/kmlPoints.Rd b/man/kmlPoints.Rd
new file mode 100644
index 0000000..6f8365a
--- /dev/null
+++ b/man/kmlPoints.Rd
@@ -0,0 +1,64 @@
+\name{kmlPoints}
+\alias{kmlPoints}
+
+\title{Create and write a KML file on the basis of a given Points object}
+\description{
+  The function is used to create and write a KML file on the basis of a given SpatialPointsDataFrame object for the usage in Google Earth resp. Google Maps.
+}
+\usage{
+kmlPoints(obj=NULL, kmlfile=NULL, kmlname="", kmldescription="",
+    name=NULL, description="",
+    icon="http://google.com/mapfiles/kml/paddle/wht-diamond.png")
+}
+
+\arguments{
+  \item{obj}{a \code{SpatialPointsDataFrame} object}
+  \item{kmlfile}{if not \code{NULL} the name as character string of the kml file to be written}
+  \item{kmlname}{the name of the KML layer}
+  \item{kmldescription}{the description of the KML layer (HTML tags allowed)}
+  \item{name}{a character vector to be used as names for each KML Placemark}
+  \item{description}{a character vector to be used as the description for each KML Placemark (HTML tags allowed)}
+  \item{icon}{a character vector of icon URLs to be used in the style associated with each KML Placemark}
+}
+
+\details{
+The function is used to convert a given \code{SpatialPointsDataFrame} object into a series of KML Placemarks, each with a single Point. If \code{kmlfile} is not \code{NULL} the result will be written into that file. If \code{kmlfile} is \code{NULL} the generated KML lines will be returned (see also value). 
+
+If \code{name=NULL}, the <name> tag for each Placemark will be \code{'site #'}. If a single value is used for 
+\code{name} or \code{description}, that value will be replicated for each Placemark. If a single value is used for
+\code{icon}, only a single style will be created and that style will be referenced by each Placemark.
+
+Note that the geometries should be in geographical coordinates with datum WGS84.
+}
+
+\value{
+x is a list with the elements \code{style} and \code{content} containing the generated lines of the KML file as character vectors if \code{kmlfile} is \code{NULL}.
+
+y is a list with the elements \code{header} and \code{footer} representing the KML file' header resp. footer if \code{obj} is \code{NULL}.
+}
+
+\section{KML icons}{
+The default icon URL is \url{http://google.com/mapfiles/kml/paddle/wht-diamond.png}. Additional icons are available at:
+\url{http://sites.google.com/site/gmapsdevelopment}.
+}
+
+\author{Jonathan Callahan}
+\seealso{\code{\link{kmlLine}}, \code{\link{kmlOverlay}}, \code{\link{kmlPolygon}}, \code{\link[sp]{Line}}}
+
+\examples{
+data(SplashDams)
+num <- length(SplashDams)
+td <- tempdir()
+kmlfile <- paste(td, "OregonSplashDams.kml", sep="/")
+kmlname <- "Oregon Splash Dams"
+kmldescription <- "Data for Splash Dams in western Oregon. See http://www.fs.fed.us/pnw/lwm/aem/people/burnett.html#projects_activities for more information."
+icon <- "http://google.com/mapfiles/kml/paddle/wht-diamond.png"
+name <- paste("Dam on",SplashDams$streamName)
+description <- paste("<b>owner:</b>",SplashDams$owner,"<br><b>dates:</b>",SplashDams$datesUsed)
+
+kmlPoints(SplashDams, kmlfile=kmlfile, name=name, description=description,
+          icon=icon, kmlname=kmlname, kmldescription=kmldescription)
+}
+\concept{kml}
+\keyword{spatial}
+
diff --git a/man/kmlPolygon.Rd b/man/kmlPolygon.Rd
old mode 100755
new mode 100644
index c1400f4..39fafae
--- a/man/kmlPolygon.Rd
+++ b/man/kmlPolygon.Rd
@@ -11,10 +11,6 @@
 kmlPolygon(obj=NULL, kmlfile=NULL, 
     name="R Polygon", description="", col=NULL, visibility=1, lwd=1, border=1,
     kmlname="", kmldescription="")
-x <- kmlPolygon(obj=NULL, 
-    name="R Polygon", description="", col=NULL, visibility=1, lwd=1, border=1,
-    kmlname="", kmldescription="")
-y <- kmlPolygon(kmlname="", kmldescription="")
 }
 
 \arguments{
diff --git a/man/lineLabel.Rd b/man/lineLabel.Rd
new file mode 100644
index 0000000..ae48057
--- /dev/null
+++ b/man/lineLabel.Rd
@@ -0,0 +1,132 @@
+\name{lineLabel}
+\alias{lineLabel}
+\alias{sp.lineLabel}
+\alias{label}
+\alias{sp.lineLabel-methods}
+\alias{label-methods}
+\alias{sp.lineLabel,Lines-method}
+\alias{sp.lineLabel,SpatialLines-method}
+\alias{label,SpatialLines-method}
+
+\title{
+Line label placement with spplot and lattice.
+}
+
+\description{ The \code{lineLabel} function produces and draws text
+  grobs following the paths defined by a list of \code{Line}
+  objects. The \code{sp.lineLabel} methods use this function to work
+  easily with \code{spplot}.}
+
+\usage{
+lineLabel(line, label,
+          spar=.6, position = c('above', 'below'),
+          textloc = 'constantSlope',
+          col = add.text$col,
+          alpha = add.text$alpha,
+          cex = add.text$cex,
+          lineheight = add.text$lineheight,
+          font = add.text$font,
+          fontfamily = add.text$fontfamily,
+          fontface = add.text$fontface,
+          lty = add.line$lty,
+          lwd = add.line$lwd, 
+          col.line = add.line$col,
+          identifier = 'lineLabel',
+          ...)
+
+sp.lineLabel(object, labels, byid=TRUE,...)
+
+label(object, text, ...)
+
+}
+\arguments{
+  \item{line}{a \code{list} of \code{Lines}.}
+  \item{object}{A \code{Lines} or \code{SpatialLines} object.}
+  
+  \item{label, labels, text}{a string or expression to be printed
+    following the path of \code{line}. The \code{names} of \code{labels}
+    should match the values of the \code{ID} slot of the lines to
+    label. If \code{labels} is missing, the \code{ID} slot is used
+    instead. The \code{label} method is a wrapper function to extract
+    the \code{ID} slots and create a suitable \code{character} object
+    with the correct \code{names} values.}
+
+  \item{byid}{If TRUE (default) only the longest line of each unique
+  \code{ID} value will be labelled.}
+  
+  \item{textloc}{a character or a numeric. It may be 'constantSlope',
+    'minSlope' or 'maxDepth', or the numeric index of the location. If
+    it is a numeric, its length must coincide with the number of
+    \code{Lines}.}
+
+  \item{spar}{smoothing parameter. With values near zero, the label
+    will closely follow the line. Default value is .6. See smooth.spline for details.}
+  \item{position}{character string ('above' or 'below') to define where
+    the text must be placed.}
+  \item{col, alpha, cex, lineheight, font, fontfamily,
+  fontface}{graphical arguments for the text. See gpar for details.}
+
+  \item{lty, lwd, col.line}{graphical parameters for the line. See gpar for details.}
+  \item{identifier}{A character string to identify the grob to be created.}
+  \item{...}{other arguments}
+}
+
+
+\author{
+Oscar Perpiñán Lamigueiro.
+}
+
+\details{
+Part of the label location code is adapted from \code{\link[lattice]{panel.levelplot}}. 
+\code{\link[stats]{smooth.spline}} is used to resample the segment of the line where the label is placed.}
+
+\seealso{
+  \code{\link[sp]{spplot}}
+  \code{\link{sp.pointLabel}}
+  \code{\link{pointLabel}}
+  \code{\link[lattice]{panel.levelplot}}
+  \code{\link[stats]{smooth.spline}}
+}
+\examples{
+data(meuse.grid)
+coordinates(meuse.grid) = ~x+y
+proj4string(meuse.grid) <- CRS("+init=epsg:28992")
+gridded(meuse.grid) = TRUE
+
+data(meuse)
+coordinates(meuse) = ~x+y
+data(meuse.riv)
+meuse.sl <- SpatialLines(list(Lines(list(Line(meuse.riv)), "1")))
+
+library(RColorBrewer)
+myCols <- adjustcolor(colorRampPalette(brewer.pal(n=9, 'Reds'))(100), .85)
+
+labs <- label(meuse.sl, 'Meuse River')
+
+## Maximum depth
+sl1 <- list('sp.lineLabel', meuse.sl, label=labs,
+            position='below', textloc='maxDepth',
+            spar=.2,
+            col='darkblue', cex=1,
+            fontfamily='Palatino',
+            fontface=2)
+
+spplot(meuse.grid["dist"],
+       col.regions=myCols, 
+       sp.layout = sl1)
+
+## Constant slope
+sl2 <- modifyList(sl1, list(textloc = 'constantSlope')) ## Default
+
+spplot(meuse.grid["dist"],
+       col.regions=myCols, 
+       sp.layout = sl2)
+
+## Location defined by its numeric index
+sl3 <- modifyList(sl1, list(textloc = 140, position='above'))
+
+spplot(meuse.grid["dist"],
+       col.regions=myCols, 
+       sp.layout = sl3)
+
+}
diff --git a/man/map2SpatialPolygons.Rd b/man/map2SpatialPolygons.Rd
index aded664..4648109 100644
--- a/man/map2SpatialPolygons.Rd
+++ b/man/map2SpatialPolygons.Rd
@@ -31,7 +31,7 @@ pruneMap(map, xlim=NULL, ylim=NULL)
 
 \seealso{\code{\link[maps]{map}}}
 \examples{
-library(maps)
+if(require(maps)) {
 nor_coast_poly <- map("world", "norway", fill=TRUE, col="transparent",
  plot=FALSE)
 range(nor_coast_poly$x, na.rm=TRUE)
@@ -55,5 +55,6 @@ nor_coast_lines_sp <- map2SpatialLines(nor_coast_lines,
 plot(nor_coast_poly_sp, col="grey", axes=TRUE)
 plot(nor_coast_lines_sp, col="blue", add=TRUE)
 }
+}
 \keyword{spatial}
 
diff --git a/man/nearestPointOnLine.Rd b/man/nearestPointOnLine.Rd
new file mode 100644
index 0000000..f233930
--- /dev/null
+++ b/man/nearestPointOnLine.Rd
@@ -0,0 +1,36 @@
+\name{nearestPointOnLine}
+\alias{nearestPointOnLine}
+\title{
+Get the nearest point on a line to a given point
+}
+\description{
+This function calculates the coordinates of the nearest point on a line to a 
+given point. This function does not work with geographic coordinates.
+}
+\usage{
+nearestPointOnLine(coordsLine, coordsPoint)
+}
+\arguments{
+  \item{coordsLine}{
+Matrix with coordinates of line vertices. Each row represents a vertex. 
+}
+  \item{coordsPoint}{
+A vector representing the X and Y coordinates of the point.
+}
+}
+\value{
+Vector with the X and Y coordinates of the nearest point on a line to the 
+given point.
+}
+\author{
+German Carrillo
+}
+\seealso{
+\code{\link{nearestPointOnSegment}}, \code{\link{snapPointsToLines}} 
+}
+\examples{
+coordsLine = cbind(c(1,2,3),c(3,2,2))
+coordsPoint = c(1.2,1.5)
+nearestPointOnLine(coordsLine, coordsPoint)
+}
+\keyword{ spatial }
diff --git a/man/nearestPointOnSegment.Rd b/man/nearestPointOnSegment.Rd
new file mode 100644
index 0000000..04bcb7c
--- /dev/null
+++ b/man/nearestPointOnSegment.Rd
@@ -0,0 +1,42 @@
+\name{nearestPointOnSegment}
+\alias{nearestPointOnSegment}
+\title{
+Get the nearest point on a segment to a given point
+}
+\description{
+This function calculates the coordinates of and the distance to the nearest 
+point on a segment to a given point. This function does not work with 
+geographic coordinates.
+}
+\usage{
+nearestPointOnSegment(s, p)
+}
+\arguments{
+  \item{s}{
+A matrix representing the coordinates of the segment. The matrix has 2x2 
+dimension where each row represents one of the end points. 
+}
+  \item{p}{
+A vector representing the X and Y coordinates of the point.
+}
+}
+\value{
+A vector with three numeric values representing X and Y coordinates of the 
+nearest point on a segment to a given point as well as the distance between
+both points.
+}
+\references{
+The function was ported to R based on this code: http://pastebin.com/n9rUuGRh
+}
+\author{
+German Carrillo 
+}
+\seealso{
+\code{\link{nearestPointOnLine}}, \code{\link{snapPointsToLines}} 
+}
+\examples{
+segment = cbind(c(1,2),c(1,1.5))
+point = c(1.2,1.5)
+nearestPointOnSegment(segment, point)
+}
+\keyword{ spatial }
diff --git a/man/nowrapRecenter.Rd b/man/nowrapRecenter.Rd
index e31804f..501cddb 100644
--- a/man/nowrapRecenter.Rd
+++ b/man/nowrapRecenter.Rd
@@ -7,14 +7,17 @@
   When recentering a world map, say to change an "Atlantic" view with longitude range -180 to 180, to a "Pacific" view, with longitude range 0 to 360, polygons crossed by the new offset, here 0/360, need to be clipped into left and right sub.polygons to avoid horizontal scratches across the map. The \code{nowrapSpatialPolygons} function performs this operation using polygon intersection, and \code{nowrapRecenter} recenters the output SpatialPolygons object. 
 }
 \usage{
-nowrapRecenter(obj, offset = 0, eps = rep(.Machine$double.eps, 2))
-nowrapSpatialPolygons(obj, offset = 0, eps=rep(.Machine$double.eps, 2))
+nowrapRecenter(obj, offset = 0, eps = rep(.Machine$double.eps^(1/2), 2),
+ avoidGEOS = FALSE)
+nowrapSpatialPolygons(obj, offset = 0, eps=rep(.Machine$double.eps^(1/2), 2),
+ avoidGEOS = FALSE)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
   \item{obj}{ A SpatialPolygons object }
   \item{offset}{ offset from the Greenwich meridian }
-  \item{eps}{vector of two (left and right) fuzz factors to retract the ring from the offset}
+  \item{eps}{vector of two (left and right) fuzz factors to retract the ring from the offset (square root to accommodate \pkg{rgeos} precision rules)}
+  \item{avoidGEOS}{use \pkg{gpclib} code even if \pkg{rgeos} is available}
 }
 
 \value{
@@ -28,10 +31,16 @@ nowrapSpatialPolygons(obj, offset = 0, eps=rep(.Machine$double.eps, 2))
 
 \examples{
 \dontrun{
-gpclibPermit()
+if (!rgeosStatus()) gpclibPermit()
 library(maps)
 world <- map("world", fill=TRUE, col="transparent", plot=FALSE)
 worldSpP <- map2SpatialPolygons(world, world$names, CRS("+proj=longlat"))
+worldSpP <- worldSpP[-grep("Antarctica", row.names(worldSpP)),]
+# incomplete polygons
+worldSpP <- worldSpP[-grep("Ghana", row.names(worldSpP)),]
+# self-intersection mouth of Volta
+worldSpP <- worldSpP[-grep("UK:Great Britain", row.names(worldSpP)),]
+# self-intersection Humber estuary
 worldSpPr <- recenter(worldSpP)
 plot(worldSpPr)
 title("Pacific view without polygon splitting")
diff --git a/man/pal2SpatialPolygons.Rd b/man/pal2SpatialPolygons.Rd
index e813eef..ca13a37 100644
--- a/man/pal2SpatialPolygons.Rd
+++ b/man/pal2SpatialPolygons.Rd
@@ -28,17 +28,16 @@ pal2SpatialPolygons(arc, pal, IDs, dropPoly1=TRUE,
 \examples{
 nc1 <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], ID="FIPS")
 plot(nc1)
-text(coordinates(nc1), labels=sapply(slot(nc1, "polygons"),
- function(i) slot(i, "ID")), cex=0.6)
-library(maps)
+text(coordinates(nc1), labels=row.names(nc1), cex=0.6)
+if(require(maps)){
 ncmap <- map("county", "north carolina", fill=TRUE, col="transparent",
  plot=FALSE)
 IDs <- sapply(strsplit(ncmap$names, "[,:]"), function(x) x[2])
 nc2 <- map2SpatialPolygons(ncmap, IDs)
 plot(nc2)
-text(coordinates(nc2), labels=sapply(slot(nc2, "polygons"),
- function(i) slot(i, "ID")), cex=0.6)
-library(RArcInfo)
+text(coordinates(nc2), labels=row.names(nc2), cex=0.6)
+}
+if(require(RArcInfo)) {
 td <- tempdir()
 tmpcover <- paste(td, "nc", sep="/")
 if (!file.exists(tmpcover)) e00toavc(system.file("share/co37_d90.e00",
@@ -50,7 +49,7 @@ sapply(pal[[2]], function(x) length(x[[1]]))
 IDs <- paste(pat$ST[-1], pat$CO[-1], sep="")
 nc3 <- pal2SpatialPolygons(arc, pal, IDs=IDs)
 plot(nc3)
-text(coordinates(nc3), labels=sapply(slot(nc3, "polygons"),
- function(i) slot(i, "ID")), cex=0.6)
+text(coordinates(nc3), labels=row.names(nc3), cex=0.6)
+}
 }
 \keyword{spatial}
diff --git a/man/pointLabel.Rd b/man/pointLabelBase.Rd
similarity index 97%
rename from man/pointLabel.Rd
rename to man/pointLabelBase.Rd
index 97dd541..335e0fd 100644
--- a/man/pointLabel.Rd
+++ b/man/pointLabelBase.Rd
@@ -1,103 +1,103 @@
-\name{pointLabel}
-\alias{pointLabel}
-\title{ Label placement for points to avoid overlaps  }
-\description{
-  Use optimization routines to find good locations for point labels
-  without overlaps. 
-}
-\usage{
-pointLabel(x, y = NULL, labels = seq(along = x), cex = 1,
-           method = c("SANN", "GA"),
-           allowSmallOverlap = FALSE,
-           trace = FALSE,
-           doPlot = TRUE,
-           ...)
-}
-\arguments{
-  \item{x, y}{ as with \code{plot.default}, these provide the x and y coordinates for
-          the point labels.  Any reasonable way of defining the coordinates is
-          acceptable.  See the function \code{xy.coords} for details. }
-  \item{labels}{ as with \code{text}, a character vector or expression specifying the text to be
-          written.  An attempt is made to coerce other language objects
-          (names and calls) to expressions, and vectors and other
-          classed objects to character vectors by \code{as.character}. }
-  \item{cex}{ numeric character expansion factor as with \code{text}. }
-  \item{method}{ the optimization method, either \dQuote{SANN} for simulated
-          annealing (the default) or \dQuote{GA} for a genetic algorithm. }
-  \item{allowSmallOverlap}{ logical; if \code{TRUE}, labels are allowed
-          a small overlap. The overlap allowed is 2\% of the diagonal
-          distance of the plot area.}
-  \item{trace}{ logical; if \code{TRUE}, status updates are given as the optimization algorithms
-          progress.}
-  \item{doPlot}{ logical; if \code{TRUE}, the labels are plotted on the
-          existing graph with \code{text}.}
-  \item{\ldots}{ arguments passed along to \code{text} to specify
-          labeling parameters such as \code{col}. }
-
-}
-\details{
-  
-  Eight positions are candidates for label placement, either
-  horizontally, vertically, or diagonally offset from the points. The
-  default position for labels is the top right diagonal relative to the
-  point (considered the preferred label position). 
-
-  With the default settings, simulating annealing solves faster than the
-  genetic algorithm. It is an open question as to which settles into a
-  global optimum the best (both algorithms have parameters that may be
-  tweaked).
-
-  The label positioning problem is NP-hard (nondeterministic
-  polynomial-time hard). Placement becomes difficult and slows
-  considerably with large numbers of points. This function places all
-  labels, whether overlaps occur or not. Some placement algorithms
-  remove labels that overlap.
-  
-  Note that only \code{cex} is used to calculate string width and
-  height (using \code{strwidth} and \code{strheight}), so passing a
-  different font may corrupt the label dimensions. You could get around
-  this by adjusting the font parameters with \code{par} prior to running
-  this function.
-  
-}
-\value{
-  An \code{xy} list giving the \code{x} and \code{y} positions of the
-  label as would be placed by \code{text(xy, labels)}.
-}
-\references{
-
-\url{http://en.wikipedia.org/wiki/Automatic_label_placement}
-
-\url{http://i11www.iti.uni-karlsruhe.de/map-labeling/bibliography/}
-
-\url{http://www.eecs.harvard.edu/~shieber/Projects/Carto/carto.html}
-
-\url{http://www.szoraster.com/Cartography/PracticalExperience.htm}
-
-The genetic algorithm code was adapted from the python code at 
-
-\url{http://meta.wikimedia.org/wiki/Map_generator}.
-
-The simulated annealing code follows the algorithm and guidelines in:
-
-Jon Christensen, Joe Marks, and Stuart Shieber. Placing text labels on
-maps and diagrams. In Paul Heckbert, editor, Graphics Gems IV, pages
-497-504. Academic Press, Boston, MA, 1994.
-\url{http://www.eecs.harvard.edu/~shieber/Biblio/Papers/jc.label.pdf}
-
-}
-\author{ Tom Short, EPRI, \email{tshort at epri.com} }
-\seealso{ \code{\link{text}}, \code{\link[plotrix]{thigmophobe.labels}}
-  in package \pkg{plotrix} }
-\examples{
-n <- 50
-x <- rnorm(n)*10
-y <- rnorm(n)*10
-plot(x, y, col = "red", pch = 20)
-pointLabel(x, y, as.character(round(x,5)), offset = 0, cex = .7)
-
-plot(x, y, col = "red", pch = 20)
-pointLabel(x, y, expression(over(alpha, beta[123])), offset = 0, cex = .8)
-
-}
-\keyword{aplot}
+\name{pointLabel}
+\alias{pointLabel}
+\title{ Label placement for points to avoid overlaps  }
+\description{
+  Use optimization routines to find good locations for point labels
+  without overlaps. 
+}
+\usage{
+pointLabel(x, y = NULL, labels = seq(along = x), cex = 1,
+           method = c("SANN", "GA"),
+           allowSmallOverlap = FALSE,
+           trace = FALSE,
+           doPlot = TRUE,
+           ...)
+}
+\arguments{
+  \item{x, y}{ as with \code{plot.default}, these provide the x and y coordinates for
+          the point labels.  Any reasonable way of defining the coordinates is
+          acceptable.  See the function \code{xy.coords} for details. }
+  \item{labels}{ as with \code{text}, a character vector or expression specifying the text to be
+          written.  An attempt is made to coerce other language objects
+          (names and calls) to expressions, and vectors and other
+          classed objects to character vectors by \code{as.character}. }
+  \item{cex}{ numeric character expansion factor as with \code{text}. }
+  \item{method}{ the optimization method, either \dQuote{SANN} for simulated
+          annealing (the default) or \dQuote{GA} for a genetic algorithm. }
+  \item{allowSmallOverlap}{ logical; if \code{TRUE}, labels are allowed
+          a small overlap. The overlap allowed is 2\% of the diagonal
+          distance of the plot area.}
+  \item{trace}{ logical; if \code{TRUE}, status updates are given as the optimization algorithms
+          progress.}
+  \item{doPlot}{ logical; if \code{TRUE}, the labels are plotted on the
+          existing graph with \code{text}.}
+  \item{\ldots}{ arguments passed along to \code{text} to specify
+          labeling parameters such as \code{col}. }
+
+}
+\details{
+  
+  Eight positions are candidates for label placement, either
+  horizontally, vertically, or diagonally offset from the points. The
+  default position for labels is the top right diagonal relative to the
+  point (considered the preferred label position). 
+
+  With the default settings, simulating annealing solves faster than the
+  genetic algorithm. It is an open question as to which settles into a
+  global optimum the best (both algorithms have parameters that may be
+  tweaked).
+
+  The label positioning problem is NP-hard (nondeterministic
+  polynomial-time hard). Placement becomes difficult and slows
+  considerably with large numbers of points. This function places all
+  labels, whether overlaps occur or not. Some placement algorithms
+  remove labels that overlap.
+  
+  Note that only \code{cex} is used to calculate string width and
+  height (using \code{strwidth} and \code{strheight}), so passing a
+  different font may corrupt the label dimensions. You could get around
+  this by adjusting the font parameters with \code{par} prior to running
+  this function.
+  
+}
+\value{
+  An \code{xy} list giving the \code{x} and \code{y} positions of the
+  label as would be placed by \code{text(xy, labels)}.
+}
+\references{
+
+\url{http://en.wikipedia.org/wiki/Automatic_label_placement}
+
+\url{http://i11www.iti.uni-karlsruhe.de/map-labeling/bibliography/}
+
+\url{http://www.eecs.harvard.edu/~shieber/Projects/Carto/carto.html}
+
+\url{http://www.szoraster.com/Cartography/PracticalExperience.htm}
+
+The genetic algorithm code was adapted from the python code at 
+
+\url{http://meta.wikimedia.org/wiki/Map_generator}.
+
+The simulated annealing code follows the algorithm and guidelines in:
+
+Jon Christensen, Joe Marks, and Stuart Shieber. Placing text labels on
+maps and diagrams. In Paul Heckbert, editor, Graphics Gems IV, pages
+497-504. Academic Press, Boston, MA, 1994.
+\url{http://www.eecs.harvard.edu/~shieber/Biblio/Papers/jc.label.pdf}
+
+}
+\author{ Tom Short, EPRI, \email{tshort at epri.com} }
+\seealso{ \code{\link{text}}, \code{\link[plotrix]{thigmophobe.labels}}
+  in package \pkg{plotrix} }
+\examples{
+n <- 50
+x <- rnorm(n)*10
+y <- rnorm(n)*10
+plot(x, y, col = "red", pch = 20)
+pointLabel(x, y, as.character(round(x,5)), offset = 0, cex = .7)
+
+plot(x, y, col = "red", pch = 20)
+pointLabel(x, y, expression(over(alpha, beta[123])), offset = 0, cex = .8)
+
+}
+\keyword{aplot}
diff --git a/man/pointLabelLattice.Rd b/man/pointLabelLattice.Rd
new file mode 100644
index 0000000..898b78c
--- /dev/null
+++ b/man/pointLabelLattice.Rd
@@ -0,0 +1,106 @@
+\name{panel.pointLabel}
+\alias{panel.pointLabel}
+\alias{sp.pointLabel}
+\alias{sp.pointLabel-methods}
+\alias{sp.pointLabel,SpatialPoints-method}
+
+\title{Label placement with spplot and lattice.}
+
+\description{
+     Use optimization routines to find good locations for point labels
+     without overlaps.
+}
+
+\usage{
+panel.pointLabel(x, y = NULL,
+                              labels = seq(along = x),
+                              method = c("SANN", "GA"),
+                              allowSmallOverlap = FALSE,
+                              col = add.text$col,
+                              alpha = add.text$alpha,
+                              cex = add.text$cex,
+                              lineheight = add.text$lineheight,
+                              font = add.text$font,
+                              fontfamily = add.text$fontfamily,
+                              fontface = add.text$fontface,
+                              fill='transparent',
+                              ...)
+
+sp.pointLabel(object, labels, ...)
+}
+
+\arguments{
+
+  \item{object}{A \code{SpatialPoints} object.}
+  
+  \item{x, y}{coordinates for the point labels. See
+    \code{\link[grDevices]{xy.coords}} for details.}
+  
+  \item{labels}{a character vector or expression.}
+  \item{method}{the optimization method, either SANN for simulated
+    annealing (the default) or GA for a genetic algorithm.}
+  
+  \item{allowSmallOverlap}{logical; if TRUE, labels are allowed a small
+          overlap. The overlap allowed is 2\% of the diagonal distance
+          of the plot area.}
+	
+  \item{col, alpha, cex, lineheight, font, fontfamily,
+  fontface, fill}{Graphical arguments. See gpar for details}
+  \item{\dots}{Additional arguments (currently not processed).}
+}
+
+
+\author{Tom Short wrote \code{\link{pointLabel}} for \code{base}
+  graphics.  Oscar Perpiñán Lamigueiro modified this function for
+  \code{lattice} and \code{spplot}.}
+
+\seealso{
+  \code{\link[sp]{spplot}}
+%  \code{\link{sp.lineLabel}}
+  \code{\link{pointLabel}}
+}
+
+\examples{
+n <- 15
+x <- rnorm(n)*10
+y <- rnorm(n)*10
+labels <- as.character(round(x, 5))
+
+
+myTheme <- list(add.text=list(
+                  cex=0.7,
+                  col='midnightblue',
+                  fontface=2,
+                  fontfamily='mono'))
+
+xyplot(y~x,
+       labels=labels,
+       par.settings=myTheme, 
+       panel=function(x, y, labels, ...){
+         panel.xyplot(x, y, ...)
+         panel.pointLabel(x, y, labels=labels, ...)
+       })
+
+
+
+data(meuse.grid)
+coordinates(meuse.grid) = ~x+y
+proj4string(meuse.grid) <- CRS("+init=epsg:28992")
+gridded(meuse.grid) = TRUE
+
+library(RColorBrewer)
+myCols <- adjustcolor(colorRampPalette(brewer.pal(n=9, 'Reds'))(100), .85)
+
+pts <- spsample(meuse.grid, n=15, type="random")
+
+Rauthors <- readLines(file.path(R.home("doc"), "AUTHORS"))[9:28]
+someAuthors <- Rauthors[seq_along(pts)]
+
+sl1 <- list('sp.points', pts, pch=19, cex=.8, col='midnightblue')
+sl2 <- list('sp.pointLabel', pts, label=someAuthors,
+            cex=0.7, col='midnightblue',
+            fontfamily='Palatino')
+
+spplot(meuse.grid["dist"], col.regions=myCols, sp.layout=list(sl1, sl2))
+}
+
diff --git a/man/readShapeLines.Rd b/man/readShapeLines.Rd
index 013731c..f879062 100644
--- a/man/readShapeLines.Rd
+++ b/man/readShapeLines.Rd
@@ -4,7 +4,7 @@
 %- Also NEED an '\alias' for EACH other topic documented here.
 \title{Read arc shape files into SpatialLinesDataFrame objects}
 \description{
-  The \code{readShapeLines} function reads data from an arc/line shapefile into a \code{SpatialLinesDataFrame} object; the shapefile may be of type polygon, but for just plotting for example coastlines, a SpatialLines object is sufficient. The \code{writeLinesShape} function writes data from a \code{SpatialLinesDataFrame} object to a shapefile.
+  The \code{readShapeLines} function reads data from an arc/line shapefile into a \code{SpatialLinesDataFrame} object; the shapefile may be of type polygon, but for just plotting for example coastlines, a SpatialLines object is sufficient. The \code{writeLinesShape} function writes data from a \code{SpatialLinesDataFrame} object to a shapefile. Note DBF file restrictions in \code{\link[foreign]{write.dbf}}.
 }
 \usage{
 readShapeLines(fn, proj4string=CRS(as.character(NA)), verbose=FALSE,
@@ -22,7 +22,7 @@ writeLinesShape(x, fn, factor2char = TRUE, max_nchar=254)
   \item{factor2char}{logical, default TRUE, convert factor columns to character}
   \item{max_nchar}{default 254, may be set to a higher limit and passed through to the DBF writer, please see Details in \code{\link[foreign]{write.dbf}}}
 }
-\details{The shpID values of the shapefile will be used as \code{Lines} ID values; when writing shapefiles, the object data slot rownames are added to the DBF file as column SL\_ID.}
+\details{The shpID values of the shapefile will be used as \code{Lines} ID values; when writing shapefiles, the object data slot row.names are added to the DBF file as column SL\_ID.}
 
 \value{
   a SpatialLinesDataFrame object
@@ -30,6 +30,8 @@ writeLinesShape(x, fn, factor2char = TRUE, max_nchar=254)
 
 \author{ Roger Bivand }
 
+\seealso{\code{\link[foreign]{write.dbf}}}
+
 
 \examples{
 xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1],
diff --git a/man/readShapePoints.Rd b/man/readShapePoints.Rd
index ec35c1e..9182993 100644
--- a/man/readShapePoints.Rd
+++ b/man/readShapePoints.Rd
@@ -4,7 +4,7 @@
 %- Also NEED an '\alias' for EACH other topic documented here.
 \title{Read points shape files into SpatialPointsDataFrame objects}
 \description{
-  The \code{readShapePoints} reads data from a points shapefile into a \code{SpatialPointsDataFrame} object. The \code{writePointsShape} function writes data from a \code{SpatialPointsDataFrame} object to a shapefile. Both reading and writing can be carried out for 2D and 3D point coordinates.
+  The \code{readShapePoints} reads data from a points shapefile into a \code{SpatialPointsDataFrame} object. The \code{writePointsShape} function writes data from a \code{SpatialPointsDataFrame} object to a shapefile. Both reading and writing can be carried out for 2D and 3D point coordinates. Note DBF file restrictions in \code{\link[foreign]{write.dbf}}.
 }
 \usage{
 readShapePoints(fn, proj4string = CRS(as.character(NA)), verbose = FALSE,
@@ -28,6 +28,8 @@ writePointsShape(x, fn, factor2char = TRUE, max_nchar=254)
 
 \author{ Roger Bivand }
 
+\seealso{\code{\link[foreign]{write.dbf}}}
+
 \examples{
 library(maptools)
 xx <- readShapePoints(system.file("shapes/baltim.shp", package="maptools")[1])
diff --git a/man/readShapePoly.Rd b/man/readShapePoly.Rd
index c384cd8..7114a0d 100644
--- a/man/readShapePoly.Rd
+++ b/man/readShapePoly.Rd
@@ -4,7 +4,7 @@
 %- Also NEED an '\alias' for EACH other topic documented here.
 \title{Read polygon shape files into SpatialPolygonsDataFrame objects}
 \description{
-   The \code{readShapePoly} reads data from a polygon shapefile into a \code{SpatialPolygonsDataFrame} object. The \code{writePolyShape} function writes data from a \code{SpatialPolygonsDataFrame} object to a shapefile.
+   The \code{readShapePoly} reads data from a polygon shapefile into a \code{SpatialPolygonsDataFrame} object. The \code{writePolyShape} function writes data from a \code{SpatialPolygonsDataFrame} object to a shapefile. Note DBF file restrictions in \code{\link[foreign]{write.dbf}}.
 }
 \usage{
 readShapePoly(fn, IDvar=NULL, proj4string=CRS(as.character(NA)),
@@ -28,20 +28,21 @@ null geometries inserted by ABS}
   \item{factor2char}{logical, default TRUE, convert factor columns to character}
   \item{max_nchar}{default 254, may be set to a higher limit and passed through to the DBF writer, please see Details in \code{\link[foreign]{write.dbf}}}
 }
-\details{If no IDvar argument is given, the shpID values of the shapefile will be used as \code{Polygons} ID values; when writing shapefiles, the object data slot rownames are added to the DBF file as column SP\_ID.}
+\details{If no IDvar argument is given, the shpID values of the shapefile will be used as \code{Polygons} ID values; when writing shapefiles, the object data slot row.names are added to the DBF file as column SP\_ID.}
 \value{
    a SpatialPolygonsDataFrame object
 }
 
 \author{ Roger Bivand }
 
+\seealso{\code{\link[foreign]{write.dbf}}}
+
 \examples{
 library(maptools)
 xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
  IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
 plot(xx, border="blue", axes=TRUE, las=1)
-text(coordinates(xx), labels=sapply(slot(xx, "polygons"),
- function(i) slot(i, "ID")), cex=0.6)
+text(coordinates(xx), labels=row.names(xx), cex=0.6)
 as(xx, "data.frame")[1:5, 1:6]
 xxx <- xx[xx$SID74 < 2,]
 plot(xxx, border="red", add=TRUE)
diff --git a/man/readShapeSpatial.Rd b/man/readShapeSpatial.Rd
index 7543d73..c179f65 100644
--- a/man/readShapeSpatial.Rd
+++ b/man/readShapeSpatial.Rd
@@ -4,7 +4,7 @@
 %- Also NEED an '\alias' for EACH other topic documented here.
 \title{Read shape files into Spatial*DataFrame objects}
 \description{
-   The \code{readShapeSpatial} reads data from a shapefile into a \code{Spatial*DataFrame} object. The \code{writeSpatialShape} function writes data from a \code{Spatial*DataFrame} object to a shapefile.
+   The \code{readShapeSpatial} reads data from a shapefile into a \code{Spatial*DataFrame} object. The \code{writeSpatialShape} function writes data from a \code{Spatial*DataFrame} object to a shapefile. Note DBF file restrictions in \code{\link[foreign]{write.dbf}}.
 }
 \usage{
 readShapeSpatial(fn, proj4string=CRS(as.character(NA)), 
@@ -28,13 +28,15 @@ null geometries inserted by ABS (Polygons only)}
   \item{factor2char}{logical, default TRUE, convert factor columns to character}
   \item{max_nchar}{default 254, may be set to a higher limit and passed through to the DBF writer, please see Details in \code{\link[foreign]{write.dbf}}}
 }
-\details{If no IDvar argument is given, the shpID values of the shapefile will be used as \code{Polygons} ID values; when writing shapefiles, the object data slot rownames are added to the DBF file as column SP\_ID.}
+\details{If no IDvar argument is given, the shpID values of the shapefile will be used as \code{Polygons} ID values; when writing shapefiles, the object data slot row.names are added to the DBF file as column SP\_ID.}
 \value{
    a Spatial*DataFrame object of a class corresponding to the input shapefile
 }
 
 \author{ Roger Bivand }
 
+\seealso{\code{\link[foreign]{write.dbf}}}
+
 \examples{
 library(maptools)
 xx <- readShapeSpatial(system.file("shapes/sids.shp", package="maptools")[1],
diff --git a/man/readSplus.Rd b/man/readSplus.Rd
index e5ac081..68ad909 100644
--- a/man/readSplus.Rd
+++ b/man/readSplus.Rd
@@ -24,7 +24,7 @@ readSplus(file, proj4string = CRS(as.character(NA)))
 \examples{
 geobugs <- readSplus(system.file("share/Splus.map", package="maptools"))
 plot(geobugs, axes=TRUE, col=1:3)
-sapply(slot(geobugs, "polygons"), slot, "ID")
+row.names(geobugs)
 pls <- slot(geobugs, "polygons")
 sapply(pls, function(i) sapply(slot(i, "Polygons"), slot, "hole"))
 pls1 <- lapply(pls, checkPolygonsHoles)
diff --git a/man/snapPointsToLines.Rd b/man/snapPointsToLines.Rd
new file mode 100644
index 0000000..38e9856
--- /dev/null
+++ b/man/snapPointsToLines.Rd
@@ -0,0 +1,61 @@
+\name{snapPointsToLines}
+\alias{snapPointsToLines}
+\title{
+Snap a set of points to a set of lines
+}
+\description{
+This function snaps a set of points to a set of lines based on the minimum 
+distance of each point to any of the lines. This function does not work with 
+geographic coordinates.
+}
+\usage{
+snapPointsToLines(points, lines, maxDist = NA, withAttrs = TRUE)
+}
+\arguments{
+  \item{points}{
+An object of the class SpatialPoints or SpatialPointsDataFrame.
+}
+  \item{lines}{
+An object of the class SpatialLines or SpatialLinesDataFrame.
+}
+  \item{maxDist}{
+Numeric value for establishing a maximum distance to avoid snapping points that 
+are farther apart. This parameter is optional.
+}
+  \item{withAttrs}{
+Boolean value for preserving (TRUE) or getting rid (FALSE) of the original point 
+attributes. Default: TRUE. This parameter is optional. 
+}
+}
+\value{
+SpatialPointsDataFrame object as defined by the R package 'sp'. This object 
+contains the snapped points, therefore all of them lie on the lines.
+}
+\author{
+German Carrillo
+}
+\seealso{
+\code{\link{nearestPointOnSegment}}, \code{\link{nearestPointOnLine}}, 
+\code{\link{sp}}
+}
+\examples{
+# From the sp vignette
+l1 = cbind(c(1,2,3),c(3,2,2))
+l1a = cbind(l1[,1]+.05,l1[,2]+.05)
+l2 = cbind(c(1,2,3),c(1,1.5,1))
+Sl1 = Line(l1)
+Sl1a = Line(l1a)
+Sl2 = Line(l2)
+S1 = Lines(list(Sl1, Sl1a), ID="a")
+S2 = Lines(list(Sl2), ID="b")
+Sl = SpatialLines(list(S1,S2))
+df = data.frame(z = c(1,2), row.names=sapply(slot(Sl, "lines"), function(x) slot(x, "ID")))
+Sldf = SpatialLinesDataFrame(Sl, data = df)
+
+xc = c(1.2,1.5,2.5)
+yc = c(1.5,2.2,1.6)
+Spoints = SpatialPoints(cbind(xc, yc))
+
+snapPointsToLines(Spoints, Sldf)
+}
+\keyword{ spatial }
diff --git a/man/sp2WB.Rd b/man/sp2WB.Rd
index b3831ea..c81ffc8 100644
--- a/man/sp2WB.Rd
+++ b/man/sp2WB.Rd
@@ -19,7 +19,7 @@ sp2WB(map, filename, Xscale = 1, Yscale = Xscale, plotorder = FALSE)
 }
 
 \references{\url{http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/geobugs12manual.pdf}}
-\author{Virgilio G�mez Rubio, partly derived from earlier code by Thomas Jagger}
+\author{Virgilio Gómez Rubio, partly derived from earlier code by Thomas Jagger}
 
 
 \examples{
diff --git a/man/state.vbm.Rd b/man/state.vbm.Rd
new file mode 100644
index 0000000..9a632b5
--- /dev/null
+++ b/man/state.vbm.Rd
@@ -0,0 +1,49 @@
+\name{state.vbm}
+\alias{state.vbm}
+\docType{data}
+\title{ US State Visibility Based Map}
+\description{
+  A SpatialPolygonsDataFrame object (for use with the maptools package) to plot a Visibility Based Map.
+}
+\usage{
+data(state.vbm)
+}
+\details{
+  A SpatialPolygonsDataFrame object
+  (for use with the maptools package) to plot a map of the
+  US states where the sizes of the states have been adjusted to be more
+  equal.
+
+  This map can be useful for plotting state data using colors patterns
+  without the larger states dominating and the smallest states being
+  lost.
+
+  The original map is copyrighted by Mark Monmonier.  Official
+  publications based on this map should acknowledge him.
+  Comercial publications of maps based on this probably need permission
+  from him to use.
+}
+\source{
+  The data was converted from the maps library for S-PLUS.  S-PLUS uses
+  the map with permission from the author.  This version of the data
+  has not received permission from the author (no attempt made, not that
+  it was refused), most of my uses I feel fall under fair use and do not
+  violate copyright, but you will need to decide for yourself and your
+  applications.
+}
+\author{Greg Snow \email{greg.snow at imail.org} (of this compilation)}
+
+\references{
+  \url{http://www.markmonmonier.com/index.htm},
+  \url{http://www.math.yorku.ca/SCS/Gallery/bright-ideas.html}
+}
+\examples{
+  data(state.vbm)
+  plot(state.vbm)
+
+  tmp <- state.x77[,'HS Grad']
+  tmp2 <- cut(tmp, seq(min(tmp),max(tmp), length.out=11),
+    include.lowest=TRUE)
+  plot(state.vbm,col=cm.colors(10)[tmp2])
+}
+\keyword{datasets}
diff --git a/man/sun-methods.Rd b/man/sun-methods.Rd
index e643134..12acd37 100644
--- a/man/sun-methods.Rd
+++ b/man/sun-methods.Rd
@@ -42,10 +42,12 @@
          proj4string=CRS("+proj=longlat +datum=WGS84"),
          direction=c("sunrise", "sunset"), POSIXct.out=FALSE)
 \S4method{solarnoon}{SpatialPoints,POSIXct}(crds, dateTime, POSIXct.out=FALSE)
-\S4method{solarnoon}{matrix,POSIXct}(crds, dateTime, proj4string=CRS("+proj=longlat +datum=WGS84"),
+\S4method{solarnoon}{matrix,POSIXct}(crds, dateTime,
+          proj4string=CRS("+proj=longlat +datum=WGS84"),
           POSIXct.out=FALSE)
 \S4method{solarpos}{SpatialPoints,POSIXct}(crds, dateTime, ...)
-\S4method{solarpos}{matrix,POSIXct}(crds, dateTime, proj4string=CRS("+proj=longlat +datum=WGS84"), ...)
+\S4method{solarpos}{matrix,POSIXct}(crds, dateTime,
+         proj4string=CRS("+proj=longlat +datum=WGS84"), ...)
 
 }
 
@@ -75,43 +77,54 @@
 }
 
 
-\details{NOAA used the reference below to develop their Sunrise/Sunset
+\details{
 
-\url{http://www.srrb.noaa.gov/highlights/sunrise/sunrise.html} and Solar
-Position 
+  NOAA used the reference below to develop their Sunrise/Sunset
 
-\url{http://www.srrb.noaa.gov/highlights/sunrise/azel.html}
-Calculators.  The algorithms include corrections for atmospheric
-refraction effects.
+  \url{http://www.srrb.noaa.gov/highlights/sunrise/sunrise.html} and Solar
+  Position 
 
-Input can consist of one location and at least one POSIXct times, or one
-POSIXct time and at least one location.  \var{solarDep} is recycled as
-needed.
+  \url{http://www.srrb.noaa.gov/highlights/sunrise/azel.html}
+  Calculators.  The algorithms include corrections for atmospheric
+  refraction effects.
 
-Do not use the daylight savings time zone string for supplying
-\var{dateTime}, as many OS will not be able to properly set it to
-standard time when needed.}
+  Input can consist of one location and at least one POSIXct times, or one
+  POSIXct time and at least one location.  \var{solarDep} is recycled as
+  needed.
+
+  Do not use the daylight savings time zone string for supplying
+  \var{dateTime}, as many OS will not be able to properly set it to
+  standard time when needed.
+
+}
 
 
 \section{Warning}{Compared to NOAA's original Javascript code, the
-sunrise and sunset estimates from this translation may differ by +/- 1
-minute, based on tests using selected locations spanning the globe.
-This translation does not include calculation of prior or next
-sunrises/sunsets for locations above the Arctic Circle or below the
-Antarctic Circle.}
+  sunrise and sunset estimates from this translation may differ by +/- 1
+  minute, based on tests using selected locations spanning the globe.
+  This translation does not include calculation of prior or next
+  sunrises/sunsets for locations above the Arctic Circle or below the
+  Antarctic Circle.}
+
 
+\value{
 
-\value{\code{crepuscule}, \code{sunriset}, and \code{solarnoon} return a
+  \code{crepuscule}, \code{sunriset}, and \code{solarnoon} return a
   numeric vector with the time of day at which the event occurs,
   expressed as a fraction, if POSIXct.out is FALSE; otherwise they
   return a data frame with both the fraction and the corresponding
-  POSIXct date and time. \code{solarpos} returns a matrix with the solar
-  azimuth (in degrees from North), and elevation.}
+  POSIXct date and time.
+
+  \code{solarpos} returns a matrix with the solar azimuth (in degrees
+  from North), and elevation.
+
+}
 
 
 \note{NOAA notes that \dQuote{for latitudes greater than 72 degrees N
-and S, calculations are accurate to within 10 minutes.  For latitudes
-less than +/- 72 degrees accuracy is approximately one minute.}}
+    and S, calculations are accurate to within 10 minutes.  For
+    latitudes less than +/- 72 degrees accuracy is approximately one
+    minute.}}
 
 
 \references{
diff --git a/man/thinnedSpatialPoly.Rd b/man/thinnedSpatialPoly.Rd
index 4e856fd..e814a49 100644
--- a/man/thinnedSpatialPoly.Rd
+++ b/man/thinnedSpatialPoly.Rd
@@ -7,13 +7,16 @@
 The function applies the implementation of the Douglas-Peuker algorithm for line generalization or simplification (originally from shapefiles) to objects inheriting from Spatial Polygons. It does not preserve topology, so is suitable for visualisation, but not for the subsequent analysis of the polygon boundaries, as artefacts may be created, and boundaries of neighbouring entities may be generalized differently. If the rgeos package is available, \code{thinnedSpatialPolyGEOS} will be us [...]
 }
 \usage{
-thinnedSpatialPoly(SP, tolerance, minarea=0)
+thinnedSpatialPoly(SP, tolerance, minarea=0, topologyPreserve = FALSE,
+                 avoidGEOS = FALSE)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
   \item{SP}{an object inheriting from the SpatialPolygons class}
   \item{tolerance}{the tolerance value in the metric of the input object}
-  \item{minarea}{the smallest area of Polygon objects to be retained}
+  \item{minarea}{the smallest area of Polygon objects to be retained, ignored if \pkg{rgeos} used}
+  \item{topologyPreserve}{choose between two \pkg{rgeos} options: logical determining if the algorithm should attempt to preserve the topology (nodes not complete edges) of the original geometry}
+  \item{avoidGEOS}{use R DP code even if \pkg{rgeos} is available}
 }
 \value{An object of the same class as the input object}
 \references{Douglas, D. and Peucker, T. (1973). Algorithms for 
@@ -24,7 +27,7 @@ represent a digitized line or its caricature.
 
 \note{Warnings reporting: Non-finite label point detected and replaced, reflect the changes in the geometries of the polygons induced by line generalization.}
 
-%\seealso{\code{\link[rgeos]{thinnedSpatialPolyGEOS}}}
+%\seealso{\code{\link[rgeos]{gSimplify}}}
 
 \examples{
 xx <- readShapeSpatial(system.file("shapes/sids.shp", package="maptools")[1],
diff --git a/man/unionSpatialPolygons.Rd b/man/unionSpatialPolygons.Rd
index 8cd5ea8..89ddf8d 100644
--- a/man/unionSpatialPolygons.Rd
+++ b/man/unionSpatialPolygons.Rd
@@ -3,17 +3,18 @@
 %- Also NEED an '\alias' for EACH other topic documented here.
 \title{Aggregate Polygons in a SpatialPolygons object}
 \description{
-  The function aggregates Polygons in a SpatialPolygons object, according to the IDs vector specifying which input Polygons belong to which output Polygons; internal boundaries are dissolved using the gpclib package union() function. If the rgeos package is available, \code{unionSpatialPolygonsGEOS} will be used with partial topology preservation instead of the R implementation here by passing arguments through.
+  The function aggregates Polygons in a SpatialPolygons object, according to the IDs vector specifying which input Polygons belong to which output Polygons; internal boundaries are dissolved using the rgeos package \code{gUnaryUnion} function. If the rgeos package is not available, and if the gpclib package is available and the user confirms that its restrictive license conditions are met, its \code{union} function will be used.
 }
 \usage{
-unionSpatialPolygons(SpP, IDs, threshold=NULL, avoidGEOS=FALSE)
+unionSpatialPolygons(SpP, IDs, threshold=NULL, avoidGEOS=FALSE, avoidUnaryUnion=FALSE)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
   \item{SpP}{A SpatialPolygons object as defined in package sp}
-  \item{IDs}{A vector defining the output Polygons objects, equal in length to the length of the polygons slot of SpRs; it may be character, integer, or factor (try table(factor(IDs)) for a sanity check)}
+  \item{IDs}{A vector defining the output Polygons objects, equal in length to the length of the polygons slot of SpRs; it may be character, integer, or factor (try table(factor(IDs)) for a sanity check). It may contain NA values for input objects not included in the union}
   \item{threshold}{if not NULL, an area measure below which slivers will be discarded (some polygons have non-identical boundaries, for instance along rivers, generating slivers on union which are artefacts, not real sub-polygons)}
   \item{avoidGEOS}{default FALSE; if TRUE force use of gpclib even when GEOS is available}
+  \item{avoidUnaryUnion}{avoid gUnaryUnion if it is available; not relevant before GEOS 3.3.0}
 }
 
 \value{
@@ -23,15 +24,14 @@ unionSpatialPolygons(SpP, IDs, threshold=NULL, avoidGEOS=FALSE)
 \section{Warning}{When using GEOS Unary Union, it has been found that some polygons are not dissolved correctly when the absolute values of the coordinates are very small. No work-around is available at present.}
 
 \author{Roger Bivand}
-%\seealso{\code{\link[rgeos]{unionSpatialPolygonsGEOS}}}
+%\seealso{\code{\link[rgeos]{gUnaryUnion}}}
 \examples{
-gpclibPermit()
-require(gpclib)
+if (!rgeosStatus()) gpclibPermit()
 nc1 <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
  proj4string=CRS("+proj=longlat +datum=NAD27"))
 lps <- coordinates(nc1)
 ID <- cut(lps[,1], quantile(lps[,1]), include.lowest=TRUE)
 reg4 <- unionSpatialPolygons(nc1, ID)
-sapply(slot(reg4, "polygons"), function(i) slot(i, "ID"))
+row.names(reg4)
 }
 \keyword{spatial}
diff --git a/maptools-Ex.R b/maptools-Ex.R
new file mode 100644
index 0000000..de26b77
--- /dev/null
+++ b/maptools-Ex.R
@@ -0,0 +1,1654 @@
+pkgname <- "maptools"
+source(file.path(R.home("share"), "R", "examples-header.R"))
+options(warn = 1)
+library('maptools')
+
+assign(".oldSearch", search(), pos = 'CheckExEnv')
+cleanEx()
+nameEx("CCmaps")
+### * CCmaps
+
+flush(stderr()); flush(stdout())
+
+### Name: CCmaps
+### Title: Conditioned choropleth maps
+### Aliases: CCmaps
+### Keywords: spatial
+
+### ** Examples
+
+nc.sids <- readShapeSpatial(system.file("shapes/sids.shp",
+ package="maptools")[1], IDvar="FIPSNO",
+ proj4string=CRS("+proj=longlat +ellps=clrk66"))
+nc.sids$ft.SID74 <- sqrt(1000)*(sqrt(nc.sids$SID74/nc.sids$BIR74) +
+ sqrt((nc.sids$SID74+1)/nc.sids$BIR74))
+nc.sids$ft.NWBIR74 <- sqrt(1000)*(sqrt(nc.sids$NWBIR74/nc.sids$BIR74) +
+ sqrt((nc.sids$NWBIR74+1)/nc.sids$BIR74))
+library(lattice)
+sh_nw4 <- equal.count(nc.sids$ft.NWBIR74, number=4, overlap=1/5)
+CCmaps(nc.sids, "ft.SID74", list("Nonwhite_births"=sh_nw4),
+ col.regions=colorRampPalette(c("yellow1", "brown3"))(20),
+ main="Transformed SIDS rates 1974-8")
+
+
+
+cleanEx()
+nameEx("ContourLines2SLDF")
+### * ContourLines2SLDF
+
+flush(stderr()); flush(stdout())
+
+### Name: ContourLines2SLDF
+### Title: Converter functions to build SpatialLinesDataFrame objects
+### Aliases: ArcObj2SLDF ContourLines2SLDF MapGen2SL
+### Keywords: spatial
+
+### ** Examples
+
+#data(co37_d90_arc) # retrieved as: 
+# library(RArcInfo)
+# fl <- "http://www.census.gov/geo/cob/bdy/co/co90e00/co37_d90_e00.zip"
+# download.file(fl, "co37_d90_e00.zip")
+# e00 <- zip.file.extract("co37_d90.e00", "co37_d90_e00.zip")
+# e00toavc(e00, "ncar")
+# arc <- get.arcdata(".", "ncar")
+#res <- arcobj2SLDF(arc)
+#plot(res)
+#invisible(title(""))
+res <- ContourLines2SLDF(contourLines(volcano))
+plot(res, col=terrain.colors(nrow(as(res, "data.frame"))))
+title("Volcano contours as SpatialLines")
+
+
+
+cleanEx()
+nameEx("GE_SpatialGrid")
+### * GE_SpatialGrid
+
+flush(stderr()); flush(stdout())
+
+### Name: GE_SpatialGrid
+### Title: Create SpatialGrid for PNG output to GE
+### Aliases: GE_SpatialGrid Sobj_SpatialGrid
+### Keywords: spatial
+
+### ** Examples
+
+opt_exask <- options(example.ask=FALSE)
+qk <- SpatialPointsDataFrame(quakes[, c(2:1)], quakes)
+summary(Sobj_SpatialGrid(qk)$SG)
+t2 <- Sobj_SpatialGrid(qk, n=10000)$SG
+summary(t2)
+prod(slot(slot(t2, "grid"), "cells.dim"))
+proj4string(qk) <- CRS("+proj=longlat")
+tf <- tempfile()
+SGqk <- GE_SpatialGrid(qk)
+png(file=paste(tf, ".png", sep=""), width=SGqk$width, height=SGqk$height,
+  bg="transparent")
+par(mar=c(0,0,0,0), xaxs="i", yaxs="i")
+plot(qk, xlim=SGqk$xlim, ylim=SGqk$ylim, setParUsrBB=TRUE)
+dev.off()
+kmlOverlay(SGqk, paste(tf, ".kml", sep=""), paste(tf, ".png", sep=""))
+## Not run: 
+##D qk0 <- quakes
+##D qk0$long <- ifelse(qk0$long <= 180, qk0$long, qk0$long-360)
+##D qk0a <- SpatialPointsDataFrame(qk0[, c(2:1)], qk0)
+##D proj4string(qk0a) <- CRS("+proj=longlat")
+##D writeOGR(qk0a, paste(tf, "v.kml", sep=""), "Quakes", "KML")
+##D system(paste("googleearth ", tf, ".kml", sep=""))
+## End(Not run)
+options(example.ask=opt_exask)
+
+
+
+graphics::par(get("par.postscript", pos = 'CheckExEnv'))
+cleanEx()
+nameEx("Rgshhs")
+### * Rgshhs
+
+flush(stderr()); flush(stdout())
+
+### Name: Rgshhs
+### Title: Read GSHHS data into sp object
+### Aliases: Rgshhs getRgshhsMap
+### Keywords: spatial
+
+### ** Examples
+
+if (!rgeosStatus()) gpclibPermit()
+gshhs.c.b <- system.file("share/gshhs_c.b", package="maptools")
+WEx <- c(-12, 3)
+WEy <- c(48, 59)
+WE <- getRgshhsMap(gshhs.c.b, xlim=WEx, ylim=WEy)
+plot(WE, col="khaki", xlim=WEx, ylim=WEy, xaxs="i", yaxs="i", axes=TRUE)
+NZx <- c(160,180)
+NZy <- c(-50,-30)
+NZ <- Rgshhs(gshhs.c.b, xlim=NZx, ylim=NZy)
+plot(NZ$SP, col="khaki", pbg="azure2", xlim=NZx, ylim=NZy, xaxs="i", yaxs="i", axes=TRUE)
+GLx <- c(265,285)
+GLy <- c(40,50)
+GL <- Rgshhs(gshhs.c.b, xlim=GLx, ylim=GLy)
+plot(GL$SP, col="khaki", pbg="azure2", xlim=GLx, ylim=GLy, xaxs="i", yaxs="i", axes=TRUE)
+BNLx <- c(2,8)
+BNLy <- c(49,54)
+wdb_lines <- system.file("share/wdb_borders_c.b", package="maptools")
+BNLp <- Rgshhs(gshhs.c.b, xlim=BNLx, ylim=BNLy)
+BNLl <- Rgshhs(wdb_lines, xlim=BNLx, ylim=BNLy)
+plot(BNLp$SP, col="khaki", pbg="azure2", xlim=BNLx, ylim=BNLy, xaxs="i", yaxs="i", axes=TRUE)
+lines(BNLl$SP)
+xlims <- c(0,360)
+ylims <- c(-90,90)
+world <- Rgshhs(gshhs.c.b, xlim=xlims, ylim=ylims, level=1, checkPolygons=TRUE)
+
+
+
+cleanEx()
+nameEx("SpatialLines2PolySet")
+### * SpatialLines2PolySet
+
+flush(stderr()); flush(stdout())
+
+### Name: SpatialLines2PolySet
+### Title: Convert sp line and polygon objects to PBSmapping PolySet
+###   objects
+### Aliases: SpatialLines2PolySet SpatialPolygons2PolySet
+###   PolySet2SpatialPolygons PolySet2SpatialLines
+### Keywords: spatial
+
+### ** Examples
+
+if(require(PBSmapping)) {
+if(require(maps)) {
+nor_coast_lines <- map("world", interior=FALSE, plot=FALSE, xlim=c(4,32),
+ ylim=c(58,72))
+nor_coast_lines <- pruneMap(nor_coast_lines, xlim=c(4,32), ylim=c(58,72))
+nor_coast_lines_sp <- map2SpatialLines(nor_coast_lines,
+ proj4string=CRS("+proj=longlat +datum=wgs84"))
+nor_coast_lines_PS <- SpatialLines2PolySet(nor_coast_lines_sp)
+summary(nor_coast_lines_PS)
+plotLines(nor_coast_lines_PS)
+o3 <- PolySet2SpatialLines(nor_coast_lines_PS)
+plot(o3, axes=TRUE)
+nor_coast_poly <- map("world", "norway", fill=TRUE, col="transparent",
+ plot=FALSE, ylim=c(58,72))
+IDs <- sapply(strsplit(nor_coast_poly$names, ":"), function(x) x[1])
+nor_coast_poly_sp <- map2SpatialPolygons(nor_coast_poly, IDs=IDs,
+ proj4string=CRS("+proj=longlat +datum=wgs84"))
+nor_coast_poly_PS <- SpatialPolygons2PolySet(nor_coast_poly_sp)
+summary(nor_coast_poly_PS)
+plotPolys(nor_coast_poly_PS)
+o1 <- PolySet2SpatialPolygons(nor_coast_poly_PS)
+plot(o1, axes=TRUE)
+}}
+
+
+
+cleanEx()
+nameEx("SpatialLinesMidPoints")
+### * SpatialLinesMidPoints
+
+flush(stderr()); flush(stdout())
+
+### Name: SpatialLinesMidPoints
+### Title: Line midpoints
+### Aliases: SpatialLinesMidPoints
+### Keywords: spatial
+
+### ** Examples
+
+xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1],
+ proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
+plot(xx, col="blue")
+spdf <- SpatialLinesMidPoints(xx)
+plot(spdf, col="orange", add=TRUE)
+
+
+
+cleanEx()
+nameEx("SplashDams")
+### * SplashDams
+
+flush(stderr()); flush(stdout())
+
+### Name: SplashDams
+### Title: Data for Splash Dams in western Oregon
+### Aliases: SplashDams
+### Keywords: datasets
+
+### ** Examples
+
+data(SplashDams)
+plot(SplashDams, axes=TRUE)
+
+
+
+cleanEx()
+nameEx("as.ppp")
+### * as.ppp
+
+flush(stderr()); flush(stdout())
+
+### Name: as.ppp
+### Title: coercion between sp objects and spatstat objects
+### Aliases: as.owin.SpatialGridDataFrame as.owin.SpatialPixelsDataFrame
+###   as.owin.SpatialPolygons as.im.SpatialGridDataFrame
+###   coerce,SpatialGridDataFrame,owin-method
+###   coerce,SpatialPixelsDataFrame,owin-method
+###   coerce,SpatialPolygons,owin-method as.SpatialPolygons.tess
+###   as.SpatialPolygons.owin coerce,tess,SpatialPolygons-method
+###   coerce,owin,SpatialPolygons-method
+###   coerce,SpatialGridDataFrame,im-method as.ppp.SpatialGridDataFrame
+###   as.ppp.SpatialPoints as.ppp.SpatialPointsDataFrame
+###   coerce,SpatialPoints,ppp-method
+###   coerce,SpatialPointsDataFrame,ppp-method as.psp.Line as.psp.Lines
+###   as.psp.SpatialLines as.psp.SpatialLinesDataFrame
+###   coerce,Line,psp-method coerce,Lines,psp-method
+###   coerce,SpatialLines,psp-method
+###   coerce,SpatialLinesDataFrame,psp-method as.SpatialLines.psp
+###   coerce,psp,SpatialLines-method coerce,im,SpatialGridDataFrame-method
+###   coerce,ppp,SpatialGridDataFrame-method
+###   coerce,ppp,SpatialPointsDataFrame-method
+###   coerce,ppp,SpatialPoints-method as.SpatialPointsDataFrame.ppp
+###   as.SpatialGridDataFrame.ppp as.SpatialPoints.ppp
+###   as.SpatialGridDataFrame.im
+### Keywords: spatial
+
+### ** Examples
+
+library(spatstat)
+data(meuse)
+coordinates(meuse) = ~x+y
+zn1 <- as(meuse["zinc"], "ppp")
+zn1
+plot(zn1)
+as(as(meuse, "SpatialPoints"), "ppp")
+data(meuse.grid)
+gridded(meuse.grid) = ~x+y
+mg_owin <- as(meuse.grid, "owin")
+zn1a <- ppp(x=zn1$x, y=zn1$y, marks=zn1$marks, window=mg_owin)
+zn1a
+plot(zn1a)
+rev_ppp_SP <- as.SpatialPoints.ppp(zn1a)
+summary(rev_ppp_SP)
+rev_ppp_SPDF <- as.SpatialPointsDataFrame.ppp(zn1a)
+summary(rev_ppp_SPDF)
+rev_ppp_SGDF <- as.SpatialGridDataFrame.ppp(zn1a)
+summary(rev_ppp_SGDF)
+data(meuse.riv)
+mr <- Line(meuse.riv)
+mr_psp <- as(mr, "psp")
+mr_psp
+plot(mr_psp)
+xx_back <- as(mr_psp, "SpatialLines")
+plot(xx_back)
+xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1],
+ proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
+xx_psp <- as(xx, "psp")
+xx_psp
+plot(xx_psp)
+xx_back <- as(xx_psp, "SpatialLines")
+plot(xx_back)
+mg_owin <- as(as(meuse.grid["ffreq"], "SpatialPixelsDataFrame"), "owin")
+mg_owin
+ho_sp <- SpatialPolygons(list(Polygons(list(Polygon(cbind(c(0,1,1,0,0),
+  c(0,0,1,1,0))), Polygon(cbind(c(0.6,0.4,0.4,0.6,0.6), 
+  c(0.2,0.2,0.4,0.4,0.2)), hole=TRUE)), ID="ho")))
+plot(ho_sp, col="red", pbg="pink")
+ho <- as(ho_sp, "owin")
+plot(ho)
+pp <- runifpoint(500, win=ho)
+plot(pp)
+ho_orig <- owin(poly=list(list(x=c(0,1,1,0), y=c(0,0,1,1)),
+  list(x=c(0.6,0.4,0.4,0.6), y=c(0.2,0.2,0.4,0.4))))
+identical(ho, ho_orig)
+ho_sp1 <- as(ho, "SpatialPolygons")
+all.equal(ho_sp, ho_sp1, check.attributes=FALSE)
+A <- tess(xgrid=0:4,ygrid=0:4)
+A_sp <- as(A, "SpatialPolygons")
+plot(A_sp)
+text(coordinates(A_sp), labels=row.names(A_sp), cex=0.6)
+mg_dist <- meuse.grid["dist"]
+fullgrid(mg_dist) <- TRUE
+image(mg_dist, axes=TRUE)
+mg_im <- as(mg_dist, "im")
+plot(mg_im)
+mg2 <- as.SpatialGridDataFrame.im(mg_im)
+image(mg2, axes=TRUE)
+
+
+
+cleanEx()
+nameEx("asciigrid")
+### * asciigrid
+
+flush(stderr()); flush(stdout())
+
+### Name: readAsciiGrid
+### Title: read/write to/from (ESRI) asciigrid format
+### Aliases: readAsciiGrid writeAsciiGrid
+### Keywords: programming
+
+### ** Examples
+
+x <- readAsciiGrid(system.file("grids/test.ag", package="maptools")[1])
+summary(x)
+image(x)
+xp <- as(x, "SpatialPixelsDataFrame")
+abline(h=332000, lwd=3)
+xpS <- xp[coordinates(xp)[,2] < 332000,]
+summary(xpS)
+xS <- as(xpS, "SpatialGridDataFrame")
+summary(xS)
+tmpfl <- paste(tempdir(), "testS.ag", sep="/")
+writeAsciiGrid(xS, tmpfl)
+axS <- readAsciiGrid(tmpfl)
+opar <- par(mfrow=c(1,2))
+image(xS, main="before export")
+image(axS, main="after import")
+par(opar)
+unlink(tmpfl)
+
+
+
+graphics::par(get("par.postscript", pos = 'CheckExEnv'))
+cleanEx()
+nameEx("checkPolygonsHoles")
+### * checkPolygonsHoles
+
+flush(stderr()); flush(stdout())
+
+### Name: checkPolygonsHoles
+### Title: Check holes in Polygons objects
+### Aliases: checkPolygonsHoles rgeosStatus gpclibPermit gpclibPermitStatus
+### Keywords: spatial
+
+### ** Examples
+
+if (!rgeosStatus()) gpclibPermit()
+nc1 <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
+ proj4string=CRS("+proj=longlat +ellps=clrk66"))
+pl <- slot(nc1, "polygons")
+sapply(slot(pl[[4]], "Polygons"), function(x) slot(x, "hole"))
+pl[[4]] <- Polygons(list(slot(pl[[4]], "Polygons")[[1]],
+ Polygon(slot(slot(pl[[4]], "Polygons")[[2]], "coords"), hole=TRUE),
+ slot(pl[[4]], "Polygons")[[3]]), slot(pl[[4]], "ID"))
+sapply(slot(pl[[4]], "Polygons"), function(x) slot(x, "hole"))
+pl_new <- lapply(pl, checkPolygonsHoles)
+sapply(slot(pl_new[[4]], "Polygons"), function(x) slot(x, "hole"))
+srs <- slot(slot(pl[[1]], "Polygons")[[1]], "coords")
+hle2 <- structure(c(-81.64093, -81.38380, -81.34165, -81.66833, -81.64093, 
+ 36.57865, 36.57234, 36.47603, 36.47894, 36.57865), .Dim = as.integer(c(5, 2)))
+hle3 <- structure(c(-81.47759, -81.39118, -81.38486, -81.46705, -81.47759, 
+ 36.56289, 36.55659, 36.49907, 36.50380, 36.56289), .Dim = as.integer(c(5, 2)))
+x <- Polygons(list(Polygon(srs), Polygon(hle2), Polygon(hle3)),
+ ID=slot(pl[[1]], "ID"))
+sapply(slot(x, "Polygons"), function(x) slot(x, "hole"))
+res <- checkPolygonsHoles(x)
+sapply(slot(res, "Polygons"), function(x) slot(x, "hole"))
+## Not run: 
+##D opar <- par(mfrow=c(1,2))
+##D SPx <- SpatialPolygons(list(x))
+##D plot(SPx)
+##D text(t(sapply(slot(x, "Polygons"), function(i) slot(i, "labpt"))),
+##D  labels=sapply(slot(x, "Polygons"), function(i) slot(i, "hole")), cex=0.6)
+##D title(xlab="Hole slot values before checking")
+##D SPres <- SpatialPolygons(list(res))
+##D plot(SPres)
+##D text(t(sapply(slot(res, "Polygons"), function(i) slot(i, "labpt"))),
+##D  labels=sapply(slot(res, "Polygons"), function(i) slot(i, "hole")), cex=0.6)
+##D title(xlab="Hole slot values after checking")
+##D par(opar)
+##D p1 <- Polygon(cbind(x=c(0, 0, 10, 10, 0), y=c(0, 10, 10, 0, 0))) # I
+##D p2 <- Polygon(cbind(x=c(3, 3, 7, 7, 3), y=c(3, 7, 7, 3, 3))) # H
+##D p8 <- Polygon(cbind(x=c(1, 1, 2, 2, 1), y=c(1, 2, 2, 1, 1))) # H
+##D p9 <- Polygon(cbind(x=c(1, 1, 2, 2, 1), y=c(5, 6, 6, 5, 5))) # H
+##D p3 <- Polygon(cbind(x=c(20, 20, 30, 30, 20), y=c(20, 30, 30, 20, 20))) # I
+##D p4 <- Polygon(cbind(x=c(21, 21, 29, 29, 21), y=c(21, 29, 29, 21, 21))) # H
+##D p14 <- Polygon(cbind(x=c(21, 21, 29, 29, 21), y=c(21, 29, 29, 21, 21))) # H
+##D p5 <- Polygon(cbind(x=c(22, 22, 28, 28, 22), y=c(22, 28, 28, 22, 22))) # I
+##D p15 <- Polygon(cbind(x=c(22, 22, 28, 28, 22), y=c(22, 28, 28, 22, 22))) # I
+##D p6 <- Polygon(cbind(x=c(23, 23, 27, 27, 23), y=c(23, 27, 27, 23, 23))) # H
+##D p7 <- Polygon(cbind(x=c(13, 13, 17, 17, 13), y=c(13, 17, 17, 13, 13))) # I
+##D p10 <- Polygon(cbind(x=c(24, 24, 26, 26, 24), y=c(24, 26, 26, 24, 24))) # I
+##D p11 <- Polygon(cbind(x=c(24.25, 24.25, 25.75, 25.75, 24.25),
+##D  y=c(24.25, 25.75, 25.75, 24.25, 24.25))) # H
+##D p12 <- Polygon(cbind(x=c(24.5, 24.5, 25.5, 25.5, 24.5),
+##D  y=c(24.5, 25.5, 25.5, 24.5, 24.5))) # I
+##D p13 <- Polygon(cbind(x=c(24.75, 24.75, 25.25, 25.25, 24.75),
+##D  y=c(24.75, 25.25, 25.25, 24.75, 24.75))) # H
+##D lp <- list(p1, p2, p13, p7, p6, p5, p4, p3, p8, p11, p12, p9, p10, p14, p15)
+##D #           1   2    3   4   5   6   7   8   9   10   11  12   13   14   15
+##D #           0   1   11   0   6   0   8   0   1   13    0   1    0  (7)  (6)
+##D #           I   H    H   I   H   I   H   I   H    H    I   H    I   ?    ?
+##D pls <- Polygons(lp, ID="1")
+##D comment(pls)
+##D pls1 <- checkPolygonsHoles(pls)
+##D comment(pls1)
+##D opar <- par(mfrow=c(1,2))
+##D plot(SpatialPolygons(list(pls)), col="magenta", pbg="cyan", usePolypath=FALSE)
+##D title(xlab="Hole slot values before checking")
+##D plot(SpatialPolygons(list(pls1)), col="magenta", pbg="cyan", usePolypath=FALSE)
+##D title(xlab="Hole slot values after checking")
+##D par(opar)
+## End(Not run)
+
+
+
+cleanEx()
+nameEx("dotsInPolys")
+### * dotsInPolys
+
+flush(stderr()); flush(stdout())
+
+### Name: dotsInPolys
+### Title: Put dots in polygons
+### Aliases: dotsInPolys
+### Keywords: spatial
+
+### ** Examples
+
+nc_SP <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
+ proj4string=CRS("+proj=longlat  +ellps=clrk66"))
+## Not run: 
+##D library(spgpc)
+##D pls <- slot(nc_SP, "polygons")
+##D pls_new <- lapply(pls, checkPolygonsHoles)
+##D nc_SP <- SpatialPolygonsDataFrame(SpatialPolygons(pls_new,
+##D  proj4string=CRS(proj4string(nc_SP))), data=as(nc_SP, "data.frame"))
+## End(Not run)
+try1 <- dotsInPolys(nc_SP, as.integer(nc_SP$SID74))
+plot(nc_SP, axes=TRUE)
+plot(try1, add=TRUE, pch=18, col="red")
+try2 <- dotsInPolys(nc_SP, as.integer(nc_SP$SID74), f="regular")
+plot(nc_SP, axes=TRUE)
+plot(try2, add=TRUE, pch=18, col="red")
+
+
+
+cleanEx()
+nameEx("elide-methods")
+### * elide-methods
+
+flush(stderr()); flush(stdout())
+
+### Name: elide-methods
+### Title: Methods for Function elide in Package 'maptools'
+### Aliases: elide-methods elide,SpatialPoints-method
+###   elide,SpatialPointsDataFrame-method elide,SpatialLines-method
+###   elide,SpatialLinesDataFrame-method elide,SpatialPolygons-method
+###   elide,SpatialPolygonsDataFrame-method elide
+### Keywords: methods spatial
+
+### ** Examples
+
+data(meuse)
+coordinates(meuse) <- c("x", "y")
+proj4string(meuse) <- CRS("+init=epsg:28992")
+data(meuse.riv)
+river_polygon <- Polygons(list(Polygon(meuse.riv)), ID="meuse")
+rivers <- SpatialPolygons(list(river_polygon))
+proj4string(rivers) <- CRS("+init=epsg:28992")
+rivers1 <- elide(rivers, reflect=c(TRUE, TRUE), scale=TRUE)
+meuse1 <- elide(meuse, bb=bbox(rivers), reflect=c(TRUE, TRUE), scale=TRUE)
+opar <- par(mfrow=c(1,2))
+plot(rivers, axes=TRUE)
+plot(meuse, add=TRUE)
+plot(rivers1, axes=TRUE)
+plot(meuse1, add=TRUE)
+par(opar)
+meuse1 <- elide(meuse, shift=c(10000, -10000))
+bbox(meuse)
+bbox(meuse1)
+rivers1 <- elide(rivers, shift=c(10000, -10000))
+bbox(rivers)
+bbox(rivers1)
+meuse1 <- elide(meuse, rotate=-30, center=apply(bbox(meuse), 1, mean))
+bbox(meuse)
+bbox(meuse1)
+plot(meuse1, axes=TRUE)
+
+
+
+graphics::par(get("par.postscript", pos = 'CheckExEnv'))
+cleanEx()
+nameEx("gcDestination")
+### * gcDestination
+
+flush(stderr()); flush(stdout())
+
+### Name: gcDestination
+### Title: Find destination in geographical coordinates
+### Aliases: gcDestination
+### Keywords: spatial
+
+### ** Examples
+
+data(state)
+res <- gcDestination(state.center$x, state.center$y, 45, 250, "km")
+plot(state.center$x, state.center$y, asp=1, pch=16)
+arrows(state.center$x, state.center$y, res[,1], res[,2], length=0.05)
+llist <- vector(mode="list", length=length(state.center$x))
+for (i in seq(along=llist)) llist[[i]] <- gcDestination(state.center$x[i],
+  state.center$y[i], seq(0, 360, 5), 250, "km")
+plot(state.center$x, state.center$y, asp=1, pch=3)
+nll <- lapply(llist, lines)
+
+
+
+cleanEx()
+nameEx("getKMLcoordinates")
+### * getKMLcoordinates
+
+flush(stderr()); flush(stdout())
+
+### Name: getKMLcoordinates
+### Title: Get a list of coordinates out of a KML file
+### Aliases: getKMLcoordinates
+### Keywords: spatial
+
+### ** Examples
+
+data(wrld_simpl)
+## creates a KML file containing the polygons of South Africa (plus hole)
+sw <- slot(wrld_simpl[wrld_simpl$NAME=="South Africa",], "polygons")[[1]]
+tf <- tempfile()
+kmlPolygon(sw, kmlfile=tf, name="South Africa", col="#df0000aa", lwd=5, 
+    border=4, kmlname="R Test", 
+    kmldescription="This is <b>only</b> a <a href='http://www.r-project.org'>R</a> test.")
+zz <- getKMLcoordinates(tf, ignoreAltitude=TRUE)
+str(zz)
+
+
+
+cleanEx()
+nameEx("getinfo.shape")
+### * getinfo.shape
+
+flush(stderr()); flush(stdout())
+
+### Name: getinfo.shape
+### Title: Get shapefile header information
+### Aliases: getinfo.shape print.shapehead
+### Keywords: spatial
+
+### ** Examples
+
+res <- getinfo.shape(system.file("shapes/fylk-val.shp", package="maptools")[1])
+res
+str(res)
+
+
+
+cleanEx()
+nameEx("gzAzimuth")
+### * gzAzimuth
+
+flush(stderr()); flush(stdout())
+
+### Name: gzAzimuth
+### Title: Find azimuth for geographical coordinates
+### Aliases: gzAzimuth trackAzimuth
+### Keywords: spatial
+
+### ** Examples
+
+name <- c("Mecca", "Anchorage", "Washington")
+long <- c(39.823333, -149.883333, -77.0166667)
+lat <- c(21.423333, 61.2166667, 38.9)
+x <- cbind(long, lat)
+row.names(x) <- name
+crib <- c(-9.098363, 56.575960)
+r1 <- gzAzimuth(x[2:3,], x[1,])
+r1
+all.equal(r1, crib)
+r2 <- gzAzimuth(x[2:3,], x[1,], type="abdali")
+r2
+all.equal(r2, crib)
+trackAzimuth(x)
+
+
+
+cleanEx()
+nameEx("holepolys")
+### * holepolys
+
+flush(stderr()); flush(stdout())
+
+### Name: gpcholes
+### Title: Hisaji Ono's lake/hole problem
+### Aliases: gpcholes h1pl h2pl
+### Keywords: datasets
+
+### ** Examples
+
+data(gpcholes)
+opar <- par(mfrow=c(1,2))
+plot(SpatialPolygons(list(h2pl)), col="red", pbg="white", border="blue")
+plot(SpatialPolygons(list(h1pl)), col="red", pbg="white", border="blue")
+par(opar)
+
+
+
+graphics::par(get("par.postscript", pos = 'CheckExEnv'))
+cleanEx()
+nameEx("kmlLine")
+### * kmlLine
+
+flush(stderr()); flush(stdout())
+
+### Name: kmlLine
+### Title: Create and write a KML file on the basis of a given Lines object
+### Aliases: kmlLine
+### Keywords: spatial
+
+### ** Examples
+
+xx <- readShapeSpatial(system.file("shapes/fylk-val-ll.shp",
+      package="maptools")[1], proj4string=CRS("+proj=longlat"))
+out <- sapply(slot(xx, "lines"), function(x) { kmlLine(x,
+    name=slot(x, "ID"), col="blue", lwd=1.5, 
+    description=paste("river:", slot(x, "ID"))) })
+tf <- tempfile()
+kmlFile <- file(tf, "w")
+tf
+cat(kmlLine(kmlname="R Test", kmldescription="<i>Hello</i>")$header, 
+    file=kmlFile, sep="\n")
+cat(unlist(out["style",]), file=kmlFile, sep="\n")
+cat(unlist(out["content",]), file=kmlFile, sep="\n")
+cat(kmlLine()$footer, file=kmlFile, sep="\n")
+close(kmlFile)
+
+
+
+cleanEx()
+nameEx("kmlOverlay")
+### * kmlOverlay
+
+flush(stderr()); flush(stdout())
+
+### Name: kmlOverlay
+### Title: Create and write KML file for PNG image overlay
+### Aliases: kmlOverlay
+### Keywords: spatial
+
+### ** Examples
+
+opt_exask <- options(example.ask=FALSE)
+qk <- SpatialPointsDataFrame(quakes[, c(2:1)], quakes)
+proj4string(qk) <- CRS("+proj=longlat")
+tf <- tempfile()
+SGqk <- GE_SpatialGrid(qk)
+png(file=paste(tf, ".png", sep=""), width=SGqk$width, height=SGqk$height,
+  bg="transparent")
+par(mar=c(0,0,0,0), xaxs="i", yaxs="i")
+plot(qk, xlim=SGqk$xlim, ylim=SGqk$ylim, setParUsrBB=TRUE)
+dev.off()
+kmlOverlay(SGqk, paste(tf, ".kml", sep=""), paste(tf, ".png", sep=""))
+## Not run: 
+##D library(rgdal)
+##D qk0 <- quakes
+##D qk0$long <- ifelse(qk0$long <= 180, qk0$long, qk0$long-360)
+##D qk0a <- SpatialPointsDataFrame(qk0[, c(2:1)], qk0)
+##D proj4string(qk0a) <- CRS("+proj=longlat")
+##D writeOGR(qk0a, paste(tf, "v.kml", sep=""), "Quakes", "KML")
+##D system(paste("googleearth ", tf, ".kml", sep=""))
+## End(Not run)
+options(example.ask=opt_exask)
+
+
+
+graphics::par(get("par.postscript", pos = 'CheckExEnv'))
+cleanEx()
+nameEx("kmlPoints")
+### * kmlPoints
+
+flush(stderr()); flush(stdout())
+
+### Name: kmlPoints
+### Title: Create and write a KML file on the basis of a given Points
+###   object
+### Aliases: kmlPoints
+### Keywords: spatial
+
+### ** Examples
+
+data(SplashDams)
+num <- length(SplashDams)
+td <- tempdir()
+kmlfile <- paste(td, "OregonSplashDams.kml", sep="/")
+kmlname <- "Oregon Splash Dams"
+kmldescription <- "Data for Splash Dams in western Oregon. See http://www.fs.fed.us/pnw/lwm/aem/people/burnett.html#projects_activities for more information."
+icon <- "http://google.com/mapfiles/kml/paddle/wht-diamond.png"
+name <- paste("Dam on",SplashDams$streamName)
+description <- paste("<b>owner:</b>",SplashDams$owner,"<br><b>dates:</b>",SplashDams$datesUsed)
+
+kmlPoints(SplashDams, kmlfile=kmlfile, name=name, description=description,
+          icon=icon, kmlname=kmlname, kmldescription=kmldescription)
+
+
+
+cleanEx()
+nameEx("kmlPolygon")
+### * kmlPolygon
+
+flush(stderr()); flush(stdout())
+
+### Name: kmlPolygon
+### Title: Create and write a KML file on the basis of a given Polygons
+###   object
+### Aliases: kmlPolygon
+### Keywords: spatial
+
+### ** Examples
+
+data(wrld_simpl)
+## creates a KML file containing the polygons of South Africa (plus hole)
+sw <- slot(wrld_simpl[wrld_simpl$NAME=="South Africa",], "polygons")[[1]]
+tf <- tempfile()
+kmlPolygon(sw, kmlfile=tf, name="South Africa", col="#df0000aa", lwd=5, 
+    border=4, kmlname="R Test", 
+    kmldescription="This is <b>only</b> a <a href='http://www.r-project.org'>R</a> test.")
+tf
+
+## creates a KML file containing the polygons of South Africa, Switzerland, and Canada
+sw  <- wrld_simpl[wrld_simpl$NAME %in% c("South Africa", "Switzerland", "Canada"),]
+out <- sapply(slot(sw, "polygons"), function(x) { kmlPolygon(x,
+    name=as(sw, "data.frame")[slot(x, "ID"), "NAME"], 
+    col="red", lwd=1.5, border='black', 
+    description=paste("ISO3:", slot(x, "ID"))) })
+tf <- tempfile()
+kmlFile <- file(tf, "w")
+tf
+cat(kmlPolygon(kmlname="R Test", kmldescription="<i>Hello</i>")$header, 
+    file=kmlFile, sep="\n")
+cat(unlist(out["style",]), file=kmlFile, sep="\n")
+cat(unlist(out["content",]), file=kmlFile, sep="\n")
+cat(kmlPolygon()$footer, file=kmlFile, sep="\n")
+close(kmlFile)
+
+
+
+cleanEx()
+nameEx("leglabs")
+### * leglabs
+
+flush(stderr()); flush(stdout())
+
+### Name: leglabs
+### Title: Make legend labels
+### Aliases: leglabs
+### Keywords: spatial
+
+### ** Examples
+
+mappolys <- readShapeSpatial(system.file("shapes/columbus.shp", package="maptools")[1], ID="NEIGNO")
+brks <- round(quantile(mappolys$CRIME, probs=seq(0,1,0.2)), digits=2)
+colours <- c("salmon1", "salmon2", "red3", "brown", "black")
+plot(mappolys, col=colours[findInterval(mappolys$CRIME, brks,
+ all.inside=TRUE)])
+legend(x=c(5.8, 7.1), y=c(13, 14.5), legend=leglabs(brks),
+  fill=colours, bty="n")
+invisible(title(main=paste("Columbus OH: residential burglaries and vehicle",
+ "thefts per thousand households, 1980", sep="\n")))
+
+
+
+cleanEx()
+nameEx("lineLabel")
+### * lineLabel
+
+flush(stderr()); flush(stdout())
+
+### Name: lineLabel
+### Title: Line label placement with spplot and lattice.
+### Aliases: lineLabel sp.lineLabel label sp.lineLabel-methods
+###   label-methods sp.lineLabel,Lines-method
+###   sp.lineLabel,SpatialLines-method label,SpatialLines-method
+
+### ** Examples
+
+data(meuse.grid)
+coordinates(meuse.grid) = ~x+y
+proj4string(meuse.grid) <- CRS("+init=epsg:28992")
+gridded(meuse.grid) = TRUE
+
+data(meuse)
+coordinates(meuse) = ~x+y
+data(meuse.riv)
+meuse.sl <- SpatialLines(list(Lines(list(Line(meuse.riv)), "1")))
+
+library(RColorBrewer)
+myCols <- adjustcolor(colorRampPalette(brewer.pal(n=9, 'Reds'))(100), .85)
+
+labs <- label(meuse.sl, 'Meuse River')
+
+## Maximum depth
+sl1 <- list('sp.lineLabel', meuse.sl, label=labs,
+            position='below', textloc='maxDepth',
+            spar=.2,
+            col='darkblue', cex=1,
+            fontfamily='Palatino',
+            fontface=2)
+
+spplot(meuse.grid["dist"],
+       col.regions=myCols, 
+       sp.layout = sl1)
+
+## Constant slope
+sl2 <- modifyList(sl1, list(textloc = 'constantSlope')) ## Default
+
+spplot(meuse.grid["dist"],
+       col.regions=myCols, 
+       sp.layout = sl2)
+
+## Location defined by its numeric index
+sl3 <- modifyList(sl1, list(textloc = 140, position='above'))
+
+spplot(meuse.grid["dist"],
+       col.regions=myCols, 
+       sp.layout = sl3)
+
+
+
+
+cleanEx()
+nameEx("map2SpatialPolygons")
+### * map2SpatialPolygons
+
+flush(stderr()); flush(stdout())
+
+### Name: map2SpatialPolygons
+### Title: Convert map objects to sp classes
+### Aliases: map2SpatialPolygons map2SpatialLines pruneMap
+### Keywords: spatial
+
+### ** Examples
+
+if(require(maps)) {
+nor_coast_poly <- map("world", "norway", fill=TRUE, col="transparent",
+ plot=FALSE)
+range(nor_coast_poly$x, na.rm=TRUE)
+range(nor_coast_poly$y, na.rm=TRUE)
+nor_coast_poly <- map("world", "norway", fill=TRUE, col="transparent",
+ plot=FALSE, ylim=c(58,72))
+nor_coast_poly$names
+IDs <- sapply(strsplit(nor_coast_poly$names, ":"), function(x) x[1])
+nor_coast_poly_sp <- map2SpatialPolygons(nor_coast_poly, IDs=IDs,
+ proj4string=CRS("+proj=longlat +datum=wgs84"))
+sapply(slot(nor_coast_poly_sp, "polygons"),
+ function(x) length(slot(x, "Polygons")))
+plot(nor_coast_poly_sp, col="grey", axes=TRUE)
+nor_coast_lines <- map("world", interior=FALSE, plot=FALSE, xlim=c(4,32),
+ ylim=c(58,72))
+plot(nor_coast_lines, type="l")
+nor_coast_lines <- pruneMap(nor_coast_lines, xlim=c(4,32), ylim=c(58,72))
+lines(nor_coast_lines, col="red")
+nor_coast_lines_sp <- map2SpatialLines(nor_coast_lines,
+ proj4string=CRS("+proj=longlat +datum=wgs84"))
+plot(nor_coast_poly_sp, col="grey", axes=TRUE)
+plot(nor_coast_lines_sp, col="blue", add=TRUE)
+}
+
+
+
+cleanEx()
+nameEx("nearestPointOnLine")
+### * nearestPointOnLine
+
+flush(stderr()); flush(stdout())
+
+### Name: nearestPointOnLine
+### Title: Get the nearest point on a line to a given point
+### Aliases: nearestPointOnLine
+### Keywords: spatial
+
+### ** Examples
+
+coordsLine = cbind(c(1,2,3),c(3,2,2))
+coordsPoint = c(1.2,1.5)
+nearestPointOnLine(coordsLine, coordsPoint)
+
+
+
+cleanEx()
+nameEx("nearestPointOnSegment")
+### * nearestPointOnSegment
+
+flush(stderr()); flush(stdout())
+
+### Name: nearestPointOnSegment
+### Title: Get the nearest point on a segment to a given point
+### Aliases: nearestPointOnSegment
+### Keywords: spatial
+
+### ** Examples
+
+segment = cbind(c(1,2),c(1,1.5))
+point = c(1.2,1.5)
+nearestPointOnSegment(segment, point)
+
+
+
+cleanEx()
+nameEx("nowrapRecenter")
+### * nowrapRecenter
+
+flush(stderr()); flush(stdout())
+
+### Name: nowrapRecenter
+### Title: Break polygons at meridian for recentering
+### Aliases: nowrapRecenter nowrapSpatialPolygons
+### Keywords: spatial
+
+### ** Examples
+
+## Not run: 
+##D if (!rgeosStatus()) gpclibPermit()
+##D library(maps)
+##D world <- map("world", fill=TRUE, col="transparent", plot=FALSE)
+##D worldSpP <- map2SpatialPolygons(world, world$names, CRS("+proj=longlat"))
+##D worldSpP <- worldSpP[-grep("Antarctica", row.names(worldSpP)),]
+##D # incomplete polygons
+##D worldSpP <- worldSpP[-grep("Ghana", row.names(worldSpP)),]
+##D # self-intersection mouth of Volta
+##D worldSpP <- worldSpP[-grep("UK:Great Britain", row.names(worldSpP)),]
+##D # self-intersection Humber estuary
+##D worldSpPr <- recenter(worldSpP)
+##D plot(worldSpPr)
+##D title("Pacific view without polygon splitting")
+##D worldSpPnr <- nowrapRecenter(worldSpP)
+##D plot(worldSpPnr)
+##D title("Pacific view with polygon splitting")
+## End(Not run)
+crds <- matrix(c(-1, 1, 1, -1, 50, 50, 52, 52), ncol=2)
+rcrds <- rbind(crds, crds[1,])
+SR <- SpatialPolygons(list(Polygons(list(Polygon(rcrds)), ID="r1")),
+ proj4string=CRS("+proj=longlat"))
+bbox(SR)
+SRr <- recenter(SR)
+bbox(SRr)
+SRnr <- nowrapRecenter(SR)
+bbox(SRnr)
+
+
+
+cleanEx()
+nameEx("pal2SpatialPolygons")
+### * pal2SpatialPolygons
+
+flush(stderr()); flush(stdout())
+
+### Name: pal2SpatialPolygons
+### Title: Making SpatialPolygons objects from RArcInfo input
+### Aliases: pal2SpatialPolygons
+### Keywords: spatial
+
+### ** Examples
+
+nc1 <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], ID="FIPS")
+plot(nc1)
+text(coordinates(nc1), labels=row.names(nc1), cex=0.6)
+if(require(maps)){
+ncmap <- map("county", "north carolina", fill=TRUE, col="transparent",
+ plot=FALSE)
+IDs <- sapply(strsplit(ncmap$names, "[,:]"), function(x) x[2])
+nc2 <- map2SpatialPolygons(ncmap, IDs)
+plot(nc2)
+text(coordinates(nc2), labels=row.names(nc2), cex=0.6)
+}
+if(require(RArcInfo)) {
+td <- tempdir()
+tmpcover <- paste(td, "nc", sep="/")
+if (!file.exists(tmpcover)) e00toavc(system.file("share/co37_d90.e00",
+ package="maptools")[1], tmpcover)
+arc <- get.arcdata(td, "nc")
+pal <- get.paldata(td, "nc")
+pat <- get.tabledata(paste(td, "info", sep="/"), "NC.PAT")
+sapply(pal[[2]], function(x) length(x[[1]]))
+IDs <- paste(pat$ST[-1], pat$CO[-1], sep="")
+nc3 <- pal2SpatialPolygons(arc, pal, IDs=IDs)
+plot(nc3)
+text(coordinates(nc3), labels=row.names(nc3), cex=0.6)
+}
+
+
+
+cleanEx()
+nameEx("pointLabelBase")
+### * pointLabelBase
+
+flush(stderr()); flush(stdout())
+
+### Name: pointLabel
+### Title: Label placement for points to avoid overlaps
+### Aliases: pointLabel
+### Keywords: aplot
+
+### ** Examples
+
+n <- 50
+x <- rnorm(n)*10
+y <- rnorm(n)*10
+plot(x, y, col = "red", pch = 20)
+pointLabel(x, y, as.character(round(x,5)), offset = 0, cex = .7)
+
+plot(x, y, col = "red", pch = 20)
+pointLabel(x, y, expression(over(alpha, beta[123])), offset = 0, cex = .8)
+
+
+
+
+cleanEx()
+nameEx("pointLabelLattice")
+### * pointLabelLattice
+
+flush(stderr()); flush(stdout())
+
+### Name: panel.pointLabel
+### Title: Label placement with spplot and lattice.
+### Aliases: panel.pointLabel sp.pointLabel sp.pointLabel-methods
+###   sp.pointLabel,SpatialPoints-method
+
+### ** Examples
+
+n <- 15
+x <- rnorm(n)*10
+y <- rnorm(n)*10
+labels <- as.character(round(x, 5))
+
+
+myTheme <- list(add.text=list(
+                  cex=0.7,
+                  col='midnightblue',
+                  fontface=2,
+                  fontfamily='mono'))
+
+xyplot(y~x,
+       labels=labels,
+       par.settings=myTheme, 
+       panel=function(x, y, labels, ...){
+         panel.xyplot(x, y, ...)
+         panel.pointLabel(x, y, labels=labels, ...)
+       })
+
+
+
+data(meuse.grid)
+coordinates(meuse.grid) = ~x+y
+proj4string(meuse.grid) <- CRS("+init=epsg:28992")
+gridded(meuse.grid) = TRUE
+
+library(RColorBrewer)
+myCols <- adjustcolor(colorRampPalette(brewer.pal(n=9, 'Reds'))(100), .85)
+
+pts <- spsample(meuse.grid, n=15, type="random")
+
+Rauthors <- readLines(file.path(R.home("doc"), "AUTHORS"))[9:28]
+someAuthors <- Rauthors[seq_along(pts)]
+
+sl1 <- list('sp.points', pts, pch=19, cex=.8, col='midnightblue')
+sl2 <- list('sp.pointLabel', pts, label=someAuthors,
+            cex=0.7, col='midnightblue',
+            fontfamily='Palatino')
+
+spplot(meuse.grid["dist"], col.regions=myCols, sp.layout=list(sl1, sl2))
+
+
+
+cleanEx()
+nameEx("readGPS")
+### * readGPS
+
+flush(stderr()); flush(stdout())
+
+### Name: readGPS
+### Title: GPSbabel read interface
+### Aliases: readGPS
+### Keywords: spatial
+
+### ** Examples
+
+## Not run: 
+##D b1 <- readGPS(f="usb:")
+##D str(b1)
+##D b2 <- b1[1:172,]
+##D wp0 <- b2[,c(2,3,4,8,9,19)]
+##D str(wp0)
+##D wp0$long <- wp0$V9
+##D wp0$lat <- as.numeric(as.character(wp0$V8))
+##D wp0$id <- as.character(wp0$V2)
+##D wp0$alt <- as.numeric(substring(as.character(wp0$V19), 1,
+##D  (nchar(as.character(wp0$V19))-1)))
+##D wp0$time <- as.POSIXct(strptime(paste(as.character(wp0$V3),
+##D  as.character(wp0$V4)), format="%d-%b-%y %H:%M:%S"))
+##D str(wp0)
+##D wp1 <- wp0[,-(1:6)]
+##D str(wp1)
+##D summary(wp1)
+## End(Not run)
+
+
+
+cleanEx()
+nameEx("readShapeLines")
+### * readShapeLines
+
+flush(stderr()); flush(stdout())
+
+### Name: readShapeLines
+### Title: Read arc shape files into SpatialLinesDataFrame objects
+### Aliases: readShapeLines writeLinesShape
+### Keywords: spatial
+
+### ** Examples
+
+xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1],
+ proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
+plot(xx, col="blue")
+summary(xx)
+xxx <- xx[xx$LENGTH > 30000,]
+plot(xxx, col="red", add=TRUE)
+tmpfl <- paste(tempdir(), "xxline", sep="/")
+writeLinesShape(xxx, tmpfl)
+getinfo.shape(paste(tmpfl, ".shp", sep=""))
+axx <- readShapeLines(tmpfl, proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
+plot(xxx, col="black", lwd=4)
+plot(axx, col="yellow", lwd=1, add=TRUE)
+unlink(paste(tmpfl, ".*", sep=""))
+xx <- readShapeLines(system.file("shapes/sids.shp", package="maptools")[1],
+ proj4string=CRS("+proj=longlat +datum=NAD27"))
+plot(xx, col="blue")
+
+
+
+cleanEx()
+nameEx("readShapePoints")
+### * readShapePoints
+
+flush(stderr()); flush(stdout())
+
+### Name: readShapePoints
+### Title: Read points shape files into SpatialPointsDataFrame objects
+### Aliases: readShapePoints writePointsShape
+### Keywords: spatial
+
+### ** Examples
+
+library(maptools)
+xx <- readShapePoints(system.file("shapes/baltim.shp", package="maptools")[1])
+plot(xx)
+summary(xx)
+xxx <- xx[xx$PRICE < 40,]
+tmpfl <- paste(tempdir(), "xxpts", sep="/")
+writePointsShape(xxx, tmpfl)
+getinfo.shape(paste(tmpfl, ".shp", sep=""))
+axx <- readShapePoints(tmpfl)
+plot(axx, col="red", add=TRUE)
+unlink(paste(tmpfl, ".*", sep=""))
+xx <- readShapePoints(system.file("shapes/pointZ.shp", package="maptools")[1])
+dimensions(xx)
+plot(xx)
+summary(xx)
+
+
+
+cleanEx()
+nameEx("readShapePoly")
+### * readShapePoly
+
+flush(stderr()); flush(stdout())
+
+### Name: readShapePoly
+### Title: Read polygon shape files into SpatialPolygonsDataFrame objects
+### Aliases: readShapePoly writePolyShape
+### Keywords: spatial
+
+### ** Examples
+
+library(maptools)
+xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
+ IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
+plot(xx, border="blue", axes=TRUE, las=1)
+text(coordinates(xx), labels=row.names(xx), cex=0.6)
+as(xx, "data.frame")[1:5, 1:6]
+xxx <- xx[xx$SID74 < 2,]
+plot(xxx, border="red", add=TRUE)
+tmpfl <- paste(tempdir(), "xxpoly", sep="/")
+writePolyShape(xxx, tmpfl)
+getinfo.shape(paste(tmpfl, ".shp", sep=""))
+axx <- readShapePoly(tmpfl, proj4string=CRS("+proj=longlat +ellps=clrk66"))
+plot(xxx, border="black", lwd=4)
+plot(axx, border="yellow", lwd=1, add=TRUE)
+unlink(paste(tmpfl, ".*", sep=""))
+
+
+
+cleanEx()
+nameEx("readShapeSpatial")
+### * readShapeSpatial
+
+flush(stderr()); flush(stdout())
+
+### Name: readShapeSpatial
+### Title: Read shape files into Spatial*DataFrame objects
+### Aliases: readShapeSpatial writeSpatialShape
+### Keywords: spatial
+
+### ** Examples
+
+library(maptools)
+xx <- readShapeSpatial(system.file("shapes/sids.shp", package="maptools")[1],
+ IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
+summary(xx)
+xxx <- xx[xx$SID74 < 2,]
+tmpfl <- paste(tempdir(), "xxpoly", sep="/")
+writeSpatialShape(xxx, tmpfl)
+getinfo.shape(paste(tmpfl, ".shp", sep=""))
+unlink(paste(tmpfl, ".*", sep=""))
+xx <- readShapeSpatial(system.file("shapes/fylk-val.shp",
+ package="maptools")[1], proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
+summary(xx)
+xxx <- xx[xx$LENGTH > 30000,]
+plot(xxx, col="red", add=TRUE)
+tmpfl <- paste(tempdir(), "xxline", sep="/")
+writeSpatialShape(xxx, tmpfl)
+getinfo.shape(paste(tmpfl, ".shp", sep=""))
+unlink(paste(tmpfl, ".*", sep=""))
+xx <- readShapeSpatial(system.file("shapes/baltim.shp", package="maptools")[1])
+summary(xx)
+xxx <- xx[xx$PRICE < 40,]
+tmpfl <- paste(tempdir(), "xxpts", sep="/")
+writeSpatialShape(xxx, tmpfl)
+getinfo.shape(paste(tmpfl, ".shp", sep=""))
+unlink(paste(tmpfl, ".*", sep=""))
+
+
+
+cleanEx()
+nameEx("readSplus")
+### * readSplus
+
+flush(stderr()); flush(stdout())
+
+### Name: readSplus
+### Title: Read exported WinBUGS maps
+### Aliases: readSplus
+### Keywords: spatial
+
+### ** Examples
+
+geobugs <- readSplus(system.file("share/Splus.map", package="maptools"))
+plot(geobugs, axes=TRUE, col=1:3)
+row.names(geobugs)
+pls <- slot(geobugs, "polygons")
+sapply(pls, function(i) sapply(slot(i, "Polygons"), slot, "hole"))
+pls1 <- lapply(pls, checkPolygonsHoles)
+sapply(pls1, function(i) sapply(slot(i, "Polygons"), slot, "hole"))
+plot(SpatialPolygons(pls1), axes=TRUE, col=1:3)
+
+
+
+cleanEx()
+nameEx("snapPointsToLines")
+### * snapPointsToLines
+
+flush(stderr()); flush(stdout())
+
+### Name: snapPointsToLines
+### Title: Snap a set of points to a set of lines
+### Aliases: snapPointsToLines
+### Keywords: spatial
+
+### ** Examples
+
+# From the sp vignette
+l1 = cbind(c(1,2,3),c(3,2,2))
+l1a = cbind(l1[,1]+.05,l1[,2]+.05)
+l2 = cbind(c(1,2,3),c(1,1.5,1))
+Sl1 = Line(l1)
+Sl1a = Line(l1a)
+Sl2 = Line(l2)
+S1 = Lines(list(Sl1, Sl1a), ID="a")
+S2 = Lines(list(Sl2), ID="b")
+Sl = SpatialLines(list(S1,S2))
+df = data.frame(z = c(1,2), row.names=sapply(slot(Sl, "lines"), function(x) slot(x, "ID")))
+Sldf = SpatialLinesDataFrame(Sl, data = df)
+
+xc = c(1.2,1.5,2.5)
+yc = c(1.5,2.2,1.6)
+Spoints = SpatialPoints(cbind(xc, yc))
+
+snapPointsToLines(Spoints, Sldf)
+
+
+
+cleanEx()
+nameEx("sp2Mondrian")
+### * sp2Mondrian
+
+flush(stderr()); flush(stdout())
+
+### Name: sp2Mondrian
+### Title: write map data for Mondrian
+### Aliases: sp2Mondrian
+### Keywords: spatial
+
+### ** Examples
+
+## Not run: 
+##D xx <- readShapePoly(system.file("shapes/columbus.shp", package="maptools")[1])
+##D sp2Mondrian(xx, file="columbus1.txt")
+##D xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1])
+##D sp2Mondrian(xx, file="sids1.txt")
+## End(Not run)
+
+
+
+cleanEx()
+nameEx("sp2WB")
+### * sp2WB
+
+flush(stderr()); flush(stdout())
+
+### Name: sp2WB
+### Title: Export SpatialPolygons object as S-Plus map for WinBUGS
+### Aliases: sp2WB
+### Keywords: spatial
+
+### ** Examples
+
+xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
+ IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
+plot(xx, border="blue", axes=TRUE, las=1)
+tf <- tempfile()
+sp2WB(as(xx, "SpatialPolygons"), filename=tf)
+xxx <- readSplus(tf, proj4string=CRS("+proj=longlat +ellps=clrk66"))
+all.equal(xxx, as(xx, "SpatialPolygons"), tolerance=.Machine$double.eps^(1/4),
+ check.attributes=FALSE)
+## Not run: 
+##D x <- readAsciiGrid(system.file("grids/test.ag", package="maptools")[1])
+##D xp <- as(x, "SpatialPixelsDataFrame")
+##D pp <- as.SpatialPolygons.SpatialPixels(xp)
+##D sp2WB(pp, filename="test.map")
+## End(Not run)
+
+
+
+cleanEx()
+nameEx("sp2tmap")
+### * sp2tmap
+
+flush(stderr()); flush(stdout())
+
+### Name: sp2tmap
+### Title: Convert SpatialPolygons object for Stata tmap command
+### Aliases: sp2tmap
+### Keywords: spatial
+
+### ** Examples
+
+## Not run: 
+##D xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
+##D  IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
+##D plot(xx, border="blue", axes=TRUE, las=1)
+##D tmapdf <- sp2tmap(as(xx, "SpatialPolygons"))
+##D write.dta(tmapdf, file="NCmap.dta", version=7)
+##D NCdf <- as(xx, "data.frame")
+##D NCdf$ID_n <- attr(tmapdf, "ID_names")
+##D write.dta(NCdf, file="NC.dta", version=7)
+## End(Not run)
+
+
+
+cleanEx()
+nameEx("spCbind-methods")
+### * spCbind-methods
+
+flush(stderr()); flush(stdout())
+
+### Name: spCbind-methods
+### Title: cbind for spatial objects
+### Aliases: spCbind-methods
+###   spCbind,SpatialPointsDataFrame,data.frame-method
+###   spCbind,SpatialPointsDataFrame,vector-method
+###   spCbind,SpatialLinesDataFrame,data.frame-method
+###   spCbind,SpatialLinesDataFrame,vector-method
+###   spCbind,SpatialPolygonsDataFrame,data.frame-method
+###   spCbind,SpatialPolygonsDataFrame,vector-method spCbind
+### Keywords: methods spatial
+
+### ** Examples
+
+xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], 
+  IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
+xtra <- read.dbf(system.file("share/nc_xtra.dbf", package="maptools")[1])
+o <- match(xx$CNTY_ID, xtra$CNTY_ID)
+xtra1 <- xtra[o,]
+row.names(xtra1) <- xx$FIPSNO
+xx1 <- spCbind(xx, xtra1)
+names(xx1)
+identical(xx1$CNTY_ID, xx1$CNTY_ID.1)
+
+
+
+cleanEx()
+nameEx("spRbind-methods")
+### * spRbind-methods
+
+flush(stderr()); flush(stdout())
+
+### Name: spRbind-methods
+### Title: rbind for spatial objects
+### Aliases: spRbind-methods spRbind,SpatialPoints,SpatialPoints-method
+###   spRbind,SpatialPointsDataFrame,SpatialPointsDataFrame-method
+###   spRbind,SpatialLines,SpatialLines-method
+###   spRbind,SpatialLinesDataFrame,SpatialLinesDataFrame-method
+###   spRbind,SpatialPolygons,SpatialPolygons-method
+###   spRbind,SpatialPolygonsDataFrame,SpatialPolygonsDataFrame-method
+###   spRbind
+### Keywords: methods spatial
+
+### ** Examples
+
+xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], 
+  IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
+summary(xx)
+xx$FIPSNO
+xx1 <- xx[xx$CNTY_ID < 1982,]
+xx2 <- xx[xx$CNTY_ID >= 1982,]
+xx3 <- spRbind(xx2, xx1)
+summary(xx3)
+xx3$FIPSNO
+
+
+
+cleanEx()
+nameEx("state.vbm")
+### * state.vbm
+
+flush(stderr()); flush(stdout())
+
+### Name: state.vbm
+### Title: US State Visibility Based Map
+### Aliases: state.vbm
+### Keywords: datasets
+
+### ** Examples
+
+  data(state.vbm)
+  plot(state.vbm)
+
+  tmp <- state.x77[,'HS Grad']
+  tmp2 <- cut(tmp, seq(min(tmp),max(tmp), length.out=11),
+    include.lowest=TRUE)
+  plot(state.vbm,col=cm.colors(10)[tmp2])
+
+
+
+cleanEx()
+nameEx("sun-methods")
+### * sun-methods
+
+flush(stderr()); flush(stdout())
+
+### Name: sun-methods
+### Title: Methods for sun ephemerides calculations
+### Aliases: crepuscule sunriset solarnoon solarpos crepuscule-methods
+###   crepuscule,SpatialPoints,POSIXct-method
+###   crepuscule,matrix,POSIXct-method solarnoon-methods
+###   solarnoon,SpatialPoints,POSIXct-method
+###   solarnoon,matrix,POSIXct-method solarpos-methods
+###   solarpos,SpatialPoints,POSIXct-method solarpos,matrix,POSIXct-method
+###   sunriset-methods sunriset,SpatialPoints,POSIXct-method
+###   sunriset,matrix,POSIXct-method
+### Keywords: methods manip utilities
+
+### ** Examples
+
+## Location of Helsinki, Finland, in decimal degrees,
+## as listed in NOAA's website
+hels <- matrix(c(24.97, 60.17), nrow=1)
+Hels <- SpatialPoints(hels, proj4string=CRS("+proj=longlat +datum=WGS84"))
+d041224 <- as.POSIXct("2004-12-24", tz="EET")
+## Astronomical dawn
+crepuscule(hels, d041224, solarDep=18, direction="dawn", POSIXct.out=TRUE)
+crepuscule(Hels, d041224, solarDep=18, direction="dawn", POSIXct.out=TRUE)
+## Nautical dawn
+crepuscule(hels, d041224, solarDep=12, direction="dawn", POSIXct.out=TRUE)
+crepuscule(Hels, d041224, solarDep=12, direction="dawn", POSIXct.out=TRUE)
+## Civil dawn
+crepuscule(hels, d041224, solarDep=6, direction="dawn", POSIXct.out=TRUE)
+crepuscule(Hels, d041224, solarDep=6, direction="dawn", POSIXct.out=TRUE)
+solarnoon(hels, d041224, POSIXct.out=TRUE)
+solarnoon(Hels, d041224, POSIXct.out=TRUE)
+solarpos(hels, as.POSIXct(Sys.time(), tz="EET"))
+solarpos(Hels, as.POSIXct(Sys.time(), tz="EET"))
+sunriset(hels, d041224, direction="sunrise", POSIXct.out=TRUE)
+sunriset(Hels, d041224, direction="sunrise", POSIXct.out=TRUE)
+## Using a sequence of dates
+Hels_seq <- seq(from=d041224, length.out=365, by="days")
+up <- sunriset(Hels, Hels_seq, direction="sunrise", POSIXct.out=TRUE)
+down <- sunriset(Hels, Hels_seq, direction="sunset", POSIXct.out=TRUE)
+day_length <- down$time - up$time
+plot(Hels_seq, day_length, type="l")
+
+## Using a grid of spatial points for the same point in time
+grd <- GridTopology(c(-179,-89), c(1,1), c(359,179))
+SP <- SpatialPoints(coordinates(grd),
+                    proj4string=CRS("+proj=longlat +datum=WGS84"))
+wint <- as.POSIXct("2004-12-21", tz="GMT")
+win <- crepuscule(SP, wint, solarDep=6, direction="dawn")
+SPDF <- SpatialGridDataFrame(grd,
+ proj4string=CRS("+proj=longlat +datum=WGS84"),
+ data=data.frame(winter=win))
+image(SPDF, axes=TRUE, col=cm.colors(40))
+
+
+
+cleanEx()
+nameEx("symbolsInPolys")
+### * symbolsInPolys
+
+flush(stderr()); flush(stdout())
+
+### Name: symbolsInPolys
+### Title: Place grids of points over polygons
+### Aliases: symbolsInPolys
+### Keywords: spatial
+
+### ** Examples
+
+nc_SP <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
+ proj4string=CRS("+proj=longlat +ellps=clrk66"))
+## Not run: 
+##D library(spgpc)
+##D pls <- slot(nc_SP, "polygons")
+##D pls_new <- lapply(pls, checkPolygonsHoles)
+##D nc_SP <- SpatialPolygonsDataFrame(SpatialPolygons(pls_new,
+##D  proj4string=CRS(proj4string(nc_SP))), data=as(nc_SP, "data.frame"))
+## End(Not run)
+symbs <- c("-", "+", "x")
+np <- sapply(slot(nc_SP, "polygons"), function(x) length(slot(x, "Polygons")))
+try1 <- symbolsInPolys(nc_SP, 100, symb=symbs[np])
+plot(nc_SP, axes=TRUE)
+plot(try1, add=TRUE, pch=as.character(try1$symb))
+
+
+
+cleanEx()
+nameEx("thinnedSpatialPoly")
+### * thinnedSpatialPoly
+
+flush(stderr()); flush(stdout())
+
+### Name: thinnedSpatialPoly
+### Title: Douglas-Peuker line generalization for Spatial Polygons
+### Aliases: thinnedSpatialPoly
+### Keywords: spatial
+
+### ** Examples
+
+xx <- readShapeSpatial(system.file("shapes/sids.shp", package="maptools")[1],
+      IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
+object.size(as(xx, "SpatialPolygons"))
+xxx <- thinnedSpatialPoly(xx, tolerance=0.05, minarea=0.001)
+object.size(as(xxx, "SpatialPolygons"))
+par(mfrow=c(2,1))
+plot(xx)
+plot(xxx)
+par(mfrow=c(1,1))
+
+
+
+graphics::par(get("par.postscript", pos = 'CheckExEnv'))
+cleanEx()
+nameEx("unionSpatialPolygons")
+### * unionSpatialPolygons
+
+flush(stderr()); flush(stdout())
+
+### Name: unionSpatialPolygons
+### Title: Aggregate Polygons in a SpatialPolygons object
+### Aliases: unionSpatialPolygons
+### Keywords: spatial
+
+### ** Examples
+
+if (!rgeosStatus()) gpclibPermit()
+nc1 <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
+ proj4string=CRS("+proj=longlat +datum=NAD27"))
+lps <- coordinates(nc1)
+ID <- cut(lps[,1], quantile(lps[,1]), include.lowest=TRUE)
+reg4 <- unionSpatialPolygons(nc1, ID)
+row.names(reg4)
+
+
+
+cleanEx()
+nameEx("wrld_simpl")
+### * wrld_simpl
+
+flush(stderr()); flush(stdout())
+
+### Name: wrld_simpl
+### Title: Simplified world country polygons
+### Aliases: wrld_simpl
+### Keywords: datasets
+
+### ** Examples
+
+data(wrld_simpl)
+plot(wrld_simpl)
+
+
+
+### * <FOOTER>
+###
+cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
+grDevices::dev.off()
+###
+### Local variables: ***
+### mode: outline-minor ***
+### outline-regexp: "\\(> \\)?### [*]+" ***
+### End: ***
+quit('no')
diff --git a/src/Rgshhs.c b/src/Rgshhs.c
index 1f0b29a..ebbc46a 100644
--- a/src/Rgshhs.c
+++ b/src/Rgshhs.c
@@ -1,6 +1,6 @@
-/*	$Id: Rgshhs.c,v 1.8 2010/04/03 16:01:48 rsbivand Exp $
+/*	$Id: Rgshhs.c 254 2013-02-09 10:22:26Z rsbivand $
  *
- *	Copyright (c) 1996-2009 by P. Wessel and W. H. F. Smith
+ *	Copyright (c) 1996-2011 by P. Wessel and W. H. F. Smith
  *	See COPYING file for copying and redistribution conditions.
  *
  * PROGRAM:	gshhs.c
@@ -24,6 +24,10 @@
  *				the polygons ancestor in the full resolution, and
  *				a flag to tell if a lake is a riverlake.
  *				Updated to deal with latest GSHHS database (2.0)
+ *		1.13 15-JUL-2011: Now contains improved area information (2.2.0),
+ *				 and revised greenwhich flags (now 2-bit; see gshhs.h).
+ *				 Also added -A and -G as suggested by José Luis García Pallero,
+ *				 as well as -Qe|i to control river-lake output.
  *
  *	Copyright (c) 1996-2004 by P. Wessel and W. H. F. Smith
  *	See COPYING file for copying and redistribution conditions.
@@ -40,7 +44,7 @@
  *	Contact info: www.soest.hawaii.edu/pwessel */
 
 /*
- * This modification of gshhs.c is Copyright (c) 2005-9 Roger Bivand
+ * This modification of gshhs.c is Copyright (c) 2005-2011 Roger Bivand
  * Modification to swap function taken from Rsystat.c in foreign 071117
 */
 
@@ -78,11 +82,11 @@ int gshhs_between(double x, double low, double up);
 SEXP Rgshhs(SEXP fn, SEXP mode, SEXP dolim, SEXP lim, SEXP level, SEXP minarea) 
 {
 	FILE *fp;
-	double w, e, s, n, area, lon, lat;
+	double w, e, s, n, area, lon, lat, scale = 10.0;
 	char source;
 	char msg[255];
-	char *name[2] = {"polygon", "line"};
-	int k, line, max_east = 270000000, n_read, /*flip,*/ Level, version, greenwich, src;
+	const char *name[2] = {"polygon", "line"};
+	int k, line, max_east = 270000000, n_read, /*flip,*/ Level, version, greenwich, src, m, river;
 	struct POINT p;
 	struct GSHHS h;
 	int npols, pc=0;
@@ -175,10 +179,11 @@ SEXP Rgshhs(SEXP fn, SEXP mode, SEXP dolim, SEXP lim, SEXP level, SEXP minarea)
 /*		    }*/
 		    Level = h.flag & 255;
 		    version = (h.flag >> 8) & 255;
-		    if (version != GSHHS_DATA_RELEASE) 
+		    if (!(version >= 9)) 
 			error("Data not same version as software");
-		    greenwich = (h.flag >> 16) & 255;
-		    src = (h.flag >> 24) & 255;
+		    greenwich = (h.flag >> 16) & 3;			/* Greenwich is 0-3 */
+		    src = (h.flag >> 24) & 1;			/* Greenwich is 0 (WDBII) or 1 (WVS) */
+		    river = (h.flag >> 25) & 1;			/* River is 0 (not river) or 1 (is river) */
 		    w = h.west  * GSHHS_SCL;	
 /* Convert from microdegrees to degrees */
 		    e = h.east  * GSHHS_SCL;
@@ -186,8 +191,9 @@ SEXP Rgshhs(SEXP fn, SEXP mode, SEXP dolim, SEXP lim, SEXP level, SEXP minarea)
 		    n = h.north * GSHHS_SCL;
 		    source = (src == 1) ? 'W' : 'C';	/* Either WVS or CIA (WDBII) pedigree */
 		    line = (h.area) ? 0 : 1;		/* Either Polygon (0) or Line (1) (if no area) */
-		    area = 0.1 * h.area;			
-/* Now im km^2 */
+		    m = h.flag >> 26;
+		    scale = pow (10.0, (double)m);		/* Area scale */
+		    area = h.area / scale;				/* Now im km^2 */
 		    INTEGER_POINTER(VECTOR_ELT(res, 0))[i] = (signed int) h.id;
 		    INTEGER_POINTER(VECTOR_ELT(res, 1))[i] = (signed int) h.n;
 		    INTEGER_POINTER(VECTOR_ELT(res, 2))[i] = 
diff --git a/src/Rgshhs.h b/src/Rgshhs.h
index 0aaf1ae..c7b29f1 100644
--- a/src/Rgshhs.h
+++ b/src/Rgshhs.h
@@ -1,4 +1,4 @@
-/*	$Id: Rgshhs.h,v 1.6 2010/04/03 16:01:48 rsbivand Exp $
+/*	
  *
  * Include file defining structures used in gshhs.c
  *
@@ -32,10 +32,14 @@
  *			  an ancestor ID, and area of the reduced polygon. Works on
  *			  GSHHS 2.0 data.
  *			  Header is now 44 bytes (all 4-byte integers)
+ *	24-MAY-2010.  PW: Data version is now 2.1.0. [no change to format]
+ *	15-JUL-2011.  PW: Data version is now 2.2.0. [Change in header format to store
+ *			  area magnitude and let greenwich be 2-bit flag (0-3)]. Also
+ *			  flag WDBII riverlakes with the river flag as used for GSHHS.
  */
 
 /*
-This modification of gshhs.h is Copyright (c) 2005-9 Roger Bivand
+This modification of gshhs.h is Copyright (c) 2005-2011 Roger Bivand
 */
 
 #ifndef _GSHHS
@@ -44,6 +48,7 @@ This modification of gshhs.h is Copyright (c) 2005-9 Roger Bivand
 
 /*#include <stdio.h>
 #include <stdlib.h>
+#include <ctype.h>
 #include <math.h> RSB */
 
 #ifndef M_PI
@@ -54,9 +59,9 @@ This modification of gshhs.h is Copyright (c) 2005-9 Roger Bivand
 #define SEEK_CUR 1
 #endif
 
-#define GSHHS_DATA_RELEASE	7	/* For v2.0 data set */
-#define GSHHS_DATA_VERSION	"2.0"	/* For v2.0 data set */
-#define GSHHS_PROG_VERSION	"1.12"
+#define GSHHS_DATA_RELEASE	9	/* For v2.2.0 data set */
+#define GSHHS_DATA_VERSION	"2.2.0"	/* For v2.2.0 data set */
+#define GSHHS_PROG_VERSION	"1.13"
 
 #define GSHHS_SCL	1.0e-6	/* COnvert micro-degrees to degrees */
 
@@ -82,16 +87,18 @@ This modification of gshhs.h is Copyright (c) 2005-9 Roger Bivand
 struct GSHHS {	/* Global Self-consistent Hierarchical High-resolution Shorelines */
 	int id;		/* Unique polygon id number, starting at 0 */
 	int n;		/* Number of points in this polygon */
-	int flag;	/* = level + version << 8 + greenwich << 16 + source << 24 + river << 25 */
-	/* flag contains 5 items, as follows:
+	int flag;	/* = level + version << 8 + greenwich << 16 + source << 24 + river << 25 + p << 26 */
+	/* flag contains 6 items, as follows:
 	 * low byte:	level = flag & 255: Values: 1 land, 2 lake, 3 island_in_lake, 4 pond_in_island_in_lake
-	 * 2nd byte:	version = (flag >> 8) & 255: Values: Should be 7 for GSHHS release 7
-	 * 3rd byte:	greenwich = (flag >> 16) & 1: Values: Greenwich is 1 if Greenwich is crossed
+	 * 2nd byte:	version = (flag >> 8) & 255: Values: Should be 9 for GSHHS release 9
+ 	 * 3rd byte:	greenwich = (flag >> 16) & 3: Values: 0 if Greenwich nor Dateline are crossed,
+	 *		1 if Greenwich is crossed, 2 if Dateline is crossed, 3 if both is crossed.
 	 * 4th byte:	source = (flag >> 24) & 1: Values: 0 = CIA WDBII, 1 = WVS
-	 * 4th byte:	river = (flag >> 25) & 1: Values: 0 = not set, 1 = river-lake and level = 2
+	 * 4th byte:	river = (flag >> 25) & 1: Values: 0 = not set, 1 = river-lake and GSHHS level = 2 (or WDBII level 0)
+	 * 4th byte:	area magnitude scale p (as in 10^p) = flag >> 26.  We divide area by 10^p.
 	 */
 	int west, east, south, north;	/* min/max extent in micro-degrees */
-	int area;	/* Area of polygon in 1/10 km^2 */
+	int area;	/* Area of polygon in km^2 * 10^p for this resolution file */
 	int area_full;	/* Area of original full-resolution polygon in 1/10 km^2 */
 	int container;	/* Id of container polygon that encloses this polygon (-1 if none) */
 	int ancestor;	/* Id of ancestor polygon in the full resolution set that was the source of this polygon (-1 if none) */
diff --git a/src/Rshapeget.c b/src/Rshapeget.c
index 6f7116c..1c9e563 100644
--- a/src/Rshapeget.c
+++ b/src/Rshapeget.c
@@ -21,7 +21,7 @@ SEXP Rshapeget(SEXP shpnm, SEXP repair)
 
 {
     SHPHandle	hSHP;
-    int    nShapeType, nEntities, nImpliedEOF, qRep, i, pc=0;
+    int    nShapeType, nEntities, qRep, i, pc=0;
     double  adfMinBound[4], adfMaxBound[4];
     int j, pz=0, k;
     SHPObject *psShape;
diff --git a/src/Rshapewrite1.c b/src/Rshapewrite1.c
index 92adbc1..5c46642 100644
--- a/src/Rshapewrite1.c
+++ b/src/Rshapewrite1.c
@@ -9,10 +9,10 @@ SEXP shpwritepolys(SEXP fname, SEXP shapes)
 {
     SHPHandle   hSHP;
     SHPObject   *psShape;
-    int         nShapeType, i, j, k, kk;
+    int         nShapeType = SHPT_POLYGON, i, j, k, kk;
     int		nShapes, maxnParts=0, maxnVerts=0, pc=0, nDims;
     int		*nParts, *nVerts, *panPartStart, *from, *to;
-    double      *padfX, *padfY, *padfZ;
+    double      *padfX, *padfY, *padfZ=NULL;
     SEXP	SnParts, Spstart, SnDims;
 
     PROTECT(SnDims = NEW_CHARACTER(1)); pc++;
diff --git a/src/shapefil.h b/src/shapefil.h
index 7ea81eb..3793373 100644
--- a/src/shapefil.h
+++ b/src/shapefil.h
@@ -2,7 +2,7 @@
 #define _SHAPEFILE_H_INCLUDED
 
 /******************************************************************************
- * $Id: shapefil.h,v 1.1.1.1 2005/09/01 18:21:44 rsbivand Exp $
+ * $Id: shapefil.h 182 2011-02-06 14:48:28Z rsbivand $
  *
  * Project:  Shapelib
  * Purpose:  Primary include file for Shapelib.
diff --git a/src/shpopen.c b/src/shpopen.c
index 29efd35..6f0347a 100644
--- a/src/shpopen.c
+++ b/src/shpopen.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: shpopen.c,v 1.3 2007/11/16 09:12:40 rsbivand Exp $
+ * $Id: shpopen.c 220 2011-11-14 21:35:15Z rsbivand $
  *
  * Project:  Shapelib
  * Purpose:  Implementation of core Shapefile read/write functions.
@@ -200,7 +200,7 @@
 #include <string.h>
 #include <stdio.h>
 
-SHP_CVSID("$Id: shpopen.c,v 1.3 2007/11/16 09:12:40 rsbivand Exp $")
+SHP_CVSID("$Id: shpopen.c 220 2011-11-14 21:35:15Z rsbivand $")
 
 typedef unsigned char uchar;
 
@@ -984,7 +984,8 @@ SHPCreateObject( int nSHPType, int nShapeId, int nParts,
             CPLError( CE_Failure, CPLE_AppDefined,
                       "panPartStart[0] != 0, patching internally.  Please fix your code!\n" );
 #else
-            fprintf( stderr, "panPartStart[0] != 0, patching internally.  Please fix your code!\n" );
+// RSB 111114
+            warning("panPartStart[0] != 0, patching internally.  Please fix your code!\n" );
 #endif
             psObject->panPartStart[0] = 0;
         }
diff --git a/src/shptree.c b/src/shptree.c
index a1a2e83..94f7c9b 100644
--- a/src/shptree.c
+++ b/src/shptree.c
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: shptree.c,v 1.2 2007/11/10 13:17:42 rsbivand Exp $
+ * $Id: shptree.c 182 2011-02-06 14:48:28Z rsbivand $
  *
  * Project:  Shapelib
  * Purpose:  Implementation of quadtree building and searching functions.
@@ -79,7 +79,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-SHP_CVSID("$Id: shptree.c,v 1.2 2007/11/10 13:17:42 rsbivand Exp $")
+SHP_CVSID("$Id: shptree.c 182 2011-02-06 14:48:28Z rsbivand $")
 
 #ifndef TRUE
 #  define TRUE 1

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/r-cran-maptools.git



More information about the debian-science-commits mailing list