Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find a clever way of connected component labelling for vector data #2

Closed
marcosci opened this issue Nov 26, 2018 · 7 comments
Closed

Comments

@marcosci
Copy link
Member

No description provided.

@marcosci
Copy link
Member Author

marcosci commented Dec 3, 2018

Started in e3b28d0 with that. @Nowosad - can I cast a multipolygon into a single polygon? Currently I end up with a multipolygon after st_union but I would need a polygon.

get_patches.sf is than also a candidate for landscapetools.

@Nowosad
Copy link
Member

Nowosad commented Dec 3, 2018

I am going to take a look at it now. One suggestion though - I think we should avoid naming an example object "landscape" again.

@marcosci
Copy link
Member Author

marcosci commented Dec 3, 2018

I am going to take a look at it now. One suggestion though - I think we should avoid naming an example object "landscape" again.

😆 You are totally right, a bad habitat that caused many headaches. The function is a bit rough, needs definitely a bit of tweaking - was just a proof of concept for us that it could work similar.

I was following this issue here:
r-spatial/sf#234

... and the labeling works quite fine (st_relate is awesome). However, the st_union always returns a MULITPOLYGON and can't be casted in a single polygon - which we would need to have a similiar behaviour than in landscapemetrics.

btw to keep you in the loop: We have a student working on the vector metrics and despite being not that familiar with R (she read geocompation with R - and her level afterwards was incredible 👍 ) she has done an awesome job so far - she finished all the metrics on patch level with vectors.

@Nowosad
Copy link
Member

Nowosad commented Dec 3, 2018

Ok, I think I understand the code now @marcosci. I will try to work on cleaning it today/tomorrow.
I can give you a simple response now to "can I cast a multipolygon into a single polygon?". No, you cannot. I will explain later today.

@marcosci
Copy link
Member Author

marcosci commented Dec 3, 2018

👍 Thanks Jakub, no rush!

@Nowosad
Copy link
Member

Nowosad commented Dec 3, 2018

http://postgis.net/docs/using_postgis_dbmanagement.html - search for the "(j-m) cannot be represented as single POLYGONs" phrase.

To expand on this topic:

  1. In simple features, a polygon is a simple object, that cannot represent patches connected by a point.
  2. They (patches connected by a point) should be represented by multipolygon.
  3. In the sf package, each patch can be represented by a row with either POLYGON or MULTIPOLYGON geometry.

@marcosci
Copy link
Member Author

marcosci commented Dec 3, 2018

OK, thanks for explaining! simple features are still here and there a little struggle for me.

This basically means that we need to be very carefull what we treat as patch then - if you look at:

https://github.com/marcosci/vectormetrics/blob/master/R/vm_p_area.R

... I thought that the most logical input would either be a sfc with a multipolygon for each class, or single polygons for each patch of a class. Hence, when we would cast the object to a polygon, we would end up with the same structure.

But it makes sense now, that this was a rather naive view ... Need to think about that 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants