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

Support extraction from multiple bands of a raster #19

Closed
kongdd opened this issue Aug 1, 2020 · 7 comments · Fixed by #69
Closed

Support extraction from multiple bands of a raster #19

kongdd opened this issue Aug 1, 2020 · 7 comments · Fixed by #69
Assignees
Labels
enhancement New feature or request

Comments

@kongdd
Copy link

kongdd commented Aug 1, 2020

One of my nc file has the dimension of [nlon, nlat, ntime], ntime = 365.
However, when using exactextract, only the data of the first date was extracted.

@dbaston
Copy link
Member

dbaston commented Aug 1, 2020

How did you load the nc file?

@kongdd
Copy link
Author

kongdd commented Aug 1, 2020

By the following command:

exactextract -r temp:NETCDF:ET_LISFLOOD.nc:Evap \
    -p Selected_Elasticity_10YThre.shp \
    -f name -s "mean(temp)" -o ET_LISFLOOD2.csv

@dbaston
Copy link
Member

dbaston commented Aug 1, 2020

Oops, I saw this in my email and thought it was referring to https://github.com/isciences/exactextractr . Currently the command-line version processes only a single band. You can specify the band manually, e.g., temp:NETCDF:ET_LISFLOOD.nc:Evap[2], and loop over all bands.

If you want to easily process all of the bands at once, maybe give the R package a try.

Here is a minimal example of the R usage: https://gist.github.com/dbaston/26e8b739dd2549cf1a4c9718981354d3

@kongdd
Copy link
Author

kongdd commented Aug 2, 2020

Thanks for your script.

@dbaston dbaston added the enhancement New feature or request label Apr 20, 2021
@relima
Copy link

relima commented Nov 22, 2021

So, is there any solution for exactextract to retrieve data from multiple dates from a netcdf file?

@dbaston
Copy link
Member

dbaston commented Nov 22, 2021

Currently you'd need to either loop through the bands or use the R package.

@relima
Copy link

relima commented Nov 22, 2021

Got it. The program is awesome -- very fast. For python it may be a good replacement for rasterstats, which is very good too, but terrible slow.

@dbaston dbaston changed the title only the data of the first date was extracted from nc file Support extraction from multiple bands of a raster Dec 1, 2023
@dbaston dbaston self-assigned this Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants