Skip to content

How to convert X/Y model data to lat/long in MetPy? #3446

Answered by dopplershift
rolypolyman asked this question in Q&A
Discussion options

You must be logged in to vote

Here's an example of how to plot without needing to do any manual coordinate manipulation:

import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import metpy
import numpy as np
from siphon.catalog import TDSCatalog
import xarray as xr
from xarray.backends import NetCDF4DataStore

# Find the latest HRRR run
latest_hrrr = TDSCatalog('https://thredds.ucar.edu/thredds/catalog/grib/NCEP/HRRR/CONUS_2p5km/catalog.xml').latest

# Download a subset of the data and open with xarray
ncss = latest_hrrr.subset()
query = ncss.query()
query.lonlat_box(-120, -60, 25, 50)
query.variables('Pressure_reduced_to_MSL_msl')
nc = ncss.get_data(query)
ds = xr.open_dataset(N…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@rolypolyman
Comment options

@dopplershift
Comment options

Answer selected by dopplershift
@rolypolyman
Comment options

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