2

I can't seem to get a basic basemap background showing from any examples for contextily v 1.0rc2. I'm on python 3.8.0, 32 bit, windows 10. My packages and version are listed at the bottom.

It was supremely difficult to get it installed with all its dependencies but that may just be my setup. I haven't included the code as I'm using 3 examples, urls below. The error partially initialized module 'contextily' indicates the package may not have installed properly.

I get the following errors:

  • basemap, extent = ctx.bounds2img(xmin, ymin, xmax, ymax, zoom=zoom, url=url) AttributeError: partially initialized module 'contextily' has no
    attribute 'bounds2img' (most likely due to a circular import)```
    
    From example:
    https://share.cocalc.com/share/56cef78b3fda5e0338c2da71b222e6b275a9193e/contextily.ipynb?viewer=share
    
  • attribute 'add_basemap' (most likely due to a circular import)```
    
    From this example:
    https://geopandas.readthedocs.io/en/latest/gallery/plotting_basemap_background.html?highlight=basemap#adding-a-background-map-to-plots
    
  • attribute 'Place' (most likely due to a circular import)```
    
    From this example  (from the actual developers of contextily?):
    https://github.com/darribas/contextily/blob/master/examples/plot_map.py
    

Can anyone tell what the problem is?

Or happy to try an alternative package if it's more supported.

I managed to get a GDAL loaded raster file into a matplotlib figure using imshow and color it - I just don't know how I would get a tile layer with a URL like OSM into the figure.

Installed packages:

['-yinstaller==3.5', 'affine==2.3.0', 'alabaster==0.7.12', 'altgraph==0.16.1', 'arrow==0.15.6', 'attrs==19.3.0', 'babel==2.8.0', 'cartopy==0.18.0', 'certifi==2019.11.28', 'cffi==1.14.0', 'chardet==3.0.4', 'click-plugins==1.1.1', 'click==7.1.2', 'cligj==0.5.0', 'colorama==0.4.3', 'contextily==1.0rc2', 'cryptography==2.8', 'cycler==0.10.0', 'decorator==4.4.2', 'deprecated==1.2.10', 'descartes==1.1.0', 'docutils==0.16', 'fiona==1.8.13', 'flask==1.1.2', 'future==0.18.2', 'gdal==3.0.4', 'geographiclib==1.50', 'geojson==2.5.0', 'geopandas==0.7.0', 'geopy==1.22.0', 'geos==0.2.2', 'gitdb==4.0.5', 'gitpython==3.1.3', 'idna==2.9', 'imagesize==1.2.0', 'itsdangerous==1.1.0', 'jinja2==2.11.2', 'joblib==0.15.1', 'kiwisolver==1.1.0', 'lxml==4.5.1', 'markupsafe==1.1.1', 'matplotlib==3.2.0', 'mercantile==1.1.4', 'munch==2.5.0', 'networkx==2.4', 'numpy==1.18.1', 'ogr==0.12.1', 'osgeo-easy==0.0.1.dev16', 'osgeo4w-installer==1.4.0', 'osmnx==0.11.4', 'overpass==0.7', 'overpy==0.4', 'packaging==20.4', 'pandas==1.0.1', 'pefile==2019.4.18', 'pillow==7.0.0', 'pip==19.3.1', 'proj==0.2.0', 'psycopg2==2.8.4', 'pycparser==2.20', 'pygithub==1.51', 'pygments==2.6.1', 'pyinstaller==4.0.dev0+9dd34bdfba', 'pyjwt==1.7.1', 'pyopenssl==19.1.0', 'pyparsing==2.4.6', 'pyproj==2.5.0', 'pyqt5-sip==12.7.0', 'pyqt5==5.13.2', 'pyshp==2.1.0', 'python-dateutil==2.8.1', 'python-gitlab==2.2.0', 'pytz==2019.3', 'pywin32-ctypes==0.2.0', 'pyyaml==5.3.1', 'rasterio==1.1.4', 'reportlab==3.5.34', 'requests==2.23.0', 'rtree==0.9.4', 'setuptools==44.0.0', 'shapely==1.7.0', 'six==1.14.0', 'smmap==3.0.4', 'snowballstemmer==2.0.0', 'snuggs==1.4.7', 'sphinx==3.0.4', 'sphinxcontrib-applehelp==1.0.2', 'sphinxcontrib-devhelp==1.0.2', 'sphinxcontrib-htmlhelp==1.0.3', 'sphinxcontrib-jsmath==1.0.1', 'sphinxcontrib-qthelp==1.0.3', 'sphinxcontrib-serializinghtml==1.1.4', 'sqlalchemy==1.3.15', 'urllib3==1.25.8', 'werkzeug==1.0.1', 'wrapt==1.12.1', 'xlrd==1.2.0']

4
  • Where in the examples, the error appears and what is the complete error messages ?
    – gene
    Commented Jun 7, 2020 at 13:18
  • And how exactly did you install it? Commented Jun 7, 2020 at 15:12
  • I installed it using pip install (either 'modulename' or .whl that I downloaded) following this progression: gdal, fiona, geopy, mercantile, ogr, geos, proj, rasterio, contexily,
    – GIS_py
    Commented Jun 7, 2020 at 20:40
  • errors from original post: Example 1: basemap, extent = ctx.bounds2img(xmin, ymin, xmax, ymax, zoom=zoom, url=url) Example 2: ctx.add_basemap(ax, url=ctx.sources.ST_TERRAIN) Example 3: loc = ctx.Place("boulder", zoom_adjust=0)
    – GIS_py
    Commented Jun 7, 2020 at 21:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.