Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
8 | |
4 | |
2 | |
2 |
User | Count |
---|---|
4 | |
3 | |
3 | |
3 | |
2 |