diff --git a/doc/source/_example_data/naturalearth_cities.README.html b/doc/source/_example_data/naturalearth_cities.README.html new file mode 100644 index 0000000..2f5786f --- /dev/null +++ b/doc/source/_example_data/naturalearth_cities.README.html @@ -0,0 +1,336 @@ + + + + + + + + +Populated Places | Natural Earth + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+
+ + + « 1:10m Cultural Vectors  +
+

Populated Places

+
+
+
pop_thumb
+
City and town points, from Tokyo to Wasilla, Cairo to Kandahar + +
+
+
+

About

+

Point symbols with name attributes. Includes all admin-0 and many admin-1 capitals, major cities and towns, plus a sampling of smaller towns in sparsely inhabited regions. We favor regional significance over population census in determining our selection of places. Use the scale rankings to filter the number of towns that appear on your map.

+

pop_banner

+

LandScan derived population estimates are provided for 90% of our cities. Those lacking population estimates are often in sparsely inhabited areas. We provide a range of population values that account for the total “metropolitan” population rather than it’s administrative boundary population. Use the PopMax column to size your town labels. Starting in version 1.1, popMax has been throttled down to the UN estimated metro population for the ~500 largest urban areas in the world. This affects towns in China, India, and parts of Africa where our Landscan counting method usually over estimated.

+

Population estimates were derived from the LANDSCAN dataset maintained and distributed by the Oak Ridge National Laboratory. These data were converted from raster to vector and pixels with fewer than 200 persons per square kilometer were removed from the dataset as they were classified as rural. Once urban pixels were selected, these pixels were aggregated into contiguous units. Concurrently Thiessen polygons were created based on the selected city points. The Thiessen polygons were used to intersect the contiguous city boundaries to produce bounded areas for the cities. As a result, our estimates capture a metropolitan and micropolitan populations per city regardless of administrative units.

+

Once intersected, the contiguous polygons were recalculated, using aerial interpolation assuming uniform population distribution within each pixel, to determine the population total. This process was conducted multiple times, for each scale level, to produce population estimates for each city at nested scales of 1:300 million, 1:110 million, 1:50 million, 1:20 million, and 1:10 million.

+ +

Population ranks

+

Are calculated as rank_max and rank_min using this general VB formula that can be pasted into ArcMap Field Calculator advanced area (set your output to x):

+

+a = [pop_max]

+

if( a > 10000000 ) then +x = 14 +elseif( a > 5000000 ) then +x = 13 +elseif( a > 1000000 ) then +x = 12 +elseif( a > 500000 ) then +x = 11 +elseif( a > 200000 ) then +x = 10 +elseif( a > 100000 ) then +x = 9 +elseif( a > 50000 ) then +x = 8 +elseif( a > 20000 ) then +x = 7 +elseif( a > 10000 ) then +x = 6 +elseif( a > 5000 ) then +x = 5 +elseif( a > 2000 ) then +x = 4 +elseif( a > 1000 ) then +x = 3 +elseif( a > 200 ) then +x = 2 +elseif( a > 0 ) then +x = 1 +else +x = 0 +end if

+

Issues

+

While we don’t want to show every admin-1 capital, for those countries where we show most admin-1 capitals, we should have a complete set. If you find we are missing one, please log it in the Cx tool at right.

+

Version History

+
    +
  • + 2.0.0 +
  • +
  • + 1.4.0 +
  • +
  • + 1.3.0 +
  • +
  • + 1.1.0 +
  • +
  • + 0.9.0 +
  • +
+ +

The master changelog is available on Github ยป +

+ +
+
+Share and Enjoy: +
+
    +
  • Twitter
  • +
  • Facebook
  • +
  • Digg
  • +
  • del.icio.us
  • +
  • Google Bookmarks
  • +
  • Slashdot
  • +
  • StumbleUpon
  • +
  • email
  • +
  • LinkedIn
  • +
  • Reddit
  • +
