0
votes

Total newb here (thanks in advance!)

In my shp file named "shape", there is a column named "RD_TYPE" and it shows me the types of roads from 1 to 5.

I want to make a simple table that counts how many items there are for each type of road, from the column named "RD_TYPE" :

count_rd_type <- shape %>%
  group_by(RD_TYPE) %>%
  count() 

So when I do this my table is created, but then I see an additional column named "geometry" with coordinates which does not exist in my original dataset "shape". Can someone explain to me how this works?

screenshot of my results

Thanks a lot :)

1
Assuming you are using sf objects, that column is the merge of the roads for each RD_TYPE. See the answer of @jindra-lackodieghernan

1 Answers

0
votes

The geometry column contains (surprise, surprise) the geometry of the roads - meaning a vector representation of your road (coordinates of start, finish, and every segment in between).

Should you find it superfluous you can remove it via sf::st_drop_geometry().

So in your use case consider this code:

count_rd_type <- shape %>%
  group_by(RD_TYPE) %>%
  count() %>%
  sf::st_drop_geometry()

class(count_rd_type) # this will be plain old data.frame, not the special sf kind