0

I am using Cartopy and Metpy to create new graphics. When using Google codelab when ever I try to set an extent with on my maps with:

track_line_gdf = geopandas.read_file('/content/al112017-020_5day_lin.shp')
cone_gdf = geopandas.read_file('/content/al112017-020_5day_lin.shp')
points_gdf = geopandas.read_file('/content/al112017-020_5day_pts.shp')

map_crs = ccrs.LambertConformal(central_latitude=35, central_longitude=100, 
standard_parallels=(30, 60))

data_crs = ccrs.PlateCarree()

fig = plt.figure(figsize=(14 , 12))

ax = plt.subplot(1, 1, 1, projection=map_crs)

ax.set_extent([-90,-72, 20, 55]) #Problem line

I get the warning: "Geometry must be a Point or LineString" then my notebook crashes. I have tried changing the values in the ax.set_extent() I still get the same issue of "Geometry must be a Point or LineString" and then my notebook crashes for an "Unknown" reason. Also the data I am using are shape-files for Hurricane Irma. Has anyone seen this issue before? Thank you for the help!

P.S. I currently live in Guam so I might respond at strange times compared to the mainland US. Thank you again for your help!

  • Please provide a [mcve]. – AMC Mar 03 '20 at 00:24
  • @AMC I provided more of my code. Let me know if that is good enough or if you need more/less. Thank you for the help! – Nick Slaughter Mar 03 '20 at 08:29
  • On a local conda environment, I don't get any errors with that code and data. My guess is that it's a problem with the Google Colaboratory environment, or how you installed cartopy/geopandas into that environment. You need to be very careful to ensure that shapely and CartoPy are using the same version of geos if you are installing using pip and not Conda. – DopplerShift Mar 18 '20 at 04:21

1 Answers1

1

This was happening to me as well on Google Colab, with the same error ending in Point or Linestring. That message seemed to be key. I noticed the regular apt-get to install cartopy didn't seem to be doing anything - as it was already installed, and so I uninstalled and reinstalled it. But, I suspect the only necessary step was what this earlier post found: Geometry must be a Point or LineString error using Cartopy

That is: preface your Cartopy use with:

!apt-get -V -y -qq install python-cartopy python3-cartopy

!pip uninstall shapely -y

!pip install shapely --no-binary shapely

BrianJ
  • 11
  • 1