I am trying to convert a geoJSON file in UTM (EPSG 29902) to WGS84. I've seen other examples online which show how to use the transform function in pyproj; however all the ones I have seen are for a single set of coordinates which are typed into the console. For example:
wgs84 = Proj(init = 'epsg:4326')
IrishGrid = Proj(init = 'epsg:29902')
x1,y1 = 318909.45839999989, 251792.64200000092
x2,y2 = transform(IrishGrid,wgs84,x1,y1)
print (x2,y2)
Could someone please tell me how I would convert all of the coordinates in my GeoJSON file from UTM to lat/long? I have been able to read in the json file but am unsure of how to transform every coordinate. I would also like to be able to create a new GeoJSON file with the projected coordinates.
Here is my code so far:
from pyproj import Proj, transform
import json
with open('C:\Program Files (x86)\Anaconda3 (64-bit)\some_file.json') as f:
data = json.load(f)
for feature in data['features']:
presume I use the transform function within my for loop but am unsure of the proper form.
The format of my json file is
"type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "REGION": "Southern Region", "REG_CODE": "03", "DIVISION": "Cork West", "DIV_CODE": "0319", "DISTRICT": "Bandon", "DIST_CODE": "4300A", "SUB_DIST": "Kinsale", "SUB_IRISH": "Cionn tSáile", "SUB_CODE": "4305B", "COUNTY_1": "Cork", "COUNTY_2": null, "GEOGID": "M4305B", "Male2011": 5765, "Female2011": 5963, "Total2011": 11728, "PPOcc2011": 4054, "Unocc2011": 1177, "Vacant2011": 1013, "HS2011": 5231, "PCVac2011": 19.4, "CREATEDBY": "Paul Creaner" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 154039.34449999966, 50090.991299999878 ], [ 154039.8311, 50105.332900000736 ], [ 154041.9757000003, 50130.335699999705 ],
followed by a list of coordinates to form a polygon for about 500 regions.
r
designator to trap the escape characters correctly (e.g.,open(r'C:\...')
)