I just want to convert OSM data to GeoJSON where it is pretty simple with node and way tags of OSM data, but relation which is giving complex can't find the logic to convert OSM relation to GeoJSON format, especially how to form coordinates parameter of GeoJSON based on their relation member roles (ex. Inner, outer,admin_centre,riverbank,side_stream,main_stream,from,via,to,forward,backward,stop_entry_only,stop_exit_only and platform_exit_only).

I have tried many documentation but no logics or code found in Java and Python.

In Python https://pypi.org/project/osm2geojson/ osm Official https://wiki.openstreetmap.org geojson Official https://geojson.org/ sample data: https://download.geofabrik.de/asia/maldives-latest.osm.bz2 https://download.geofabrik.de/asia/bhutan-latest.osm.pbf

As simple, how to form relation member's latitude and longitude in coordinates parameter of GeoJSON based on their roles?

EXample code

public void processRelations() {
    try {
        LineIterable lineIterable = LineIterable.openGzipFile(dir + OsmJoin.REL_ID_COMPLETE_JSON);
        try (JsonWriter writer = createJsonWriter(OsmType.RELATION)) {
            Processor<String, JsonObject> p = compose(entryParsingProcessor, jsonParsingProcessor, new Processor<JsonObject, JsonObject>() {
                @Override
                public JsonObject process(JsonObject input) {
                    // FIXME see if we can extract some useful things from relations                       
                    return null;
                }
            });
            try (ConcurrentProcessingIterable<String, JsonObject> concIt = processConcurrently(lineIterable, p, 10, 9, 100)) {
                for (JsonObject o : concIt) {
                    if (o != null) {
                        writer.add(o);
                    }
                }
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}

I have tried in Java and Python but reason is I could not find the logic behind the conversion of the relation tags from OSM to GeoJSON

I am expecting the logic behind the conversion of the relation tags from OSM to GeoJSON and sample code for that.

asked 20 May, 12:16

jaye19's gravatar image

jaye19
2112
accept rate: 0%

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:

×552
×219
×25
×18
×2

question asked: 20 May, 12:16

question was seen: 253 times

last updated: 20 May, 12:16

powered by OSQA