修复了在R

时间:2018-02-04 03:10:20

标签: r ggplot2

我尝试使用ggplot2创建一个显示一系列gpx文件的地图。大多数gpx文件都可以处理,但是其中一些文件会产生一些错误,其中绘制的是固体形状而不是线条。我在下面列举了一个这样的例子。基数R中的图显示了结果应该是什么样子。

我不完全确定ggplot2错误的来源是什么,任何想法都会非常感激。

下面使用的gpx文件可以下载(来自Strava)[这里](显示错误的极端版本​​的数据框的子集)粘贴在1下面。

我使用的代码是:

library(rgdal)
library(raster)
library(dplyr)
library(ggplot2)

gpxFile <- "file.gpx"
gpxRoute <- readOGR(dsn = gpxFile, layer = "tracks")

## PLOT USING BASE R

base_plot <- plot(gpxRoute)

## PLOT USING GGPLOT2

gg_plot <- gpxRoute %>%
  fortify() %>%
  ggplot() +
  geom_line(aes(x = long, y = lat, group = group, colour = "red")) 
gg_plot

基础R结果

Plot using base R ggplot结果

Attempt using ggplot2

long    lat order   piece   id  group
-83.709161  22.619206   1   1   0   0.1
-83.709266  22.619215   2   1   0   0.1
-83.709306  22.619246   3   1   0   0.1
-83.709326  22.619332   4   1   0   0.1
-83.70931   22.619351   5   1   0   0.1
-83.70928   22.619368   6   1   0   0.1
-83.709187  22.619423   7   1   0   0.1
-83.708963  22.61954    8   1   0   0.1
-83.708892  22.619578   9   1   0   0.1
-83.708747  22.619654   10  1   0   0.1
-83.70867   22.619691   11  1   0   0.1
-83.708626  22.619716   12  1   0   0.1
-83.70854   22.619751   13  1   0   0.1
-83.708441  22.619753   14  1   0   0.1
-83.708397  22.619734   15  1   0   0.1
-83.708322  22.619675   16  1   0   0.1
-83.708291  22.619636   17  1   0   0.1
-83.708225  22.619523   18  1   0   0.1
-83.707969  22.619138   19  1   0   0.1
-83.707798  22.618925   20  1   0   0.1
-83.707712  22.618808   21  1   0   0.1
-83.707538  22.618596   22  1   0   0.1
-83.707271  22.618281   23  1   0   0.1
-83.707116  22.618113   24  1   0   0.1
-83.70708   22.618067   25  1   0   0.1
-83.706976  22.617948   26  1   0   0.1
-83.706939  22.617891   27  1   0   0.1
-83.706936  22.617864   28  1   0   0.1
-83.70695   22.617832   29  1   0   0.1
-83.707005  22.617783   30  1   0   0.1
-83.707123  22.617706   31  1   0   0.1
-83.707189  22.61766    32  1   0   0.1
-83.707277  22.617599   33  1   0   0.1
-83.707458  22.617471   34  1   0   0.1
-83.707482  22.617453   35  1   0   0.1
-83.707715  22.617292   36  1   0   0.1
-83.707746  22.617274   37  1   0   0.1
-83.707911  22.617167   38  1   0   0.1
-83.707935  22.617149   39  1   0   0.1
-83.708135  22.617011   40  1   0   0.1
-83.708156  22.616995   41  1   0   0.1
-83.708371  22.616822   42  1   0   0.1
-83.708553  22.616694   43  1   0   0.1
-83.708776  22.616549   44  1   0   0.1
-83.708804  22.61653    45  1   0   0.1
-83.708968  22.616423   46  1   0   0.1
-83.709033  22.616374   47  1   0   0.1
-83.709138  22.616293   48  1   0   0.1
-83.709363  22.616137   49  1   0   0.1
-83.709538  22.61601    50  1   0   0.1
-83.709717  22.615881   51  1   0   0.1
-83.710095  22.615612   52  1   0   0.1
-83.71014   22.615576   53  1   0   0.1
-83.710229  22.615506   54  1   0   0.1
-83.710361  22.615418   55  1   0   0.1
-83.710483  22.615331   56  1   0   0.1
-83.710624  22.615228   57  1   0   0.1
-83.710839  22.615081   58  1   0   0.1
-83.711007  22.614961   59  1   0   0.1
-83.711066  22.61492    60  1   0   0.1
-83.711257  22.614781   61  1   0   0.1
-83.711387  22.614687   62  1   0   0.1
-83.711451  22.614643   63  1   0   0.1
-83.711802  22.614388   64  1   0   0.1
-83.712179  22.614133   65  1   0   0.1
-83.71261   22.613827   66  1   0   0.1
-83.712949  22.613592   67  1   0   0.1
-83.713258  22.613418   68  1   0   0.1
-83.713556  22.613264   69  1   0   0.1
-83.71398   22.613126   70  1   0   0.1
-83.714368  22.613104   71  1   0   0.1
-83.714846  22.613101   72  1   0   0.1
-83.715374  22.613075   73  1   0   0.1
-83.715969  22.612996   74  1   0   0.1
-83.716432  22.61291    75  1   0   0.1
-83.716665  22.612862   76  1   0   0.1
-83.716952  22.612805   77  1   0   0.1
-83.717541  22.612694   78  1   0   0.1
-83.71801   22.612598   79  1   0   0.1
-83.718123  22.612572   80  1   0   0.1
-83.718525  22.612503   81  1   0   0.1
-83.718725  22.612468   82  1   0   0.1
-83.718849  22.612446   83  1   0   0.1
-83.718888  22.612439   84  1   0   0.1
-83.71909   22.6124 85  1   0   0.1
-83.719118  22.612393   86  1   0   0.1
-83.719291  22.61235    87  1   0   0.1
-83.719351  22.612337   88  1   0   0.1
-83.719506  22.612314   89  1   0   0.1
-83.719567  22.612303   90  1   0   0.1
-83.719819  22.612253   91  1   0   0.1
-83.71995   22.612231   92  1   0   0.1
-83.720288  22.612167   93  1   0   0.1
-83.720704  22.612091   94  1   0   0.1
-83.72081   22.612072   95  1   0   0.1
-83.721106  22.61201    96  1   0   0.1
-83.72145   22.611942   97  1   0   0.1
-83.721593  22.611914   98  1   0   0.1
-83.722119  22.611818   99  1   0   0.1
-83.722405  22.611766   100 1   0   0.1
-83.722557  22.611739   101 1   0   0.1
-83.723005  22.61165    102 1   0   0.1
-83.723457  22.611564   103 1   0   0.1
-83.723606  22.611533   104 1   0   0.1
-83.723959  22.611457   105 1   0   0.1
-83.724322  22.611388   106 1   0   0.1
-83.724781  22.611302   107 1   0   0.1
-83.725287  22.611207   108 1   0   0.1
-83.725396  22.611187   109 1   0   0.1
-83.725812  22.611107   110 1   0   0.1
-83.726339  22.611001   111 1   0   0.1
-83.726939  22.610882   112 1   0   0.1
-83.727055  22.610859   113 1   0   0.1
-83.727628  22.61075    114 1   0   0.1
-83.727792  22.610717   115 1   0   0.1
-83.727899  22.610695   116 1   0   0.1
-83.728255  22.610629   117 1   0   0.1
-83.728406  22.610605   118 1   0   0.1
-83.728722  22.61055    119 1   0   0.1
-83.729309  22.610428   120 1   0   0.1
-83.729845  22.610325   121 1   0   0.1
-83.730203  22.610257   122 1   0   0.1
-83.730558  22.610183   123 1   0   0.1
-83.730822  22.610136   124 1   0   0.1
-83.731366  22.61003    125 1   0   0.1
-83.731729  22.609965   126 1   0   0.1
-83.732297  22.609857   127 1   0   0.1
-83.732653  22.609779   128 1   0   0.1
-83.732887  22.609733   129 1   0   0.1
-83.732972  22.609723   130 1   0   0.1
-83.733337  22.609653   131 1   0   0.1
-83.733799  22.609563   132 1   0   0.1
-83.734275  22.609466   133 1   0   0.1
-83.734796  22.609369   134 1   0   0.1
-83.735091  22.609308   135 1   0   0.1
-83.735136  22.609301   136 1   0   0.1
-83.735265  22.609282   137 1   0   0.1
-83.735326  22.609278   138 1   0   0.1
-83.73534   22.609287   139 1   0   0.1
-83.735308  22.609324   140 1   0   0.1
-83.735284  22.609359   141 1   0   0.1
-83.735222  22.60951    142 1   0   0.1
-83.735251  22.609714   143 1   0   0.1
-83.735263  22.609797   144 1   0   0.1
-83.735276  22.609971   145 1   0   0.1
-83.735271  22.610167   146 1   0   0.1
-83.73525   22.6104 147 1   0   0.1
-83.735234  22.610513   148 1   0   0.1
-83.735187  22.610721   149 1   0   0.1
-83.735164  22.610863   150 1   0   0.1
-83.735085  22.611153   151 1   0   0.1
-83.73503   22.61135    152 1   0   0.1
-83.734956  22.6116 153 1   0   0.1
-83.734906  22.611762   154 1   0   0.1
-83.734832  22.611991   155 1   0   0.1
-83.734737  22.612312   156 1   0   0.1
-83.734713  22.61238    157 1   0   0.1
-83.734674  22.612521   158 1   0   0.1
-83.734591  22.612813   159 1   0   0.1
-83.73452   22.61304    160 1   0   0.1
-83.734452  22.613273   161 1   0   0.1
-83.734377  22.613582   162 1   0   0.1
-83.734318  22.61381    163 1   0   0.1
-83.734292  22.613957   164 1   0   0.1
-83.73429   22.6141 165 1   0   0.1
-83.734309  22.614234   166 1   0   0.1
-83.734359  22.614411   167 1   0   0.1
-83.734464  22.614736   168 1   0   0.1
-83.734507  22.614834   169 1   0   0.1
-83.734627  22.615103   170 1   0   0.1
-83.734706  22.615283   171 1   0   0.1
-83.734798  22.615456   172 1   0   0.1
-83.734843  22.615539   173 1   0   0.1
-83.73498   22.61578    174 1   0   0.1
-83.735038  22.615856   175 1   0   0.1
-83.735215  22.616109   176 1   0   0.1
-83.735248  22.616154   177 1   0   0.1
-83.735389  22.616343   178 1   0   0.1
-83.735505  22.616493   179 1   0   0.1
-83.735546  22.616544   180 1   0   0.1
-83.735825  22.616842   181 1   0   0.1
-83.735868  22.616894   182 1   0   0.1
-83.736181  22.617301   183 1   0   0.1
-83.736214  22.617348   184 1   0   0.1
-83.736316  22.617533   185 1   0   0.1
-83.736471  22.617841   186 1   0   0.1
-83.736482  22.617877   187 1   0   0.1
-83.73658   22.61808    188 1   0   0.1
-83.736628  22.618179   189 1   0   0.1
-83.736714  22.618337   190 1   0   0.1
-83.736864  22.618575   191 1   0   0.1
-83.737055  22.618796   192 1   0   0.1
-83.737221  22.618952   193 1   0   0.1
-83.7373    22.619023   194 1   0   0.1
-83.737427  22.61916    195 1   0   0.1
-83.737478  22.619208   196 1   0   0.1
-83.737537  22.619251   197 1   0   0.1
-83.737602  22.619285   198 1   0   0.1
-83.737749  22.61931    199 1   0   0.1
-83.737822  22.619294   200 1   0   0.1
-83.737957  22.619251   201 1   0   0.1
-83.738281  22.619105   202 1   0   0.1
-83.73857   22.618979   203 1   0   0.1
-83.738742  22.618891   204 1   0   0.1
-83.738787  22.618871   205 1   0   0.1
-83.738853  22.618828   206 1   0   0.1
-83.738947  22.618781   207 1   0   0.1
-83.739011  22.618764   208 1   0   0.1
-83.739061  22.618742   209 1   0   0.1
-83.739144  22.618659   210 1   0   0.1
-83.739163  22.618642   211 1   0   0.1
-83.739248  22.618589   212 1   0   0.1
-83.739348  22.618564   213 1   0   0.1
-83.739471  22.618515   214 1   0   0.1
-83.739677  22.618463   215 1   0   0.1
-83.739808  22.618446   216 1   0   0.1
-83.739911  22.61845    217 1   0   0.1
-83.740005  22.618457   218 1   0   0.1
-83.740067  22.618472   219 1   0   0.1
-83.740059  22.618496   220 1   0   0.1
-83.739973  22.618493   221 1   0   0.1
-83.739825  22.618469   222 1   0   0.1
-83.739788  22.618466   223 1   0   0.1
-83.739684  22.618461   224 1   0   0.1
-83.739511  22.618476   225 1   0   0.1
-83.739444  22.618495   226 1   0   0.1
-83.739205  22.618599   227 1   0   0.1
-83.738841  22.618799   228 1   0   0.1
-83.738668  22.618898   229 1   0   0.1
-83.738514  22.618974   230 1   0   0.1
-83.738464  22.619013   231 1   0   0.1
-83.738424  22.619043   232 1   0   0.1
-83.738395  22.619061   233 1   0   0.1
-83.738284  22.619123   234 1   0   0.1
-83.738265  22.61913    235 1   0   0.1
-83.738159  22.619189   236 1   0   0.1
-83.737987  22.619272   237 1   0   0.1
-83.737766  22.619342   238 1   0   0.1
-83.737614  22.619325   239 1   0   0.1
-83.737487  22.619236   240 1   0   0.1
-83.7374    22.619133   241 1   0   0.1
-83.737379  22.619115   242 1   0   0.1
-83.737267  22.619004   243 1   0   0.1
-83.737097  22.618813   244 1   0   0.1
-83.737078  22.618794   245 1   0   0.1
-83.736933  22.618631   246 1   0   0.1
-83.736789  22.618421   247 1   0   0.1
-83.736614  22.61809    248 1   0   0.1
-83.73647   22.617792   249 1   0   0.1
-83.736445  22.617745   250 1   0   0.1
-83.736321  22.617507   251 1   0   0.1
-83.736209  22.617334   252 1   0   0.1
-83.735878  22.616923   253 1   0   0.1
-83.735591  22.616589   254 1   0   0.1
-83.73553   22.61652    255 1   0   0.1
-83.735349  22.616278   256 1   0   0.1
-83.735324  22.616245   257 1   0   0.1
-83.735164  22.616023   258 1   0   0.1
-83.735141  22.615992   259 1   0   0.1
-83.73496   22.615717   260 1   0   0.1
-83.734773  22.615392   261 1   0   0.1
-83.734602  22.615017   262 1   0   0.1
-83.734459  22.614668   263 1   0   0.1
-83.734446  22.614621   264 1   0   0.1
-83.734348  22.614326   265 1   0   0.1
-83.734308  22.613949   266 1   0   0.1
-83.734311  22.613895   267 1   0   0.1
-83.734399  22.613535   268 1   0   0.1
-83.734511  22.613182   269 1   0   0.1
-83.734584  22.61295    270 1   0   0.1
-83.734616  22.612842   271 1   0   0.1
-83.734702  22.612607   272 1   0   0.1
-83.734728  22.612534   273 1   0   0.1
-83.734736  22.612467   274 1   0   0.1
-83.734755  22.612378   275 1   0   0.1
-83.73481   22.612197   276 1   0   0.1
-83.734864  22.612037   277 1   0   0.1
-83.734911  22.611885   278 1   0   0.1
-83.734952  22.611754   279 1   0   0.1
-83.734998  22.611584   280 1   0   0.1
-83.735051  22.611412   281 1   0   0.1
-83.735123  22.611123   282 1   0   0.1
-83.735154  22.611009   283 1   0   0.1
-83.735229  22.610669   284 1   0   0.1
-83.735255  22.610522   285 1   0   0.1
-83.735291  22.61028    286 1   0   0.1
-83.735303  22.610137   287 1   0   0.1
-83.735302  22.609903   288 1   0   0.1
-83.735271  22.609513   289 1   0   0.1
-83.735259  22.60943    290 1   0   0.1
-83.735262  22.609368   291 1   0   0.1
-83.735334  22.609273   292 1   0   0.1
-83.735504  22.609238   293 1   0   0.1
-83.735884  22.609167   294 1   0   0.1
-83.736285  22.60909    295 1   0   0.1
-83.736699  22.609015   296 1   0   0.1
-83.737168  22.608971   297 1   0   0.1
-83.737219  22.608971   298 1   0   0.1
-83.73748   22.608968   299 1   0   0.1
-83.737953  22.608977   300 1   0   0.1
-83.73858   22.609001   301 1   0   0.1
-83.738633  22.609002   302 1   0   0.1
-83.738687  22.608998   303 1   0   0.1
-83.738895  22.609009   304 1   0   0.1
-83.739042  22.609014   305 1   0   0.1
-83.739288  22.609023   306 1   0   0.1
-83.739738  22.609048   307 1   0   0.1
-83.740238  22.60907    308 1   0   0.1
-83.74041   22.609076   309 1   0   0.1
-83.740791  22.609082   310 1   0   0.1
-83.741228  22.609102   311 1   0   0.1
-83.741286  22.609107   312 1   0   0.1
-83.741703  22.609118   313 1   0   0.1
-83.742255  22.60914    314 1   0   0.1
-83.742438  22.609148   315 1   0   0.1
-83.742567  22.609169   316 1   0   0.1
-83.742711  22.609181   317 1   0   0.1
-83.742773  22.609173   318 1   0   0.1
-83.742765  22.609147   319 1   0   0.1
-83.742702  22.609144   320 1   0   0.1
-83.742676  22.609144   321 1   0   0.1
-83.742605  22.609185   322 1   0   0.1
-83.7426    22.609189   323 1   0   0.1
-83.742617  22.609192   324 1   0   0.1
-83.742679  22.609184   325 1   0   0.1
-83.742925  22.609185   326 1   0   0.1
-83.743215  22.609196   327 1   0   0.1
-83.743604  22.60922    328 1   0   0.1
-83.743716  22.609232   329 1   0   0.1
-83.743951  22.609254   330 1   0   0.1
-83.744129  22.609267   331 1   0   0.1
-83.744322  22.609285   332 1   0   0.1
-83.744389  22.609288   333 1   0   0.1
-83.744598  22.609309   334 1   0   0.1
-83.744817  22.609326   335 1   0   0.1
-83.744891  22.609332   336 1   0   0.1
-83.745197  22.609355   337 1   0   0.1
-83.745506  22.609384   338 1   0   0.1
-83.745891  22.609411   339 1   0   0.1
-83.745966  22.609416   340 1   0   0.1
-83.746465  22.60945    341 1   0   0.1
-83.747062  22.609504   342 1   0   0.1
-83.747188  22.609514   343 1   0   0.1
-83.747807  22.609569   344 1   0   0.1
-83.748414  22.609623   345 1   0   0.1
-83.748533  22.609637   346 1   0   0.1
-83.749051  22.609693   347 1   0   0.1
-83.749634  22.609742   348 1   0   0.1
-83.749752  22.609754   349 1   0   0.1
-83.75034   22.609797   350 1   0   0.1
-83.75046   22.609801   351 1   0   0.1
-83.751027  22.60977    352 1   0   0.1
-83.751191  22.609746   353 1   0   0.1
-83.751511  22.609677   354 1   0   0.1
-83.751913  22.609556   355 1   0   0.1
-83.752321  22.609376   356 1   0   0.1
-83.752534  22.609281   357 1   0   0.1
-83.752703  22.609201   358 1   0   0.1
-83.753108  22.609009   359 1   0   0.1
-83.753453  22.608841   360 1   0   0.1
-83.753803  22.608683   361 1   0   0.1
-83.754121  22.608534   362 1   0   0.1
-83.754318  22.608426   363 1   0   0.1
-83.754403  22.60839    364 1   0   0.1
-83.754879  22.608192   365 1   0   0.1
-83.755255  22.608026   366 1   0   0.1
-83.755784  22.607805   367 1   0   0.1
-83.756137  22.607634   368 1   0   0.1
-83.756388  22.607508   369 1   0   0.1
-83.756613  22.607411   370 1   0   0.1
-83.756653  22.607395   371 1   0   0.1
-83.757037  22.607232   372 1   0   0.1
-83.757246  22.607142   373 1   0   0.1
-83.757343  22.607095   374 1   0   0.1
-83.757466  22.607038   375 1   0   0.1
-83.757647  22.606951   376 1   0   0.1
-83.757676  22.606936   377 1   0   0.1
-83.757816  22.60687    378 1   0   0.1
-83.75787   22.606845   379 1   0   0.1
-83.757968  22.606798   380 1   0   0.1
-83.758039  22.606765   381 1   0   0.1
-83.758153  22.606708   382 1   0   0.1
-83.758221  22.606681   383 1   0   0.1
-83.758265  22.606661   384 1   0   0.1
-83.758401  22.606606   385 1   0   0.1
-83.758445  22.606585   386 1   0   0.1
-83.758532  22.606549   387 1   0   0.1
-83.758681  22.606484   388 1   0   0.1
-83.758701  22.606473   389 1   0   0.1
-83.758873  22.606399   390 1   0   0.1
-83.758896  22.60639    391 1   0   0.1
-83.759005  22.606338   392 1   0   0.1
-83.75911   22.606289   393 1   0   0.1
-83.759131  22.606278   394 1   0   0.1
-83.759265  22.606212   395 1   0   0.1
-83.759353  22.606177   396 1   0   0.1
-83.759416  22.60615    397 1   0   0.1
-83.759546  22.606091   398 1   0   0.1
-83.759585  22.606074   399 1   0   0.1
-83.759715  22.606021   400 1   0   0.1
-83.75976   22.606005   401 1   0   0.1
-83.759825  22.605977   402 1   0   0.1
-83.759962  22.605939   403 1   0   0.1
-83.759985  22.605932   404 1   0   0.1
-83.760083  22.605913   405 1   0   0.1
-83.760202  22.605879   406 1   0   0.1
-83.760272  22.605857   407 1   0   0.1
-83.760394  22.605851   408 1   0   0.1
-83.760444  22.605847   409 1   0   0.1
-83.760624  22.605844   410 1   0   0.1
-83.760651  22.605842   411 1   0   0.1
-83.760817  22.605842   412 1   0   0.1
-83.760956  22.605851   413 1   0   0.1
-83.76104   22.605857   414 1   0   0.1
-83.761244  22.605878   415 1   0   0.1
-83.761302  22.605888   416 1   0   0.1
-83.761543  22.605928   417 1   0   0.1
-83.761603  22.605938   418 1   0   0.1
-83.761848  22.605978   419 1   0   0.1
-83.762129  22.606034   420 1   0   0.1
-83.76254   22.606101   421 1   0   0.1
-83.762905  22.606116   422 1   0   0.1
-83.762962  22.606114   423 1   0   0.1
-83.763148  22.606099   424 1   0   0.1
-83.76328   22.606078   425 1   0   0.1
-83.763393  22.60605    426 1   0   0.1
-83.763506  22.606022   427 1   0   0.1
-83.763556  22.606009   428 1   0   0.1
-83.76368   22.605977   429 1   0   0.1
-83.76374   22.605957   430 1   0   0.1
-83.763789  22.605946   431 1   0   0.1
-83.763816  22.6059 432 1   0   0.1
-83.76387   22.605841   433 1   0   0.1
-83.763963  22.605802   434 1   0   0.1
-83.76408   22.605761   435 1   0   0.1
-83.764208  22.605707   436 1   0   0.1
-83.764354  22.605645   437 1   0   0.1
-83.764435  22.605615   438 1   0   0.1
-83.764516  22.605583   439 1   0   0.1
-83.764683  22.605511   440 1   0   0.1
-83.76486   22.605437   441 1   0   0.1
-83.76495   22.605398   442 1   0   0.1
-83.765132  22.605321   443 1   0   0.1
-83.765494  22.605167   444 1   0   0.1
-83.765757  22.605058   445 1   0   0.1
-83.766234  22.604865   446 1   0   0.1
-83.7667    22.604651   447 1   0   0.1
-83.767082  22.604473   448 1   0   0.1
-83.767549  22.604282   449 1   0   0.1
-83.768037  22.604074   450 1   0   0.1
-83.768537  22.603843   451 1   0   0.1
-83.768821  22.603729   452 1   0   0.1
-83.768912  22.603689   453 1   0   0.1
-83.769131  22.603589   454 1   0   0.1
-83.769327  22.603497   455 1   0   0.1
-83.7694    22.603468   456 1   0   0.1
-83.76957   22.60339    457 1   0   0.1
-83.769603  22.603375   458 1   0   0.1
-83.769815  22.603269   459 1   0   0.1
-83.770022  22.603151   460 1   0   0.1
-83.770235  22.603008   461 1   0   0.1
-83.77026   22.602989   462 1   0   0.1
-83.770488  22.602784   463 1   0   0.1
-83.770537  22.602734   464 1   0   0.1
-83.770747  22.602537   465 1   0   0.1
-83.770822  22.602467   466 1   0   0.1
-83.770976  22.602329   467 1   0   0.1
-83.771139  22.602162   468 1   0   0.1
-83.771165  22.602138   469 1   0   0.1
-83.771425  22.601891   470 1   0   0.1
-83.771505  22.601815   471 1   0   0.1
-83.77179   22.601536   472 1   0   0.1
-83.771817  22.601511   473 1   0   0.1
-83.772057  22.60128    474 1   0   0.1
-83.772361  22.601011   475 1   0   0.1
-83.772416  22.600964   476 1   0   0.1
-83.772647  22.600784   477 1   0   0.1
-83.772706  22.60074    478 1   0   0.1
-83.772913  22.600601   479 1   0   0.1
-83.773004  22.600549   480 1   0   0.1
-83.773119  22.600475   481 1   0   0.1
-83.773224  22.600406   482 1   0   0.1
-83.773249  22.600386   483 1   0   0.1
-83.773415  22.600273   484 1   0   0.1
-83.773438  22.600258   485 1   0   0.1
-83.773558  22.600186   486 1   0   0.1
-83.773634  22.600141   487 1   0   0.1
-83.773756  22.600066   488 1   0   0.1
-83.773898  22.599973   489 1   0   0.1
-83.773923  22.599957   490 1   0   0.1
-83.77404   22.599877   491 1   0   0.1
-83.774134  22.599819   492 1   0   0.1
-83.774176  22.599785   493 1   0   0.1
-83.77432   22.599693   494 1   0   0.1
-83.774527  22.599564   495 1   0   0.1
-83.774616  22.599505   496 1   0   0.1
-83.774681  22.599458   497 1   0   0.1
-83.774819  22.599363   498 1   0   0.1
-83.774841  22.599348   499 1   0   0.1
-83.77497   22.599255   500 1   0   0.1

1 个答案:

答案 0 :(得分:1)

这是一个解决方案。您最终看到ggplot图形的原因是您使用了geom_line()。 geom_line()按x轴上的变量顺序连接数据点。你看到一个多边形的原因是有一堆垂直线沿着x轴上下移动,我认为我们认为该区域是填充的。

# geom_line() connects them in order of the variable on the x axis.
# I called your subsetted data mydata.

ggplot() +
geom_line(data = mydata, aes(x = long, y = lat, group = group), colour = "red")

enter image description here

现在我使用geom_path()并查看路线。还有一件事。在这种情况下,您希望color超出aes()

ggplot() +
geom_path(data = mydata, aes(x = long, y = lat, group = group), colour = "red")

enter image description here