Accessing polyline vector data in leaflet, shinydashboard

27 views
Skip to first unread message

dennis...@gmail.com

unread,
Sep 2, 2015, 7:17:39 PM9/2/15
to Shiny - Web Framework for R
Running leaflet within shinydashboard, I would like to display a shapefile representation of a road map dataset on top of a raster map from OSM.  This is to verify the closeness of fit.  But it is also to prepare to access individual polylines to visually traverse them.  Not a continuous traversal, but simulating motion of, say, 100 meters along the road at a time.

I have used readOGR() from the rgdal package, and readShapeLines() from the maptools package, to read a polyline structure from a shape file.  I see within the data structure what appears to be UTM coordinates.  How are these accessed? I am new to shapefile formats, and how they are placed into R structures.  I can get to a data frame with as.data.fram(), but that only captures the attribute data, not the location data.

Any advice how to proceed?  I can plot the shapefile object in my plot window.  AddPolyLines does not plot anything for me.  On other forums and tutorials, I do see some about how to display this data, or trim it, but I haven't seen anything about accessing the location data.  On the various geo packages, I don't see anything about traversal, identifying junctions, etc.

I have copied below the output of head() for the shapefile object.  I trimmed off some of the repetitive coordinates.  

R 3.2.1
RStudio 0.99.476
leaflet 1.0.0.9999
shinydashboard 0.50.
MacOS 10.8.5

Thanks for any suggestions.

An object of class "SpatialLinesDataFrame"
Slot "data":
    PID MASTER_ID PREFIX            NAME SUFFIX TYPE CLASS ROW_WIDTH
0 40101      1625   <NA> Mission Springs   <NA>   Ct    RE        52
1 18530      1626   <NA>          Berger   <NA>   Dr    RE        77
2 71869      1627   <NA>      Maple Lake   <NA>   Ct    RE        44
3 71870      1628   <NA>           Oneco   <NA>   Ct    RE        46
4 71871      1629   <NA>          Myrick   <NA>   Ct    RE        46
5 71872      1630   <NA>            Loma   <NA>   Ct    RE        51
  FOC_WIDTH     ADD_TYPE FRADD_L FRADD_R TOADD_L TOADD_R MUNI_L MUNI_R ZIP_L
0        38   CONTIGUOUS    1501    1500    1599    1600     SJ     SJ 95131
1        57 STD EVEN ODD    1401    1400    1599    1598     SJ     SJ 95112
2        24 STD EVEN ODD    1700    1701    1798    1799     SJ     SJ 95131
3        26 STD EVEN ODD    1500    1501    1598    1599     SJ     SJ 95131
4        26   CONTIGUOUS    1500      NA    1598      NA     SJ     SJ 95131
5        31         <NA>      NA      NA      NA      NA     SJ     SJ 95131
  ZIP_R PRIVATE ONE_WAY WIDTH HEIGHT WEIGHT SPD_LIM FCODE
0 95131       N       B    NA     NA     NA      25    RE
1 95112       N       B    NA     NA     NA      25    RE
2 95131       Y       B    NA     NA     NA      25    RE
3 95131       Y       B    NA     NA     NA      25    RE
4 95131       Y       B    NA     NA     NA      25    RE
5 95131       Y       B    NA     NA     NA      25    RE
                                NAME_FROM
0 Mission Springs Cl & Mission Springs Ct
1                   Berger Dr & E Gish Rd
2                           Maple Lake Ct
3                  Clampett Wy & Oneco Ct
4                 Clampett Wy & Myrick Ct
5                   Fountain Cl & Loma Ct
                                           NAME_TO
0                               Mission Springs Ct
1 Berger Dr / Golden Wheel MHP Access & Oakland Rd
2                         Bahre Ln & Maple Lake Ct
3                                         Oneco Ct
4                                        Myrick Ct
5                                          Loma Ct

Slot "lines":
[[1]]
An object of class "Lines"
Slot "Lines":
[[1]]
An object of class "Line"
Slot "coords":
         [,1]    [,2]
 [1,] 6158329 1965641
 [2,] 6158320 1965654
 [3,] 6158311 1965666
 [4,] 6158302 1965679
 [5,] 6158293 1965691
 [6,] 6158284 1965704
 [7,] 6158275 1965716
 [8,] 6158263 1965732
 [9,] 6158260 1965736
[10,] 6158258 1965739
[11,] 6158256 1965743
[12,] 6158253 1965746
[13,] 6158250 1965749
[14,] 6158248 1965752
[15,] 6158225 1965784

Slot "ID":
[1] "0"

[[2]]
An object of class "Lines"
Slot "Lines":
[[1]]
An object of class "Line"
Slot "coords":
         [,1]    [,2]
 [1,] 6155696 1960109
 [2,] 6155692 1960113
 [3,] 6155665 1960144
 [4,] 6155663 1960145
 [5,] 6155662 1960147
 [6,] 6155660 1960149
 [7,] 6155659 1960151
 [8,] 6155658 1960152
 [9,] 6155656 1960154
[10,] 6155651 1960164
[11,] 6155646 1960173
[12,] 6155642 1960183
[13,] 6155639 1960194
[14,] 6155637 1960204
[15,] 6155636 1960215

Slot "ID":
[1] "1"

[[3]]
An object of class "Lines"
Slot "Lines":
[[1]]
An object of class "Line"
Slot "coords":
        [,1]    [,2]
[1,] 6156863 1965851
[2,] 6156793 1965965
[3,] 6156786 1965977

Slot "ID":
[1] "2"

[[4]]
An object of class "Lines"
Slot "Lines":
[[1]]
An object of class "Line"
Slot "coords":
        [,1]    [,2]
[1,] 6161802 1968132
[2,] 6161781 1968115
[3,] 6161685 1968039

Slot "ID":
[1] "3"

[[5]]
An object of class "Lines"
Slot "Lines":
[[1]]
An object of class "Line"
Slot "coords":
        [,1]    [,2]
[1,] 6161718 1968239
[2,] 6161695 1968221
[3,] 6161600 1968146

Slot "ID":
[1] "4"

[[6]]
An object of class "Lines"
Slot "Lines":
[[1]]
An object of class "Line"
Slot "coords":
        [,1]    [,2]
[1,] 6153531 1969936
[2,] 6153563 1969942
[3,] 6153584 1969947
[4,] 6153606 1969951
[5,] 6153628 1969956
[6,] 6153650 1969960
[7,] 6153672 1969965
[8,] 6153694 1969969

Slot "ID":
[1] "5"

Slot "bbox":
      min     max
x 6153531 6161802
y 1960109 1969969

Slot "proj4string":
CRS arguments: NA 

Reply all
Reply to author
Forward
0 new messages