简体   繁体   English

从左下角坐标创建一个正方形多边形

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

I do have coordinates (lat, lon) and I need to create polygon of 100 meters.我确实有坐标(纬度,经度),我需要创建 100 米的多边形。 For now I can only create a polygon (square) where the point is the center of it and not the lower left corner.现在我只能创建一个多边形(正方形),其中点是它的中心,而不是左下角。

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)

Use geopy to generate/construct the remaining points.使用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