Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size of subset files too large (salem.roi) #231

Open
javedali99 opened this issue May 23, 2023 · 3 comments
Open

Size of subset files too large (salem.roi) #231

javedali99 opened this issue May 23, 2023 · 3 comments

Comments

@javedali99
Copy link

Hello there! I have been trying to use salem.roi() to subset the netCDF data using a shapefile. However, I have noticed that the file size remains the same despite selecting a smaller area, and it is also taking a significantly longer time to run. Can anyone offer any assistance or advice on this matter? Your help would be greatly appreciated.

Check the code below:

for shapefile in shapefiles:
    
    # open the shapefile
    county = salem.read_shapefile(shapefile)
        
    # subset the netcdf data for the county
    county_data = data.salem.roi(shape=county)
    
    file_name = os.path.basename(shapefile)
    
    # save county netcdf file
    county_data.to_netcdf(save_path + "/" + file_name[:-4] + "_river_discharge.nc")
        
    # close the netcdf file
    county_data.close()
@fmaussion
Copy link
Owner

Hello, if you want to subset the data to should use subset, not ROI. ROI is masking the data. See:

https://salem.readthedocs.io/en/stable/xarray_acc.html#subsetting-data
https://salem.readthedocs.io/en/stable/xarray_acc.html#regions-of-interest

@javedali99
Copy link
Author

@fmaussion Thank you. I will try the subset function.

@javedali99
Copy link
Author

@fmaussion I tried it and it appears to be working, but I am getting data that falls outside the polygon of the shapefile. Is there a way to remove this data that exceeds the boundary of the shapefile? I want to select the points on land, instead of those on the sea. Any help would be appreciated.

See this figure:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants