1

Googleマップの方向APIから折れ線を計算しました。ラインストリングを GEOSGeometry オブジェクトに変換しました。線ストリング オブジェクトから 'd' の距離にあるすべてのポイントをカバーする別の領域が必要です。距離はm、kmです。GEOS API は GEOSGeometry.buffer(width, quadsegs=8) を提供し、2D 投影でうまく機能します。

しかし、球体モデルの場合はどうすればよいでしょうか? それはSRIDに関連していますか?

from django.contrib.gis.geos import LineString
from django.contrib.gis.geos import GEOSGeometry

directions = maps_client.directions(source, destination)
overview_polyline = decode_polyline(directions[0]['overview_polyline'])

linestring_obj = LineString(overview_polyline)

# FOR 2-D projection
bounding_box = linestring_obj.buffer(width=100) 

# For spherical model
# ???
4

1 に答える 1

1

メートル単位の地理的距離を理解するには、常に投影座標系を使用する必要があるため、データを投影座標系に変換し、バッファーを作成して投影し直すことをお勧めします。例えば:

# Specify the original srid of your data
orig_srid = 4326

# Create the linestring with the correct srid
linestring_obj = LineString(overview_polyline, srid=orig_srid)

# Transform (project) the linestring into a projected coorinate system
linestring_obj.transform(3857)

# Compute bbox in in that system
bounding_box = linestring_obj.buffer(width=100)

# Transform bounding box into the original coorinate system of your data
bounding_box.transform(orig_srid)
于 2015-02-02T11:51:19.967 に答える