Post

2 followers Follow
1
Avatar

Reprojecting coordinates from a text file

Hello,
I want to reproject a series of coordinates in a text file from one projection to another using python.

I've already written a script to take the coordinates from a text file and placed them into a list, but I can't figure out how to reproject them.

Can you please provide some assistance.

TIA,
Herb.

Herbert Bergmann Answered

Please sign in to leave a comment.

1 comment

1
Avatar

Hi Herb,

You can use the Geomatica Platform API to read a coordinate system and to do coordinate system transformations using the pci.api.cts module.

The example below demonstrates how to convert between UTM and Long/Lat coordinates. You can adapt this script to iterate through your list of coordinates:

import os
import pci
from pci.api import datasource as ds
from pci.api import cts

# Create objects containing the source projection, and the destination projection.
utm = cts.mapunits_to_crs('UTM 18 D000')
ll = cts.mapunits_to_crs('LONG/LAT D000')

# Create object containing transformation to reproject
utm_to_ll = cts.create_crs_transform(utm, ll)

# Applying the transformation to your coordinates
ll_coordinates = utm_to_ll.transform_point([utm_X_coordinate, utm_Y_coordinate])

More information about Geomatica's Python API is available from our online help: http://www.pcigeomatics.com/python-api-doc/

Sarah

PCI Geomatics 1 vote