1

I have a set of data like so

"ID","geometry"
 
"GROGOL UTARARW9RT7","POLYGON((11887810.585149335 -694170.5895844387, 11887763.520539563 -694165.5079235699, 11887733.498811511 -694164.5386431288, 11887730.736926513 -694166.26253862, 11887718.505617954 -694165.5847476447, 11887708.960233262 -694165.2094483451, 11887705.691726169 -694165.0809650233, 11887704.132918153 -694165.0196555209, 11887701.254616084 -694164.9065482351, 11887683.759617103 -694164.1724747906, 11887679.233432828 -694166.5222391136, 11887667.912458485 -694165.8979339052, 11887664.65649373 -694165.5811802321, 11887623.660770087 -694161.5911621357, 11887615.063062133 -694101.3551729687, 11887592.379592206 -694084.7866236303, 11887595.239916824 -694079.7619318971, 11887599.186837088 -694072.8287096185, 11887600.340042543 -694070.7181591626, 11887604.268097974 -694063.5291417049, 11887607.197230011 -694058.0292504401, 11887613.65029986 -694045.5252885219, 11887622.498295614 -694027.3965961878, 11887625.645998329 -694020.4939466066, 11887627.94142664 -694015.4602496751, 11887686.866177533 -694044.8803428481, 11887743.647055088 -694073.7799643101, 11887830.162171714 -694123.4825396386, 11887829.766520143 -694124.4487067807, 11887829.205197228 -694125.7989765694, 11887826.526890144 -694132.2415800181, 11887812.22292561 -694166.650102832, 11887810.585149335 -694170.5895844387))"

where I would like to convert the projection system 32748 (WGS 84 / UTM zone 48S) polygon to longitude and latitude using Python.

How do I do so? I've been searching around for the same case above but could not find one.

1 Answer 1

1

You have have a csv with the geometry data in a format called WKT and in proyection ESPG:32748.

The steps to achieve what you want are something like:

  1. Read the csv
  2. Convert the text (WKT) to some kind of Python Geometry DataType
  3. Reproyect these geometries to your desired proyection, as you talk about using latitude and longitude probably what you want is ESPG:4326
  4. Write it back to a csv file, or other spatial file format like shapefile or geopackage.

There are several ways to do it. Using libraries like shapely and pyproj is an easy one.

Check this example:

import csv 
import pyproj  
from shapely.ops import transform 
from shapely import wkt 

reprojection = pyproj.Transformer.from_proj(32748, 4326) 
  
with open('data.csv', 'r') as f:  
    reader = csv.DictReader(f)  
    for row in reader:  
        geometry = wkt.loads(row['geometry'])          
        reprojected_geometry = transform(reprojection.transform, geometry)  

        row['geometry'] = reproyected_geometry  
        print (row)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.