Skip to content

How to Convert GeoX/GeoY to Lat/Lon #3171

Answered by kgoebber
edrewitz asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @edrewitz

This should be relatively straightforward using some of the accessors we have available in MetPy. Below is some example code that will read RTMA data available on the Unidata THREDDS server, but this should also work with local data. The key is that we need to first parse the coordinate reference system before we can add the latitude/longitude values.

import xarray as xr
from metpy.units import units

ds = xr.open_dataset(
    'https://thredds-jumbo.unidata.ucar.edu/thredds/dodsC/grib/NCEP/'
    'RTMA/CONUS_2p5km/RTMA_CONUS_2p5km_20230830_1500.grib2'
    ).metpy.parse_cf().metpy.assign_latitude_longitude()

This will then add two new variables to each DataArray: latitude, long…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@edrewitz
Comment options

Answer selected by edrewitz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants