TransWikia.com

Shapely parallel_offset returning an empty list

Geographic Information Systems Asked by MCRI on February 22, 2021

I have a LineString and when I try to create a right parallel line with parallel_offset I get an empty list. What am I doing wrong? The code is as follow:

Line_ = LineString([Point(-131241, 5700864), Point(-130215, 5700016.609604769), Point(-129200, 5699155), Point(-128256, 5698218), Point(-127481, 5697139), Point(-126943, 5695927), Point(-126662, 5694629), Point(-126617, 5693300), Point(-126815, 5691987), Point(-127147, 5690699)])
print(Line_.parallel_offset(15000, 'right'))
LINESTRING EMPTY

While if I use parallel_offset to calculate the left parallel line of the same LineString I get the expected result:

Line_ = LineString([Point(-131241, 5700864), Point(-130215, 5700016.609604769), Point(-129200, 5699155), Point(-128256, 5698218), Point(-127481, 5697139), Point(-126943, 5695927), Point(-126662, 5694629), Point(-126617, 5693300), Point(-126815, 5691987), Point(-127147, 5690699)])
print(Line_.parallel_offset(15000, 'left'))
LINESTRING (-121688.949663129 5712429.393826493, -120662.949663129 5711582.003431262, -120507.734800415 5711452.037115139, -119492.734800415 5710590.42751037, -118632.9431239474 5709800.999670218, -117688.9431239474 5708863.999670218, -116841.5246323321 5707949.893550635, -116072.9273087647 5706968.585111869, -115297.9273087647 5705889.585111869, -114466.0962164286 5704596.364112364, -113771.0294072872 5703224.779025478, -113233.0294072872 5702012.779025478, -112683.2909290381 5700581.105414742, -112282.6077144392 5699100.782921605, -112001.6077144392 5697802.782921605, -111776.287252372 5696477.122289002, -111670.5913831028 5695136.609772582, -111625.5913831028 5693807.609772582, -111642.1468335366 5692431.799192087, -111784.6992899678 5691063.293571526, -111982.6992899678 5689750.293571526, -112289.7845017582 5688242.922713186, -112621.7845017582 5686954.922713186)

One Answer

You're not doing anything wrong. Left and right are determined by following the direction of the line. This method may sometimes return EMPTY geometry for curved lines if offset value is huge. If you use distance values less than ~9650 for this line, you will understand clearly what I mean.

enter image description here

Review samples in Documentation.

Correct answer by Kadir Şahbaz on February 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP