Skip to main content
30 events
when toggle format what by license comment
Sep 29, 2018 at 15:01 history tweeted twitter.com/StackGIS/status/1046052357556109313
S Sep 28, 2018 at 16:58 history mod moved comments to chat
S Sep 28, 2018 at 16:58 comment added Ian Turton Comments are not for extended discussion; this conversation has been moved to chat.
Sep 28, 2018 at 15:32 vote accept user32882
Sep 28, 2018 at 15:32 comment added Jon You can upload the shapefiles to a google drive or similar and post the link. That's pretty common here. If you can upload them, I feel confident there is a much better and cleaner solution that uses geopandas.
Sep 28, 2018 at 15:22 comment added user32882 Its not possible to include shapefiles on SE. Besides I believe your script can be extended, I just don't know how. I guess I will accept it since I was not clear from the beginning on the requirements and I will try to work through it myself. If I can't figure it out I'll post another question
Sep 28, 2018 at 15:18 comment added Jon Since you're looking for something that works in 2D, I removed the answer so that others are more likely to help. Perhaps you could resubmit the question with the full requirements (and it would be very helpful if you'd include the shapefiles you want to do this with).
Sep 28, 2018 at 15:12 comment added user32882 @Jon why did you delete your answer? All I needed was some indication on how it could be extended to 2D... I wasn't saying it was incorrect, just incomplete... Could you please put it back? I'll accept it if you provide some comment on how to extend to 2D
Sep 28, 2018 at 14:03 vote accept user32882
Sep 28, 2018 at 14:03
Sep 28, 2018 at 11:34 history edited user32882 CC BY-SA 4.0
added 1321 characters in body
Sep 27, 2018 at 23:21 history edited PolyGeo CC BY-SA 4.0
deleted 12 characters in body; edited title
Sep 27, 2018 at 17:26 history edited user32882 CC BY-SA 4.0
deleted 957 characters in body
Sep 27, 2018 at 17:22 vote accept user32882
Sep 28, 2018 at 14:03
Sep 27, 2018 at 16:49 history edited user32882 CC BY-SA 4.0
added 760 characters in body
Sep 27, 2018 at 16:39 answer added Jon timeline score: 4
Sep 27, 2018 at 15:53 comment added user32882 also you say "check if the segment ID has changed for both attributes" . But the columns are in fact line_1_segment_ID and line_2_segment_ID. Where are the attributes in this table you describe? x-coordinates do not correspond to records in this case.... two segments can share the same x coordinate
Sep 27, 2018 at 15:49 comment added Jon That was a typo--you'd want to sort based on the first column (arrange all your x-coordinates from smallest to largest).
Sep 27, 2018 at 15:43 comment added user32882 Theyre sorting based on columns there. You mention sorting based on a row,
Sep 27, 2018 at 15:41 history edited user32882 CC BY-SA 4.0
deleted 475 characters in body
Sep 27, 2018 at 15:37 comment added Jon stackoverflow.com/questions/2828059/… has some solutions; Steve's is the most compact but difficult to understand.
Sep 27, 2018 at 15:29 comment added user32882 How can you sort based on a row? Sorry but this is very unclear...
Sep 27, 2018 at 14:16 comment added Jon Good point. I would make three columns, then. First one is x-coordinate, second one is line 1 segment id, third one is line 2 segment id. Then sort based on first row. Then loop through first column, and for each x-coordinate, check if the segment id has changed for both attributes. If not, store the last-used attribute, and if so, store the new attribute. The second two columns could have nan's wherever they don't change. Sorry if that's confusing. Maybe someone can still help with an easier solution.
Sep 27, 2018 at 14:11 comment added user32882 How about the attributes... and how does sorting by x value help? Could you please elaborate on this method a bit more?
Sep 27, 2018 at 14:10 comment added Jon I don't know if there's an easy gpd solution, but you could just make a Nx2 numpy array; first column is the x-coordinate, second column is the segment ID. Then just sort the array rows according to the first column. You'd need to do a little interfacing with shapely to get coordinates and re-build the final line, but that's pretty easy.
Sep 27, 2018 at 14:07 history edited user32882 CC BY-SA 4.0
added 696 characters in body
Sep 27, 2018 at 14:07 comment added user32882 Yees I am working with actual 1D lines for this test. In reality however I wish to implement this for a 2D road network
Sep 27, 2018 at 14:06 comment added Jon Are you working with actual 1-D lines like your illustration?
Sep 27, 2018 at 13:55 comment added Jon Have you tried sjoin() with op='intersection'? I can't remember if it works for multi-linestrings but I remember it would often work for me when overlay failed.
Sep 27, 2018 at 13:39 history edited user32882 CC BY-SA 4.0
added 484 characters in body
Sep 27, 2018 at 13:25 history asked user32882 CC BY-SA 4.0