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

Contains not work #69

Closed
kongdd opened this issue Oct 2, 2020 · 2 comments
Closed

Contains not work #69

kongdd opened this issue Oct 2, 2020 · 2 comments

Comments

@kongdd
Copy link
Contributor

kongdd commented Oct 2, 2020

The example is not work at L23:

using GeoData, ArchGDAL, NCDatasets, Plots, Statistics

geturl(url, filename=splitdir(url)[2]) = begin
    isfile(filename) || download(url, filename)
    filename
end


# Load some layers from NetCDF #############################################

ncurl = "https://www.unidata.ucar.edu/software/netcdf/examples/tos_O1_2001-2002.nc"
ncfilename = geturl(ncurl, "tos_O1_2001-2002.nc")
stack = NCDstack(ncfilename)

# Load the sea surface temperature layer
A = stack[:tos]

# Plot the 1st, 4th, 7th and 10th months 
A[Ti(1:3:12)] |> plot
savefig("tos_4.png")

# Plot the Australia region
A[Ti(Contains(DateTime360Day(2001, 01, 17))), Lat(Between(0, -50)), Lon(Between(100, 160))] |> plot

I got the error:

A[Ti(Contains(DateTime360Day(2001, 01, 17))), Lat(Between(0, -50)), Lon(Between(100, 160))]
ERROR: LoadError: ArgumentError: `Contains` has no meaning with `Points`. Use `Near`

https://github.com/rafaqz/GeoData.jl/blob/master/examples/examples.jl#L23

@rafaqz
Copy link
Owner

rafaqz commented Oct 2, 2020

Oh right I should change the example.

The netcdf time dimension is Points by default now, not Intervals. Points cant contain values.

Instead use Near:

A[Ti(Near(DateTime360Day(2001, 01, 17))), Lat(Between(0, -50)), Lon(Between(100, 160))] |> plot

@kongdd
Copy link
Contributor Author

kongdd commented Oct 2, 2020

Thank you!

@kongdd kongdd closed this as completed Oct 2, 2020
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