How to change a Lambert Conic Conformal raster projection to latlon degree R

前端 未结 1 1189
栀梦
栀梦 2021-01-20 21:36

I have a raster, obtained from a netcdf which is in (Lambert Conic Conformal projection):

    library(meteoForecast)
    wrf_temporary <- getRaster(\"temp         


        
相关标签:
1条回答
  • 2021-01-20 22:23

    This should work:

    > ll = projectRaster(wrf_temporary,crs="+init=epsg:4326")
    > plot(ll[[1]])
    

    and produces this:

    which looks right at first glance but the Greenwich meridian (longitude=0) doesn't go through London.

    The problem doesn't occur for resolution set to the other values, 4 or 12. When called with resolution=36, you get a raster with a larger extent than the others, but with an identical projection string. This can't be right. For example, the (0,0) coordinate on the following plots should be the same point on the earth because they claim to be the same projection, but they arent.

    I think the resolution=12 ones are correct. Here's that raster transformed to lat-long with an EU vector coverage overlaid:

    which lines up perfectly.

    So I would say its a bug - either getRaster is guessing the projection and getting it wrong, or not applying a change in projection after cropping, or whatever service it uses is lying about the projection.

    getRaster is guessing. The projection info is in the downloaded NetCDF file. In another format. For the resolution=36 file the projection info section is this:

    int Lambert_Conformal ;
        Lambert_Conformal:standard_parallel = 43., 43. ;
        Lambert_Conformal:latitude_of_projection_origin = 24.2280006408691 ;
        Lambert_Conformal:false_easting = 2182.62935 ;
        Lambert_Conformal:false_northing = -269.65597 ;
        Lambert_Conformal:grid_mapping_name = "lambert_conformal_conic" ;
        Lambert_Conformal:longitude_of_central_meridian = -14.1000003814697 ;
        Lambert_Conformal:_CoordinateTransformType = "Projection" ;
        Lambert_Conformal:_CoordinateAxisTypes = "GeoX GeoY" ;
    

    which is a bit different to the resolution=12 projection used by the R package. So make a compliant one:

    p = "+proj=lcc +lat_1=43 +lat_2=43 +lat_0=24.2280006408691 +lon_0=-14.1000003814697 +x_0=2182629.35 +y_0=-269655.97 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=km +no_defs"
     wrf <- getRaster('temp', day = testDay, resolution=36)
     projection(wrf) = p
    

    Then my test with EU overlay....

    Note this time I've reprojected the EU. Doing projectRaster to latlong works too:

    > wrfLL = projectRaster(wrf, crs="+init=epsg:4326")
    > plot(wrfLL[[1]])
    > abline(v=0)
    

    with the Greenwich meridian in its rightful place.

    0 讨论(0)
提交回复
热议问题