Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mistake in matching basemap through contextily #212

Open
EugeneGIS opened this issue Feb 23, 2023 · 2 comments
Open

Mistake in matching basemap through contextily #212

EugeneGIS opened this issue Feb 23, 2023 · 2 comments

Comments

@EugeneGIS
Copy link

Hello everyone, Greeting for Switzerland.

Recently, I am focusing on visualizing some datasets of Switzerland through 'contextily' package in python. For the geo coordinate in meter, I decided to use the 'EPSG:3857' as the CRS. However, I met a mistake during the basemap time.

Exactly, as the following code, I have finished the preliminary visualization about the dataset that I used.
seaborn.jointplot(x = "Longitude", y = "Latitude", data = CH_points, s = 2.0);
The result is here, it works well.
image

And then, I consider using the function 'contextily.add_basemap()' to make kde-plot looks better, at least in Switzerland.

# Set up figure and axis
f, ax = plt.subplots(1, figsize=(10, 10))
seaborn.kdeplot(
    CH_points_3857["X"],
    CH_points_3857["Y"],
    n_levels=50,
    shade=True,
    alpha=0.55,
    cmap="viridis_r",
)
# Add basemap
contextily.add_basemap(
    ax, crs = CH_points_3857.crs.to_string(), source=contextily.providers.OpenStreetMap.CH
)
# Remove axes
ax.set_axis_off()

The result is here. As you see, it can load the basemap, not bad, right? But the basemap now is in France, not in Switzerland.
image

I have tried to search the similar questions, infos, and solutions via Google, StackOverflow, but no idea...

So Looking forward to your comments and solutions. Have a nice day. :)

@darribas
Copy link
Collaborator

mmm... Would you be comfortable sharing a sample of your data? Or a synthetic version that replicates its characteristics? Happy to take a quick look. My sense is it has to do with the CRS set in CH_points_3857, which I can't check.

@EugeneGIS
Copy link
Author

@darribas Hello, Dani. Thanks for your reply. Here is the link to the dataset, a shapefile with more than 15000 points. https://drive.google.com/file/d/1c85ofyiHKDxjyV5m9LgvWNWL_E9fiifb/view?usp=sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants