Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python底图坐标_Python_Coordinates_Shapefile_Matplotlib Basemap - Fatal编程技术网

Python底图坐标

Python底图坐标,python,coordinates,shapefile,matplotlib-basemap,Python,Coordinates,Shapefile,Matplotlib Basemap,我正在使用Python3.6在basemap上打开亚马逊河的形状文件。然而,我对python中坐标的工作方式感到困惑。我查了一下亚马逊河的坐标,发现它是lon,lat=-55.126648,-2.163106。但要打开我的地图,我需要角点的纬度/经度值,我不知道如何获取 以下是我目前的代码: from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt map= Basemap(projection='tme

我正在使用Python3.6在basemap上打开亚马逊河的形状文件。然而,我对python中坐标的工作方式感到困惑。我查了一下亚马逊河的坐标,发现它是lon,lat=-55.126648,-2.163106。但要打开我的地图,我需要角点的纬度/经度值,我不知道如何获取

以下是我目前的代码:

from mpl_toolkits.basemap import Basemap

import matplotlib.pyplot as plt

map= Basemap(projection='tmerc',
            lon_0=180,
            lat_0=0,
            resolution='l')
map.drawmapboundary(fill_color='aqua')
map.fillcontinents(color='#ddaa66',lake_color='aqua')
map.drawcoastlines()

map.readshapefile('filename','Amazon')
plt.show()
以下是我尝试运行时收到的错误消息: ValueError:必须指定角点的纬度/经度值
(llcrnrlon、llcrnrlat、ucrnrlon、urcrnrlat)以度为单位或以米为单位的宽度和高度

创建地图(
map=Basemap(…)
)时,需要指定这些值。它们是左下角经度、左下角经度、右上角经度和右上角经度。这些定义了地图的范围。您可以绘制整个地球,然后查看您想要的区域,并从中为新的角点拾取点。

创建地图(
map=Basemap(…)
)时,您需要指定这些值。它们是左下角经度、左下角经度、右上角经度和右上角经度。这些定义了地图的范围。您可以只绘制整个地球,然后查看您想要的区域,并从中为新的角点拾取点。

这种点绘制的最佳方法是通过从点“缩小”来创建您自己的角点。这意味着您需要指定llcrnrlat(左下角纬度)等,如下所示:

my_coords = [38.9719980,-76.9219820]

# How much to zoom from coordinates (in degrees)
zoom_scale = 1

# Setup the bounding box for the zoom and bounds of the map
bbox = [my_coords[0]-zoom_scale,my_coords[0]+zoom_scale,\
        my_coords[1]-zoom_scale,my_coords[1]+zoom_scale]

plt.figure(figsize=(12,6))
# Define the projection, scale, the corners of the map, and the resolution.
m = Basemap(projection='merc',llcrnrlat=bbox[0],urcrnrlat=bbox[1],\
llcrnrlon=bbox[2],urcrnrlon=bbox[3],lat_ts=10,resolution='i')
如果您想查看有关从.csv文件打印lat/lon点的完整教程,请查看我的教程,其中我介绍了整个过程并包含完整代码:

最终的结果如下所示:


此类点打印的最佳方法是通过从点“缩小”创建自己的角点。这意味着您需要指定llcrnrlat(左下角纬度)等,如下所示:

my_coords = [38.9719980,-76.9219820]

# How much to zoom from coordinates (in degrees)
zoom_scale = 1

# Setup the bounding box for the zoom and bounds of the map
bbox = [my_coords[0]-zoom_scale,my_coords[0]+zoom_scale,\
        my_coords[1]-zoom_scale,my_coords[1]+zoom_scale]

plt.figure(figsize=(12,6))
# Define the projection, scale, the corners of the map, and the resolution.
m = Basemap(projection='merc',llcrnrlat=bbox[0],urcrnrlat=bbox[1],\
llcrnrlon=bbox[2],urcrnrlon=bbox[3],lat_ts=10,resolution='i')
如果您想查看有关从.csv文件打印lat/lon点的完整教程,请查看我的教程,其中我介绍了整个过程并包含完整代码:

最终的结果如下所示:


要添加到这一点上,这里是它的文档:。这也取决于投影-有些没有添加下/上角lat/lon,例如正交投影。要添加到这一点上,以下是相关文档:。这也取决于投影-有些没有添加下/上角lat/lon,例如正交投影。