当前位置: 首页>>代码示例>>Python>>正文


Python crs.Mercator方法代码示例

本文整理汇总了Python中cartopy.crs.Mercator方法的典型用法代码示例。如果您正苦于以下问题:Python crs.Mercator方法的具体用法?Python crs.Mercator怎么用?Python crs.Mercator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cartopy.crs的用法示例。


在下文中一共展示了crs.Mercator方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot_data

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Mercator [as 别名]
def plot_data(column, i, title):
    "Plot the column from the DataFrame in the ith subplot"
    crs = ccrs.PlateCarree()
    ax = plt.subplot(2, 2, i, projection=ccrs.Mercator())
    ax.set_title(title)
    # Set vmin and vmax to the extremes of the original data
    maxabs = vd.maxabs(data.air_temperature_c)
    mappable = ax.scatter(
        data.longitude,
        data.latitude,
        c=data[column],
        s=50,
        cmap="seismic",
        vmin=-maxabs,
        vmax=maxabs,
        transform=crs,
    )
    # Set the proper ticks for a Cartopy map
    vd.datasets.setup_texas_wind_map(ax)
    return mappable 
开发者ID:fatiando,项目名称:verde,代码行数:22,代码来源:trend.py

示例2: _finalize_axis

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Mercator [as 别名]
def _finalize_axis(self, *args, **kwargs):
        gridlabels = self.geographic and isinstance(self.projection, (ccrs.PlateCarree, ccrs.Mercator))
        if gridlabels:
            xaxis, yaxis = self.xaxis, self.yaxis
            self.xaxis = self.yaxis = None
        try:
            ret = super(GeoOverlayPlot, self)._finalize_axis(*args, **kwargs)
        except Exception as e:
            raise e
        finally:
            if gridlabels:
                self.xaxis, self.yaxis = xaxis, yaxis

        axis = self.handles['axis']
        if self.show_grid:
            axis.grid()
        if self.global_extent:
            axis.set_global()
        return ret 
开发者ID:holoviz,项目名称:geoviews,代码行数:21,代码来源:__init__.py

示例3: __init__

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Mercator [as 别名]
def __init__(self, element, **params):
        super(GeoPlot, self).__init__(element, **params)
        self.geographic = is_geographic(self.hmap.last)
        if self.geographic and not isinstance(self.projection, (PlateCarree, Mercator)):
            self.xaxis = None
            self.yaxis = None
            self.show_frame = False
            show_bounds = self._traverse_options(element, 'plot', ['show_bounds'],
                                                 defaults=False)
            self.show_bounds = not any(not sb for sb in show_bounds.get('show_bounds', []))
            if self.show_grid:
                param.main.warning(
                    'Grid lines do not reflect {0}; to do so '
                    'multiply the current element by gv.feature.grid() '
                    'and disable the show_grid option.'.format(self.projection)
                ) 
开发者ID:holoviz,项目名称:geoviews,代码行数:18,代码来源:plot.py

示例4: plot_data

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Mercator [as 别名]
def plot_data(column, i, title):
    "Plot the column from the DataFrame in the ith subplot"
    crs = ccrs.PlateCarree()
    ax = plt.subplot(2, 2, i, projection=ccrs.Mercator())
    ax.set_title(title)
    # Set vmin and vmax to the extremes of the original data
    maxabs = utils.maxabs(data.total_field_anomaly_nt)
    mappable = ax.scatter(
        data.longitude,
        data.latitude,
        c=data[column],
        s=1,
        cmap="seismic",
        vmin=-maxabs,
        vmax=maxabs,
        transform=crs,
    )
    # Set the proper ticks for a Cartopy map
    fetch_data.setup_rio_magnetic_map(ax)
    return mappable 
开发者ID:igp-gravity,项目名称:geoist,代码行数:22,代码来源:gridder_trend.py

示例5: plot_data

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Mercator [as 别名]
def plot_data(coordinates, velocity, weights, title_data, title_weights):
    "Make two maps of our data, one with the data and one with the weights/uncertainty"
    fig, axes = plt.subplots(
        1, 2, figsize=(9.5, 7), subplot_kw=dict(projection=ccrs.Mercator())
    )
    crs = ccrs.PlateCarree()
    ax = axes[0]
    ax.set_title(title_data)
    maxabs = vd.maxabs(velocity)
    pc = ax.scatter(
        *coordinates,
        c=velocity,
        s=30,
        cmap="seismic",
        vmin=-maxabs,
        vmax=maxabs,
        transform=crs,
    )
    plt.colorbar(pc, ax=ax, orientation="horizontal", pad=0.05).set_label("m/yr")
    vd.datasets.setup_california_gps_map(ax)
    ax = axes[1]
    ax.set_title(title_weights)
    pc = ax.scatter(
        *coordinates, c=weights, s=30, cmap="magma", transform=crs, norm=LogNorm()
    )
    plt.colorbar(pc, ax=ax, orientation="horizontal", pad=0.05)
    vd.datasets.setup_california_gps_map(ax)
    plt.tight_layout()
    plt.show()


# Plot the data and the uncertainties 
开发者ID:fatiando,项目名称:verde,代码行数:34,代码来源:weights.py

示例6: test_setup_texas_wind

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Mercator [as 别名]
def test_setup_texas_wind():
    "Test the map setup"
    fig = plt.figure()
    ax = plt.subplot(111, projection=ccrs.Mercator())
    setup_texas_wind_map(ax)
    return fig 
开发者ID:fatiando,项目名称:verde,代码行数:8,代码来源:test_datasets.py

