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


Python crs.PlateCarree方法代码示例

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


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

示例1: sample_data

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [as 别名]
def sample_data(shape=(20, 30)):
    """
    Returns ``(x, y, u, v, crs)`` of some vector data
    computed mathematically. The returned CRS will be a North Polar
    Stereographic projection, meaning that the vectors will be unevenly
    spaced in a PlateCarree projection.

    """
    crs = ccrs.NorthPolarStereo()
    scale = 1e7
    x = np.linspace(-scale, scale, shape[1])
    y = np.linspace(-scale, scale, shape[0])

    x2d, y2d = np.meshgrid(x, y)
    u = 10 * np.cos(2 * x2d / scale + 3 * y2d / scale)
    v = 20 * np.cos(6 * x2d / scale)

    return x, y, u, v, crs 
开发者ID:clcr,项目名称:pyeo,代码行数:20,代码来源:Test_quiver.py

示例2: main

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [as 别名]
def main():
    plt.figure(figsize=(8, 10))

    x, y, u, v, vector_crs = sample_data(shape=(50, 50))
    ax1 = plt.subplot(2, 1, 1, projection=ccrs.PlateCarree())
    ax1.coastlines('50m')
    ax1.set_extent([-45, 55, 20, 80], ccrs.PlateCarree())
    ax1.quiver(x, y, u, v, transform=vector_crs)

    ax2 = plt.subplot(2, 1, 2, projection=ccrs.PlateCarree())
    plt.title('The same vector field regridded')
    ax2.coastlines('50m')
    ax2.set_extent([-45, 55, 20, 80], ccrs.PlateCarree())
    ax2.quiver(x, y, u, v, transform=vector_crs, regrid_shape=20)

    plt.show() 
开发者ID:clcr,项目名称:pyeo,代码行数:18,代码来源:Test_quiver.py

