我试图用定制的颜色绘制一个,在地图上使用cartopy和matplotlib。
import numpy as np
import matplotlib.pyplot as plt
import cartopy as cartopy
import pandas as pd
import random as rd
def getcolor(buurtnaam):
a = rd.uniform(0.0, 255.0)
b = rd.uniform(0.0, 255.0)
c = rd.uniform(0.0, 255.0)
return tuple([a, b,
我被困在这里了。我的代码: import os
import matplotlib.pyplot as plt
from netCDF4 import Dataset as netcdf_dataset
import numpy as np
from cartopy import config
import cartopy.crs as ccrs
fname = os.path.join("path", "file")
dataset = netcdf_dataset(fname)
lats = dataset.variables['lat
我有一个shapefile,上面有Perúcountry州的名字,我想根据他们的状态在地图上画出他们的名字。
所以我做了这个代码:
import cartopy
%matplotlib inline
import cartopy.crs as ccrs
import cartopy.io.img_tiles as cimgt
import cartopy.io.shapereader as shpreader
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
from cartopy.feature impor
我已经成功地从天然地球站点创建了一张地图(国家边界和海岸线),但我发现很难绘制天气的经纬度坐标,有些站点很难绘制到地图上。经度和纬度坐标是附加的CSV文件。
下面是目前为止编译的is代码,并生成了地图:
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as feature
import cartopy.io.shapereader as shapereader
在这里输入图像描述
countries = shapereader.natural_earth(resolution=&
我正在试图绘制几个多边形作为覆盖在现有地图上与卡拉托普。但是,我收到以下错误AttributeError: 'GeoSeries' object has no attribute '_geom'。
import cartopy.crs as ccrs
from cartopy.feature import ShapelyFeature
from matplotlib import pyplot as plt
import geopandas as gpd
ax = plt.axes(projection=ccrs.Mollweide())
ax.stock_
下面的代码读取有关全球有效ASOS (天气观测站)位置的数据。我想在将来使用该列表作为绘制数据的点的列表,但许多站点距离太近,无法在全国甚至州的级别上进行查看。我想减少地图上标出的车站的密度。下面是一些绘制美国/加拿大南部所有站点的代码: import re
fh = open('../498/stations.txt', 'r')
lines = fh.readlines()
data = []
for line in lines:
comment_match = re.search('^!', line)
blank_m
我正在尝试使用here获取的shapefile并遵循this example,在一张地形图上绘制湾区城市/城镇边界的轮廓。由于某些原因,边框没有显示,即使我通过zorder指定边框在顶部。我是不是遗漏了什么? # import functions
import matplotlib.pyplot as plt
import cartopy.io.img_tiles as cimgt
import cartopy.crs as ccrs
from cartopy.io.shapereader import Reader
from cartopy.feature import ShapelyFe
我从获得了一个压缩代码的形状文件,并希望将它们绘制在一个Cartopy地图上,就像我在中所做的那样。
根据资料来源,该数据位于EPSG 4326坐标系中。当我试图绘制数据时
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.io.img_tiles as cimgt
from cartopy.io.shapereader import Reader
from cartopy.feature import ShapelyFeature
# Create a Stamen terrain back
我有两个形状文件。一个是点特征shapefile,名为"point.shp",另一个是名为"polygon.shp“的多边形shapefile。两种我都想添加到地图上使用cartopy。我成功地添加了"polygon.shp",但是"point.shp“失败了。
这是我的密码:
import matplotlib.pyplot as plt
from cartopy import crs
from cartopy.io.shapereader import Reader
from cartopy.feature import ShapelyFea
我有一个有点的GeoAxesSubplot,还有潜在的线或多边形。这个投影可以是任何由拼图支持的投影,包括正字法。
我可以使用不同的转换来绘制图,如所解释的
from matplotlib import pyplot as plt
import cartopy.crs as ccrs
# Projection could be any, e.g. globe or Arctic Stereopolar...
ax = plt.axes(projection=ccrs.Mollweide())
ax.coastlines()
# Plot using the coordinate syste
我已经使用以下代码绘制了GPP的全球地图: ( 'lon‘和'lat’都是netCDF4属性,形状分别为(144,)和(90,),而'gpp_avg‘是形状为(90,144)的numpy数组) import numpy as np
import netCDF4 as n4
import matplotlib.pyplot as plt
import cartopy as cart
import cartopy.crs as ccrs
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FOR
我正在尝试使用cartopy在地图上表示一些数据,但我遇到了一个问题,并且没有任何想法来解决它。问题是图没有显示在正确的位置。下面是我的代码: import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cf
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
# geological centre of Spain
lon, lat = (-4, 40)
fig = plt.figure(figsize=(1
我可以将深度和时间平均盐度数据绘制在下面的北海地图上(见下文),但理想情况下,我希望将数据绘制在每个网格点的顶部。 import xarray as xa
import numpy as np
import matplotlib.pyplot as plt
import cmocean.cm as cm
import matplotlib.patches as mpatches
import seaborn as sns
import cartopy.crs as ccrs
import cartopy.feature as cfeat
import cartopy
import carto