Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import shapefile
- import sys
- lon1 = float(sys.argv[1])
- lat1 = float(sys.argv[2])
- lon2 = float(sys.argv[3])
- lat2 = float(sys.argv[4])
- pref = sys.argv[5]
- # Create a polygon shapefile
- w = shapefile.Writer(shapefile.POLYGON)
- w.poly(parts=[[[lon1,lat1],[lon1,lat2],[lon2,lat2],[lon2,lat1],[lon1,lat1]]])
- w.field('FIRST_FLD','C','40')
- w.field('SECOND_FLD','C','40')
- w.record('First','Polygon')
- w.save('%s' % pref)
- # create the PRJ file
- prj = open("%s.prj" % pref, "w")
- epsg = 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'
- prj.write(epsg)
- prj.close()
Advertisement
Add Comment
Please, Sign In to add comment