PESTools / pestools

PESTools
12 stars 10 forks source link

Spatial plots #34

Closed aleaf closed 9 years ago

aleaf commented 9 years ago

First cut at spatial plotting class. Only added a binding to Res, but it can easily be implemented in other classes (e.g. IdentPar). Right now in Res it the default plot displays residuals sized by their absolute values, and colored by their values (with the colorbar centered on 0). heads_default Alternatively, binary coloring can be used to highlight spatial bias: heads_binary Shapefile overlays are also implemented (the above example includes a county outline from a shapefile). A third type of coloring allows residuals to be sized by absolute value, and colored by percent difference from the measured values: baseflow More details in the Examples/SpatialPlots notebook

aleaf commented 9 years ago

The docstrings for this need a little work yet.

echristi commented 9 years ago

Merging for now. I've had off and on success with fiona, particularly on Windows. I noticed that flopy is trying pyshp. I haven't used pyshp but wondering if it is easier.

aleaf commented 9 years ago

Yep, I saw that. I have been using fiona because I like the interface, but it is potentially more problematic, esp. on windows, because it depends on the ogr library. Although it seems like all of the python GIS tools have gotten way easier to install. Once you have ogr installed, fiona can be updated through conda or pip; if ogr isn't installed, I believe you can go to this site (http://www.lfd.uci.edu/~gohlke/pythonlibs, which also has a bunch of other binaries) and install the whl file using pip (e.g. >pip install <whl file>), and then update it subsequently using conda or pip. I believe you have to do the same thing for shapely on Windows right?

But, pyshp may be less of a hassle. I have a half-baked method in Mapping.py to write shapefiles using pyshp, and was planning to add something that will also read them. Besides the dependencies and the interface, I haven't seen any comparisons of pyshp vs. fiona for performance. This would be a good opportunity to test that.

echristi commented 9 years ago

Can we move the imports the following into the init for the SpatialPlot class? Otherwise if you don't have the packages required for spatial plotting then you can't use the Res class. If we move them down then you can still do other non-spatial plotting without shapely etc.

    from shapely.ops import transform
    from descartes import PolygonPatch
    from Mapping import read_shapefile
aleaf commented 9 years ago

Yeah, that’s probably a good idea. Maybe it would be best to move them to the add_shapefile method itself, with a try/except statement that catches the error if they aren’t found. It is against PEP8 (which says imports should usually go at the top), but I think it makes sense for cases like these.

On May 6, 2015, at 1:28 PM, echristi notifications@github.com wrote:

Can we move the imports the following into the init for the SpatialPlot class? Otherwise if you don't have the packages required for spatial plotting then you can't use the Res class. If we move them down then you can still do other non-spatial plotting without shapely etc.

from shapely.ops import transform
from descartes import PolygonPatch
from Mapping import read_shapefile

— Reply to this email directly or view it on GitHub.