0

I'm trying to plot the boundaries of the localities of Brussels. The system of coordinates of my json file has to be converted to a longlat system to display the Polygons on Folium maps. The issue I get is that my coordinates are projected into the Pacific ocean. I guess it is probably due to the fact that the parameters I set are not the good ones. Please find below my code:

import json
import pyproj
import folium

# Load JSON file
with open("districts.json", "r") as f:
    data = json.load(f)

# Create a transformation object
in_proj = pyproj.Proj(proj='utm',zone=31,datum='WGS84')
out_proj = pyproj.Proj(proj='longlat',datum='WGS84')

# Transform the coordinates
features = data["features"]
for feature in features:
    coords = feature["geometry"]["coordinates"][0]
    coords = [pyproj.transform(in_proj, out_proj, coord[0], coord[1]) for coord in coords]
    feature["geometry"]["coordinates"] = [coords]

# Plot the polyggon on a map
m = folium.Map()
folium.GeoJson(data).add_to(m)
m

This corresponds to how my json file is structured:

{"type":"FeatureCollection","features":[{"geometry":{"type":"Polygon","coordinates":[[[152914.748398394,173305.19242333],[152947.4133984,173326.530423339],...,[152961.983398418,173225.325423267],[152914.748398394,173305.19242333]]]},...

(https://i.stack.imgur.com/SuU4Q.png) (https://i.stack.imgur.com/oIKJN.png)

Does anyone has an idea how to solve this? How could I find the right parameters?

I tried different zones but I would rather know of to find the right zone number and understand how it works.

0 Answers0