2.3.8.15. Content¶
| Inheritance diagram: | |
|---|---|

Utilities derived from mpl_toolkits.basemap
-
class
GSHHS_BM(input=None, clip=None, sort=True, reverse=True, proj=False, **kwargs)[source]¶ Bases:
vacumm.misc.io.ShapesShoreline from USGS using Basemap
Initialized with a valid Basemap instance with resolution not equal to None, or thanks to arguments passed to
create_mapplot.map()- input: Basemap or Shapes instance [default: None]
-
INPUT_MULTIPOINTS= 8¶
-
INPUT_POINTS= 1¶
-
INPUT_POLYGONS= 5¶
-
INPUT_POLYLINES= 3¶
-
LINE= 1¶
-
LINES= 1¶
-
POINT= 0¶
-
POINTS= 0¶
-
POLY= 2¶
-
POLYGON= 2¶
-
POLYGONS= 2¶
-
POLYS= 2¶
-
clip(zone, copy=True, sort=True, reverse=True, **kwargs)¶ Clip to zone
Params: - zone:
[xmin, ymin, xmax, ymax] - copy, optional: If
True, make a copy of current instance, else simply rehandled the list of shapes. - If
copy==True, Other parameters are passed to the initialization of the new instance.
- zone:
-
get_data(key=None, proj=None)¶ Get the numeric version of the list of geos objects (polygons, etc)
Param: - key: A slice selector applied to the list.
- proj:
True, or a callable to project or re-project coordinates.
-
get_map()¶ Return the associated basemap instance if set
-
get_points(key=None, split=True, proj=None)¶ Get all the points from all the shapes as a tuple (x,y)
-
get_shapes(key=None, proj=None)¶ Get the list of geos objects (polygons, etc)
Param: - key: A slice selector applied to the list.
- proj:
True, or a callable to project or re-project coordinates.
-
get_type()¶ Return the type of shapes
-
get_xy(key=None, proj=None)¶ Shortcut to
get_points(split=false)
-
is_type(type)¶ Check type
Example: >>> self.is_type(self.POLYS)
-
plot(select=None, ax=None, fill=None, points=False, lines=True, fillcolor=None, color='k', s=None, linewidth=None, m=None, show=True, alpha=1, autoscale=True, title=None, **kwargs)¶ Plot shapes
Params: - select, optional: argument for selecting shapes in the list [defaul: None].
- fill, optional: Force filling (True/False), else guessed from shpe type, ie filling for polygons only [default: None]
- ax, optional: Axes instance.
- m, optional:
Mapinstance (created withmap2()) or aBasemapinstance. - points, optional: Plots shapes as points.
- lines, optional: Plot shapes as lines (if a of type
POINTS). - fill_<params>, optional:
<param>is passed toPolyCollection. - lines_<params>, optional:
<param>is passed toLineCollectionor toPolyCollection. - points_<params>, optional:
<param>is passed toscatter. - m_<params>, optional:
<param>is passed tomap2ifm is True. - autoscale, optional: Autoscale axis limits?
-
resol(deg=True)¶ Compute the mean “resolution” of the shapes based on the first shape
deg:
- if
False: return a resolution in meters has a the median distance between points - if
True: return the median distance between points as a resolution in degrees(xres,yres)
- if
-
sort(reverse=True)¶ Sort shapes according to their surface or length
- reverse: If True, greater polygons are first [default: True]
-
sorted()¶
-
xy¶ XY coordinates as a (2,npts) array
-
GSHHS_RESLIST= ['f', 'h', 'i', 'l', 'c']¶ GSHHS shorelines letters
-
RSHPERE_WGS84= (6378137.0, 6356752.3141)¶ Earth radius of wgs84 ellipsoid
-
cached_map(m=None, mapdir=None, verbose=False, **kwargs)[source]¶ Check if we have a cached map
- m: A Basemap instance [Default: None]
- mapdir: Where are stored the cached maps. If
None,matplotlib.get_configdir()is used as a parent directory, which is the matplotlib configuration directory (~/.matplotlibundex linux), andbasemap/cached_mapsas the subdirectory.
Example: >>> m = cached_map(lon_min=-5, lon_max=6, lat_min=40, lat_max=50, projection='lcc', resolution='f') >>> m = cached_map(m) # Does only caching of map
-
clean_cache(mapdir=None, maxsize=None)[source]¶ Clean cache directory by checking its size
Params: - mapdir, optional: Directory where maps are cached
- maxsize, optional: Maximal size of directory in bytes.
Default value from
[vacumm.misc.grid.basemap]max_cache_sizeconfiguration value.
-
create_map(lon_min=-180.0, lon_max=180.0, lat_min=-90.0, lat_max=90.0, projection='cyl', resolution='auto', epsg=None, lon_center=None, lat_center=None, lat_ts=None, zoom=None, ax=None, overlay=False, fullscreen=False, nocache=False, cache_dir=None, **kwargs)[source]¶ Generic creation of a
Basemapinstance with cachingTodo
Merge
get_map()withcreate_map()
-
get_map(gg=None, proj=None, res=None, auto=False, **kwargs)[source]¶ Quickly create
BasemapinstanceParams: - gg, optional: cdms grid or variable, or (xx,yy).
- res, optional: Resolution.
- proj, optional: Projection [default: None->’merc’]
- auto, optional: If True, get geo specs according to grid. If False, whole earth. If None, auto = res is None.
Todo
Merge with
create_map()
-
get_proj(gg=None, proj=None, **kwargs)[source]¶ Setup a default projection using x,y coordinates and
Projorbasic_proj()Projection is set by default to “basic”.
Params: - gg, optional: Grid or coordinates (see
get_xy()). If not provided, lon bounds are set to (-180,180) and lat bounds to (-89.99,89.99). - Other keywords are passed to
Proj. One of them is the projection type, which defaults to configuration option[vacumm.misc.grid.basemap] proj.
Return: A
mpl_toolkits.basemap.proj.Projinstance orbasic_proj()Examples: >>> proj = get_proj(sst.getGrid(), proj='laea') >>> x, y = proj(lon, lat)
>>> proj = get_proj((lon, lat)) >>> xx, yy = N.meshgrid(lon, lat) >>> xx, yy = proj(xx, yy) >>> print proj(xx, yy, inverse=True)
>>> proj = get_proj(R=6000000.)
- gg, optional: Grid or coordinates (see
-
gshhs_autores(lon_min, lon_max, lat_min, lat_max, asindex=False, shift=None)[source]¶ Guess best resolution from lon/lat bounds
-
merc(lon=None, lat=None, **kwargs)[source]¶ Mercator map
- Extra keywords are passed to
mpl_toolkits.basemap.Basemap - lon: Longitudes to define
llcrnrlonandurcrnrlon - lat: Latitudes to define
lat_ts,llcrnrlatandurcrnrlat
- Extra keywords are passed to