def to_latlon(geojson, origin_espg=None):
"""
Convert a given geojson to wgs84. The original epsg must be included insde the crs
tag of geojson
"""
if isinstance(geojson, dict):
# get epsg code:
if origin_espg:
code = origin_espg
else:
code = epsg_code(geojson)
if code:
origin = Proj(init='epsg:%s' % code)
wgs84 = Proj(init='epsg:4326')
wrapped = test_wrap_coordinates(geojson['coordinates'], origin, wgs84)
new_coords = convert_coordinates(geojson['coordinates'], origin, wgs84, wrapped)
if new_coords:
geojson['coordinates'] = new_coords
try:
del geojson['crs']
except KeyError:
pass
return geojson
评论列表
文章目录