geopandas / contextily

Context geo-tiles in Python
https://contextily.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
520 stars 82 forks source link

Wrong map extent #178

Closed marcbosch-idencity closed 3 years ago

marcbosch-idencity commented 3 years ago

I am plotting the building data from the Spanish cadaster (http://www.catastro.minhap.es/webinspire/index.html) and trying to set a contextily Basemap. However, the basemap shows an area a few hundreds of kilometres to the West. I'm running the following code and data is originally in EPSG:25830 projection.

buildings = gpd.read_file("A.ES.SDGC.BU.08900.building.geojson")
buildings = buildings.to_crs("EPSG:3857")
f, ax = plt.subplots(figsize = (15,15))
buildings.plot(ax = ax, column = "end", scheme = "fisherjenks", k = 10, cmap = "viridis_r", legend = True)
ctx.add_basemap(ax, source=ctx.providers.OpenStreetMap.Mapnik)
ax.axis("equal")
ax.axis("off")
f.suptitle("Antiguitat dels edificis de Barcelona", fontsize = 20)
plt.show()

The result is as follows

imagen

If I don't reproject the buildings gdf and pass the crs parameter to the add_basemap function, the result is exactly the same. I'm using Python 3.7 and running Geopandas 0.9 and Contextily 1. Thanks in advance!