2

I have a .shp file that I want to use in my Power BI dashboard, however I keep running into multiple issues. Because Power BI only accepts TopoJSON for its shape maps, I have to do some transformations.

In QGIS, I've ensured the CRS is WGS84. However, when I load it into mapshaper.org along with the .prj file, it tells me that it's missing projection data. I inspect the .prj file in Notepad++ and see that it has a CRS.

This is where I got with my data set before I didn't get further, but out of curiosity I tried continuing with a dummy data set. I used mapshaper.org to convert the data into GeoJSON, and then copy pasted the GeoJSON into geojsonlint.com to validate it. All good, so I imported it into Power BI, and voila I have a map (albeit with the wrong data set).

Is there an easier way to do all of this? I've spent quite a few hours trying to get this pipeline to work.

1
  • The .prj file needs to have the same name as the .shp file.
    – GforGIS
    Sep 28, 2023 at 14:28

3 Answers 3

2

I was finally able to find a workflow that ended up being compatible with Power BI.

Long story short: I downloaded the file that I needed as GeoJSON, opened it in QGIS and exported it as a shapefile to fix the incorrect CRS (could have exported it as a GeoJSON?), fixed a field in the attribute table that was giving me trouble, exported it as GeoJSON, then opened the data in Mapshaper and finally exported it to TopoJSON. This allowed me to integrate it into Power BI with the custom shape map.

1

There is a QGIS plugin that might help you. You shouldn't have to do much as far as a pipeline since it's already built in: https://plugins.qgis.org/plugins/topojson_writer/

6
  • Thanks for the suggestion! I tried the plugin, but whenever I bring it into mapshaper I'm still told that the file is missing projection data. If I convert it to JSON and bring it into Power BI, it doesn't load at all, presumably due to the lack of projection. However, if I enable basemap in Mapshaper, the aerial photos align perfectly with my TopoJSON. Unfortunately this leaves me none the wiser. Sep 28, 2023 at 18:38
  • 1
    I can't answer to your specific shapefile, but it seems to me that there might be a problem with your .prj file, either corrupted or not correctly put together. If you are only finding this error on your dataset, that is probably the case. Let me know how it works on a dummy dataset and I can try to give more detailed suggestions. Alternately, link your shapefile (if not sensitive) and I can validate it. Sep 29, 2023 at 14:09
  • @JacksonDunn Thank you for the continued help. The data is not sensitive, so I have uploaded it here: file.io/u3w1ZP1Ed2py. One thought I had as to why this might be happening: the shapefile originally comes from a sosi-file, which I had converted into a shapefile. Could this be messing with the CRS somehow? Sep 29, 2023 at 15:26
  • the file link is now deleted. do you want a topojson in wgs84?
    – Mapperz
    Sep 29, 2023 at 19:43
  • 1
0

If you drag your zipped shapefile from https://file.io/u3w1ZP1Ed2py (which now doesn't work any more) to mapshaper, you get this:

enter image description here

But if you then export this to GeoJSON, you get GeoJSON with projected coordinates. This indicates that your conversion from SOSI file to shapefile retained projected coordinates, just .prj file was changed.

You have to change content of the .prj file with the WKT definition for EPSG:23032 (UTM zone 32N):

PROJCS["ED50 / UTM zone 32N",
    GEOGCS["ED50",
        DATUM["European_Datum_1950",
            SPHEROID["International 1924",6378388,297],
            TOWGS84[-87,-98,-121,0,0,0,0]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4230"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",9],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH],
    AUTHORITY["EPSG","23032"]]

Then again drag shapefile to mapshaper and then export it to GeoJSON in the mapshaper console with the command:

mapshaper -proj wgs84 -o out.json

If you then drag out.json to geojson.io, you'll get this:

enter image description here

5
  • Thanks for checking. I get the same result, however if I export that file into a JSON file and try to use that in Power BI, the map doesn't load, leading me to believe that there's something wrong with the coordinates in the file. Maybe the problem might lie with Power BI, or maybe I'm not entirely understanding the may shape maps work. I'll do some more digging. Sep 29, 2023 at 19:15
  • 1
    Your are right, coordinates are obviously projected, not [lng, lat]. I'm not familiar with Mapshaper and couldn't find a way to force unprojected coordinates.
    – TomazicM
    Sep 29, 2023 at 19:27
  • What is projection of your original file from which you created shapefile?
    – TomazicM
    Sep 29, 2023 at 20:25
  • The projection of the original file was EPSG:28532 I believe, UTM zone 32 which is used in my region of Norway. I managed to find a solution, see my comment further down. Thank you for assisting me! Sep 29, 2023 at 20:32
  • See modified answer.
    – TomazicM
    Sep 30, 2023 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.