Sometimes when I want to convert a subset of ways from an osm file loaded with the osmar package, I run into an error complaining about duplicate row names. The following code run on this file in attach throws this error:
Error in `row.names<-.data.frame`(`*tmp*`, value = c(4067932, 4296467, :
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘123074181’, ‘154043350’, ‘171826984’, ‘176273732’, ‘196520271’, ‘202157002’, ‘24240315’, ‘24913519’, ‘284493291’, ‘304517627’, ‘35556702’, ‘38210407’, ‘4399491’, ‘4840974’, ‘4840977’, ‘60333308’, ‘61583424’, ‘67627350’, ‘67627353’, ‘68711084’, ‘72157174’
This is the code:
osm_data <- get_osm(complete_file(), source = osmsource_file('extract.osm'))
hw_ids <- find(osm_data, way(tags(k == "highway")))
hw_ids <- find_down(osm_data, way(hw_ids))
ways <- subset(osm_data, ids = hw_ids)
ways <- as_sp(ways, "lines")
I suppose this is because of SpatialLines objects with the same osm_id ? How do I avoid this problem ?