示例7: test_setup_baja_bathymetry

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Mercator [as 别名]
def test_setup_baja_bathymetry():
    "Test the map setup"
    fig = plt.figure()
    ax = plt.subplot(111, projection=ccrs.Mercator())
    setup_baja_bathymetry_map(ax)
    return fig 
开发者ID:fatiando,项目名称:verde,代码行数:8,代码来源:test_datasets.py

示例8: test_setup_rio_magnetic

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Mercator [as 别名]
def test_setup_rio_magnetic():
    "Test the map setup"
    fig = plt.figure()
    ax = plt.subplot(111, projection=ccrs.Mercator())
    setup_rio_magnetic_map(ax)
    return fig 
开发者ID:fatiando,项目名称:verde,代码行数:8,代码来源:test_datasets.py

示例9: load

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Mercator [as 别名]
def load(self, df, centerings):
        """
        A meta-method which abstracts the internals of individual projections' load procedures.

        Parameters
        ----------
        df : GeoDataFrame
            The GeoDataFrame which has been passed as input to the plotter at the top level.
            This data is needed to calculate reasonable centering variables in cases in which the
            user does not already provide them; which is, incidentally, the reason behind all of
            this funny twice-instantiation loading in the first place.
        centerings: dict
            A dictionary containing names and centering methods. Certain projections have certain
            centering parameters whilst others lack them. For example, the geospatial projection
            contains both ``central_longitude`` and ``central_latitude`` instance parameter, which
            together control the center of the plot, while the North Pole Stereo projection has
            only a ``central_longitude`` instance parameter, implying that latitude is fixed (as
            indeed it is, as this projection is centered on the North Pole!).

            A top-level centerings method is provided in each of the ``geoplot`` top-level plot
            functions; each of the projection wrapper classes defined here in turn selects the
            functions from this list relevent to this particular instance and passes them to
            the ``_generic_load`` method here.

            We then in turn execute these functions to get defaults for our ``df`` and pass them
            off to our output ``cartopy.crs`` instance.

        Returns
        -------
        crs : ``cartopy.crs`` object instance
            Returns a ``cartopy.crs`` object instance whose appropriate instance variables have
            been set to reasonable defaults wherever not already provided by the user.
        """
        # WebMercator is a special case.
        if self.__class__.__name__ == 'WebMercator':
            class WebMercator(ccrs.Mercator):
                def __init__(self, args):
                    super().__init__(
                        central_longitude=0,
                        min_latitude=-85.0511287798066,
                        max_latitude=85.0511287798066,
                        globe=ccrs.Globe(
                            ellipse=None,
                            semimajor_axis=ccrs.WGS84_SEMIMAJOR_AXIS,
                            semiminor_axis=ccrs.WGS84_SEMIMAJOR_AXIS,
                            nadgrids='@null'
                        ),
                        **args
                    )
            return WebMercator(self.args)
        else:
            return getattr(ccrs, self.__class__.__name__)(**{**centerings, **self.args}) 
开发者ID:ResidentMario,项目名称:geoplot,代码行数:54,代码来源:crs.py

示例10: _process_element

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Mercator [as 别名]
def _process_element(self, element):
        proj = self.p.projection
        irregular = any(element.interface.irregular(element, kd)
                        for kd in element.kdims)

        zs = element.dimension_values(2, flat=False)
        if irregular:
            X, Y = [np.asarray(element.interface.coords(
                element, kd, expanded=True, edges=False))
                    for kd in element.kdims]
        else:
            X = element.interface.coords(element, 0, True, True, False)
            if np.all(X[0, 1:] < X[0, :-1]):
                X = X[:, ::-1]
            Y = element.interface.coords(element, 1, True, True, False)
            if np.all(Y[1:, 0] < Y[:-1, 0]):
                Y = Y[::-1, :]

        if X.shape != zs.shape:
            X = X[:-1] + np.diff(X, axis=0)/2.
            X = X[:, :-1] + (np.diff(X, axis=1)/2.)
        if Y.shape != zs.shape:
            Y = Y[:-1] + np.diff(Y, axis=0)/2.
            Y = Y[:, :-1] + (np.diff(Y, axis=1)/2.)

        coords = proj.transform_points(element.crs, X, Y)
        PX, PY = coords[..., 0], coords[..., 1]

        # Mask quads which are wrapping around the x-axis
        wrap_proj_types = (ccrs._RectangularProjection,
                           ccrs._WarpedRectangularProjection,
                           ccrs.InterruptedGoodeHomolosine,
                           ccrs.Mercator)

        if isinstance(proj, wrap_proj_types):
            with np.errstate(invalid='ignore'):
                edge_lengths = np.hypot(
                    np.diff(PX, axis=1),
                    np.diff(PY, axis=1)
                )
                to_mask = (
                    (edge_lengths >= abs(proj.x_limits[1] -
                                         proj.x_limits[0]) / 2) |
                    np.isnan(edge_lengths)
                )
            if np.any(to_mask):
                mask = np.zeros(zs.shape, dtype=np.bool)
                mask[:, 1:][to_mask] = True
                mask[:, 2:][to_mask[:, :-1]] = True
                mask[:, :-1][to_mask] = True
                mask[:, :-2][to_mask[:, 1:]] = True
                mask[1:, 1:][to_mask[:-1]] = True
                mask[1:, :-1][to_mask[:-1]] = True
                mask[:-1, 1:][to_mask[1:]] = True
                mask[:-1, :-1][to_mask[1:]] = True
                zs[mask] = np.NaN

        params = get_param_values(element)
        return element.clone((PX, PY, zs), crs=self.p.projection, **params) 
开发者ID:holoviz,项目名称:geoviews,代码行数:61,代码来源:projection.py


注:本文中的cartopy.crs.Mercator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。