-
If "data" is a GeoPandas dataframe, the following feature does not work, Even if the "data" has the "id" field, the error message says the "data" needs to have a "id" field. However, if I export the "data" to a "json" file and read it back like the following, add_labels() can work fine. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
It has been fixed. Update the package using |
Beta Was this translation helpful? Give feedback.
-
Try the following example. It works on my end. If it does not work for you, that means your leafmap is not up to date. If it works, then it is the problem if own dataset. Please provide a sample dataset for debugging. import leafmap
import geopandas as gpd
data = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson"
gdf = gpd.read_file(data)
m = leafmap.Map()
m.add_labels(data, "NAME", font_size="12pt", font_color="blue", font_family="arial", font_weight="bold")
m |
Beta Was this translation helpful? Give feedback.
-
I run the code you provided, and got an error message (attached at the end). But it worked if I only add the first three lines of your above code. It seems that the GeoDataFrame variable needs to be in certain format for the "label" to work. The error message: KeyError Traceback (most recent call last) ~\Miniconda3\envs\geo\lib\site-packages\leafmap\common.py in gdf_to_df(gdf, drop_geom) ~\Miniconda3\envs\geo\lib\site-packages\pandas\core\frame.py in drop(self, labels, axis, index, columns, level, inplace, errors) ~\Miniconda3\envs\geo\lib\site-packages\pandas\core\generic.py in drop(self, labels, axis, index, columns, level, inplace, errors) ~\Miniconda3\envs\geo\lib\site-packages\pandas\core\generic.py in _drop_axis(self, labels, axis, level, errors) ~\Miniconda3\envs\geo\lib\site-packages\pandas\core\indexes\base.py in drop(self, labels, errors) KeyError: "['geometry'] not found in axis" |
Beta Was this translation helpful? Give feedback.
-
The GeoDataFrame must have a |
Beta Was this translation helpful? Give feedback.
-
Thanks for all your help. Really appreciated. sql_cmd = '''select geoid10 as zipcode, ST_Centroid(geom) as geom, ST_Centroid(geom) as geometry from zipcode where geoid10 in ( '''+selected_zip+''' )''' |
Beta Was this translation helpful? Give feedback.
It has been fixed. Update the package using
leafmap.update_package()
and restart the kernel to take effect.