Skip to content Skip to sidebar Skip to footer

Numpy Mgrid Shapely For Linestring Coordinates

I've been making little maps to orient myself to using shapely. for example: from shapely.geometry import MultiLineString from pprint import pprint import pylab coords = [((1,1),

Solution 1:

You can you vstack combined with transpose:

>>> x, y = np.mgrid[:2, :3]
>>> np.vstack((x.ravel(),y.ravel())).T
array([[0, 0],
       [0, 1],
       [0, 2],
       [1, 0],
       [1, 1],
       [1, 2]])

If you need a list of tuples:

>>>[(x,y) for x,y inzip(x.ravel(),y.ravel())]
[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2)]

Post a Comment for "Numpy Mgrid Shapely For Linestring Coordinates"