0

I am having an issue with the PlotGoogleMap package of R. When I am trying to plot my points(Lat, Long) using this package , then some of my points doesn't get plotted. I don't how to deal with this issue.

coordinates(engine) <- ~longt+latit # convert to SPDF
 proj4string(engine) <-  CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
 ic <- iconlabels(engine$vehicle_id, height=10,colPalette=rainbow(4), icon=TRUE)
 m <- plotGoogleMaps(engine,filename='myMap.htm', iconMarker=ic,colPalette=rainbow(4),mapTypeId='ROADMAP',layerName = 'Vehicle_id')

This is the code I am using ^

Here is a sample data.

Vehicle_id   longt   latit
    24143   86.4311 23.735
    24143   86.439  23.7392
    24143   86.4916 23.7275
    24143   86.5216 23.7695
    24143   86.5885 23.8091
    24143   86.6498 23.7984
    24143   86.7148 23.7937
    24143   86.439  23.7392
    24143   86.5249 23.723
    24143   86.5882 23.8088
    24143   86.7261 23.8197
SK Singh
  • 153
  • 1
  • 1
  • 14
  • I can't plot your points with the code you provided. I get an error. However, you said that you succeeded in plotting your map... Now looking at your sample dataset it seems to me that the problem is due to some overlapping features. Two are identical (86.439 23.7392) and two coordinates are very close and if you don't zoom enough they look like one feature only (86.5885 23.8091 and 86.5882 23.8088). So if plotting your map you see at the default zoom level just 9 out of 11 features, the problem is that – G. Cocca Jun 06 '16 at 11:10
  • I am also getting an error Error in "" if (ticks[length(ticks)] ==ticks[length(ticks) - 1]) { : argument is of length zero "". Its a sample data and in this case all the vehicle_id is same. Code is working fine at the large data set having different vehicle_id but at the same time some point goes missing. I am not getting why selectively some points are missing from the plot. In my case, most of the points are overlapping. @G.Cocca – SK Singh Jun 06 '16 at 11:23
  • Overlapping features should not be of concern. Earlier , when I tried to run the code then there was no such discrepancy. But I don't know why the plot is missing some important point now. – SK Singh Jun 06 '16 at 11:56
  • I see.. Now I fixed the code and all the points display correctly. This means that I can't reproduce the problem you are experiencing (i.e. loss of points). However I suspect that the problem is in the data that in your dataset are not displayed. It could be a comma instead of a dot as decimal separator. Or that the coordinates are strings and not numbers. Or that the coordinates are out of range in your CRS or simply swapped (lng and lat). Try to check the data that are not displaying are consistent. – G. Cocca Jun 06 '16 at 12:20
  • Can you show me your fixed code ?? @G.Cocca – SK Singh Jun 06 '16 at 12:22
  • I just changed the id in order to have a unquei id `engine@data$Vehicle_id <- seq_along(engine)` and then I run your code.. Ah.. I dropped also the arcument `colPalette=rainbow(4)` from your object `ic` – G. Cocca Jun 06 '16 at 12:25
  • Thankss for you help!!! – SK Singh Jun 06 '16 at 12:33

0 Answers0