Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Get BBOX value from poly file
import re
def parse(input_file):
f = open(input_file)
lines = f.readlines()
longitudes = []
latitudes = []
for line in lines:
r = re.match("\s+([\w\.\+]+)\s+([\w\.\+]+)", line)
if r:
print "BBOX=" + str(min(longitudes)) + "," + str(min(latitudes)) + "," + str(max(longitudes)) + "," + str(max(latitudes))
if __name__ == '__main__':
import argparse
import os
p = argparse.ArgumentParser(description='Get BBOX value from poly file')
p.add_argument("input_file", metavar="input_file", help="Input file")
args = p.parse_args()
input_file = os.path.abspath(args.input_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment