In [11]:
Copied!
import pandas as pd
import pyproj
# Define the coordinate reference systems
in_crs_string = 'EPSG:27700' # British National Grid
out_crs_string = 'EPSG:4326' # WGS84
# Create the coordinate transformer
bng = pyproj.CRS.from_string(in_crs_string)
wgs84 = pyproj.CRS.from_string(out_crs_string)
transformer = pyproj.Transformer.from_crs(bng, wgs84, always_xy=True)
# Read the CSV file
data = pd.read_csv('snowdata.csv')
# Convert X and Y coordinates to longitude and latitude
data['Longitude'], data['Latitude'] = transformer.transform(data['COORD_X'].values, data['COORD_Y'].values)
# Save the updated data to a new CSV file
data.to_csv('snowdatanew.csv', index=False)
import pandas as pd
import pyproj
# Define the coordinate reference systems
in_crs_string = 'EPSG:27700' # British National Grid
out_crs_string = 'EPSG:4326' # WGS84
# Create the coordinate transformer
bng = pyproj.CRS.from_string(in_crs_string)
wgs84 = pyproj.CRS.from_string(out_crs_string)
transformer = pyproj.Transformer.from_crs(bng, wgs84, always_xy=True)
# Read the CSV file
data = pd.read_csv('snowdata.csv')
# Convert X and Y coordinates to longitude and latitude
data['Longitude'], data['Latitude'] = transformer.transform(data['COORD_X'].values, data['COORD_Y'].values)
# Save the updated data to a new CSV file
data.to_csv('snowdatanew.csv', index=False)
In [ ]:
Copied!
Last update:
2023-08-08