Skip to content

Commit f6ed423

Browse files
committed
geodata fix
1 parent ebe2643 commit f6ed423

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

vignettes/make-geo-json.Rmd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ library(rmapshaper)
4848
Get India map data from gadm website, this command need network available, it will download the rds data to the current directory.
4949

5050
```{r}
51-
india_sp <- raster::getData('GADM', country = 'INDIA', level = 2)
51+
india_sp <- geodata::gadm(country = "INDIA", level = 2)
52+
53+
india_sp <- methods::as(india_sp, "Spatial")
5254
india_sp |>
5355
head() |>
5456
knitr::kable()
@@ -58,6 +60,7 @@ Note that you can then combine maps with `raster::union(map1, map2)` or with the
5860

5961
```{r}
6062
india_json <- geojsonio::geojson_list(india_sp)
63+
6164
print(object.size(india_json), units = "Mb")
6265
```
6366

@@ -69,7 +72,7 @@ india_json_small <- geojsonio::geojson_list(india_small)
6972
print(object.size(india_json_small), units = "Mb")
7073
```
7174

72-
The function `raster::getData` gives each polygon a `NAME_*` property (where `*` is the `level` specified) rather than just `name`. The tooltip will not display properly unless we use the `nameMap` to point to that property, by default echarts expects the `name` property.
75+
The function `geodata::gadm` gives each polygon a `NAME_*` property (where `*` is the `level` specified) rather than just `name`. The tooltip will not display properly unless we use the `nameMap` to point to that property, by default echarts expects the `name` property.
7376

7477
Now we can use the `GeoJSON` with `e_map_register`.
7578

0 commit comments

Comments
 (0)