如何获取所有定义shapefile的经/纬度坐标


9

我有一个Shapefile,其中有几个形状。

使用MapWindow,我可以确定所需的形状是shapeId为19的形状。

您可能会说,我一般对GIS的了解很少,但是我认为我来对地方了,寻求帮助。

我需要提取确定形状的所有纬度/经度坐标。

是否可以使用MapWindow进行此操作,还是需要使用其他软件?

如果需要更多信息来帮助您,请发表评论,我会尽快进行更新。

感谢任何帮助,因为这使我发疯!

Answers:


10

QGIS可以提供​​帮助。将此答案(WKT部分)检查为一个类似的问题:将税收地图多边形从Shapefile转换为地图编号和角坐标的表格


谢谢!我现在正在下载QGIS,我将对结果发表评论!
Zebs 2011年

复制到文本编辑器非常容易。我的补充问题是如何将积分转换为经纬度长的信息?
Zebs 2011年

2
打开原始的shapefile。在图例中右键单击它,然后选择“另存为...”。选择一个目标文件名并坐标系统EPSG:4326(WGS84)。加载新的shapefile。现在,您可以获取经/纬坐标。
黑暗

4

谢谢,您知道我如何将X,Y值转换为lon / lat。我知道我需要投影,但是我可以从shapefile中得到投影吗?
Zebs 2011年

@zebs是的,我知道;不,您无法按照自己的想法去做。shapefile仅包含坐标和属性。没有元数据。有时,投影信息会显示在.prj文件中(共享shapefile的基本名称)。如果没有,那么您就知道了。(数据提供者应告知您。)您需要GIS软件或等效软件来取消投影坐标。这意味着将GIS中的shapefile转换为另一个shapefile(或等效文件),然后导出其新坐标。
ub

2

下面是一种使用Python访问ESRI shapefile纬度和经度坐标以及其他信息位(例如空间参考,字段属性,字段值等)的方法。下面的代码仅适用于多边形和点(因为我还没有写折线的代码)。基本上,我将散布在ArcGIS Desktop帮助9.3周围的一些代码拼凑在一起,添加了一些自己的代码,并将它们组合在一个函数中。它是用ArcGIS 9.3编写的。您应该能够传入多边形shapefile或点shapefile,并且逻辑将相应地对其进行定向。

 def get_shapefile( shape_file ):
    # Import native arcgisscripting module
    import arcgisscripting

    # Create the geoprocessor object
    gp = arcgisscripting.create(9.3)

    # Identify the geometry field
    desc = gp.Describe( shape_file )
    shapefieldname = desc.ShapeFieldName

    # Get shapefile Name
    print
    print 'Shapefile Name: ', desc.Name

    # Get the spatial reference
    spatial_reference = desc.SpatialReference.Name
    print 'Spatial Reference: ', spatial_reference
    print

    # Create search cursor
    rows = gp.SearchCursor( shape_file )
    row = rows.Next()

    # Enter while loop for each feature/row
    while row:

        # Create the geometry object
        feat = row.GetValue(shapefieldname)

        print '*' * 30
        print

        print 'Geometry related Information'
        print
        # Get Geometry Type
        geometry_Type = feat.Type
        print 'Geometry Type: ', geometry_Type

        # Get the area of the feature
        geometry_Area = feat.Area
        print 'geometry_Area; ', geometry_Area

        # Get the centroid for the feature
        geometry_Centroid = feat.Centroid
        print 'geometry_Centroid:', geometry_Centroid

        # Get the extent for the feature
        geometry_Extent = feat.Extent
        print 'geometry_extent: ', geometry_Extent

        print
        print 'Get Attribute Table Information'

        # Get all the fields for the feature class
        fields = desc.Fields

        total_number_of_fields = len( fields )
        print 'Total number of fields: ', total_number_of_fields
        print

        print 'List attribute table related information:'
        print

        field_num_cntr = 0

        # Loop through all the fields in the feature class
        for field in fields:

            print '*'*5, field_num_cntr, '*'*5
            print
            print 'field Type: ', field.Type
            print 'Scale: ', str(field.Scale)
            print 'Precision: ', str(field.Precision)
            print field.Name, '=> ', row.GetValue( field.Name )
            print

            field_num_cntr += 1


        if geometry_Type == 'polygon':

            # Variable to keep track of how many multipart polygons are in
            # featureclass
            partnum = 0 

            # Count the number of points in the current multipart feature
            partcount = feat.PartCount

            print
            print 'Number of polygons in feature class: ', partcount
            print

            # Enter while loop for each part in the feature (if a singlepart feature
            # this will occur only once)
            while partnum < partcount:

                # Print the part number
                print "Part ", str(partnum), "of", partcount, ":"
                print
                part = feat.GetPart(partnum)
                pnt = part.Next()

                pntcount = 0

                # Enter while loop for each vertex
                while pnt:

                    # Print x,y coordinates of current point
                    print 'X coord:', pnt.x, 'Y coord:', pnt.y
                    pnt = part.Next()
                    pntcount += 1

                    # If pnt is null, either the part is finished or there is an interior ring
                    if not pnt:
                        pnt = part.Next()
                        if pnt:
                            print "Interior Ring:"
                partnum += 1

                print
                print 'Number of coordinates in feature class: ', pntcount - 1
                print

        elif geometry_Type == 'point':

            feat = row.GetValue(shapefieldname)

            # Get coords
            pnt = feat.GetPart()

            # Print x,y coordinates of current point object
            print 'X coord:', pnt.x, 'Y coord:', pnt.y


        row = rows.Next()


 your_shapefile = 'Path\To\Your\Shapefile.shp'
 get_shapefile( your_shapefile )
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.