Timeline for Masking NetCDF time series data from shapefile using Python
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 7, 2020 at 12:21 | comment | added | snowman2 | It might be worth creating a new question @user97103 | |
Jul 7, 2020 at 5:11 | comment | added | user97103 | I used your script to mask nc files from CHIRPS: chirps-v2.0.1981.days_p05.nc Source: data.chc.ucsb.edu/products/CHIRPS-2.0/global_daily/netcdf/p05 using shapefile. But experience an error: ``` File "Clip_NetCDF_with_SHP.py", line 10 CHIRPS_daily = xarray.open_dataarray('Z:\Temp\CHIRPS\NC\chirps-v2.0.1981.days_p05.nc') ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 14-15: malformed \N character escape``` | |
Mar 23, 2020 at 16:02 | vote | accept | Ehsan | ||
Mar 23, 2020 at 14:44 | comment | added | snowman2 | Ah, got it. I updated the geopandas read_file command so it should have the CRS set. | |
Mar 23, 2020 at 14:42 | history | edited | snowman2 | CC BY-SA 4.0 |
added 17 characters in body
|
Mar 23, 2020 at 14:10 | comment | added | Ehsan | Yes, the CRS of the shapefile is missing. | |
Mar 23, 2020 at 13:15 | comment | added | snowman2 | The CRS passed in should be the CRS of the input shapefile. Is the CRS of the shapefile missing? | |
Mar 23, 2020 at 11:41 | comment | added | Ehsan |
Dear snowman2, Thanks for your answer. That works like a charm, very straightforward and super-fast, but I think you need to update your answer as follow, then I can confirm it as the correct answer. clipped = MSWEP_monthly2.rio.clip(Africa_Shape.geometry.apply(mapping), MSWEP_monthly2.rio.crs, drop=False)
|
|
Mar 23, 2020 at 2:28 | history | edited | snowman2 | CC BY-SA 4.0 |
deleted 2 characters in body
|
Mar 23, 2020 at 2:16 | history | answered | snowman2 | CC BY-SA 4.0 |