MCPcopy
hub / github.com/python-visualization/folium / convert_to_feature_collection

Method convert_to_feature_collection

folium/features.py:785–800  ·  view source on GitHub ↗

Convert data into a FeatureCollection if it is not already.

(self)

Source from the content-addressed store, hash-verified

783 return requests.get(url).json()
784
785 def convert_to_feature_collection(self) -> None:
786 """Convert data into a FeatureCollection if it is not already."""
787 if self.data["type"] == "FeatureCollection":
788 return
789 if not self.embed:
790 raise ValueError(
791 "Data is not a FeatureCollection, but it should be to apply "
792 "style or highlight. Because `embed=False` it cannot be "
793 "converted into one.\nEither change your geojson data to a "
794 "FeatureCollection, set `embed=True` or disable styling."
795 )
796 # Catch case when GeoJSON is just a single Feature or a geometry.
797 if "geometry" not in self.data.keys():
798 # Catch case when GeoJSON is just a geometry.
799 self.data = {"type": "Feature", "geometry": self.data}
800 self.data = {"type": "FeatureCollection", "features": [self.data]}
801
802 def _validate_function(self, func: Callable, name: str) -> None:
803 """

Callers 2

__init__Method · 0.95

Calls

no outgoing calls

Tested by 1