Skip to content

Commit

Permalink
Prepare articles
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Jan 12, 2024
1 parent bc199d1 commit 4f068ba
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 81 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Suggests:
tidygeocoder
VignetteBuilder:
knitr
Config/Needs/website: dieghernan/gitdevr,ggplot2,sf, lwgeom,leaflet
Config/Needs/website:
dieghernan/gitdevr,ggplot2,sf,lwgeom,leaflet,terra,tidyterra,maptiles
Config/testthat/edition: 3
Config/testthat/parallel: true
Encoding: UTF-8
Expand Down
6 changes: 6 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ ggplot(food_eiffel_sf) +
coord_sf(crs = 3035)
```

See additional articles showing how **arcgeocoder** can be use in combination
with **leaflet** to create [dynamic
maps](https://dieghernan.github.io/arcgeocoder/articles/ex_leaflet.html) and
with **sf** and **terra** to create [static
maps](https://dieghernan.github.io/arcgeocoder/articles/ex_static.html).

## Citation

```{r echo=FALSE, results='asis'}
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ ggplot(food_eiffel_sf) +

<img src="man/figures/README-eiffel_sf-1.png" width="100%" />

See additional articles showing how **arcgeocoder** can be use in
combination with **leaflet** to create [dynamic
maps](https://dieghernan.github.io/arcgeocoder/articles/ex_leaflet.html)
and with **sf** and **terra** to create [static
maps](https://dieghernan.github.io/arcgeocoder/articles/ex_static.html).

## Citation

<p>
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
},
"applicationCategory": "cartography",
"keywords": ["r", "geocoding", "arcgis", "address", "reverse-geocoding", "rstats", "r-package", "api-wrapper", "api-rest", "arcgis-api", "gis"],
"fileSize": "392.368KB",
"fileSize": "342.403KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down
51 changes: 5 additions & 46 deletions vignettes/arcgeocoder.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -193,51 +193,10 @@ ggplot(eiffel_tower, aes(x, y)) +

### **arcgeocoder** and **r-spatial**

It is straightforward to convert the results of **arcgeocoder** to an **sf**
object (geospatial format):


```r
library(sf)

food_eiffel_sf <- st_as_sf(food_eiffel,
coords = c("lon", "lat"),
# The CRS of the resulting coords is here
crs = eiffel_tower$wkid
)

food_eiffel_sf
#> Simple feature collection with 50 features and 75 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: 2.29211 ymin: 48.85416 xmax: 2.30085 ymax: 48.86252
#> Geodetic CRS: WGS 84
#> # A tibble: 50 × 76
#> q_category q_x q_y q_bbox_xmin q_bbox_ymin q_bbox_xmax q_bbox_ymax address score x y
#> * <chr> <dbl> <dbl> <lgl> <lgl> <lgl> <lgl> <chr> <int> <dbl> <dbl>
#> 1 Food 2.29 48.9 NA NA NA NA Le Jules Ver… 100 2.30 48.9
#> 2 Food 2.29 48.9 NA NA NA NA 58 Tour Eiff… 100 2.29 48.9
#> 3 Food 2.29 48.9 NA NA NA NA Le Bailli de… 100 2.29 48.9
#> 4 Food 2.29 48.9 NA NA NA NA Le Bailli de… 100 2.29 48.9
#> 5 Food 2.29 48.9 NA NA NA NA Castel Café 100 2.29 48.9
#> 6 Food 2.29 48.9 NA NA NA NA Le Castel Ca… 100 2.29 48.9
#> 7 Food 2.29 48.9 NA NA NA NA Ribe 100 2.29 48.9
#> 8 Food 2.29 48.9 NA NA NA NA Chez Ribe 100 2.29 48.9
#> 9 Food 2.29 48.9 NA NA NA NA Bistrot de L… 100 2.30 48.9
#> 10 Food 2.29 48.9 NA NA NA NA Bistrot de L… 100 2.30 48.9
#> # ℹ 40 more rows
#> # ℹ 65 more variables: Loc_name <chr>, Status <chr>, Score <int>, Match_addr <chr>, LongLabel <chr>,
#> # ShortLabel <chr>, Addr_type <chr>, Type <chr>, PlaceName <chr>, Place_addr <chr>, Phone <chr>,
#> # URL <chr>, Rank <int>, AddBldg <chr>, AddNum <chr>, AddNumFrom <chr>, AddNumTo <chr>,
#> # AddRange <chr>, Side <chr>, StPreDir <chr>, StPreType <chr>, StName <chr>, StType <chr>,
#> # StDir <chr>, BldgType <chr>, BldgName <chr>, LevelType <chr>, LevelName <chr>, UnitType <chr>,
#> # UnitName <chr>, SubAddr <chr>, StAddr <chr>, Block <chr>, Sector <chr>, Nbrhd <chr>, …

ggplot(food_eiffel_sf) +
geom_sf(aes(color = Type)) +
coord_sf(crs = 3035)
```

![Example: Converting points to sf objects](./eiffel_sf-1.png)
See additional articles showing how **arcgeocoder** can be use in combination
with **leaflet** to create [dynamic
maps](https://dieghernan.github.io/arcgeocoder/articles/ex_leaflet.html) and
with **sf** and **terra** to create [static
maps](https://dieghernan.github.io/arcgeocoder/articles/ex_static.html).

## References
Expand Down
23 changes: 5 additions & 18 deletions vignettes/arcgeocoder.Rmd.orig
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,10 @@ ggplot(eiffel_tower, aes(x, y)) +

### **arcgeocoder** and **r-spatial**

It is straightforward to convert the results of **arcgeocoder** to an **sf**
object (geospatial format):

```{r eiffel_sf, fig.cap="Example: Converting points to sf objects"}
library(sf)

food_eiffel_sf <- st_as_sf(food_eiffel,
coords = c("lon", "lat"),
# The CRS of the resulting coords is here
crs = eiffel_tower$wkid
)

food_eiffel_sf

ggplot(food_eiffel_sf) +
geom_sf(aes(color = Type)) +
coord_sf(crs = 3035)
```
See additional articles showing how **arcgeocoder** can be use in combination
with **leaflet** to create [dynamic
maps](https://dieghernan.github.io/arcgeocoder/articles/ex_leaflet.html) and
with **sf** and **terra** to create [static
maps](https://dieghernan.github.io/arcgeocoder/articles/ex_static.html).

## References
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Example: arcgeocoder and leaflet maps"
subtitle: "Minimal example showing how to combine arcgeocoder and leaflet maps"
subtitle: "Combine arcgeocoder and leaflet maps"
resource_files:
- vignettes/articles/eiffel-tower.png
- vignettes/articles/eiffel-coffee-cup.png
Expand Down Expand Up @@ -37,14 +37,22 @@ eiffel_tower <- arc_geo_multi("Eiffel Tower",
city = "Paris", countrycode = "FR",
category = "POI"
)
eiffel_icon <- makeIcon("eiffel-tower.png",
iconWidth = 50, iconHeight = 50,
iconAnchorX = 25, iconAnchorY = 25)
eiffel_icon <- makeIcon(
iconUrl = "https://dieghernan.github.io/arcgeocoder/articles/eiffel-tower.png",
iconWidth = 50, iconHeight = 50,
iconAnchorX = 25, iconAnchorY = 25
)
# Leaflet map
lm <- leaflet(elementId = "EiffelTower", width = "100%", height = "60vh",
options = leafletOptions(minZoom = 14)) %>%
addProviderTiles(provider = "CartoDB.Positron") %>%
lm <- leaflet(
elementId = "EiffelTower", width = "100%", height = "60vh",
options = leafletOptions(minZoom = 12)
) %>%
addProviderTiles(
provider = "CartoDB.Positron",
group = "CartoDB.Positron"
) %>%
addTiles(group = "OSM") %>%
addMarkers(data = eiffel_tower, ~lon, ~lat, icon = eiffel_icon)
Expand All @@ -57,12 +65,17 @@ cf <- arc_geo_categories("Coffee Shop",
# Label for PopUp
cf$labelpop <- paste0("<strong>", cf$PlaceName, "</strong><br>", cf$StAddr)
coffee_icon <- makeIcon("coffee-cup.png",
iconWidth = 20, iconHeight = 20,
iconAnchorX = 10, iconAnchorY = 10)
coffee_icon <- makeIcon(
iconUrl = "https://dieghernan.github.io/arcgeocoder/articles/coffee-cup.png",
iconWidth = 20, iconHeight = 20,
iconAnchorX = 10, iconAnchorY = 10
)
lm <- lm %>%
addMarkers(data = cf, ~lon, ~lat, popup = ~labelpop, icon = coffee_icon)
addMarkers(
data = cf, ~lon, ~lat, popup = ~labelpop, icon = coffee_icon,
group = "Coffee Shops"
)
# Step 3: Bakeries nearby
bk <- arc_geo_categories("Bakery",
Expand All @@ -73,12 +86,27 @@ bk <- arc_geo_categories("Bakery",
# Label for PopUp
bk$labelpop <- paste0("<strong>", bk$PlaceName, "</strong><br>", bk$StAddr)
bk_icon <- makeIcon("croissant.png",
iconWidth = 20, iconHeight = 20,
iconAnchorX = 10, iconAnchorY = 10)
bk_icon <- makeIcon(
iconUrl = "https://dieghernan.github.io/arcgeocoder/articles/croissant.png",
iconWidth = 20, iconHeight = 20,
iconAnchorX = 10, iconAnchorY = 10
)
lm <- lm %>%
addMarkers(
data = bk, ~lon, ~lat, popup = ~labelpop, icon = bk_icon,
group = "Bakeries"
)
# Add layer control
lm <- lm %>%
addMarkers(data = bk, ~lon, ~lat, popup = ~labelpop, icon = bk_icon)
addLayersControl(
baseGroups = c("CartoDB.Positron", "OSM"),
overlayGroups = c("Coffee Shops", "Bakeries"),
position = "topleft",
options = layersControlOptions(collapsed = FALSE)
)
lm
```
Expand Down
17 changes: 17 additions & 0 deletions vignettes/articles/ex_static.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: "Example: arcgeocoder and static maps"
subtitle: "Combine arcgeocoder with sf and terra"
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
warning = FALSE,
message = FALSE,
dpi = 300,
tidy = "styler",
dev = "ragg_png",
out.width = "100%"
)
```
Binary file modified vignettes/eiffel-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed vignettes/eiffel_sf-1.png
Binary file not shown.

0 comments on commit 4f068ba

Please sign in to comment.