Skip to content
This repository was archived by the owner on Dec 11, 2022. It is now read-only.
This repository was 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

@gabrieldansereau

Description

@gabrieldansereau

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions