簡體   English   中英

從左下角坐標創建一個正方形多邊形

[英]Create a square Polygon from lower left corner coordinates

我確實有坐標(緯度,經度),我需要創建 100 米的多邊形。 現在我只能創建一個多邊形(正方形),其中點是它的中心,而不是左下角。

import geopandas as gpd
from shapely.geometry import Point


# Generate some sample data 
p1 = Point((-122.431297, 37.773972))
points = gpd.GeoSeries([p1])

# Buffer the points using a square cap style
# Note cap_style: round = 1, flat = 2, square = 3
buffer = points.buffer(1, cap_style = 3)

使用geopy生成/構建剩余點。

import geopy
import geopy.distance as distance
from shapely.geometry import Polygon

#Assume each site is 100m (question not clear)
d = distance.distance(kilometers=100/1000)

# Going clockwise, from lower-left to upper-left, upper-right...
p1 = geopy.Point(( 37.773972, -122.431297))
p2 = d.destination(point=p1, bearing=0)
p3 = d.destination(point=p2, bearing=90)
p4 = d.destination(point=p3, bearing=180)

points = [(p.latitude, p.longitude) for p in [p1,p2,p3,p4]]
polygon = Polygon(points)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM