简体   繁体   English

从给定角生成地理坐标

[英]Generating geographical coordinates from giver corner

Based on the given corner in the map(position A), I want to generate more coordinates towards position B by adding some small values (distances) in the given latitude and longitude.基于地图中的给定角(位置 A),我想通过在给定的纬度和经度中添加一些小值(距离)来生成更多朝向位置 B 的坐标。 For instance:例如:

  • There are 6 houses from position A to B in a map.在地图中从位置 A 到位置 B 有 6 个房子。 If I know the latitude, Longitude of 1 house ( 143.5689855, -38.328956999999996) , how can I create the coordinates for the remaining 5?如果我知道 1 所房子的纬度、经度( 143.5689855, -38.328956999999996) ,我该如何创建其余 5 所房子的坐标?
  • I tried to achieve this by adding some small numbers in coordinates of a given corner as shown in below script.我试图通过在给定角的坐标中添加一些小数字来实现这一点,如下面的脚本所示。 But the code only output for 1 house.但代码只输出 1 个房子。 How can I create a loop in my code that will automatically add the given small number and displays new coordinates for the rest of houses or even for bigger area?如何在我的代码中创建一个循环来自动添加给定的小数字并显示其余房屋甚至更大区域的新坐标?

在此处输入图片说明

What I have tried:我尝试过的:

from arcgis.gis import GIS
from arcgis.geocoding import geocode
from arcgis.geocoding import reverse_geocode
import pprint

# Create an anonymous connection to ArcGIS Online
gis = GIS()


#45-Stodart-St (given corner)
geocode_home = geocode(address="45 Stodart St, Colac VIC 3250")
location = [geocode_home[0]["location"]['x'], geocode_home[0]["location"]['y']]
pprint.pprint(location)


#Add some small numbers in origanal location. This will give us coordinates of next house i.e 43-Stodart-St

#43-Stodart-St

new_loc = [location[0]+0.0002215*1,location[1]*0.999999]

pprint.pprint(new_loc)

Output:输出:

在此处输入图片说明

Assuming you have the 2 locations of house A and house B as loc_A and loc_B .假设你有房子 A 和房子 B 的 2 个位置作为loc_Aloc_B Assuming you know the house numbers of A and B. --> You know the number of houses.假设你知道 A 和 B 的门牌号。 --> 你知道门牌号。

The following code will iterate over the house numbers and create a list of locations:以下代码将遍历门牌号并创建位置列表:

longitude_diff = loc_B[0] - loc_A[0]
latitude_diff = loc_B[1] - loc_A[1]
house_locations = []

for i in range(1, house_number_B - house_number_A):
    house_locations.append([loc_B[0] + i * longitude_diff/(house_number_B - house_number_A),
           loc_B[1] + i * latitude_diff/(house_number_B - house_number_A)])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM