I'm having some trouble reading a WRF weather forecast prediction file where the coordinates are in a custom Lambert Conformal Conical projection.

My final goal is to get the weather forecast a a certain location given in a WGS84 projection (lat/lon), which I know for sure is within the NetCDF file.

I'm using a Python script and the NetCDF4 and PyProj libraries.

In the NetCDF file, downloaded from the local weather forecast service, there is the following information about the used projection:

<class 'netCDF4._netCDF4.Variable'>
int32 Lambert_Conformal()
    grid_mapping_name: lambert_conformal_conic
    longitude_of_central_meridian: -14.100000381469727
    standard_parallel: [43. 43.]
    latitude_of_projection_origin: 40.71900177001953
    false_easting: -241.44951
    false_northing: -4.10447
unlimited dimensions: 
current shape = ()
filling on, default _FillValue of -2147483647 used

So I try to recreate this using the pyproj library:

lat_0 = variables['Lambert_Conformal'].latitude_of_projection_origin
lon_0 = variables['Lambert_Conformal'].longitude_of_central_meridian
lat_1 = variables['Lambert_Conformal'].standard_parallel[0]
lat_2 = variables['Lambert_Conformal'].standard_parallel[1]
x_0 = variables['Lambert_Conformal'].false_easting
y_0 = variables['Lambert_Conformal'].false_northing

I create a LCC origin projection with PyProj, as well as the destination WSG84 projection:

lcc = Proj(proj='lcc' , lat_1=lat_1, lat_2=lat_2,
           lat_0=lat_0, lon_0=lon_0, x_0=x_0, y_0=y_0,
           a=6370000, b=6370000)
# Resulting projection string: '+proj=lcc +lat_0=40.7190017700195 +lon_0=-14.1000003814697 +lat_1=43 +lat_2=43 +x_0=-241.44951 +y_0=-4.10447 +R=6370000 +units=m +no_defs'

wgs84 = Proj(proj='latlong', datum='WGS84')

Now that I have everything set-up, I perform the actual conversion between projections:

transformer = Transformer.from_proj(proj_from=wgs84, proj_to=lcc)

# Geographical point which I know is contained within the weather forecast.
lat_geo = 42.666981
lon_geo = -8.006540


As result, I get:

(497466.92765635485, 234691.1045065646)

which makes no sense to me, as I was expected something contained within the range of the variables in NetCDF file. For reference, the latitude variable in the NetCDF file is between 40.719 and 40.44141.

So, what am I missing here?

  • Are the lat_0, lat_1, lat_2... parameters correctly loaded? Did I misplaced some of them?
  • Is there some missing projection information in NetCDF file?
  • I see that there is actually a single standard parallel (the same, but repeated twice). Does that make sense?

TLDR: How do I go from this custom LCC projection to standard WGS84 coordinates?

More information:

  • The weather forecast agency says that the global lon/lat coordinates are supossed to be:

    Longitude: -11.261331695726343 to -5.101928395629246 degrees_east
    Latitude: 40.421302033295966 to 45.230011083267385 degrees_north
  • This is a map using their available web tools:

Weather forecast domain

  • 1
    did you try with coords=transformer.transform(lat_geo,lon_geo)?
    – Ian Turton
    Commented Dec 18, 2020 at 17:47
  • Yes, I did try inverting lat_geo and lon_geo. If I do that I get (8295902.637445953, -3265084.29720419) , which is still far from correct. Also, I double check by feeding the projection string to QGIS and I got that the correct order seems to be longitude first, latitude later. So, everything points to the projection string and the projection parameters... Commented Dec 18, 2020 at 17:59
  • 2
    I might be completely wrong, but the false_easting and false_northing look odd to me. Commonly they are in units of meters in the projected system, but numerically, -241.44951 and -4.10447 look more like degrees.
    – Dave X
    Commented Dec 18, 2020 at 18:09
  • Thanks, @DaveX. It does look akward indeed. Thank you for your suggestion. But I found the problem. I'll update the question Commented Dec 20, 2020 at 19:38

1 Answer 1


Well... I found the solution to my problem. The coordinates were always in geodetic coordinates. I didn't realise because I was misreading the variables['lat'] and variables['lon'] arrays. Also, I was mislead by the specification of a Lambert Conformal Conic projection.

Lessons learned:

  • Always check the data contained within your file.
  • Lots of experience gained with the pyproj library.

Thank you everyone for your time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.