【问题标题】:How to find minimum longitude of coordinate system?如何找到坐标系的最小经度?
【发布时间】:2020-06-25 16:13:29
【问题描述】:

我必须在 Python 中编写一个函数,该函数采用坐标列表和坐标参考系统(作为 EPSG 代码)。如果坐标在坐标系中有效,则返回 True,否则返回 False。我怎样才能做到这一点?

我的想法是获取最小和最大纬度和经度,创建一个粘合多边形并检查点是否落在里面。问题是我不知道如何从 EPSG 代码中获取最小和最大纬度和经度。我唯一的想法是将它们手动写入函数,这是毫无意义的。

这是正确的方法还是我想多了而有更简单的方法?

到目前为止我有:

def valid_coordinates(EPSG):
    print "Coordinate System : ", arcpy.SpatialReference(EPSG).name
    array = arcpy.Array([
        arcpy.Point(-180, -90),
        arcpy.Point(180, -90),
        arcpy.Point(-180, 90),
        arcpy.Point(180, 90),
        arcpy.Point(-180, -90),
        ])# build a polygon based on the array 
    polygon = arcpy.Polygon(array, EPSG)
    point_1 = Point(-0.4, 30.3) 
    point_2 = Point(-1000,-5000)
    print "Point 1: ", polygon.contains(point_1) #returns True which is correct
    print "Point 2: ", polygon.contains(point_2) #returns False is correct

但这毫无意义,因为函数应该采用任何坐标和任何 EPSG

【问题讨论】:

  • 你试过什么代码?
  • 我在“EPSG python”上进行了一次快速的 Google 搜索,发现了 python-epsg 库,此示例的最后一个项目符号听起来像您需要的。
  • 欢迎来到 SO。这不是讨论论坛或教程。请使用tour 并花时间阅读How to Ask 以及该页面上的其他链接。花一些时间与the Tutorial 练习示例。它会让你了解 Python 提供的工具来帮助你解决问题。

标签: python coordinates gis arcmap epsg


【解决方案1】:

通过len() 实现这一目标:

latitude = 'your_extension' len(latitude)

【讨论】:

    猜你喜欢
    • 2018-06-18
    • 1970-01-01
    • 1970-01-01
    • 2015-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多