Commit f47af3f3 authored by Jon Pye's avatar Jon Pye
Browse files

Simplified the cartopy example.

parent b1fd7d73
# Installation requirements for Visualization demo:
# It is not necessary to install these to follow the demo on Tuesday. The presentation will not assume you are also going through the steps, and will show you the results of what's being entered/run. If you want to follow along on your own machine, though, these packages are the ones you'll need.
For working in a GUI - QGIS: It helps to do this install first, because for some OSes, it will automatically install requirements we'll need later for the Python install.
link: https://www.qgis.org/en/site/forusers/download.html
Mac users note - you will need to install the secondary packages from kyngchaos.com listed on this site.
Working in Python - CartoPy:
Python, cartopy, and owslib are needed. Below we will create a Python virtual environment to hold these things and all their prerequisites. I will try and be OS-agnostic in these instructions, apologies if they are incomplete for your distribution.
1) Getting Python:
link: https://www.python.org/download/releases/2.7/
Follow instructions for your OS/platform
Windows users may have to add python to their PATH variable
2) Installing the python package manager pip:
howto: https://pip.pypa.io/en/latest/installing.html
link: https://bootstrap.pypa.io/get-pip.py
run get-pip.py in your new python environment
#> python get-pip.py
3) Now we can install python packages on the command line through pip. In a command-line window (cmd or Terminal), type:
#> pip install virtualenv
4) Now make a virtual environment somewhere (in your home folder, perhaps):
#> cd place/to/put/my/python/virtualenvs
#> virtualenv carto-demo
And activate this virtual python environment
Windows:
#> Scripts/activate
Mac/Linux:
#> source carto-demo/bin/activate
5) Now we can use pip to install (most of) the rest of our requirements
pip will install prerequisites, so this is the most painless way to do things
#>pip install matplotlib
#>pip install owslib
#>pip install shapely
#>pip install pillow
#>pip install pyshp
#>pip install cython
#>pip install pyproj
5a)You may also need to install GDAL (to get PROJ and GEOS), follow these instructions
for Windows:
http://trac.osgeo.org/osgeo4w/
Mac users:
If you use Homebrew, you can install these libraries on the command line:
#>brew install geos
#>brew install gdal
#>brew install proj
or download KyngChaos' GDAL Complete Frameworks .dmg
http://www.kyngchaos.com/software/frameworks#gdal_complete
Alas, cartopy is not in pip's library, we'll have to install it manually
6)Install python module cartopy:
howto: http://scitools.org.uk/cartopy/docs/latest/installing.html#installing
link: https://github.com/SciTools/cartopy/archive/master.zip
#>unzip master.zip
cd cartopy-master
python setup.py install
7) Download the example from the GitLab repo:
https://utility.oceantrack.org/gitlab/jdpye/otn-python-visualization/repository/archive.zip
......@@ -61,7 +61,7 @@ print locs[0]['properties'].values()
# But we also have the coordinates, which is what gets us onto the map.
#lons, lats = zip(*[(x["geometry"]["coordinates"][0], x["geometry"]["coordinates"][1]) for x in locs])
# You could also subselect if that fits your project.
lons, lats = zip(*[(x["geometry"]["coordinates"][0], x["geometry"]["coordinates"][1]) for x in locs if x['properties']['collectioncode']=="Howslib_example_output.png"])
lons, lats = zip(*[(x["geometry"]["coordinates"][0], x["geometry"]["coordinates"][1]) for x in locs if x['properties']['collectioncode']=="HFX"])
# Do some simple buffering of the map edges based on your returned data.
plt.axis([min(lons)-1, max(lons)+1, min(lats)-1, max(lats)+1])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment