Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

mask overload for DataFrames errors with coordinates outside the layer's range #111

Open
gabrieldansereau opened this issue Aug 3, 2021 · 0 comments

Comments

@gabrieldansereau
Copy link
Member

The mask overload for DataFrames returns an unintuitive error if the DataFrame contains observations outside the template layer's range. For example, I encountered this when trying to create a presence-absence layer for a small region, but using a DataFrame with observations across a continent.

julia> mask_layer = mask(layer, df, Bool)
ERROR: LoadError: ArgumentError: invalid index: nothing of type Nothing

I'll fix the mask implementation to allow this, but for now a workaround is to make sure to filter out the coordinates around the layer's bounding coordinates.

filtered_df = filter!(:longitude => >(layer.left), df)
filter!(:longitude => <(layer.right), filtered_df)
filter!(:latitude => >(layer.bottom), filtered_df)
filter!(:latitude => <(layer.top), filtered_df)
mask_layer = mask(layer, filtered_df, Bool)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant