繁体   English   中英

如何根据位置的坐标找出地图图像上的颜色?

[英]How can I find out which color is there on an image of map based on the coordinates of the location?

我有印度地图的这张图片,如果我搜索一个坐标,我想知道地图上的颜色是什么。

这是我尝试使用Python实现的项目。

例如,在此图像中,如果我搜索28.7041°N,77.1025°E这是印度德里的坐标,我想得到该坐标处的颜色为橙色。 链接到图片: https//drive.google.com/open?id = 1GDj_HCnAy_CgL9IQ0d2p8Q8Dd4i-eydK

这是一个有点模糊的问题,但我会尝试指导您向您展示示例代码。 这是一个虚假的代码,可以帮助您找到正确的库和执行路径,最终您将不得不自己动手

1 - 请求您要从中下载图像的Web服务中的坐标。 使用Web库(如requests或任何其他抓取库)可能会更容易。

import requests

resp = requests.get('https://my-web-service', params={'lat':42.42,'lng':77.1025})

2 - 在响应中找到图像URL,发出另一个下载图像的请求。 您可能需要使用re或使用其他形式的Web解析来解析响应(例如beautifulsoup

image_url = re.match('https://[a-z].png', resp.text).group(0)
image_resp = requests.get(image_url)

3 - 将图像的内容输入图像库,例如pyopencv

import cv2

img_array = cv2.imdecode(image_resp.content)

4 - 检查像素

print(img_array[40][40])

暂无
暂无

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

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