This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Greetings! The approach taken in that video is handling the fact that the points that were given in the shapefile were coordinates in a Lambert Conformal Conic (LCC) projection. My best guess is SPC previously generated the points directly in an LCC projection and shipped those raw points in the shapefile; then, recently, they started sending out those points converted to lat/lon coordinates instead. Regardless, I was able to make things work by changing the offending line to `data_crs = ccrs.PlateCarree()` So the complete set of functional code is: import matplotlib.pyplot as plt import geopandas from cartopy import crs as ccrs import cartopy.feature as cfeature %matplotlib inline cat_gdf = geopandas.read_file('./day1otlk-shp/day1otlk_cat.shp') cat_gdf.plot() map_crs = ccrs.LambertConformal(central_latitude = 35, central_longitude = -100, standard_parallels = (30, 60)) data_crs = ccrs.PlateCarree() cat_plot_colors = {2: 'palegreen', 3: 'green', 4: 'yellow', 5: 'brown', 6: 'red', 7: 'magenta'} fig = plt.figure(1, figsize = (14, 12)) ax = plt.subplot(1, 1, 1, projection = map_crs) ax.set_extent([-130, -72, 20, 55], ccrs.PlateCarree()) ax.add_feature(cfeature.COASTLINE.with_scale('50m')) ax.add_feature(cfeature.STATES.with_scale('50m')) for key in cat_plot_colors.keys(): geometries = cat_gdf[cat_gdf['DN'] == key] if len(geometries) > 0: ax.add_geometries(geometries['geometry'], crs = data_crs, facecolor = cat_plot_colors[key], edgecolor = 'black', alpha = 0.5) Cheers! Ryan > I’m having trouble with the code outlined in one of the MetPy Monday video > tutorials for the SPC convective outlook maps. > > Line 8 of the code in the video is --- > data_crs = ccrs.LambertConformal(central_latitude=cat_gdf.crs['lat_0'], > central_longitude=cat_gdf.crs['lon_0'], > standard_parallels=(cat_gdf.crs['lat_1'], cat_gdf.crs['lat_2'])) > > This works fine, obviously, in the video. However, when I go to put this > into my system, I get a “TypeError: ‘CRS’ object is not subscriptable” > message. Is there a fix or a workaround for this line of code to work so > that the rest of the code works and the map can be plotted? > > Thanks for any input and help! Ticket Details =================== Ticket ID: GPD-109280 Department: Support Python Priority: Low Status: Closed =================== NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.