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)
EDIT FOLLOWING COMMENT (26/03/16): This will not work on a raster because OGR is a library for vectors. You need the gdal libraries (these days usually bundled together for any install). The simplest approach for rasters is to use the gdalinfo utility.
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/
You may have already discovered how trivial a task ArcPy makes this sort of question. Expanding further on MappaGnosis' answer, to get the full extents of the feature class using ArcPy, call the GetExtent() method of the Layer object:
To list the extents for each feature, open a search cursor on the feature class and loop through it:
The optional, second argument to the