示例3: plot_data

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [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

示例4: paint_clip

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [as 别名]
def paint_clip(self):
        clip = self.kwargs.pop('clip')
        clip = _to_geom_geoseries(self.df, clip, "clip")
        if clip is not None:
            if self.projection is not None:
                xmin, xmax, ymin, ymax = self.ax.get_extent(crs=ccrs.PlateCarree())
                extent = (xmin, ymin, xmax, ymax)
                clip_geom = self._get_clip(extent, clip)
                feature = ShapelyFeature([clip_geom], ccrs.PlateCarree())
                self.ax.add_feature(feature, facecolor=(1,1,1), linewidth=0, zorder=2)
            else:
                xmin, xmax = self.ax.get_xlim()
                ymin, ymax = self.ax.get_ylim()
                extent = (xmin, ymin, xmax, ymax)
                clip_geom = self._get_clip(extent, clip)
                xmin, xmax = self.ax.get_xlim()
                ymin, ymax = self.ax.get_ylim()
                polyplot(
                    gpd.GeoSeries(clip_geom), facecolor='white', linewidth=0, zorder=2,
                    extent=extent, ax=self.ax
                ) 
开发者ID:ResidentMario,项目名称:geoplot,代码行数:23,代码来源:geoplot.py

示例5: plot

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [as 别名]
def plot(self, ax: GeoAxesSubplot, **kwargs) -> None:  # coverage: ignore
        flat = self.flatten()
        if isinstance(flat, base.BaseMultipartGeometry):
            for poly in flat:
                # quick and dirty
                sub = Airspace("", [ExtrudedPolygon(poly, 0, 0)])
                sub.plot(ax, **kwargs)
            return

        if "facecolor" not in kwargs:
            kwargs["facecolor"] = "None"
        if "edgecolor" not in kwargs:
            kwargs["edgecolor"] = ax._get_lines.get_next_color()

        if "projection" in ax.__dict__:
            ax.add_geometries([flat], crs=PlateCarree(), **kwargs)
        else:
            ax.add_patch(MplPolygon(list(flat.exterior.coords), **kwargs)) 
开发者ID:xoolive,项目名称:traffic,代码行数:20,代码来源:airspace.py

示例6: gridlines

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [as 别名]
def gridlines(self, draw_labels: bool = True, linewidth: Number_T = 0, **kwargs):
        r"""Draw grid lines on cartopy axes"""
        if not isinstance(self.geoax.projection, ccrs.PlateCarree):
            # Some workaround about the issue that cartopy version lower than 0.18 cannot
            # draw ticks on AzimuthalEquidistant plot
            from cartopy import __version__

            ver = tuple([i for i in __version__.split(".")])
            if ver < ("0", "18", "0"):
                warnings.warn(
                    "Cartopy older than 0.18 cannot draw ticks on AzimuthalEquidistant plot.",
                    RuntimeWarning,
                )
                return
        liner = self.geoax.gridlines(
            draw_labels=draw_labels,
            linewidth=linewidth,
            transform=self.data_crs,
            **kwargs
        )
        liner.xlabels_top = False
        liner.ylabels_right = False 
开发者ID:CyanideCN,项目名称:PyCINRAD,代码行数:24,代码来源:ppi.py

示例7: make_map

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [as 别名]
def make_map(axes):
    import matplotlib.ticker as mticker
    import cartopy.crs as ccrs
    from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER

    gl = axes.gridlines(crs=ccrs.PlateCarree(), draw_labels=True,
                      linewidth=2, color='gray', alpha=0.5, linestyle='-')
    axes.coastlines('10m')

    gl.xlabels_top = False
    gl.ylabels_right = False
    gl.xlocator = mticker.MaxNLocator(nbins=5,min_n_ticks=3,steps=None)
    gl.ylocator = mticker.MaxNLocator(nbins=5,min_n_ticks=3,steps=None)
    gl.xformatter = LONGITUDE_FORMATTER
    gl.yformatter = LATITUDE_FORMATTER
    #gl.xlabel_style = {'size': 15, 'color': 'gray'}
    #gl.xlabel_style = {'color': 'red', 'weight': 'bold'}
    return axes 
开发者ID:climate-processes,项目名称:tobac,代码行数:20,代码来源:plotting.py

示例8: projected_area_factor

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [as 别名]
def projected_area_factor(ax, original_crs=4326):
    """
    Helper function to get the area scale of the current projection in
    reference to the default projection. The default 'original crs' is assumed
    to be 4326, which translates to the cartopy default cartopy.crs.PlateCarree()
    """
    if not hasattr(ax, 'projection'):
        return 1
    if isinstance(ax.projection, ccrs.PlateCarree):
        return 1
    x1, x2, y1, y2 = ax.get_extent()
    pbounds = \
        get_projection_from_crs(original_crs).transform_points(ax.projection,
                    np.array([x1, x2]), np.array([y1, y2]))

    return np.sqrt(abs((x2 - x1) * (y2 - y1))
                   /abs((pbounds[0] - pbounds[1])[:2].prod())) 
开发者ID:PyPSA,项目名称:PyPSA,代码行数:19,代码来源:plot.py

示例9: _finalize_axis

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [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

示例10: __init__

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [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

示例11: plot_data

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [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

示例12: map_unique_events

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [as 别名]
def map_unique_events(cat, catname, mids):
    """Map unassociated events from a catalog."""
    if len(mids) == len(cat):
        return

    cat = cat[~cat['id'].isin(mids)].reset_index(drop=True)
    lllat, lllon, urlat, urlon, _, _, _, clon = qcu.get_map_bounds(cat)

    plt.figure(figsize=(12, 7))
    mplmap = plt.axes(projection=ccrs.PlateCarree(central_longitude=clon))
    mplmap.coastlines('50m')
    mplmap.scatter(cat['longitude'].tolist(), cat['latitude'].tolist(),
                   color='r', s=2, zorder=4, transform=ccrs.PlateCarree())
    mplmap.gridlines(crs=ccrs.PlateCarree(), draw_labels=True,
                     linewidth=1, color='gray', alpha=0.5, linestyle='--')
    mplmap.add_feature(cfeature.NaturalEarthFeature('cultural',
        'admin_1_states_provinces_lines', '50m', facecolor='none',
        edgecolor='k', zorder=9))
    mplmap.add_feature(cfeature.BORDERS)
    plt.title('%s unassociated events' % catname, fontsize=20, y=1.08)    
    #print(catname)
    plt.savefig('%s_uniquedetecs.png' % catname, dpi=300)
    plt.close() 
开发者ID:igp-gravity,项目名称:geoist,代码行数:25,代码来源:QCmulti.py

示例13: setup

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [as 别名]
def setup(self):
        # Image length.
        self.imlen = 256

        # Image.
        self.img = Image.open(
            "LunarLROLrocKaguya_1180mperpix_downsamp.png").convert("L")
        self.imgsize = self.img.size

        # Crater catalogue.
        self.craters = igen.ReadLROCHeadCombinedCraterCSV(
            filelroc="../catalogues/LROCCraters.csv",
            filehead="../catalogues/HeadCraters.csv",
            sortlat=True)

        # Long/lat limits
        self.cdim = [-180., 180., -60., 60.]

        # Coordinate systems.
        self.iglobe = ccrs.Globe(semimajor_axis=1737400,
                                 semiminor_axis=1737400,
                                 ellipse=None)
        self.geoproj = ccrs.Geodetic(globe=self.iglobe)
        self.iproj = ccrs.PlateCarree(globe=self.iglobe) 
开发者ID:silburt,项目名称:DeepMoon,代码行数:26,代码来源:test_input_data_gen.py

示例14: create_cartopy

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [as 别名]
def create_cartopy(self,proj='PlateCarree',mapobj=None,**kwargs):
        
        r"""
        Initialize a cartopy instance passed projection.
        
        Parameters:
        -----------
        projection
            String representing the cartopy map projection.
        ax
            Axis on which to draw on. Default is None.
        mapobj
            Existing cartopy projection. If passed, will be used instead of generating a new one.
        **kwargs
            Additional arguments that are passed to those associated with projection.
        """
        
        #Initialize an instance of cartopy if not passed
        if mapobj == None:
            self.proj = getattr(ccrs, proj)(**kwargs)
        else:
            self.proj = mapobj 
开发者ID:tropycal,项目名称:tropycal,代码行数:24,代码来源:plot.py

示例15: test_plot_projection

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import PlateCarree [as 别名]
def test_plot_projection():

    # default is PlateCarree
    with figure_context():
        ax = r1.plot(subsample=False)
        assert isinstance(ax.projection, ccrs.PlateCarree)

    # make sure the proj keword is respected
    with figure_context():
        ax = r1.plot(subsample=False, proj=ccrs.Miller())
        assert isinstance(ax.projection, ccrs.Miller)

    # projection given with axes is respected
    with figure_context() as f:
        ax = f.subplots(subplot_kw=dict(projection=ccrs.Mollweide()))
        ax = r1.plot(subsample=False, ax=ax)
        assert isinstance(ax.projection, ccrs.Mollweide) 
开发者ID:mathause,项目名称:regionmask,代码行数:19,代码来源:test_plot.py


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