-
Hello, I would like to know what would be the best way to
Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Answered by
mwtoews
Mar 26, 2023
Replies: 1 comment 1 reply
-
Here's a quick ipython demo: In [1]: from shapely.geometry import MultiPoint
In [2]: mp = MultiPoint([(1, 2), (3, 4)])
In [3]: mp
Out[3]: <MULTIPOINT (1 2, 3 4)>
In [4]: mp_list = list(mp.geoms) # convert to mutable list of Point objects
In [5]: mp_list
Out[5]: [<POINT (1 2)>, <POINT (3 4)>]
In [6]: mp_list.append((5, 6)) # add additional point
In [7]: mp_list[1] = (7, 8) # modify existing point in second index position
In [8]: mp_list # this is now a mixed Point and tuple list, which should be fine
Out[8]: [<POINT (1 2)>, (7, 8), (5, 6)]
In [9]: MultiPoint(mp_list) # voila
Out[9]: <MULTIPOINT (1 2, 7 8, 5 6)> This demo should work the same for Shapely 2 or earlier, although the outputs will look different. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
fuhrmanj
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a quick ipython demo:
This demo should work the same for Shapely 2 or earlier, although t…