Friday 27 April 2018

Change shapefile coordinate system using Python


I am struggling with Python and Kartograph.py. I'd like to change coordinate system of the whole shapefile from EPSG:5514 to EPSG:4326. Found some code in here working for points, but I don't know how to cope with shapefile. Code for point goes like this:


from kartograph import Kartograph
from pyproj import Proj, transform
K = Kartograph()
# S-JTSK EPSG:5514
# Kartograph uses EPSG:4326

inProj = Proj(init='epsg:5514', preserve_units=True)
outProj = Proj(init='epsg:4326')
x1,y1 = -599411.949672, -599411.949672
x2,y2 = transform(inProj,outProj,x1,y1)

Do I need to do anything like this for shp?


from kartograph import Kartograph
from pyproj import Proj, transform
K = Kartograph()
# S-JTSK EPSG:5514

# Kartograph uses EPSG:4326
inProj = Proj(init='epsg:5514', preserve_units=True)
outProj = Proj(init='epsg:4326')
for point in shapefile:
SX = #coordinateX in shp attribute table
SY = #coordinateY
x1,y1 = -599411.949672, -599411.949672 #do something to transform every point
x2,y2 = transform(inProj,outProj,x1,y1)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...