I'm using pyshp to create new shapefiles with Python 3. My code runs without errors, but when I open the resulting file in ArcMap I get this error:
The following datasource you added is missing spatial reference information.
This is not surprising, since I never told my code that the coordinates in the shapefile are supposed to be in EPSG:3006. How do I set this property in pyshp?
Here's some short example code. I want to tell the writer shape
that the coordinates in start
and stop
are in EPSG:3006.
import shapefile
start = [6400137, 321751] # Coordinates in EPSG:3006
stop = [6400095, 319357] # Coordinates in EPSG:3006
with shapefile.Writer("my_shapefile") as shape:
shape.fileType = 3 # Polyline
shape.field("FOO", "C", size = 32)
shape.field("BAR", "C", size = 32)
shape.line([[start, stop]])
shape.record("foo", "bar")