Created
December 3, 2016 09:55
-
-
Save smellman/a2770f3a6c4717315cc0a4538b985a1c to your computer and use it in GitHub Desktop.
Get BBOX value from poly file
This file contains hidden or 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
| import re | |
| def parse(input_file): | |
| f = open(input_file) | |
| lines = f.readlines() | |
| f.close() | |
| longitudes = [] | |
| latitudes = [] | |
| for line in lines: | |
| r = re.match("\s+([\w\.\+]+)\s+([\w\.\+]+)", line) | |
| if r: | |
| longitudes.append(float(r.groups()[0])) | |
| latitudes.append(float(r.groups()[1])) | |
| 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) | |
| parse(input_file) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!