Given a set of simple graph coordinates inside a square, how to identify all base polygons?Howto project a planar polygon on a plane in 3d-spaceCalculate coordinates of a regular polygon's verticeshow to order vertices in a simple, non-convex polygonHow do I generate a grid of coordinates within specified polygons in R?Bounding boxes in coordinate system based on right triangle quadrants of square tilesDraw circle with lines in it using Java graphicsRedraw drawn line on mapviewCSV of XY coordinates for multiple polygonsCalculation of shape width at given horizontal lineexport coordinates inside polygon

Multi tool use
My players want to grind XP but we're using milestone advancement
Why was this character made Grand Maester?
Manager questioning my time estimates for a project
Determine this limit
Of strange atmospheres - the survivable but unbreathable
Drums and punctuation
Python program to take in two strings and print the larger string
Why haven't we yet tried accelerating a space station with people inside to a near light speed?
Parallel fifths in the orchestra
How to politely tell someone they did not hit "reply to all" in an email?
How to patch glass cuts in a bicycle tire?
便利な工具 what does な means
What does kpsewhich stand for?
Gravitational effects of a single human body on the motion of planets
How to cut a climbing rope?
Why does Bran want to find Drogon?
Dad jokes are fun
Why did British Steel have to borrow 120 million pounds (from the government) to cover its ETS obligations?
Can I tell a prospective employee that everyone in the team is leaving?
USPS Back Room - Trespassing?
Why did Drogon spare this character?
Nuke it from orbit - surely can only mean bin and buy replacement?
Can my floppy disk still work without a shutter spring?
Are black holes spherical during merger?
Given a set of simple graph coordinates inside a square, how to identify all base polygons?
Howto project a planar polygon on a plane in 3d-spaceCalculate coordinates of a regular polygon's verticeshow to order vertices in a simple, non-convex polygonHow do I generate a grid of coordinates within specified polygons in R?Bounding boxes in coordinate system based on right triangle quadrants of square tilesDraw circle with lines in it using Java graphicsRedraw drawn line on mapviewCSV of XY coordinates for multiple polygonsCalculation of shape width at given horizontal lineexport coordinates inside polygon
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a 4x4 square within which one can draw lines either vertically or horizontally in units of 1. The result would look something like this (as an example).
Given this problem, how would one go about identifying the 3 polygons that construct this image?
I understand that the large square in which the pieces lie is a polygon too, but I'm only interested in the 'base' polygons - not sure if that's the right way to call them.
Clarification: We only know the coordinates of the lines from inputting them, we don't know the polygons in advance.
The solution accordingly would be the polygons themselves (in pseudo-code):
pol[1] = c(0, 0),
c(1, 0),
c(1, 1),
c(2, 1),
c(2, 2),
c(1, 2),
c(1, 3),
c(0, 3),
c(0, 0)
pol[2] = c(1, 0),
c(3, 0),
c(3, 4),
c(0, 4),
c(0, 3),
c(1, 3),
c(1, 2),
c(2, 2),
c(2, 1),
c(1, 1),
c(1, 0)
pol[3] = c(3, 0),
c(4, 0),
c(4, 4),
c(3, 4),
c(3, 0)
r geometry coordinates
add a comment |
I have a 4x4 square within which one can draw lines either vertically or horizontally in units of 1. The result would look something like this (as an example).
Given this problem, how would one go about identifying the 3 polygons that construct this image?
I understand that the large square in which the pieces lie is a polygon too, but I'm only interested in the 'base' polygons - not sure if that's the right way to call them.
Clarification: We only know the coordinates of the lines from inputting them, we don't know the polygons in advance.
The solution accordingly would be the polygons themselves (in pseudo-code):
pol[1] = c(0, 0),
c(1, 0),
c(1, 1),
c(2, 1),
c(2, 2),
c(1, 2),
c(1, 3),
c(0, 3),
c(0, 0)
pol[2] = c(1, 0),
c(3, 0),
c(3, 4),
c(0, 4),
c(0, 3),
c(1, 3),
c(1, 2),
c(2, 2),
c(2, 1),
c(1, 1),
c(1, 0)
pol[3] = c(3, 0),
c(4, 0),
c(4, 4),
c(3, 4),
c(3, 0)
r geometry coordinates
Sorry. What exactly do you want? Do you want people to create an R object that describes the polygons?
– www
Mar 24 at 1:03
Looking more for direction regarding the methodology to do so. I wouldn't expect anyone to create an R code for this on my behalf.
– Deuterium
Mar 24 at 1:05
add a comment |
I have a 4x4 square within which one can draw lines either vertically or horizontally in units of 1. The result would look something like this (as an example).
Given this problem, how would one go about identifying the 3 polygons that construct this image?
I understand that the large square in which the pieces lie is a polygon too, but I'm only interested in the 'base' polygons - not sure if that's the right way to call them.
Clarification: We only know the coordinates of the lines from inputting them, we don't know the polygons in advance.
The solution accordingly would be the polygons themselves (in pseudo-code):
pol[1] = c(0, 0),
c(1, 0),
c(1, 1),
c(2, 1),
c(2, 2),
c(1, 2),
c(1, 3),
c(0, 3),
c(0, 0)
pol[2] = c(1, 0),
c(3, 0),
c(3, 4),
c(0, 4),
c(0, 3),
c(1, 3),
c(1, 2),
c(2, 2),
c(2, 1),
c(1, 1),
c(1, 0)
pol[3] = c(3, 0),
c(4, 0),
c(4, 4),
c(3, 4),
c(3, 0)
r geometry coordinates
I have a 4x4 square within which one can draw lines either vertically or horizontally in units of 1. The result would look something like this (as an example).
Given this problem, how would one go about identifying the 3 polygons that construct this image?
I understand that the large square in which the pieces lie is a polygon too, but I'm only interested in the 'base' polygons - not sure if that's the right way to call them.
Clarification: We only know the coordinates of the lines from inputting them, we don't know the polygons in advance.
The solution accordingly would be the polygons themselves (in pseudo-code):
pol[1] = c(0, 0),
c(1, 0),
c(1, 1),
c(2, 1),
c(2, 2),
c(1, 2),
c(1, 3),
c(0, 3),
c(0, 0)
pol[2] = c(1, 0),
c(3, 0),
c(3, 4),
c(0, 4),
c(0, 3),
c(1, 3),
c(1, 2),
c(2, 2),
c(2, 1),
c(1, 1),
c(1, 0)
pol[3] = c(3, 0),
c(4, 0),
c(4, 4),
c(3, 4),
c(3, 0)
r geometry coordinates
r geometry coordinates
edited Mar 24 at 1:54
Deuterium
asked Mar 24 at 0:59
DeuteriumDeuterium
4718
4718
Sorry. What exactly do you want? Do you want people to create an R object that describes the polygons?
– www
Mar 24 at 1:03
Looking more for direction regarding the methodology to do so. I wouldn't expect anyone to create an R code for this on my behalf.
– Deuterium
Mar 24 at 1:05
add a comment |
Sorry. What exactly do you want? Do you want people to create an R object that describes the polygons?
– www
Mar 24 at 1:03
Looking more for direction regarding the methodology to do so. I wouldn't expect anyone to create an R code for this on my behalf.
– Deuterium
Mar 24 at 1:05
Sorry. What exactly do you want? Do you want people to create an R object that describes the polygons?
– www
Mar 24 at 1:03
Sorry. What exactly do you want? Do you want people to create an R object that describes the polygons?
– www
Mar 24 at 1:03
Looking more for direction regarding the methodology to do so. I wouldn't expect anyone to create an R code for this on my behalf.
– Deuterium
Mar 24 at 1:05
Looking more for direction regarding the methodology to do so. I wouldn't expect anyone to create an R code for this on my behalf.
– Deuterium
Mar 24 at 1:05
add a comment |
1 Answer
1
active
oldest
votes
Here is an approach to create the spatial object in R. pol_sf
is the final output, which is an sf
object. This approach needs the sf
package. The tidyverse
package is not required but work well on the sf
object.
library(tidyverse)
library(sf)
# Polygon 1
pol1 <- st_polygon(list(rbind(c(0, 0),
c(1, 0),
c(1, 1),
c(2, 1),
c(2, 2),
c(1, 2),
c(1, 3),
c(0, 3),
c(0, 0))))
# Polygon 2
pol2 <- st_polygon(list(rbind(c(1, 0),
c(3, 0),
c(3, 4),
c(0, 4),
c(0, 3),
c(1, 3),
c(1, 2),
c(2, 2),
c(2, 1),
c(1, 1),
c(1, 0))))
# Polygon 3
pol3 <- st_polygon(list(rbind(c(3, 0),
c(4, 0),
c(4, 4),
c(3, 4),
c(3, 0))))
# Combine pol1, pol2, and pol3
pol_sfc <- st_as_sfc(list(pol1, pol2, pol3))
# Create an sf object
pol_sf <- tibble(ID = c("a", "b", "c")) %>%
mutate(geometry = pol_sfc) %>%
st_as_sf()
# Plot the data
ggplot(pol_sf) + geom_sf(aes(fill = ID))
Hey www, I feel bad because my original question might not have been clear. The problem is that although we know all the coordinates, we don't know the polygons in advance. The problem is less about showing the polygons in a graph and more about an algorithm that can tell these polygons apart just from coordinates (and then maybe plot them similarly to how you have done it as the cherry on top).
– Deuterium
Mar 24 at 1:42
Not clear what do you want. Good luck.
– www
Mar 24 at 1:44
It's cool. Thanks for the attempt.
– Deuterium
Mar 24 at 1:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319813%2fgiven-a-set-of-simple-graph-coordinates-inside-a-square-how-to-identify-all-bas%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is an approach to create the spatial object in R. pol_sf
is the final output, which is an sf
object. This approach needs the sf
package. The tidyverse
package is not required but work well on the sf
object.
library(tidyverse)
library(sf)
# Polygon 1
pol1 <- st_polygon(list(rbind(c(0, 0),
c(1, 0),
c(1, 1),
c(2, 1),
c(2, 2),
c(1, 2),
c(1, 3),
c(0, 3),
c(0, 0))))
# Polygon 2
pol2 <- st_polygon(list(rbind(c(1, 0),
c(3, 0),
c(3, 4),
c(0, 4),
c(0, 3),
c(1, 3),
c(1, 2),
c(2, 2),
c(2, 1),
c(1, 1),
c(1, 0))))
# Polygon 3
pol3 <- st_polygon(list(rbind(c(3, 0),
c(4, 0),
c(4, 4),
c(3, 4),
c(3, 0))))
# Combine pol1, pol2, and pol3
pol_sfc <- st_as_sfc(list(pol1, pol2, pol3))
# Create an sf object
pol_sf <- tibble(ID = c("a", "b", "c")) %>%
mutate(geometry = pol_sfc) %>%
st_as_sf()
# Plot the data
ggplot(pol_sf) + geom_sf(aes(fill = ID))
Hey www, I feel bad because my original question might not have been clear. The problem is that although we know all the coordinates, we don't know the polygons in advance. The problem is less about showing the polygons in a graph and more about an algorithm that can tell these polygons apart just from coordinates (and then maybe plot them similarly to how you have done it as the cherry on top).
– Deuterium
Mar 24 at 1:42
Not clear what do you want. Good luck.
– www
Mar 24 at 1:44
It's cool. Thanks for the attempt.
– Deuterium
Mar 24 at 1:56
add a comment |
Here is an approach to create the spatial object in R. pol_sf
is the final output, which is an sf
object. This approach needs the sf
package. The tidyverse
package is not required but work well on the sf
object.
library(tidyverse)
library(sf)
# Polygon 1
pol1 <- st_polygon(list(rbind(c(0, 0),
c(1, 0),
c(1, 1),
c(2, 1),
c(2, 2),
c(1, 2),
c(1, 3),
c(0, 3),
c(0, 0))))
# Polygon 2
pol2 <- st_polygon(list(rbind(c(1, 0),
c(3, 0),
c(3, 4),
c(0, 4),
c(0, 3),
c(1, 3),
c(1, 2),
c(2, 2),
c(2, 1),
c(1, 1),
c(1, 0))))
# Polygon 3
pol3 <- st_polygon(list(rbind(c(3, 0),
c(4, 0),
c(4, 4),
c(3, 4),
c(3, 0))))
# Combine pol1, pol2, and pol3
pol_sfc <- st_as_sfc(list(pol1, pol2, pol3))
# Create an sf object
pol_sf <- tibble(ID = c("a", "b", "c")) %>%
mutate(geometry = pol_sfc) %>%
st_as_sf()
# Plot the data
ggplot(pol_sf) + geom_sf(aes(fill = ID))
Hey www, I feel bad because my original question might not have been clear. The problem is that although we know all the coordinates, we don't know the polygons in advance. The problem is less about showing the polygons in a graph and more about an algorithm that can tell these polygons apart just from coordinates (and then maybe plot them similarly to how you have done it as the cherry on top).
– Deuterium
Mar 24 at 1:42
Not clear what do you want. Good luck.
– www
Mar 24 at 1:44
It's cool. Thanks for the attempt.
– Deuterium
Mar 24 at 1:56
add a comment |
Here is an approach to create the spatial object in R. pol_sf
is the final output, which is an sf
object. This approach needs the sf
package. The tidyverse
package is not required but work well on the sf
object.
library(tidyverse)
library(sf)
# Polygon 1
pol1 <- st_polygon(list(rbind(c(0, 0),
c(1, 0),
c(1, 1),
c(2, 1),
c(2, 2),
c(1, 2),
c(1, 3),
c(0, 3),
c(0, 0))))
# Polygon 2
pol2 <- st_polygon(list(rbind(c(1, 0),
c(3, 0),
c(3, 4),
c(0, 4),
c(0, 3),
c(1, 3),
c(1, 2),
c(2, 2),
c(2, 1),
c(1, 1),
c(1, 0))))
# Polygon 3
pol3 <- st_polygon(list(rbind(c(3, 0),
c(4, 0),
c(4, 4),
c(3, 4),
c(3, 0))))
# Combine pol1, pol2, and pol3
pol_sfc <- st_as_sfc(list(pol1, pol2, pol3))
# Create an sf object
pol_sf <- tibble(ID = c("a", "b", "c")) %>%
mutate(geometry = pol_sfc) %>%
st_as_sf()
# Plot the data
ggplot(pol_sf) + geom_sf(aes(fill = ID))
Here is an approach to create the spatial object in R. pol_sf
is the final output, which is an sf
object. This approach needs the sf
package. The tidyverse
package is not required but work well on the sf
object.
library(tidyverse)
library(sf)
# Polygon 1
pol1 <- st_polygon(list(rbind(c(0, 0),
c(1, 0),
c(1, 1),
c(2, 1),
c(2, 2),
c(1, 2),
c(1, 3),
c(0, 3),
c(0, 0))))
# Polygon 2
pol2 <- st_polygon(list(rbind(c(1, 0),
c(3, 0),
c(3, 4),
c(0, 4),
c(0, 3),
c(1, 3),
c(1, 2),
c(2, 2),
c(2, 1),
c(1, 1),
c(1, 0))))
# Polygon 3
pol3 <- st_polygon(list(rbind(c(3, 0),
c(4, 0),
c(4, 4),
c(3, 4),
c(3, 0))))
# Combine pol1, pol2, and pol3
pol_sfc <- st_as_sfc(list(pol1, pol2, pol3))
# Create an sf object
pol_sf <- tibble(ID = c("a", "b", "c")) %>%
mutate(geometry = pol_sfc) %>%
st_as_sf()
# Plot the data
ggplot(pol_sf) + geom_sf(aes(fill = ID))
answered Mar 24 at 1:20
wwwwww
29.1k112345
29.1k112345
Hey www, I feel bad because my original question might not have been clear. The problem is that although we know all the coordinates, we don't know the polygons in advance. The problem is less about showing the polygons in a graph and more about an algorithm that can tell these polygons apart just from coordinates (and then maybe plot them similarly to how you have done it as the cherry on top).
– Deuterium
Mar 24 at 1:42
Not clear what do you want. Good luck.
– www
Mar 24 at 1:44
It's cool. Thanks for the attempt.
– Deuterium
Mar 24 at 1:56
add a comment |
Hey www, I feel bad because my original question might not have been clear. The problem is that although we know all the coordinates, we don't know the polygons in advance. The problem is less about showing the polygons in a graph and more about an algorithm that can tell these polygons apart just from coordinates (and then maybe plot them similarly to how you have done it as the cherry on top).
– Deuterium
Mar 24 at 1:42
Not clear what do you want. Good luck.
– www
Mar 24 at 1:44
It's cool. Thanks for the attempt.
– Deuterium
Mar 24 at 1:56
Hey www, I feel bad because my original question might not have been clear. The problem is that although we know all the coordinates, we don't know the polygons in advance. The problem is less about showing the polygons in a graph and more about an algorithm that can tell these polygons apart just from coordinates (and then maybe plot them similarly to how you have done it as the cherry on top).
– Deuterium
Mar 24 at 1:42
Hey www, I feel bad because my original question might not have been clear. The problem is that although we know all the coordinates, we don't know the polygons in advance. The problem is less about showing the polygons in a graph and more about an algorithm that can tell these polygons apart just from coordinates (and then maybe plot them similarly to how you have done it as the cherry on top).
– Deuterium
Mar 24 at 1:42
Not clear what do you want. Good luck.
– www
Mar 24 at 1:44
Not clear what do you want. Good luck.
– www
Mar 24 at 1:44
It's cool. Thanks for the attempt.
– Deuterium
Mar 24 at 1:56
It's cool. Thanks for the attempt.
– Deuterium
Mar 24 at 1:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319813%2fgiven-a-set-of-simple-graph-coordinates-inside-a-square-how-to-identify-all-bas%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
h6pMS,RM mGT77nPRcswTCW fKHbDKL,t4nl8E5 xt
Sorry. What exactly do you want? Do you want people to create an R object that describes the polygons?
– www
Mar 24 at 1:03
Looking more for direction regarding the methodology to do so. I wouldn't expect anyone to create an R code for this on my behalf.
– Deuterium
Mar 24 at 1:05