Open mdsumner opened 5 years ago
Example MVT:
# https://docs.mapbox.com/vector-tiles/reference/ #token <- ceramic::get_api_key() token <- YOUR_TOKEN u <- "http://a.tiles.mapbox.com/v4/mapbox.mapbox-streets-v7/14/4823/6160.mvt?access_token={token}" curl::curl_download(glue::glue(u), "6160.mvt")
# ceramic$ ogrinfo 6160.mvt # INFO: Open of `6160.mvt' # using driver `MVT' successful. # 1: landuse (Multi Polygon) # 2: waterway (Line String) # 3: water (Multi Polygon) # 4: aeroway (Polygon) # 5: barrier_line # 6: building (Multi Polygon) # 7: landuse_overlay (Polygon) # 8: road # 9: admin (Line String) # 10: place_label (Point) # 11: rail_station_label (Point) # 12: poi_label (Point) # 13: motorway_junction (Point) # 14: road_label (Multi Line String) # 15: waterway_label (Line String)
There are 81 geometries, and 81 names, but 85 rows of fields. The last rows of field values are "".
This seems to be a reliable way to match geometries to rows, not sure if names may interspersed.
sf fails to read
## bring the empty rows to the top with arrange as_tibble(vapour_read_attributes("6160.mvt", layer = 0)) %>% arrange(class) # A tibble: 85 x 3 mvt_id class type <dbl> <chr> <chr> 1 0 "" "" 2 0 "" "" 3 0 "" "" 4 0 "" "" 5 0 cemetery christian 6 0 cemetery christian 7 0 cemetery christian 8 0 grass grass 9 0 grass grass 10 0 grass grass # … with 75 more rows ## 81 geometries str(vapour_read_geometry("6160.mvt", layer = 0)) List of 81 $ : raw [1:550] 01 06 00 00 ... $ : # 81 names vapour_read_names("6160.mvt") [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 [34] 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 [67] 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
vapour is ignoring NULL geometries, and it should not do that
Example MVT:
There are 81 geometries, and 81 names, but 85 rows of fields. The last rows of field values are "".
This seems to be a reliable way to match geometries to rows, not sure if names may interspersed.
sf fails to read