def ogr_to_numpy(ogrobj):
"""Backconvert a gdal/ogr geometry to a numpy vertex array.
.. versionadded:: 0.7.0
Using JSON as a vehicle to efficiently deal with numpy arrays.
Parameters
----------
ogrobj : ogr.Geometry
object
Returns
-------
out : :class:`numpy:numpy.ndarray`
a nested ndarray of vertices of shape (num vertices, 2)
"""
jsonobj = eval(ogrobj.ExportToJson())
return np.squeeze(jsonobj['coordinates'])
评论列表
文章目录