Home | Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python3 2 # ****************************************************************************** 3 # $Id$ 4 # 5 # Project: GDAL 6 # Purpose: Simple command line program for translating ESRI .prj files 7 # into WKT. 8 # Author: Frank Warmerdam, warmerda@home.com 9 # 10 # ****************************************************************************** 11 # Copyright (c) 2000, Frank Warmerdam 12 # 13 # Permission is hereby granted, free of charge, to any person obtaining a 14 # copy of this software and associated documentation files (the "Software"), 15 # to deal in the Software without restriction, including without limitation 16 # the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 # and/or sell copies of the Software, and to permit persons to whom the 18 # Software is furnished to do so, subject to the following conditions: 19 # 20 # The above copyright notice and this permission notice shall be included 21 # in all copies or substantial portions of the Software. 22 # 23 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 # DEALINGS IN THE SOFTWARE. 30 # ****************************************************************************** 31 32 import sys 33 34 from osgeo import osr 3537 if len(argv) < 2: 38 print('Usage: esri2wkt.py <esri .prj file>') 39 sys.exit(1) 40 41 prj_fd = open(argv[1]) 42 prj_lines = prj_fd.readlines() 43 prj_fd.close() 44 45 for i, prj_line in enumerate(prj_lines): 46 prj_lines[i] = prj_line.rstrip() 47 48 prj_srs = osr.SpatialReference() 49 err = prj_srs.ImportFromESRI(prj_lines) 50 if err != 0: 51 print('Error = %d' % err) 52 else: 53 print(prj_srs.ExportToPrettyWkt())54 55 56 if __name__ == '__main__': 57 sys.exit(main(sys.argv)) 58
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Oct 26 13:28:01 2020 | http://epydoc.sourceforge.net |