Print

Print


Eduardo,

I haven't used R for anything GIS so anyone with more knowledge is welcome to correct me, but I do work with GIS quite a bit.  You may look for a function that creates polygons (instead of points), where you use these coordinates as the vertices of your polygons.  I suggest this because in GIS points and polygons are two very different things.  You may also find that you can create polygons with extents, in which case you would use just the relevant half of your point coordinate to indicate your NESW extent.

Tricia Kyzar
Ph: 352-392-7260
Email: [log in to unmask]<mailto:[log in to unmask]>

From: UF R Users List <[log in to unmask]> On Behalf Of Schmitz Bongiolo,Eduardo
Sent: Wednesday, December 5, 2018 1:45 PM
To: [log in to unmask]
Subject: Convert points into a polygon sf


Dear R community,



I am creating a map using R (prod_mapv12_fruit.png), but now I cannot figure it out how to draw the squares of the zoom-in in the middle map.

I have the coordinates of the edges for the two polygons I want to draw but cannot make them into a square. When I plot them, it only plots four dots.



# attempt one importing the data using a CSV file. In this case, I could not find a predefined function to transform the points in a polygon.
zoom_square <- read.csv("zoom_square.csv")

zoom_square_1<- zoom_square %>%
  filter(square == "A") %>%
  select(X,Y)
zoom_square_2<- zoom_square %>%
  filter(square == "B") %>%
  select(X,Y)
plot(zoom_square_1)
plot(zoom_square_2)


# attempt two: this was a suggestion I find in the internet, but could not make it work.
zoom_square_1<- rbind(c(-10.821079,-68.403542),
                                            c(-10.862918,-68.367060),
                                            c(-10.821079,-68.367060),
                                            c(-10.862918,-68.403542))
zoom_square_1_pol <- st_polygon(list(zoom_square_1))



Once the points are converted to polygons I can add the Coordinates reference system and plot them into the map.



To summarize, I want help to convert these two sets of four points into two squares (polygons) that can be used with ggplot2::geom_sf().



Best regards,



Eduardo S. Bongiolo

Masters student

School of Forest Resources and Conservation

University of Florida
This list strives to be beginner friendly. However, we still ask that you PLEASE do read the posting guide http://www.R-project.org/posting-guide.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwMFAw&c=pZJPUDQ3SB9JplYbifm4nt2lEVG5pWx2KikqINpWlZM&r=qAn3Rfw8U3lg9nI7C8Nc4g&m=NVm3ylEDSO86sOxEIjUbE3C-xODR5vzyE-x0smMJ4Tg&s=OtYEOgyL0hewdFRUADqo7eAR8MIdfL0O_oepThcjgYU&e=> and provide commented, minimal, self-contained, reproducible code.

This list strives to be beginner friendly.  However, we still ask that you
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.