+
+ + +
+ +
+ + +
+ + + + +
+ +
+ + + + + + + + + + + \ No newline at end of file diff --git a/doc/source/_example_data/naturalearth_cities.VERSION.txt b/doc/source/_example_data/naturalearth_cities.VERSION.txt new file mode 100644 index 0000000..359a5b9 --- /dev/null +++ b/doc/source/_example_data/naturalearth_cities.VERSION.txt @@ -0,0 +1 @@ +2.0.0 \ No newline at end of file diff --git a/doc/source/_example_data/naturalearth_cities.cpg b/doc/source/_example_data/naturalearth_cities.cpg new file mode 100644 index 0000000..cd89cb9 --- /dev/null +++ b/doc/source/_example_data/naturalearth_cities.cpg @@ -0,0 +1 @@ +ISO-8859-1 \ No newline at end of file diff --git a/doc/source/_example_data/naturalearth_cities.dbf b/doc/source/_example_data/naturalearth_cities.dbf new file mode 100644 index 0000000..d9b9726 Binary files /dev/null and b/doc/source/_example_data/naturalearth_cities.dbf differ diff --git a/doc/source/_example_data/naturalearth_cities.prj b/doc/source/_example_data/naturalearth_cities.prj new file mode 100644 index 0000000..a30c00a --- /dev/null +++ b/doc/source/_example_data/naturalearth_cities.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/doc/source/_example_data/naturalearth_cities.shp b/doc/source/_example_data/naturalearth_cities.shp new file mode 100644 index 0000000..d180259 Binary files /dev/null and b/doc/source/_example_data/naturalearth_cities.shp differ diff --git a/doc/source/_example_data/naturalearth_cities.shx b/doc/source/_example_data/naturalearth_cities.shx new file mode 100644 index 0000000..e7eca86 Binary files /dev/null and b/doc/source/_example_data/naturalearth_cities.shx differ diff --git a/doc/source/mapping.rst b/doc/source/mapping.rst index 435b29d..2ce1cb6 100644 --- a/doc/source/mapping.rst +++ b/doc/source/mapping.rst @@ -5,20 +5,18 @@ import geopandas as gpd world = gpd.GeoDataFrame().from_file('_example_data/naturalearth_lowres.shp') + cities = gpd.GeoDataFrame().from_file('_example_data/naturalearth_cities.shp') Mapping Tools ========================================= -mapping! - -Chloropleth Maps ------------------ +*geopandas* provides a high-level interface to the ``matplotlib`` library for making maps. Mapping shapes is as easy as using the ``plot()`` method on a ``GeoSeries`` or ``GeoDataFrame``. .. ipython:: python - + # Examine country GeoDataFrame world.head() @@ -26,11 +24,92 @@ Chloropleth Maps @savefig world_randomcolors.png width=5in world.plot(); +Note that in general, any options one can pass to `pyplot `_ in ``matplotlib`` (or `style options that work for lines `_) can be passed to the ``plot()`` method. + + +Chloropleth Maps +----------------- + +*geopandas* makes it easy to create Chloropleth maps (maps where the color of each shape is based on the value of an associated variable). Simply use the plot command with the ``column`` argument set to the column whose values you want used to assign colors. + +.. ipython:: python + # Plot by GDP per capta + world = world[(world.pop_est>0) & (world.name!="Antarctica")] world['gdp_per_cap'] = world.gdp_md_est / world.pop_est @savefig world_gdp_per_cap.png width=5in world.plot(column='gdp_per_cap'); -Adding Basemaps +Choosing colors +~~~~~~~~~~~~~~~~ + +One can also modify the colors used by ``plot`` with the ``cmap`` option (for a full list of colormaps, see the `matplotlib website `_): + +.. ipython:: python + + @savefig world_gdp_per_cap_red.png width=5in + world.plot(column='gdp_per_cap', cmap='OrRd'); + + +The way color maps are scaled can also be manipulated with the ``scheme`` option (if you have ``pysal`` installed, which can be accomplished via ``conda install pysal``). By default, ``scheme`` is set to 'equal_intervals', but it can also be adjusted to any other `pysal option `_, like 'quantiles', 'percentiles', etc. + +.. ipython:: python + + @savefig world_gdp_per_cap_quantiles.png width=5in + world.plot(column='gdp_per_cap', cmap='OrRd', scheme='quantiles'); + + +Maps with Layers ----------------- + +There are two strategies for making a map with multiple layers -- one more succinct, and one that is a littel more flexible. + +Before combining maps, however, remember to always ensure they share a common CRS (so they will align). + +.. ipython:: python + + # Look at capitals + # Note use of standard `pyplot` line style options + @savefig capitals.png width=5in + cities.plot(marker='*', color='green', markersize=5); + + # Check crs + cities = cities.to_crs(world.crs) + + # Now we can overlay over country outlines + # And yes, there are lots of island capitals + # apparently in the middle of the ocean! + +**Method 1** + +.. ipython:: python + + base = world.plot(color='white') + @savefig capitals_over_countries_1.png width=5in + cities.plot(ax=base, marker='o', color='red', markersize=5); + +**Method 2: Using matplotlib objects** + +.. ipython:: python + + import matplotlib.pyplot as plt + fig, ax = plt.subplots() + + # set aspect to equal. This is done automatically + # when using *geopandas* plot on it's own, but not when + # working with pyplot directly. + ax.set_aspect('equal') + + world.plot(ax=ax, color='white') + cities.plot(ax=ax, marker='o', color='red', markersize=5) + @savefig capitals_over_countries_2.png width=5in + plt.show(); + + +Other Resources +----------------- +Links to jupyter Notebooks for different mapping tasks: + +`Making Heat Maps `_ +