3

When I ran exact_extract(rasterlayer, sf_object) I was getting the following error:

in CPP_exact_extract(x, weights, wkb, default_value, default_weight, : Unsupported geometry type.

I wasn't sure what was going on, since my other extracts with nearly identical sf objects worked. I figured it out, so documenting my answer here.

1
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a minimal reproducible example. Commented Sep 11, 2021 at 16:51

1 Answer 1

4

To identify the issue I looked up the geometry types in my sf_object and compared them to the geometries contained in extractions that worked:

st_geometry_type(sf_object) %>% as.data.frame(.) %>% distinct(.) %>% View(.)

It turns out exact_extract() doesn't like "GEOMETRYCOLLECTION" shapes.

So next, I filtered out these types of geometric shapes from my sf_object, and afterwards running exact_extract() worked.

dplyr::filter(st_is(sf_object,c("POLYGON","MULTIPOLYGON")))
Sign up to request clarification or add additional context in comments.

1 Comment

It should be OK with GEOMETRYCOLLECTION provided that they're polygonal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.