contextily | Context geo-tiles in Python | Map library

 by   geopandas Jupyter Notebook Version: 1.6.0 License: BSD-3-Clause

kandi X-RAY | contextily Summary

kandi X-RAY | contextily Summary

contextily is a Jupyter Notebook library typically used in Geo, Map applications. contextily has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

contextily is a small Python 3 (3.7 and above) package to retrieve tile maps from the internet. It can add those tiles as basemap to matplotlib figures or write tile maps to disk into geospatial raster files. Bounding boxes can be passed in both WGS84 (EPSG:4326) and Spheric Mercator (EPSG:3857). See the notebook contextily_guide.ipynb for usage.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              contextily has a low active ecosystem.
              It has 390 star(s) with 68 fork(s). There are 15 watchers for this library.
              There were 4 major release(s) in the last 12 months.
              There are 32 open issues and 78 have been closed. On average issues are closed in 341 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of contextily is 1.6.0

            kandi-Quality Quality

              contextily has 0 bugs and 0 code smells.

            kandi-Security Security

              contextily has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              contextily code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              contextily is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              contextily releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.
              It has 1258 lines of code, 53 functions and 14 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of contextily
            Get all kandi verified functions for this library.

            contextily Key Features

            No Key Features are available at this moment for contextily.

            contextily Examples and Code Snippets

            No Code Snippets are available at this moment for contextily.

            Community Discussions

            QUESTION

            Geopandas can't plot the right country
            Asked 2022-Jan-05 at 09:57

            I'm trying to plot a trip on the map of France but I can't plot only the map of France (see image), could someone help me with this ? I believe this may be an issue with the crs from the contextily library but I didn't find any information on the web Here is a reproducible example...

            ...

            ANSWER

            Answered 2022-Jan-05 at 09:57

            Two points

            • France is a MutliPolygon, where part is in Antartica. Have excluded this from geometry
            • need to be very consistent with CRS. Additionally best not to use legacy for of referencing CRS {"init": "epsg:4326"}

            Source https://stackoverflow.com/questions/70568019

            QUESTION

            seaborn jointplot with same size plots
            Asked 2021-Dec-11 at 00:14

            I'm doing a jointplot with a basemap, the problem is that when I add the basemap the main plot doesn't have the same size of the marginal plots. I've tried with different parameters without luck. Does anyone have an idea?

            ...

            ANSWER

            Answered 2021-Dec-11 at 00:14

            Here is an approach that:

            • removes the axes sharing in the y-direction to be able to change the aspect to 'datalim'
            • sets the aspect to 'equal', 'datalim'
            • sets the y data limits of the marginal plot to be the same as the joint plot; this seems to need a redraw

            The following code shows the idea (using imshow, as I don't have contextily installed):

            Source https://stackoverflow.com/questions/70299714

            QUESTION

            GeoViews: adding a tile basemap using matplotlib backend
            Asked 2021-Aug-02 at 14:49

            Using the matplotlib backend, is it possible to add a tile basemap such as OSM to a GeoViewsplot, e.g. by somehow calling contextily? Using the Bokeh backend, this is done via gv.tile_sources and then adding it to an overlay but is there a similar function for the mpl backend?

            Post-answer edit

            Adding a reproducible example assuming one is switching between backends, and using neighbourhood-level polygon gdfs in EPSG:4326.

            What made me initially think adding a basemap was not possible was (1) not defining the WMTS zoom level (causing undecipherable pixelated text to be plotted instead of features), and, after reading James' answer, (2) adding the tiles layer to the layout last, not first, which caused tiles to cover the polygons layers (not an issue on the bokeh backend, but with matplotlib apparently it does matter).

            ...

            ANSWER

            Answered 2021-Aug-01 at 16:58

            QUESTION

            Contextily basemap is blank with point GeoDataFrame
            Asked 2021-May-05 at 09:29

            I have a dataframe of individual addresses with lat/long that I converted to a GeoPandas dataframe. I set the projection to the Contextily EPSG:3857 projection.

            ...

            ANSWER

            Answered 2021-May-05 at 09:29

            The CRS of your geometries is not 3857 but 4326. Coordinates are clearly in degrees.

            Source https://stackoverflow.com/questions/67393682

            QUESTION

            Contextily Basemap matching issue
            Asked 2021-Jan-18 at 23:17

            I'm trying to plot a set of points on a basemap using contextily in python. I have the following points object generated by shapely.geometry, long first and then lat.

            0 POINT (-122.44040676 37.7452892821)

            1 POINT (-122.432337016 37.7814273807)

            2 POINT (-122.409302275 37.7923551768)

            3 POINT (-122.446989285 37.7963790178)

            4 POINT (-122.412922159 37.8076612624)

            I then converted it into a geopandas data and used to following to plot it.

            ...

            ANSWER

            Answered 2021-Jan-16 at 10:10

            Assuming your geoDataFrame is created with a valid crs, when you add_basemap the crs can be specified with option crs=gdf.crs.to_string() to reproject the map images properly. Here is the relevant line of code that needs to change.

            Source https://stackoverflow.com/questions/65745391

            QUESTION

            Contextily, how to get max zoom allowable and set map extents accordingly
            Asked 2021-Jan-17 at 06:19

            Using Python 3.8, GeoPandas, and Contextily, I am plotting a lot of maps in different areas at different zoom levels (looping through list of points in a GeoDataFrame). Different zoom levels work for different global areas.

            What is the best way to set the zoom to the max allowable, capturing the points that I am plotting? In the code below, I don't know how to:

            1. Return max zoom allowable (I just used 13 in second plot because that was in error message)
            2. Change the extents in the second plot-- the extents of the second plot are the same as the first; I would have expected that changing the zoom level would change the extents

            I think I have correctly set the EPSG, which was the gist of the answer to a similar question here.

            Code:

            ...

            ANSWER

            Answered 2021-Jan-17 at 06:19

            As it is confirmed by the asker. Adding option reset_extent=False to ctx.add_basemap(ax2, ... ) will solve the problem of plotting on ax2.

            For checking a possible zoom value before actually using it. Use this

            Source https://stackoverflow.com/questions/65753760

            QUESTION

            Geographic points extend beyond expected boundary
            Asked 2021-Jan-15 at 07:18

            I have a point geometry of US locations contained in a GeoDataFrame. I want to plot this as a scatterplot over the US map. My code is:

            ...

            ANSWER

            Answered 2021-Jan-15 at 07:18

            The plot looks good. I guess you want to exclude the points outside conterminous USA. Those points are clearly in Hawaii, Alaska, and Canada.

            From your geodataframe with point geometry, gdf, and with polygon geometry, boundary, you can create a proper boundary that can be used to limit the scatter of the points.

            Source https://stackoverflow.com/questions/65717683

            QUESTION

            How to add a real map as the background to a plot
            Asked 2020-Dec-02 at 20:45

            I am trying to add a real map behind my plot in order to show the locations of my datapoints.

            But I don't know how to add the real map...

            I've tried several ways, like put another png behind the plot.

            But it just not right.

            Here is what I got.

            ...

            ANSWER

            Answered 2020-Dec-02 at 16:53

            QUESTION

            Contextily add_basemap uses wrong extent and zoom level
            Asked 2020-Nov-10 at 08:16

            I'm trying to add a contextily basemap to a Matplotlib figure containing a GeoPandas data frame. When I just plot the data frame using df.plot the map extent is calculated correctly.

            However, when I try adding a contextily basemap the map extent (and zoom level) is calculated wrongly and the following warning is shown:

            ...

            ANSWER

            Answered 2020-Nov-10 at 08:16

            The GML file of Linz is based on Gauss-Krüger system M31-5Mio (EPSG:31255). Here is runnable code that demonstrates all the steps to produce a plot of the GML with basemap requested from webmap tiles' provider of choice.

            Source https://stackoverflow.com/questions/64755552

            QUESTION

            How to set fixed size for 'basemap' subplot when iterating through rows?
            Asked 2020-Oct-19 at 17:59

            Please forgive me as this is my first go at a Python 'Project'.

            A quick overview: I am trying to produce maps (MatPlotLib figures) by iterating through a GeoPandas dataframe of a GeoJSON file containing the boundaries of active subdivision phases in order to show the progress of construction of the individual lots in each subdivision phase. We normally did this manually in GIS, but I figured I'd take a stab at automating some, or all, of the process. I am also attempting to do this without using ESRI's python functionality and would prefer to keep it that way for stability for future use as ESRI can move around quite a bit.

            I am able to iterate through the geodataframe and produce a map (figure) that is zoomed to the extent of the subdivision phase boundary, however, it is clipping the background aerial imagery basemap to the minimum binding box of the subdivision phase that I have been using to set the 'zoom' of the figure.

            Example of what I am aiming to produce. This was made in ArcGIS Pro:

            What I am able to make in Python:

            I am unable to get the basemap to be a constant size that fills a standard landscape letter page whilst still being correctly zoomed in to the extent of the subdivision phase. My output jpeg is sized correctly, but the aerial imagery basemap is continuously croppped to the extent of the subdivision phase boundary leaving large borders around the figure.

            ...

            ANSWER

            Answered 2020-Oct-19 at 17:59

            If you want to have a fixed area which, say, extends the bounding box by 10m, you have to set xlim and ylim extended. You are explicitly specifying both to bounding box.

            Source https://stackoverflow.com/questions/64431494

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install contextily

            Python 3 only (3.7 and above).

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install contextily

          • CLONE
          • HTTPS

            https://github.com/geopandas/contextily.git

          • CLI

            gh repo clone geopandas/contextily

          • sshUrl

            git@github.com:geopandas/contextily.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link