[R-sig-Geo] extract lat-long pairs from sf::st_read MULTIPOLYGON format

Brandon Payne payneb at post.bgu.ac.il
Sat May 6 22:56:52 CEST 2017


## I am trying to modify the

install_github("choroplethrAdmin1", "arilamstein")

package.  It can show a map by

choroplethrAdmin1::admin1_map("israel")

The shape data is hidden in .Rdata, (principle of encapsulation)
so to get at it I had to

```{bash}
git clone git at github.com:arilamstein/choroplethrAdmin1.git
cd chor*
```
```{r}
load("/Users/AbuDavid/scratch/R/choroplethrAdmin1/data/admin1.regions.rdata")
ilmap<-admin1.map[which(admin1.map$admin == name), ]
View(ilmap)
#write.csv(ilmap, file = "israel.csv", row.names=FALSE)

```

the format of this data looks like

35.13070357	32.70585928	israel	haifa district	1879.1	272218	FALSE	1	1879
35.12837813	32.70314627	israel	haifa district	1879.1	272219	FALSE	1	1879
35.12574263	32.7008725	israel	haifa district	1879.1	272220	FALSE	1	1879
35.12419234	32.69989065	israel	haifa district	1879.1	272221	FALSE	1	1879
35.12248701	32.69919302	israel	haifa district	1879.1	272222	FALSE	1	1879
35.12078169	32.69911551	israel	haifa district	1879.1	272223	FALSE	1	1879
35.02130456	32.38117626	israel	central district	1880.1	272295	FALSE	1	1880
35.0327303	32.38220026	israel	central district	1880.1	272296	FALSE	1	1880
35.02879684	32.36515737	israel	central district	1880.1	272297	FALSE	1	1880
35.02156213	32.34459015	israel	central district	1880.1	272298	FALSE	1	1880
35.01784143	32.34221303	israel	central district	1880.1	272299	FALSE
1	1880

## Question:

How can I get the data from my shape file as 2 columns: c(lat, long) ?

I don't mind using something other than sf:st_read.

```{r importshapes}
editedmap <- sf::st_read("../includes/ISR_adm_edited/ISR_adm1.shp")
golan <- editedmap[which(editedmap$NAME_1 == "Golan"), ]
names(editedmap)
```

> names(editedmap)
 [1] "ID_0"      "ISO"       "NAME_0"    "ID_1"      "NAME_1"    "TYPE_1"   

 [7] "ENGTYPE_1" "NL_NAME_1" "VARNAME_1" "geometry"



More information about the R-sig-Geo mailing list