英文:
How to plot a rectangular grid on word map?
问题
I've the coordinates(Latitude, Longitude) of the 4 corners of all the 300 grids that I want to plot on the world map. How do I do it in python?
这些网格的坐标(Latitude, Longitude)存储在Excel/CSV文件中,具有以下标题:"Box Number","Top left coordinate","Top right coordinate","Bottom left coordinate" 和 "Bottom right coordinate"。
如何在Python中绘制它?
英文:
I've the coordinates(Latitude, Longitude) of the 4 corners of all the 300 grids that I want to plot on the world map. How do I do it in python?
The grids' coordinates are stored in excel/Csv file with the headers : "Box Number", "Top left coordinate", "Top right coordinate", "Bottom left coordinate" and "Bottom right coordinate".
How do I plot it in python?
答案1
得分: 0
我开发了一种相对灵活的方法来在地图上添加有界的网格线,使用了EOmaps:
查看文档以获取更多信息:EOmaps - gridlines
from eomaps import Maps
m = Maps()
m.add_feature.preset.ocean()
for i in range(-180, 180, 20):
for j in range(-90, 90, 20):
bounds = [i + 5, i + 15, j + 5, j + 15]
m.add_gridlines(d=2.5, bounds=bounds, c=f"C{i%9}")
英文:
Not sure if this is what you're searching for, but I've developed a rather flexible way to add bounded gridlines to a map with EOmaps:
Check the docs for more info: EOmaps - gridlines
from eomaps import Maps
m = Maps()
m.add_feature.preset.ocean()
for i in range(-180, 180, 20):
for j in range(-90, 90, 20):
bounds = [i + 5, i + 15, j + 5, j + 15]
m.add_gridlines(d=2.5, bounds=bounds, c=f"C{i%9}")
答案2
得分: 0
Sure, here is the translated code snippet:
top_left_coordinates = (float(values[2]), float(values[1]))
bottom_right_coordinates = (float(values[2]) - difference, float(values[3]))
folium.Rectangle([top_left_coordinates, bottom_right_coordinates]).add_child(folium.Popup(values[0])).add_to(mapobj)
mapobj.save('map.html')
If you have any more code that needs translation, feel free to ask.
英文:
top_left_coordinates = (float(values[2]),float(values[1]))
bottom_right_coordinates = (float(values[2])- difference,float(values[3]))
folium.Rectangle([top_left_coordinates,bottom_right_coordinates]).add_child(folium.Popup(values[0])).add_to(mapobj)
mapobj.save('map.html')
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论