Skip to content

Commit

Permalink
cartopy additions
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldorman committed Aug 11, 2023
1 parent db45d6e commit 7ae6189
Show file tree
Hide file tree
Showing 7 changed files with 1,457 additions and 1,730 deletions.
1,443 changes: 1,443 additions & 0 deletions 08-read-write-plot.ipynb

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion 08-read-write-plot.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ These provide interfaces to one or more spatial libraries or geoportals and aim

Each data package has its own syntax for accessing data.
This diversity is demonstrated in the subsequent code chunks, which show how to get data using three packages from @tbl-data-packages.
Country borders are often useful and these can be accessed with the ne_countries() function from the rnaturalearth package as follows:
Country borders are often useful and these can be accessed with the `cartopy.io.shapereader.natural_earth` function from the `cartopy` package, as follows.

```{python}
import cartopy
Expand All @@ -127,10 +127,23 @@ counties = gpd.read_file(filename)
counties
```

The layer of counties is plotted in @fig-ne-counties:

```{python}
#| label: fig-ne-counties
#| fig-cap: US counties, downloaded from the Natural Earth Data website using package `cartopy`
counties.plot();
```

Other layers can be accessed the same way:

* you need to locate the `resolution`, `category`, and `name` of the requested dataset, then
* run the `cartopy.io.shapereader.natural_earth`, which downloads the file(s) and returns the path, and
* read the file into the Python environment, e.g., using `gpd.read_file`

This is an alternative approach to "directly" downloading files (@sec-retrieving-open-data).

## Geographic web services

To complete...
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,729 changes: 0 additions & 1,729 deletions output/plot_rasterio2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/world.gpkg
Binary file not shown.
Binary file modified output/world_many_features.gpkg
Binary file not shown.
Binary file modified output/world_many_layers.gpkg
Binary file not shown.

0 comments on commit 7ae6189

Please sign in to comment.