{'northeast': {'lat':}, 'southwest': {'lat': }}(Google 지도) Python에서 다각형을 만드는 방법 (How to create Polygon out of {'northeast': {'lat':}, 'southwest': {'lat': }} (google maps) Python)


문제 설명

{'northeast': {'lat':}, 'southwest': {'lat': }}(Google 지도) Python에서 다각형을 만드는 방법 (How to create Polygon out of {'northeast': {'lat':}, 'southwest': {'lat': }} (google maps) Python)

Google 지도는 위치 경계를 '북동쪽' 및 '남서쪽' 지점이 있는 정사각형으로 반환합니다.

이 데이터에서 다각형을 계산하는 방법은 무엇입니까?

감사합니다!</ 피>


참조 솔루션

방법 1:

Assuming you have a dictionary like this:

bounds = {'northeast': {'lat': 10, 'lng': 15}, 'southwest': {'lat': 5, 'lng': 6}}

then you can use the shapely.geometry.box function, which takes "minx, miny, maxx, maxy" as arguments:

from shapely.geometry import box

bounds_polygon = box(bounds['southwest']['lng'], bounds['southwest']['lat'],
                     bounds['northeast']['lng'], bounds['northeast']['lat'])

which gives:

>>> print(bounds_polygon)
POLYGON ((15 5, 15 10, 6 10, 6 5, 15 5))

(by Dmitriy Grankinjoris)

참조 문서

  1. How to create Polygon out of {'northeast': {'lat':}, 'southwest': {'lat': }} (google maps) Python (CC BY‑SA 2.5/3.0/4.0)

#geopandas #shapely #Python #geometry






관련 질문

{'northeast': {'lat':}, 'southwest': {'lat': }}(Google 지도) Python에서 다각형을 만드는 방법 (How to create Polygon out of {'northeast': {'lat':}, 'southwest': {'lat': }} (google maps) Python)

모양이 교차하는 다각형의 수를 어떻게 계산합니까? (How can I count the number of polygons a shape intersects?)

GeoPandas를 사용하여 Python에서 GRASS 벡터 데이터 소스 읽기 (Read GRASS vector datasources in Python using GeoPandas)

어떤 점에 포함된 영역을 찾는 Geopandas (Geopandas to locate which area does a point contains)

Geopandas Dataframe이 인덱스 오류를 반환하는 이유 (Why is the Geopandas Dataframe returning an Index Error)

여러 선스트링으로 구성된 shapefile을 분할하는 방법 (How to split a shapefile compose of multiple linestrings)

LineString 유형의 개체는 JSON 직렬화가 불가능합니다. (Object of type LineString is not JSON serializable)

큰 geotif 파일 열기 (Open large geotif file)

점이 있는 geopandas 데이터 프레임에서 다각형 만들기 (Creating a polygon from a geopandas dataframe with points)

여러 소스 및 대상 노드에 대한 Networkx 최단 경로 분석 (Networkx Shortest Path Analysis on multiple source and target nodes)

위도/경도 포인트가 다각형 내에 있는지 어떻게 확인합니까? (How do I determine if a lat/long point is within a polygon?)

Geodataframe.explore() 오류: __init__() 누락된 1개의 필수 위치 인수: '위치' (Geodataframe.explore() error: __init__() missing 1 required positional argument: 'location')







코멘트