[R-sig-Geo] How to extract values in an sf Points object

Richard Careaga public @ending from c@re@g@@net
Mon Nov 12 05:14:12 CET 2018


I have a a **tibble** containing objects of class **sfc_POINT** such as

    # A tibble: 1 x 1
              geometry
    *          <POINT [°]>
    1 (-86.82857 32.78871)

where, of course, the two dbl represent longitude and latitude that I wish
to combine to another data frame for plotting as the centroids of
geographic units that can be (1) adjusted manually for position (it's a
more or less permanent basemap, so I only have to do this once) and (2)
optionally located on a thematic map, in my case, the US. (I apologize for
our current political situation.)

Although I can do this by subsetting

    str(foo[[1]][2])
    num 32.8

to get the latitude of a point (which, blessedly is only displayed, not
truncated to one decimal) and by making the second subindex [[1]] for
latitude, what I want is to do this at a pass for a tibble column of 50.

This is possible, of course, with some fancy footwork and, if I had to do
it 50 times, I would. Before that, however, I'd like to be sure I haven't
missed a recipe.

My plan is to use this with the **usmap** package to create a standardized,
projected base map on which to create thematic maps. The package returns a
*ggplot* friendly object of a converted shapefile of US states and
optionally counties and subsets of states. **And** it insets Alaska and
Hawaii and discards  the farflung territories. Since the boundaries (for
now) of the states are stable, once created, it can be saved as an Rda
object along with its centroid data and dyplr::inner_joint on the state
fips.

Again, the object is to decompose a POINT object -- (-86.82857 32.78871)
into a list c(-86.82857, 32.78871) or some other structure amenable to
tidyverse treatment.

Thanks in advance.

Richard Careaga
Unaffiliated (so much more a gracious term than permanently unemployable)
@technocrat
https://technocrat.rbind.io

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list