Giter Club home page Giter Club logo

Comments (17)

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

Thank you very much for reporting this. I'll take a look at this when I can and get back to you as soon as possible.

from wdpar.

ntaxus avatar ntaxus commented on June 8, 2024

Thanks Jeffrey! Hope you can check it out soon.
Best,
N

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

Thanks again, I've just pushed a new version to GitHub (version 0.0.1.2) which should fix the bug. When I run the following code, the points appear in the cleaned data as buffered polygons:

# load packages
library(wdpar) # version 0.0.1.2
library(ggmap)
library(gridExtra)

# download and clean data
bol_raw_pa_data <- wdpa_fetch("Bolivia")
bol_pa_data <- wdpa_clean(bol_raw_pa_data)

# I changed the crs for plotting purpose only
bol_pa_data<-st_transform(bol_pa_data, "+proj=longlat +datum=WGS84 +no_defs")

# download map background
bg <- get_stamenmap(unname(st_bbox(bol_pa_data)), zoom = 4, 
                    maptype = "watercolor", force = TRUE)

# make plot for raw data
rawplot <- 
  ggmap(bg) +
  geom_sf(data = bol_raw_pa_data, fill = "#31A35480", inherit.aes = FALSE) +
  theme(axis.title = element_blank()) +
  ggtitle("RawData")+
  geom_sf(data = bol_raw_pa_data[bol_raw_pa_data$WDPAID=="98183",], 
          fill = "black", inherit.aes = FALSE)

# make plot for cleaned data
cleanplot <- 
  ggmap(bg) +
  geom_sf(data = bol_pa_data, fill = "#31A35480", inherit.aes = FALSE) +
  theme(axis.title = element_blank()) +
  ggtitle("CleanData")

# render plots
grid.arrange(rawplot, cleanplot, ncol = 2)

bol

I think I've addressed the bug, so I've closed this issue. But if you're still experiencing this problems with the new version, please re-open it.

from wdpar.

ntaxus avatar ntaxus commented on June 8, 2024

Thanks for your reply!
Unfortunately, I have to say that I am still getting the same results (I used the code you posted here). Maybe I need to upload some package? Below the session info.

Also, I would like you to notice that there are some polygons missing after the cleaning process. In the example I posted above I shaded a polygon (WDPAID= 98183, name="Madidi") which is a National Park (not a UNESCO Biosphere Reserve) that should remain after the clean process, but it doesn't.

I am working with the Latin American countries and I found the same kind of problem with other countries as well.
Thanks for your help!
N

This is my session info:

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
[1] LC_CTYPE=es_AR.UTF-8 LC_NUMERIC=C LC_TIME=es_AR.UTF-8 LC_COLLATE=es_AR.UTF-8 LC_MONETARY=es_AR.UTF-8
[6] LC_MESSAGES=es_AR.UTF-8 LC_PAPER=es_AR.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_AR.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] raster_2.8-4 sp_1.3-1 gridExtra_2.3 ggmap_2.6.2 ggplot2_3.1.0 usethis_1.4.0 devtools_2.0.1 wdpar_0.0.1.2 sf_0.7-2

loaded via a namespace (and not attached):
[1] httr_1.4.0 pkgload_1.0.2 maps_3.3.0 jsonlite_1.6 binman_0.1.1 assertthat_0.2.0 askpass_1.1 wdman_0.2.4
[9] countrycode_1.1.0 RSelenium_1.7.5 yaml_2.2.0 remotes_2.0.2 progress_1.2.0 sessioninfo_1.1.1 pillar_1.3.1 backports_1.1.3
[17] lattice_0.20-35 glue_1.3.0 digest_0.6.18 colorspace_1.4-0 plyr_1.8.4 XML_3.98-1.16 pkgconfig_2.0.2 purrr_0.2.5
[25] scales_1.0.0 processx_3.2.1 jpeg_0.1-8 tibble_2.0.1 openssl_1.2.1 withr_2.1.2 lazyeval_0.2.1 cli_1.0.1
[33] proto_1.0.0 magrittr_1.5 crayon_1.3.4 memoise_1.1.0 ps_1.3.0 fansi_0.4.0 fs_1.2.6 xml2_1.2.0
[41] lwgeom_0.1-5 class_7.3-14 pkgbuild_1.0.2 tools_3.4.4 prettyunits_1.0.2 hms_0.4.2 geosphere_1.5-7 RgoogleMaps_1.4.3
[49] stringr_1.3.1 munsell_0.5.0 bindrcpp_0.2.2 pingr_1.1.2 callr_3.1.1 compiler_3.4.4 e1071_1.7-0.1 caTools_1.17.1.1
[57] rlang_0.3.1 classInt_0.3-1 units_0.6-2 grid_3.4.4 rstudioapi_0.9.0 rjson_0.2.20 rappdirs_0.3.1 bitops_1.0-6
[65] codetools_0.2-15 gtable_0.2.0 DBI_1.0.0 curl_3.3 reshape2_1.4.3 R6_2.3.0 dplyr_0.7.8 utf8_1.1.4
[73] bindr_0.1.1 rprojroot_1.3-2 subprocess_0.8.3 semver_0.2.0 desc_1.2.0 stringi_1.2.4 Rcpp_1.0.0 mapproj_1.2.6
[81] png_0.1-7 tidyselect_0.2.5

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

