-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Cannot convert
an object of type Type{Union{Missing, Float64}} to an object of type DataType
#37
Comments
Thank you @evetion for reporting the issue. It is always great to see people playing with missing values 👍 I've submitted a patch release with a fix, and it was already merged. Missing values are supported, but for some reason I forgot to update the problem definitions to retrieve the underlying data types: JuliaEarth/GeoStatsBase.jl@2d55fec I would like to comment on your use case however because I think there is a hidden assumption about some of the solvers I didn't clarify well in the docs. At the moment, some solvers (not all) assume that the data object is "inside" the domain object (interpolation). In your case the coordinates of the estimation domain lie outside the convex hull of the spatial data (extrapolation), and I think solvers like Kriging won't work. I have to rethink the API at some point in the future to handle completely disconnected data and domain. As an alternative solution, you could try formulate your estimation problem as a "gap-filling" problem where you copy all the data with gaps to the domain, and let Kriging fill the gaps. By default, the using GeoStats
data = RegularGridData(...)
domain = PointSet(...) + PointSet(coordinates(data))
problem = EstimationProblem(data, domain, :z, mapper=CopyMapper(...)) The I will try to find the time to work on these features, please let me know if something is not clear. Also feel free to contribute :) The union operation between various types of domains would be very handy. |
Adding a note to my previous comment. You should be fine with the current problem setup if you are only using global Kriging. That is, you are not using the options |
Thanks for fixing this bug so quickly! With regards to your comments, I have two questions:
It seems I still have some fundamental misunderstanding of GeoStats, I will try to dive into source code. |
Sorry for the confusion! When you typed Everything is correct as shown in the plot below. Please ignore the fact that there is an offset between using GeoStats
using Plots
z = Array{Float64}(rand(10, 10))
z[2,2] = NaN
z[3,3] = NaN
problemdata = RegularGridData(Dict(:z=>z), (0.,0.), (1.,1.))
problemdomain = PointSet([1.5 2.5; 1.5 2.5])
plot(problemdata)
plot!(problemdomain) |
@evetion I just want to make sure you are using the Please let me know if you need help in the use case. |
Ok, after some reading the source in the different repositories, the So my example above should be: using GeoStats
z = Array{Float64}(rand(10, 10))
z[2,2] = NaN
z[3,3] = NaN
problemdata = RegularGridData(Dict(:z=>z), (0.,0.), (1.,1.))
problemdomain = RegularGrid(size(z), (0.,0.), (1.,1.))
# mapper = Dict(x=>x for x in LinearIndices(z)[.!isnan.(z)]) # copymapper behaviour
problem = EstimationProblem(problemdata, problemdomain, :z, mapper=CopyMapper())
@assert length(datamap(problem, :z)) == 98 # 10 x 10 - 2 locations for which we have data
solution = solve(problem, Kriging()) I would advise to document this default Thanks for all the advice! |
You've got it right! You can also pass the list of indices you wish to copy in the I am actually thinking about a major rewrite of these components in the future to allow for more general spatial problems. I didn't find the time yet, but I will try to look into it for the next paper that I am writing. Sorry for the confusion again. If you have a good documentation in mind, please feel free to submit a PR. I'd be happy to merge. |
Thanks for the package!
I'm in the process of adding interpolation methods to https://github.com/evetion/GeoRasters.jl using GeoStats (GeoStatsDevTools). I hope to just provide an
interpolate(::GeoArray, ::Solver)
method.However, I run into trouble with
Array{Union{Missing, Float64}}
support. The following code works flawlessly:While the same code, using Missing support:
fails with:
The text was updated successfully, but these errors were encountered: