ggpolypath | Polygons with holes for ggplot2 | Data Visualization library
kandi X-RAY | ggpolypath Summary
kandi X-RAY | ggpolypath Summary
A ggplot2 geom for polygons with holes, called 'geom_polypath'.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ggpolypath
ggpolypath Key Features
ggpolypath Examples and Code Snippets
Community Discussions
Trending Discussions on ggpolypath
QUESTION
I have objects with multiple holes. I can plot them successfully with geom_polypath
and some geometry identification courtesy of Z.Lin. See geom_polypath(aes(x = x, y = y, group = section))
below.
I with to use geom_sf
to plot these same objects. It is not clear to me how to maintain this geometry information when using sf objects.
The documentation for st_cast states:
ids integer vector, denoting how geometries should be grouped (default: no grouping)
Is that a clue? It's still not clear to me.
The xml file for the letter 'g' is here.
...ANSWER
Answered 2019-Mar-04 at 23:46Here's my first approach, though it feels a bit clumsy. I downloaded letter_g
and made a reprex version of one_letter
, so you can work with that. The first thing to do is to get a polygon for the boundary and each hole by grouping by section, but then it is a bit convoluted to erase the holes from the boundary polygon. I do it here by using st_intersection
and keeping only the resulting polygon that originates entirely from the boundary. I'm also assuming that the section
variable is numbered properly so that the boundary is the first set of points; if we don't know which is supposed to be the boundary I don't know how you can get the right holes.
I am not sure if this method is better than manually converting the points into the format for the st_polygon
constructor.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ggpolypath
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page