Error in the dataframe sigmine_active
Hi In the 'sigmine_active' database I used the command below to add a characteristic. But an error appears that I've never seen - do you know? It seems to point an error in the dataframe
library(tidyverse)
library(datazoom.amazonia)
minera <- load_sigmine(dataset = 'sigmine_active', raw_data = TRUE, language = "pt")
# In the "CONCESSÃO DE LAVRA" phase, which are the 20 companies that have the most records
filter(minera, fase=="CONCESSÃO DE LAVRA") %>%
group_by(nome) %>%
summarize(total=n()) %>%
arrange(desc(total)) %>%
head(20)
Error: st_as_s2(): dropping Z and/or M coordinate st_as_s2(): dropping Z and/or M coordinate Error in s2_geography_from_wkb(x, oriented = oriented, check = check) : Evaluation error: Found 1 feature with invalid spherical geometry. [1] Loop 0 is not valid: Edge 39 has duplicate vertex with edge 51.
Hi @reichaves
For now, I think you can achieve what you intended by dropping the geometry feature with sf::st_drop_geometry():
filter(minera, fase=="CONCESSÃO DE LAVRA") %>%
sf::st_drop_geometry() %>%
group_by(nome) %>%
summarize(total=n()) %>%
arrange(desc(total)) %>%
head(20)
The error is probably due to an inconsistency in the geometries in the sigmine database.
Thanks @gnjardim I don't know this command
I tried:
sf::st_drop_geometry()
Error in UseMethod("st_drop_geometry") :
no applicable method for 'st_drop_geometry' applied to an object of class "NULL"
Should I assign to dataframe minera?
No problem, @reichaves
Yes, you can use:
minera_no_geom <- sf::st_drop_geometry(minera)
That will return the same dataframe but without the geometry column
Thanks
I created a script of usage examples, next week we should publish it on Abraji's website - https://github.com/abraji/datazoomamazonia/blob/main/amazonia.R