python: 3.9
arcgis: 2.3.0.1
I am accessing a Feature Layer from the Living Atlas. I convert it to a sdf with the column 'SHAPE' as the geometry. How do I add the sdf to a leafmap map. I have added other layers to the map via add_gdf(). Can I convert the sdf to a gdf? or a geojson which i could then create a gdf from. I found this but need to create the geojson as a variable instead of a local file.
Here is some of the code I am using:
from arcgis.gis import GIS
from arcgis import gis, GeoAccessor, geometry
gis = GIS()
def read_fl(item_id):
living_atlas_item = gis.content.get(item_id)
feature_layer = living_atlas_item.layers[0]
sdf = feature_layer.query(where="1=1", out_sr=4326).sdf
return sdf
item_id = "21638fcd54d14a25b6f1affdef812146"
sdf = read_fl(item_id)
# Transform sdf to gdf somehow
# Create map
map = leafmap.Map(
layers_control=True,
draw_control=False,
measure_control=False,
fullscreen_control=False)
map.add_basemap(basemap_selection)
map.add_gdf(
gdf=sdf,
zoom_to_layer=False,
layer_name='Fires',
info_mode='on_click',
)