Closed GoogleCodeExporter closed 9 years ago
You are correct but there is a good reason the library does not write the prj
file. The projection (prj) file specifies the Well-Known Text (WKT) format for
the projection of the shapefile. The projection cannot be automatically
detected so the programmer or user must manually specify the projection. All
GIS software works in this way. Some packages automatically assume WGS84 (epsg
code 4326) which is unprojected unless you change it.
I've thought about adding the ability to optionally write prj files but the
list of "commonly-used" WKT strings is over .5 megs and would be bigger than
the shapefile library itself.
The easiest thing to do right now is just figure out what WKT string you need
for your data and quickly write a file. Here's a modified version of our
example using WGS84:
import shapefile as sf
filename = 'test/point'
# create the shapefile
w = sf.Writer(sf.POINT)
w.point(37.7793, -122.4192)
w.field('FIRST_FLD')
w.record('First','Point')
w.save(filename)
# create the PRJ file
prj = open("%s.prj" % filename, "w")
epsg = 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS
84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.01745329251994
33]]'
prj.write(epsg)
prj.close()
Original comment by geospati...@gmail.com
on 11 Feb 2011 at 3:36
Original issue reported on code.google.com by
thesa...@gmail.com
on 10 Feb 2011 at 11:23