NOTICE: help.openstreetmap.org is being shutdown on 1st March 2024. Please use the OpenStreetMap Community Forum

I am running this query on overpass-turbo

[out:json][timeout:25];
rel(223133);
(
  rel(r);
);
rel(1250951);

out geom;

and I have received this polygon.

enter image description here

but when I process this data my Image is like this :

enter image description here

I am using dot net core and this is my query

foreach (var m in geoElement.members)
{
    if (m is { type: "way", role: "outer" })
    {
        foreach (var g in m.geometry)
        {
            Coordinate coordinate = new Coordinate(g.lon, g.lat);
            coordinates.Add(coordinate);
        }
    }

}
var shell = new LinearRing(coordinates.ToArray());

var p = new Polygon(shell);
        var serializer = GeoJsonSerializer.Create();
        using var stringWriter = new StringWriter();
        using var jsonWriter = new JsonTextWriter(stringWriter);

        serializer.Serialize(jsonWriter, p);
        var geoJson = stringWriter.ToString();
        return geoJson;

First I added all geometries lat and lng into a coordinate list and finally, I make a polygon and at the end I make a GeoJson.

can someone guild me on what tips exist here?

I downloaded GeoJson file from Overpass and I checked with my made GeoJson.there is so different from points. I don't know why? how can I make GeoJson like an overpass downloaded file?

asked 30 Apr '23, 19:00

alt2020's gravatar image

alt2020
11335
accept rate: 0%

First off, this query will return the same data as yours:

[out:json];
rel(1250951);
out geom;

I've used a couple of osmtogeojson converters & they all output as expected. Is GeoJsonSerializer an internal command?

(30 Apr '23, 20:14) DaveF

(following on from the conversation elsewhere)

I think that you're assuming that your "foreach" will get you the OSM ways in the "correct" order (sequentially around the relation). This isn't guaranteed. There is probably some multipolygon code out there for your language; I'd be tempted to borrow from that :)

(30 Apr '23, 20:21) SomeoneElse ♦

Did u get the correct answer? @DaveF

(30 Apr '23, 22:17) alt2020

the output of query, first geometry is "geometry": [ { "lat": 38.2591626, "lon": 33.1844776 }, but if u download Geojson the first coordinate is [ 33.0320818, 38.1524781 ], . as you can see there is a difference here @DaveF

(30 Apr '23, 22:22) alt2020
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×483
×36
×2

question asked: 30 Apr '23, 19:00

question was seen: 569 times

last updated: 30 Apr '23, 22:22

NOTICE: help.openstreetmap.org is being shutdown on 1st March 2024. Please use the OpenStreetMap Community Forum