python - 重新网格并重新投影 NETCDF 以匹配 Geotiff - Python
问题描述
我在 netcdf 中有 ERA5 气候数据,在将 ERA5 数据从每小时转换为每天,并将它们一起计算以获得单个每日产品后,我需要在此气候数据和同一地理区域的相应像素之间进行一些计算在一组 geotiffs 中,具有更高的空间分辨率和不同的投影。netCDF 投影在 EPSG 4326 中,并带有纬度/经度图块。geotiff 的分辨率更高(3.125km2),并以南极投影进行投影。我已经在 QGIS 中一起打开了 netcdf 和 geotiffs 并验证了一切都很好并且它们匹配。
我一直不确定如何解决这个问题,但我的感觉是我需要重新投影原始的 netCDF 以匹配 Geotiff,同时还要重新网格化/上采样 netcdf 数据以使像素匹配。
有没有办法简单地“匹配”这两个文件?
(我曾尝试通过在 gdal 中重新投影并在 python 中手动设置新投影开始,这不会导致错误,但也不会创建文件! - 什么也没发生:
import gdal
path = '//Users/gj/Documents/Sea Ice Project/AutoSeaIceProduc/adaptor.mars.internal-1618515503.3594973-11959-19-93fbbedb-7e77-4565-ba2b-05ef0e8b1c71.nc'#Path to file
out = '//Users/gj/Documents/Sea Ice Project/AutoSeaIceProduc/ReprojectedTest.nc'#Path to file
gdal.Warp(out,path, srcSRS='EPSG:4326',dstSRS='EPSG:3976')
NetCDF 的 Gdal 信息:
Driver: netCDF/Network Common Data Format
Files: adaptor.mars.internal-1618515503.3594973-11959-19-93fbbedb-7e77-4565-ba2b-05ef0e8b1c71.nc
adaptor.mars.internal-1618515503.3594973-11959-19-93fbbedb-7e77-4565-ba2b-05ef0e8b1c71.nc.aux.xml
Size is 512, 512
Metadata:
NC_GLOBAL#Conventions=CF-1.6
NC_GLOBAL#history=2021-04-15 19:39:59 GMT by grib_to_netcdf-2.16.0: /opt/ecmwf/eccodes/bin/grib_to_netcdf -S param -o /cache/data8/adaptor.mars.internal-1618515503.3594973-11959-19-93fbbedb-7e77-4565-ba2b-05ef0e8b1c71.nc /cache/tmp/93fbbedb-7e77-4565-ba2b-05ef0e8b1c71-adaptor.mars.internal-1618515503.360069-11959-2-tmp.grib
Subdatasets:
SUBDATASET_1_NAME=NETCDF:"adaptor.mars.internal-1618515503.3594973-11959-19-93fbbedb-7e77-4565-ba2b-05ef0e8b1c71.nc":u10
SUBDATASET_1_DESC=[720x13x85] u10 (16-bit integer)
SUBDATASET_2_NAME=NETCDF:"adaptor.mars.internal-1618515503.3594973-11959-19-93fbbedb-7e77-4565-ba2b-05ef0e8b1c71.nc":v10
SUBDATASET_2_DESC=[720x13x85] v10 (16-bit integer)
SUBDATASET_3_NAME=NETCDF:"adaptor.mars.internal-1618515503.3594973-11959-19-93fbbedb-7e77-4565-ba2b-05ef0e8b1c71.nc":d2m
SUBDATASET_3_DESC=[720x13x85] d2m (16-bit integer)
SUBDATASET_4_NAME=NETCDF:"adaptor.mars.internal-1618515503.3594973-11959-19-93fbbedb-7e77-4565-ba2b-05ef0e8b1c71.nc":t2m
SUBDATASET_4_DESC=[720x13x85] t2m (16-bit integer)
SUBDATASET_5_NAME=NETCDF:"adaptor.mars.internal-1618515503.3594973-11959-19-93fbbedb-7e77-4565-ba2b-05ef0e8b1c71.nc":sp
SUBDATASET_5_DESC=[720x13x85] surface_air_pressure (16-bit integer)
SUBDATASET_6_NAME=NETCDF:"adaptor.mars.internal-1618515503.3594973-11959-19-93fbbedb-7e77-4565-ba2b-05ef0e8b1c71.nc":ssrd
SUBDATASET_6_DESC=[720x13x85] surface_downwelling_shortwave_flux_in_air (16-bit integer)
SUBDATASET_7_NAME=NETCDF:"adaptor.mars.internal-1618515503.3594973-11959-19-93fbbedb-7e77-4565-ba2b-05ef0e8b1c71.nc":strd
SUBDATASET_7_DESC=[720x13x85] strd (16-bit integer)
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 512.0)
Upper Right ( 512.0, 0.0)
Lower Right ( 512.0, 512.0)
Center ( 256.0, 256.0)
样本 geotiff 的相关 gdal 信息
Driver: GTiff/GeoTIFF
Files: clip_asi-AMSR2-s3125-20200301-v5.4.tif
Size is 117, 163
Coordinate System is:
PROJCRS["IDL GeoTIFF Suport
Projection = Polar Stereographic
True scale: -70.0000deg
Gunnar Spreen, Apr 2004",
BASEGEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]],
CONVERSION["Polar Stereographic (variant B)",
METHOD["Polar Stereographic (variant B)",
ID["EPSG",9829]],
PARAMETER["Latitude of standard parallel",-70,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8832]],
PARAMETER["Longitude of origin",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8833]],
PARAMETER["False easting",0,
LENGTHUNIT["metre",1],
ID["EPSG",8806]],
PARAMETER["False northing",0,
LENGTHUNIT["metre",1],
ID["EPSG",8807]]],
CS[Cartesian,2],
AXIS["(E)",north,
MERIDIAN[90,
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]],
ORDER[1],
LENGTHUNIT["metre",1]],
AXIS["(N)",north,
MERIDIAN[0,
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]],
ORDER[2],
LENGTHUNIT["metre",1]]]
Data axis to CRS axis mapping: 1,2
Origin = (-1810937.500000000000000,-554687.500000000000000)
Pixel Size = (3125.000000000000000,-3125.000000000000000)
Metadata:
AREA_OR_POINT=Area
TIFFTAG_DATETIME=2020:03:02 05:15:07
TIFFTAG_DOCUMENTNAME=/ssmi/www/htdocs/data/amsr2/asi_daygrid_swath/s3125/2020/mar/Amundsen/asi-AMSR2-s3125-20200301-v5.4.tif
TIFFTAG_IMAGEDESCRIPTION=IDL TIFF file
TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
TIFFTAG_SOFTWARE=IDL 8.1, ITT Visual Information Solutions
TIFFTAG_XRESOLUTION=100
TIFFTAG_YRESOLUTION=100
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left (-1810937.500, -554687.500) (107d 1'47.10"W, 72d38'40.82"S)
Lower Left (-1810937.500,-1064062.500) (120d26'14.82"W, 70d47' 7.34"S)
Upper Right (-1445312.500, -554687.500) (110d59'45.57"W, 75d46'46.47"S)
Lower Right (-1445312.500,-1064062.500) (126d21'39.97"W, 73d32'29.83"S)
Center (-1628125.000, -809375.000) (116d25'58.56"W, 73d19'46.09"S)
解决方案
推荐阅读
- python - 如何使用我已经安装在其他 IDE 中的 python 包
- json - 在 Python 中将数据结构转换为另一个数据结构
- ios - 画中画崩溃-iOS
- python - 使用 Pyinstaller 打包 Kivy 应用程序 - AttributeError
- websocket - 接收“400 Bad Request”的 WebSocket 请求调用到 sap 应用程序
- typescript - 从对象中提取子类型
- oracle - 解释计划在名称部分显示列名?
- python-3.x - 如何将列表中的元组删除到python中的元组列表中?
- c++ - 当在 main() 之外初始化时,C++ 将向量中的右值作为指针存储不工作
- powershell - 自动为现有 Azure 应用服务启用 Keyvault 证书