Ok that's not right. Could you please upload an Rdata file containing the output so I can compare it with what I'm getting? For instance, by running saveRDS("bol_pa_data", "bol_pa.rds", compress = "xz") and attaching the bol_pa_data.rds file to a new post?

from wdpar.

ntaxus avatar ntaxus commented on June 8, 2024

Sure!
Find attached the raw and the clean data. I put them into a zip file since I wasn't allowed to upload xz files here. Is that OK?
Thanks!

bol_data.zip

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

Yeah that's great - thank you!

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

Sorry there was a typo in the code I told you to use to save the data, and so the zip file doesn't contain the spatial data. Could you please export the output with saveRDS(bol_pa_data, "bol_pa.rds", compress = "xz") and upload the file to GitHub? Sorry about this.

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

Also when I try running the code on my computer, Madidi national park remains in the cleaned data set.

# load packages
library(wdpar)

# download data
bol_raw_pa_data <- wdpa_fetch("Bolivia")

# verify raw data has Madidi
print(sum(bol_raw_pa_data$WDPAID == 98183) == 1)
#> TRUE

# clean data
bol_pa_data <- wdpa_clean(bol_raw_pa_data)

# verify cleaned data has Madidi
print(sum(bol_pa_data$WDPAID == 98183) == 1)
#> TRUE

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

I see that you're using R 3.4.4 - could you please try upgrading to R 3.5.2? I don't know why that would cause any problems, but if we can reduce the number of differences between our computing environments that will help me track down the problem.

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

Ok - the problem with Madidi National park is that it has two polygons in the raw data, and one of those polygons (the bigger one) is getting omitted in the cleaning process.

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

I've tracked down the problem with Madidi National park - I'll try and push a patch for it later today.

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

Ok, can you please try running the code below with the new version on GitHub (0.0.1.3)? Hopefully, htis fixes the problem with Madidi National park.

# load packages
library(wdpar) # version 0.0.1.3
library(ggmap)
library(Rmisc)
library(ggplot2)

# download and clean data
bol_raw_pa_data <- wdpa_fetch("Bolivia")
bol_pa_data <- wdpa_clean(bol_raw_pa_data)

# I changed the crs for plotting purpose only
bol_pa_data<-st_transform(bol_pa_data, "+proj=longlat +datum=WGS84 +no_defs")

# download map background
bg <- get_stamenmap(unname(st_bbox(bol_pa_data)), zoom = 4, 
                    maptype = "watercolor", force = TRUE)

# make plot for raw data
rawplot <- 
  ggmap(bg) +
  geom_sf(data = bol_raw_pa_data, fill = "#31A35480", inherit.aes = FALSE) +
  theme(axis.title = element_blank()) +
  ggtitle("RawData")+
  geom_sf(data = bol_raw_pa_data[bol_raw_pa_data$WDPAID=="98183",], 
          fill = "black", inherit.aes = FALSE)

# make plot for cleaned data
cleanplot <- 
  ggmap(bg) +
  geom_sf(data = bol_pa_data, fill = "#31A35480", inherit.aes = FALSE) +
  theme(axis.title = element_blank()) +
  ggtitle("CleanData")

# make plot
multiplot(rawplot, cleanplot, cols = 2)

bol

from wdpar.

ntaxus avatar ntaxus commented on June 8, 2024

Hi Jeffrey, I've checked out the outputs for several countries and everything seems to be OK.
I'll let you know if I find any other mistake.
Thanks!
N

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

Brilliant - thank you so much for raising this issue and helping me fix it. I'll close this issue now, but please do open another issue (or reopen this one if you notice the same problem again) if you find anymore problems.

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on June 8, 2024

Also, I'll submit the updated version to CRAN on Feb 11th (CRAN prefers monthly updates), so this fix gets into the official version asap.

from wdpar.

ntaxus avatar ntaxus commented on June 8, 2024

Excellent! :)

from wdpar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.