projection.py 文件源码

python
阅读 49 收藏 0 点赞 0 评论 0

项目:pandarus 作者: cmutel 项目源码 文件源码
def project(geom, from_proj=None, to_proj=None):
    """
Project a ``shapely`` geometry, and returns a new geometry of the same type from the transformed coordinates.

Default input projection is `WGS84 <https://en.wikipedia.org/wiki/World_Geodetic_System>`_, default output projection is `Mollweide <http://spatialreference.org/ref/esri/54009/>`_.

Inputs:
    *geom*: A ``shapely`` geometry.
    *from_proj*: A ``PROJ4`` string. Optional.
    *to_proj*: A ``PROJ4`` string. Optional.

Returns:
    A ``shapely`` geometry.

    """
    from_proj = wgs84(from_proj)
    if to_proj is None:
        to_proj = MOLLWEIDE
    else:
        to_proj = wgs84(to_proj)

    to_proj, from_proj = pyproj.Proj(to_proj), pyproj.Proj(from_proj)

    if ((to_proj == from_proj) or
            (to_proj.is_latlong() and from_proj.is_latlong())):
        return geom

    projection_func = partial(pyproj.transform, from_proj, to_proj)
    return transform(projection_func, geom)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号