Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello, my end goal is to create a Power BI page with two components: a table and a map.
Here is a box link to the shapefile I am working with.
Right now, I am trying to use geopandas (the python library) to plot the region polygons on a map in Power BI with the Python visual tool, but I can't get any polygons to be displayed. Here are the steps I have taken:
1. I imported the data using the Python script tool:
import geopandas as gpd
from shapely import wkt
region_polygons = gpd.read_file("insert_local_file_path_here")
region_polygons = pd.DataFrame(region_polygons)
(I had to convert it from a geodataframe to a dataframe since Power BI wouldn't recognize anything to import unless it was in the form of a pandas dataframe).
2. I created a python visual and dragged my 'geometry' column onto that visual. I then wrote the following script to convert the dataframe to a geodataframe and plot it in on the page using .plot():
import geopandas as gpd
gdf = gpd.GeoDataFrame(dataset, geometry='geometry')
gdf.plot()
The visual then displays a message saying "Can't display this visual" and when I click to see details, I get a type error stating that my 'input must be valid geometry objects':
3. Through some troubleshooting, I've determined that it's the second line throwing the error, when I attempt to create a geodataframe from the dataframe that holds my geometry data. It is expecting geometry objects such as Shapely polygons, but the geometry column is stored as text in Power BI. I verified this by inspecting its data type in Power BI:
4. I found this StackOverflow thread and tried to convert the geometry column to Shapely polygons, but immediately encountered an error:
import geopandas as gpd
from shapely import wkt
# convert dataset column from well-known text type (string) to shapely polygons
dataset['geometry'] = gpd.GeoSeries.from_wkt(dataset['geometry'])
I am finding it almost impossible to troubleshoot further as I can't find a way to output variables to a console in Power BI and because I can't reproduce the problem in my Jupyter Python environment. Is it possible to convert data to data types that geopandas requires, such as Shapely polygons and geometry columns? Is geopandas compatible at all with Power BI for this type of work? If anyone has any ideas please let me know. Thanks in advance.
For context, only four lines of code are necessary in my Jupyter Python environment to display these polygons. This works:
import geopandas as gpd
file_path = "insert_local_file_path_here"
region_polygons = gpd.read_file(file_path)
region_polygons.plot()
And produces this plot:
You must use the standard plotting engine. Only matplotlib is supported.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
6 | |
6 | |
3 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
3 |