當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。