opengeos / leafmap

A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment
https://leafmap.org
MIT License
3.23k stars 389 forks source link

`add_geojson` from local path unable to transform CRS correctly #920

Closed patel-zeel closed 1 month ago

patel-zeel commented 1 month ago

Environment Information

Description

I was working with a GeoJSON file in UTM projection Zone 43 (EPSG:32643). I kept it in EPSG:32643 and not in EPSG:4326 because I wanted to create a K km buffer around the geometry as accurately as I can. When I saved this file locally with GeoPandas and tried to visualize it by providing a path to the add_geojson method, it was unable to show the geometry correctly (lines are visible at the perimeter of the entire map). I have included a minimum working example below.

What I Did

show_what_fails = True

import leafmap.foliumap as leafmap
# OR
# import leafmap.leafmap as leafmap  # This also fails

import geopandas as gpd

m = leafmap.Map()
m.add_basemap("HYBRID")

gdf = gpd.read_file("https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cable_geo.geojson")
if show_what_fails:
    gdf = gdf.to_crs("EPSG:3857")
gdf.to_file("/tmp/cable_geo.geojson", driver='GeoJSON')
m.add_geojson("/tmp/cable_geo.geojson")
m
giswqs commented 1 month ago

Thank you for reporting! The bug has been fixed. Please update leafmap to the latest version and try again

patel-zeel commented 1 month ago

Thank you, Prof. @giswqs, for fixing it quickly.

patel-zeel commented 1 month ago

Prof. @giswqs, the latest version is not yet pushed to PyPI right?

giswqs commented 1 month ago

I just published it. Please try again.

patel-zeel commented 1 month ago

It's working now. Thank you, Prof. @giswqs.