1

I have some spatial lines from a shapefile representing roads. I'd like to attribute to each segment an information, for example the state of the segment or more generally a scalar that gives an information on the segment. For example I'd like to map portion of the roads that need to be repaired or the portion of the roads that no longer exist.

enter image description here

As far I know, we can only attribute values to individual lines and this prevent to map anything that applies only to some portion of the lines.

My question is language and software agnostic. I'm actually able to deal with that programmatically using lines and points but them I don't know how to share that in a simple way that is compatible with GIS software.

Is there some file formats supported by spatial software to achieve this task?

2 Answers 2

1

I am not sure what object class you are dealing with but in both sf and sp SpatialLinesDataFrame objects, each feature (line segment) has a row in the attribute table. There are cases where the geometry is stored as MULTILINE (multiple lines represented as one feature). In this case, all you have to do is explode the feature geometry. For sf objects, you can use sf::st_cast and for sp objects spatialEco::explode or coerce to sf, recast the feature geometry, and then coerce back to sp. It is easy to check for MULTI feature geometry by looking at a print of the object or, looking at the number of features compared to the number of rows in the attributes.

3
  • I'm dealing with either sf or sp or anything else actually it does not matter. As you said for a line or a multi-lines their is only one row in the table of attribute. The only solution I see is to explode every single pieces the road into a set of small lines. But the topology of the network will be lost. This is not a solution I like.
    – JRR
    Commented Nov 5, 2020 at 20:37
  • What do you mean by "the topology of the network will be lost"? Unless you have this set up as a graph (eg., iGraph object) this is irrelevant. You may want to read up on the structure of spatial objects in R. There are not explicit topology models applied to spatial objects as you may be thinking from ArcGIS abstractions. Whe the data is exploded the original attributed from the source like is retained but, a new ID assigned as it is not its own feature. You still have the attribude data from when it was part of the multiline. Commented Nov 5, 2020 at 20:58
  • In theory I do agree but in practice sharing a fragmented shapefile where the fragments are identified by a IDs is not convenient. My question is more "how can I share easily such product in simple files with people who simply want to click on a file and see the result in a GIS software"
    – JRR
    Commented Nov 5, 2020 at 23:35
1

I think what you are describing are events (linear and point) located along linear features (routes) using linear referencing.

Other terms useful for learning about dealing with data along linear features, rather than the whole linear feature, are chainage and dynamic segmentation.

1
  • Thank you I will read about 'chainage 'and 'dynamic segmentation'. Hope that will help.
    – JRR
    Commented Nov 5, 2020 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.