简体   繁体   English

Python:过滤带有向量的 NetCDF 文件

[英]Python : filter a NetCDF file with vectors

I have vectors of bounding-boxes of cities in the following form我有以下形式的城市边界框向量

Paris = (longmin,latmin, longmax, latmax)
Beirut = (longmin,latmin, longmax, latmax)
#etc...
#longmin being the minimum longitude, latmin the minimum longitude and max being the maximum.

I want to filter different NetCDF files, all of which contain all the coordinates in the world, to only keep the data matching the coordinates of the vectors' bounding boxes.我想过滤不同的 NetCDF 文件,所有这些文件都包含世界上的所有坐标,只保留与向量边界框坐标匹配的数据。

How should I proceed?我应该如何进行?

If you are new to netCDF in Python you should consider using xarray or my package nctoolkit for spatial subsetting.如果您不熟悉 Python 中的 netCDF,您应该考虑使用 xarray 或我的包nctoolkit进行空间子集化。 In the case of nctoolkit, you can subset spatially as follows:在 nctoolkit 的情况下,您可以按如下方式在空间上进行子集化:

import nctoolkit as nc
ds = nc.open_data("infile.nc")
ds.subset(lon = [longmin, longmax], lat = [latmin, latmax])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM