简体   繁体   English

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

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

I have this image of the map of India and I want to find out what is the color on the map if I search for a coordinate. 我有印度地图的这张图片,如果我搜索一个坐标,我想知道地图上的颜色是什么。

This is for a project I am trying to implement using Python. 这是我尝试使用Python实现的项目。

For example, in this image if I search for 28.7041° N, 77.1025° E which is the coordinates for Delhi, India, I want to get that the color at that coordinates is orange. 例如,在此图像中,如果我搜索28.7041°N,77.1025°E这是印度德里的坐标,我想得到该坐标处的颜色为橙色。 Link to image : https://drive.google.com/open?id=1GDj_HCnAy_CgL9IQ0d2p8Q8Dd4i-eydK 链接到图片: https//drive.google.com/open?id = 1GDj_HCnAy_CgL9IQ0d2p8Q8Dd4i-eydK

This is a bit vague question but I'll try to guide you showing you example code. 这是一个有点模糊的问题,但我会尝试指导您向您展示示例代码。 This is bogus code to help you find the right library and execution path, ultimately you will have to roll your own 这是一个虚假的代码,可以帮助您找到正确的库和执行路径,最终您将不得不自己动手

1 - Request for the coordinates in the web service you want to download image from. 1 - 请求您要从中下载图像的Web服务中的坐标。 This will probably be easier using a web library such as requests or any other scraping library. 使用Web库(如requests或任何其他抓取库)可能会更容易。

import requests

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

2 - Locate the image url in the response, make another request to download the image. 2 - 在响应中找到图像URL,发出另一个下载图像的请求。 You may need to parse the response using re or using other forms of web parsing (such as beautifulsoup ) 您可能需要使用re或使用其他形式的Web解析来解析响应(例如beautifulsoup

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

3 - Feed the content of the image to an image library such as pyopencv 3 - 将图像的内容输入图像库,例如pyopencv

import cv2

img_array = cv2.imdecode(image_resp.content)

4 - Check the pixel 4 - 检查像素

print(img_array[40][40])

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

相关问题 如何找出从哪个模块导入名称? - How can I find out which module a name is imported from? 我怎样才能找到不同值的坐标? - How can i find the coordinates of distinct values? 如何在 Python 的圆圈内包含 map 上的许多坐标? - How can I include many coordinates on a map within a circle with Python? 在循环通过pandas数据帧之前,如何找出支持哪些操作数? - How can I find out which operands are supported before looping through pandas dataframe? 如何找出这张 excel 表中的哪一行数据重复最多 - How can I find out which row of data from this excel sheet is duplicated the most 你如何找出一个值属于哪个对象? - How can you find out which object a value belongs to? 如何在Python中的图像中找到矩形的坐标? - How to find the coordinates of a rectangle in an image in Python? 如何使用 Python 中位置的确切坐标在底图中注释文本? - How can I annotate text in Basemap using the exact coordinates of the location in Python? 如何使用 Python Selenium 按屏幕位置查找元素? - How can I find an element by screen location with Python Selenium? 如果我有细胞的坐标,如何找到 voronoi 细胞的种子? - How can I find the seeds of the voronoi cells if I have the coordinates of the cells?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM