900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > python随机生成一个地区地址_为特定地区/国家生成随机坐标的轻量级工具?

python随机生成一个地区地址_为特定地区/国家生成随机坐标的轻量级工具?

时间:2020-03-12 05:18:49

相关推荐

python随机生成一个地区地址_为特定地区/国家生成随机坐标的轻量级工具?

不得不做类似的事情,但希望在这个案例中真正统一地在欧洲传播。在import shapefile

from shapely.geometry import Point, shape

from numpy.random import uniform

from collections import Counter

shp = shapefile.Reader('shapefiles/TM_WORLD_BORDERS-0.3.shp')

# Adjust for your case:

EU3 = ['ARM', 'BIH', 'BIH', 'CYP', 'DNK', 'IRL', 'AUT', 'EST', 'CZE', 'FIN'

, 'FRA', 'DEU', 'GRC', 'HRV', 'HUN', 'ISL', 'ITA', 'LTU', 'LVA', 'BLR'

, 'MLT', 'BEL', 'AND', 'GIB', 'LUX', 'MCO', 'NLD', 'NOR', 'POL', 'PRT'

, 'ROU', 'MDA', 'ESP', 'CHE', 'GBR', 'SRB', 'SWE', 'ALB', 'MKD', 'MNE'

, 'SVK', 'SVN'] # 'TUR'

EU = [(boundary, record) for boundary, record in

zip(shp.shapes(), shp.records()) if record[2] in EU3]

# Adjust the borders

count = Counter() # small optimisation to check for big shapes first

def sample(shapes, min_x=-11, max_x=26, min_y=37, max_y=71):

while True:

point = (uniform(interval_x), uniform(interval_y))

for boundary, record in sorted(shapes, key=lambda x: -count[x[1][2]]):

if Point(point).within(shape(boundary)):

count[record[2]] += 1

return point

这给了你想要的样品。下面是一幅来自欧洲的5000点样本的图。获得一次样品使用

^{pr2}$

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。