Last active
December 12, 2015 08:58
-
-
Save jgcasta/4747435 to your computer and use it in GitHub Desktop.
Get the extent from a shapefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 | |
""" | |
Get extent from SHP | |
version 1.0 | |
autor José Gómez Castaño | |
email jgcasta@gmail.com | |
@precondition GDAL must be installed | |
""" | |
from os import chdir,system | |
from osgeo import ogr | |
system("clear") | |
driver = ogr.GetDriverByName('ESRI Shapefile') | |
dataSource1 = driver.Open('madrid.shp', 0) | |
layer1 = dataSource1.GetLayer() | |
extent = layer1.GetExtent() | |
print 'Extent:', extent | |
print 'UL:', extent[0], extent[3] | |
print 'LR:', extent[1], extent[2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment