Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions area_weights.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@
"cell_type": "code",
"collapsed": false,
"input": [
"shp_file = shpreader.natural_earth(resolution='110m',\n",
"filename = shpreader.natural_earth(resolution='110m',\n",
" category='cultural',\n",
" name='admin_0_countries')\n",
"borders = shpreader.Reader(shp_file)\n",
"borders = shpreader.Reader(filename)\n",
"uk_geom, = [g for g in borders.records() if g.attributes['name_long']=='United Kingdom']"
],
"language": "python",
Expand All @@ -147,11 +147,11 @@
"source": [
"Here the shapefile is specified and read using the `cartopy.io.shapereader` module. The UK's geometry is determined by iterating over all the records in the shapefile, choosing the record where the attribute `name_long` matches 'United Kingdom'.\n",
"\n",
"This Natural Earth shapefile was chosen here for simplicity's sake, but any loaded shapefile should be able to be accessed using the methods demonstrated here. It is worth noting that all `shpreader.natural_earth()` above returns is a known filepath to the Cartopy default save location for the specific Natural Earth data requested.\n",
"This Natural Earth shapefile was chosen here for simplicity's sake, but any other shapefile can be accessed using the methods demonstrated here. It is worth noting that whilst `shpreader.natural_earth()` will download Natural Earth shapefiles as required, all it returns is a filepath to a shapefile.\n",
"\n",
"A very similar process should be able to be followed with any standard shapefile, as all shapefiles should be loaded with both `geometries()` and `records()` methods. The former returns a generator object of each geometry within the shapefile while the latter returns a generator object of each record within the shapefile.\n",
"\n",
"A record is made up of a geometry (one of the geometries from the geometries method) and an attributes dictionary. The keys within the attributes dictionary will change dependant on the shapefile loaded, but are simple to locate:"
"A record is made up of a geometry (one of the geometries from the geometries method) and an attributes dictionary. The keys within the attributes dictionary are dependant on the shapefile loaded, but are simple to locate:"
]
},
{
Expand All @@ -177,9 +177,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"These operations can be performed on any shapefile records instance.\n",
"These operations can be performed on any shapefile record.\n",
"\n",
"Note, however, that the keys within an attributes dictionary are subject to change, and that code that expects a certain key to appear within the attributes may fail if the key is changed unexpectedly."
"Note, however, that the keys within an attributes dictionary are dependent on the shapefile, and that code that expects a certain key to appear within the attributes may fail if a different shapefile is processed."
]
},
{
Expand Down Expand Up @@ -232,4 +232,4 @@
"metadata": {}
}
]
}
}