i want to extract a rectangle corner coordinates of a shape file in python script..please suggest me a solution.
Thanks in advance, Bhavya
|
i want to extract a rectangle corner coordinates of a shape file in python script..please suggest me a solution. Thanks in advance, Bhavya |
||||
|
|
|
A lot depends on what APIs you have installed. Since you haven't tagged this post as 'ArcGIS' or 'ESRI', I assume you are not using ArcPy. Probably the most common Python GIS APIs is OGR. In OGR do this:
This gives the extent of the entire shapefile. To get the extent of individual features you must drill down and get their envelopes. PS: I should have said that the above code give you the extent as (xMin, xMax, yMin, yMax) |
|||||||||||
|
|
I'm assuming you have ArcGIS. There is a very good worked example at http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Dataset_properties/000v0000002m000000/ Otherwise a common python library for geo-related tasks is Shapely. However, I think you might have more luck with OGR/GDAL. There is a tutorial here, including how to get the extent (see page 18) |
|||||||
|