[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[python #ZAX-411038]: Retrieving lat and/or lon value from projection x and y coordinate


I'm sure there is a pyproj solution, you would want to create a Lambert 
conformal projection to match the attributes in the file, and then convert your 
lon/lat into a x/y. But there's an easier way if you're using THREDDS:

from datetime import datetime, timedelta
from siphon.catalog import TDSCatalog
cat = 
best = cat.datasets['Best GFS CONUS 20km Time Series']
ncss = best.subset()

start = datetime(2020, 1, 29, 12)
end = start + timedelta(hours=24)

query = ncss.query()
query.lonlat_point(lon=-105, lat=40)
query.time_range(start, end)

nc = ncss.get_data(query)

That should get you a netCDF dataset with a time series of profiles at the 
location you specify. If you only need 1 profile at a specific time, replace 
time_range with time.

Hope that helps,


> Good morning team,
> I'm working with some GFS gridded data sets and I've been trying to figure
> out how to find a specific lat/lon pair based off x and y projected
> coordinates.
> I'm looking at the GFS 20km data via THREDDS and am wanting to plot
> variables based off Denver's lat and lon. Grabbing the data for say
> temperature at isobaric levels, the dimensions are [time, level, x, y].
> I've tried using pyproj to figure this out but I'm not sure what the epsg
> code would be for the GeoX and GeoY coordinates. I believe I want to put it
> in epsg 4326 for lat/lon projections. Would 3412 be the epsg code I'm
> looking for? And if so, should I multiple the x and y values by 1000 since
> 3412 is based off meters and the GFS projections are kilometers?

Ticket Details
Ticket ID: ZAX-411038
Department: Support Python
Priority: Low
Status: Closed
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.