This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Greetings! I think you may be able to use Rasterio's `mask` module to do what you want: https://rasterio.readthedocs.io/en/latest/api/rasterio.mask.html It seems like you can mask using a list of polygons, which includes polygons from Shapely. You would need to open a shapefile with US states using Shapely. This is how I would approach the problem anyway--I'm not sure if there are some challenges to this approach. Hope this helps, Ryan > Hi! > > > I downloaded some General Circulation Models (GCM's) from the Coupled Model > Intercomparison Project Phase 5 (CMIP5) , which are NetCDF files. I used > MetPy to open the data and found Panoply a good format to visualize the > data. Now, I'm looking for a NetCDF tool which can convert latitude and > longitude (latlon) to states in the United States (maybe just take the mean > of all latlons in a state)? Is there a function in MatPy which can do this? > > > > In the end, I want for all states in the United States one precipitation / > maximum temperature value per timestamp (months). > > Ticket Details =================== Ticket ID: WVL-148071 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.