Giter Site home page Giter Site logo

Cleaning Brazil areas issue about wdpar HOT 8 CLOSED

prioritizr avatar prioritizr commented on May 21, 2024
Cleaning Brazil areas issue

from wdpar.

Comments (8)

jeffreyhanson avatar jeffreyhanson commented on May 21, 2024 1

Hi,

I'm very sorry for the slow response. I've been on vacation and then attending a conference, so I haven't had a chance to respond to you earlier. It looks like the wdpar is having problems with the geometry of the data. Broadly speaking, R's ability to clean invalid geometry is generally pretty good (and by this I specifically mean the lwgeom package), but it can fail to clean really invalid geometries. Unfortunately, there isn't much I can do about this.

I would recommend: (i) manually saving the data to a shapefile (see sf::st_write), (ii) fixing it ESRI ArcMap using the repair geometry tool, and (iii) then importing the fixed data into R and running the wdpa_clean function again. I'm sorry I don't have a better solution that doesn't involve commercial software.

Cheers,

Jeff

from wdpar.

antoinestevens avatar antoinestevens commented on May 21, 2024 1

Hello,
I ran into the same problem (see also #16 ) and solved it by changing in st_erase_overlaps this line:

 u <- sf::st_union(sf::st_set_precision(sf::st_buffer(o[ovr], 0), precision))

to

u <- sf::st_buffer(sf::st_union(sf::st_set_precision(sf::st_buffer(o[ovr], 0), precision)),dist = 0)

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on May 21, 2024 1

Awesome work @antoinestevens! Thank you so much for coming up with a fix! I'll patch that into the dev version of the wdpar package now.

from wdpar.

antoinestevens avatar antoinestevens commented on May 21, 2024 1

Actually, it essentially fixed #16 but not this issue.
Modifying 2 lines below (don't ask me why) with st_make_valid will finally fix all my problems
d <- sf::st_difference(sf::st_set_precision(g[i],precision), lwgeom::st_make_valid(sf::st_set_precision(u, precision)))

from wdpar.

antoinestevens avatar antoinestevens commented on May 21, 2024 1

Thank YOU for your awesome work (inc. your other super useful packages)

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on May 21, 2024 1

Ok brilliant - I'll patch that fix in as well - thanks again!

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on May 21, 2024

Thank you - I really appreciate it.

from wdpar.

jeffreyhanson avatar jeffreyhanson commented on May 21, 2024

I forgot to tag this issue in the latest commit, so I'll close this manually now.

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.