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
generality of st_cast #110
Comments
I'd be happy to see this work more general, no reason to stay with the |
Ok thanks that's good. Currently, only the first part is kept for conversion to the single-part types, but another option is to replicate the feature out for every part, though now I think that's not a job for st_cast. Other related issues,
I'll proceed with
|
Sounds good! |
The new plot defaults are excellent for this! |
Note that we now have |
Oh cool that's great. I'm happy with the framework I have for this now. More in a few days. |
@mdsumner : any news on this one? |
Nothing useful yet, I got most of the combinations working in test-mode but not ready for integration. I have questions about managing the require-closed argument to the internal poly-builder (MatrixSetSet) - can it be brought up to the user to decide etc? but I'm not able to spend time on that right now. I'm hoping to get back to this before the end of the year. |
You mean we can let sf close a polygon in case it is not closed? Yeah, we could do that; sp does that too. Conversion from polygon to multipoint could also drop the closing (=duplicate) point. |
But not dropped for polygon to line, and then dropped (or not)when cast
again from line to mpoints? It makes me uncomfortable that round-tripping
has funny implications like this, and I needed to think more :)
|
Mike, I see the general picture like this: where:
Do look at c.sfg, which already does a lot of the arrows to the right. The 10 other geometries still need to be fitted in, but are in one of the columns of the graph. |
Thanks for the diagram and discussion, it's very helpful. I've pushed a tentative approach here: https://github.com/mdsumner/sfr/blob/cast-additions/R/cast-individual.R I've only done the from-to cases for the six usual suspects (MULTIPOLYGON, MULTILINESTRING, MULTIPOINT, POLYGON, LINESTRING, POINT). I used an override of the internal MtrxSetSet, before I realized there's no checks on polygon sense unless st_polygonize is used (which you pointed out previously). I'm also not doing the one-to-many expansion, I just drop all but the first geometry. I expect to replace my st_multipolygon and st_polygon calls with st_polygonize on appropriate linestring sets. I see that it is:
## from the first vignette "mpol"
plot(st_polygonize(st_cast(mpol, "MULTILINESTRING")), col = "grey") I think the code layout I have is reasonable, in terms of a switch for the the output type, dispatched on the generic for the input type. It's pretty easy to see how to modify things from this. I'll do some more testing and exploring before I PR this, but keen to get any feedback. I'm currently not sure where st_cast should end, and where a "st_explode" should begin - though it seems you have clear ideas on this already. |
Mike, that looks like great work; it does essentially the conversion of a single geometry to another single geometry. I've been working (not completely finished) on casting sfc_XX objects (geometry sets) with expansion and collapsing, draft here. I source it in an R session, test examples now follow the R functions. What's missing in the above graph is the |
Great, this is sounding good, it's going to be very powerful! That turned out tidier than I was expecting, but you had already put the scaffolding in to make those methods make sense. |
Could you make a PR with your cast-individual.R? |
I'm kind of confused about the difference between |
I am too, will try to find out. Looks here like it's the column vs element
type:
https://www.quora.com/What-is-the-difference-between-the-specification-for-TYPE-GEOMETRYCOLLECTION-as-opposed-to-GEOMETRY-in-Addgeometrycolumn-in-PostGIS
On Sat, Jan 7, 2017, 14:22 Etienne B. Racine ***@***.***> wrote:
I'm kind of confused about the difference between GEOMETRY and
GEOMETRYCOLLECTION and see both as interchangeable; I'd like to know if
I'm wrong. Is there an official policy on which one to prefer (if they are
interchangeable) ? I see you didn't include GEOMETRY in the diagram.
Should everything be coerced to GEOMETRYCOLLECTION ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#110 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AD6tb5RJcAWxHHbf2O1gkQfb2L1r7m7zks5rPwUGgaJpZM4LJyRl>
.
--
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia
|
Geometry is the the type of a simple feature column when the feature geometries in the column are a mix of types. GeometryCollection is the geometry type of a single feature geometry where this geometry can be anything, including a mix of geometry types. I don't think the standard is clear about whether GeometryCollections can be nested; I assume they can't. |
I've tested a case of casting MULTIPOLYGON to MULTILINESTRING, inserting this into
st_cast.sfg
This works for what I want, but then breaks the case for LINESTRING to MULTILINESTRING, since each case is exclusive.
Will other coercions be handled different than the current design in st_cast - it needs a wider mapping of type to type - or is st_cast perhaps not the place for this?
The text was updated successfully, but these errors were encountered: