python - Wrap_lon of the regionmask does not work with data span from -180 to 180 - Stack Overflow
All,
I use regionmask package 0.13.0 to mask climate NetCDF data. I found that if my data extends from -180 to 180, the mask function returns all NAN even after I set wrap_lon=180
and I did not set wrap_lon
I got the following error
ValueError: lon has data that is larger than 180 and smaller than 0. Set `wrap_lon=False` to skip this check.
I found that shp_file['geometry']
yields a very large number, which may explain this error, yet not sure why the mulipolygon number is so large.
0 MULTIPOLYGON (((-1832380.592 2237164.258, -182 Name: geometry, dtype: geometry
update : I printed the shp_file.crs
and I found that the CRS is EPSG:3857,
<Projected CRS: EPSG:3857>
Name: WGS 84 / Pseudo-Mercator
Axis Info [cartesian]:
- X[east]: Easting (metre)
- Y[north]: Northing (metre)
Area of Use:
- name: World between 85.06°S and 85.06°N.
- bounds: (-180.0, -85.06, 180.0, 85.06)
Coordinate Operation:
- name: Popular Visualisation Pseudo-Mercator
- method: Popular Visualisation Pseudo Mercator
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
yet when I tried to open the shape file using the CRS
hp_file =gpd.read_file("datafiles/"+filename+'.shp',\
crs='EPSG:3857')
I got the following error.
geo_env/lib/python3.12/site-packages/pyogrio/raw.py:198: RuntimeWarning: driver ESRI Shapefile does not support open option CRS
Here is the minimal example
import xarray as xr
import geopandas as gpd
import regionmask
#%% opening the dataset
t2m_file = xr.open_dataset("datafiles/"+"temp.nc")
# adjusting longitude.
t2m_file.coords['longitude'] = (t2m_file.coords['longitude'] + 180) % 360 - 180
t2m_file = t2m_file.sortby(t2m_file.longitude)
t2m = t2m_file['t2m']
#%%
filename='North_Africa'
shp_file =gpd.read_file("datafiles/"+filename+'.shp')
shp_region=regionmask.Regions(shp_file.geometry)
shp_file.plot()
#%%
mask_region=shp_region.mask(t2m.longitude,t2m.latitude,wrap_lon=180)
# masked temperture of the raw data
tem_masked_region=t2m.where(mask_region == 0)
The shape files and the netcdf are very small and could be downloaded from the box
Thanks
- .NET开源:微软"云为先"战略的全面铺开
- 看看CES 2014上奇葩的PC产品 安卓台式机亮相
- 软件定义网络SDN与网络可见性的挑战
- javascript - Read text file and put result to innerHTML? - Stack Overflow
- i need help troubleshooting issues with plugins, i am using gradle 8.12 - Stack Overflow
- reactjs - Why can't AWS Amplify find my components from a working version of my React App? - Stack Overflow
- reactjs - Next.js - I need static error page template in non-static app router based app - Stack Overflow
- google colaboratory - Load a Kaggle dataset into Colab notebook without extracting it - Stack Overflow
- php - New default Moodle setup, no cssimages? - Stack Overflow
- differential equations - Calculating a rocket trajectory in Matlab - Stack Overflow
- How to configure PhpStorm to work with Node.js and ESLint inside a running Docker container? - Stack Overflow
- kotlin - How to add SerialName annotation for a DTO class - Stack Overflow
- Why is my bot not able to detect when a user leaves in Telegram? - Stack Overflow
- Meta Graph API Post engagement - Stack Overflow
- glsl - How do I create Uniform Object Buffers in Qt3d with PySide 6? - Stack Overflow
- OneNote with embeded Excel having Data Connection - security warning and disabled - Stack Overflow
- Setting a global property for one web user in server function in Apps Script - Stack Overflow