Skip to main content
Solved

GEoJSON geometry replacement issue.

  • September 11, 2018
  • 5 replies
  • 54 views

amolparande
Forum|alt.badge.img+1

Hello everyone ,

I have two JSON files

1. RoadElement.json

2. WaterArea.json

I want to create geometry from each JSON file that would be polyline

& Polygon features

I have also created FME workbench but could not able to

create Geometry having some problem can any one help me what is wrong?

Please find attached JSON file and created Workbench

Best answer by nielsgerrits

I think the data doesn't validate as correct GeoJSON.

The structure for a polygon feature should be:

{
    "type": "Polygon",
    "coordinates": [
        [
            [
                100,
                0
            ],
            [
                101,
                0
            ],
            [
                101,
                1
            ],
            [
                100,
                1
            ],
            [
                100,
                0
            ]
        ]
    ]
}

Where a piece in waterarea.json is:

{
	"type": "coordinates",
	"coordinates": [[145.71758,
	-30.83595],
	[145.71769,
	-30.83532],
	[145.71895,
	-30.8348],
	[145.72022,
	-30.83381],
	[145.72158,
	-30.83383],
	[145.72241,
	-30.83428],
	[145.72374,
	-30.83646],
	[145.72404,
	-30.83773],
	[145.72403,
	-30.83846],
	[145.72028,
	-30.83697],
	[145.71872,
	-30.83623],
	[145.71758,
	-30.83595]]
}

Issues are:

  • type should be Polygon, not coordinates (case sensitive!)
  • the array of coordinates should be nested one level deeper (rings, ring, coordinatepairs)
  • polygons should follow the right-hand rule (exterior rings are counter clockwise, interior rings / holes are clockwise)

See the spec.

This works for me:

{
	"type": "Polygon",
	"coordinates": [[[145.71758,
	-30.83595],
	[145.71872,
	-30.83623],
	[145.72028,
	-30.83697],
	[145.72403,
	-30.83846],
	[145.72404,
	-30.83773],
	[145.72374,
	-30.83646],
	[145.72241,
	-30.83428],
	[145.72158,
	-30.83383],
	[145.72022,
	-30.83381],
	[145.71895,
	-30.8348],
	[145.71769,
	-30.83532],
	[145.71758,
	-30.83595]]]
}
View original
Did this help you find an answer to your question?

5 replies

nielsgerrits
VIP
Forum|alt.badge.img+53
  • Best Answer
  • September 11, 2018

I think the data doesn't validate as correct GeoJSON.

The structure for a polygon feature should be:

{
    "type": "Polygon",
    "coordinates": [
        [
            [
                100,
                0
            ],
            [
                101,
                0
            ],
            [
                101,
                1
            ],
            [
                100,
                1
            ],
            [
                100,
                0
            ]
        ]
    ]
}

Where a piece in waterarea.json is:

{
	"type": "coordinates",
	"coordinates": [[145.71758,
	-30.83595],
	[145.71769,
	-30.83532],
	[145.71895,
	-30.8348],
	[145.72022,
	-30.83381],
	[145.72158,
	-30.83383],
	[145.72241,
	-30.83428],
	[145.72374,
	-30.83646],
	[145.72404,
	-30.83773],
	[145.72403,
	-30.83846],
	[145.72028,
	-30.83697],
	[145.71872,
	-30.83623],
	[145.71758,
	-30.83595]]
}

Issues are:

  • type should be Polygon, not coordinates (case sensitive!)
  • the array of coordinates should be nested one level deeper (rings, ring, coordinatepairs)
  • polygons should follow the right-hand rule (exterior rings are counter clockwise, interior rings / holes are clockwise)

See the spec.

This works for me:

{
	"type": "Polygon",
	"coordinates": [[[145.71758,
	-30.83595],
	[145.71872,
	-30.83623],
	[145.72028,
	-30.83697],
	[145.72403,
	-30.83846],
	[145.72404,
	-30.83773],
	[145.72374,
	-30.83646],
	[145.72241,
	-30.83428],
	[145.72158,
	-30.83383],
	[145.72022,
	-30.83381],
	[145.71895,
	-30.8348],
	[145.71769,
	-30.83532],
	[145.71758,
	-30.83595]]]
}

amolparande
Forum|alt.badge.img+1
  • Author
  • September 11, 2018
nielsgerrits wrote:

I think the data doesn't validate as correct GeoJSON.

The structure for a polygon feature should be:

{
    "type": "Polygon",
    "coordinates": [
        [
            [
                100,
                0
            ],
            [
                101,
                0
            ],
            [
                101,
                1
            ],
            [
                100,
                1
            ],
            [
                100,
                0
            ]
        ]
    ]
}

Where a piece in waterarea.json is:

{
	"type": "coordinates",
	"coordinates": [[145.71758,
	-30.83595],
	[145.71769,
	-30.83532],
	[145.71895,
	-30.8348],
	[145.72022,
	-30.83381],
	[145.72158,
	-30.83383],
	[145.72241,
	-30.83428],
	[145.72374,
	-30.83646],
	[145.72404,
	-30.83773],
	[145.72403,
	-30.83846],
	[145.72028,
	-30.83697],
	[145.71872,
	-30.83623],
	[145.71758,
	-30.83595]]
}

Issues are:

  • type should be Polygon, not coordinates (case sensitive!)
  • the array of coordinates should be nested one level deeper (rings, ring, coordinatepairs)
  • polygons should follow the right-hand rule (exterior rings are counter clockwise, interior rings / holes are clockwise)

See the spec.

This works for me:

{
	"type": "Polygon",
	"coordinates": [[[145.71758,
	-30.83595],
	[145.71872,
	-30.83623],
	[145.72028,
	-30.83697],
	[145.72403,
	-30.83846],
	[145.72404,
	-30.83773],
	[145.72374,
	-30.83646],
	[145.72241,
	-30.83428],
	[145.72158,
	-30.83383],
	[145.72022,
	-30.83381],
	[145.71895,
	-30.8348],
	[145.71769,
	-30.83532],
	[145.71758,
	-30.83595]]]
}
Thank you for replay 

 

What is Wrong with Roadelement.json ?

 

 


nielsgerrits
VIP
Forum|alt.badge.img+53
amolparande wrote:
Thank you for replay

 

What is Wrong with Roadelement.json ?

 

 

Also doesn't follow the spec. The type should be LineString, not coordinates. Just test the part in a online validator like http://geojsonlint.com/

takashi
Contributor
Forum|alt.badge.img+23
  • Contributor
  • September 11, 2018
nielsgerrits wrote:

I think the data doesn't validate as correct GeoJSON.

The structure for a polygon feature should be:

{
    "type": "Polygon",
    "coordinates": [
        [
            [
                100,
                0
            ],
            [
                101,
                0
            ],
            [
                101,
                1
            ],
            [
                100,
                1
            ],
            [
                100,
                0
            ]
        ]
    ]
}

Where a piece in waterarea.json is:

{
	"type": "coordinates",
	"coordinates": [[145.71758,
	-30.83595],
	[145.71769,
	-30.83532],
	[145.71895,
	-30.8348],
	[145.72022,
	-30.83381],
	[145.72158,
	-30.83383],
	[145.72241,
	-30.83428],
	[145.72374,
	-30.83646],
	[145.72404,
	-30.83773],
	[145.72403,
	-30.83846],
	[145.72028,
	-30.83697],
	[145.71872,
	-30.83623],
	[145.71758,
	-30.83595]]
}

Issues are:

  • type should be Polygon, not coordinates (case sensitive!)
  • the array of coordinates should be nested one level deeper (rings, ring, coordinatepairs)
  • polygons should follow the right-hand rule (exterior rings are counter clockwise, interior rings / holes are clockwise)

See the spec.

This works for me:

{
	"type": "Polygon",
	"coordinates": [[[145.71758,
	-30.83595],
	[145.71872,
	-30.83623],
	[145.72028,
	-30.83697],
	[145.72403,
	-30.83846],
	[145.72404,
	-30.83773],
	[145.72374,
	-30.83646],
	[145.72241,
	-30.83428],
	[145.72158,
	-30.83383],
	[145.72022,
	-30.83381],
	[145.71895,
	-30.8348],
	[145.71769,
	-30.83532],
	[145.71758,
	-30.83595]]]
}

@nielsgerrits is right. The format of the JSON documents are similar to GeoJSON, but not GeoJSON. However, you can reconstruct them into the GeoJSON format with some JSON transformers.

 

Example: reconstruct-geojson-example.fmwt (FME 2018.1.0.0)

 

Hope this helps.


jnotter
Contributor
Forum|alt.badge.img+5
  • Contributor
  • January 29, 2020
takashi wrote:

@nielsgerrits is right. The format of the JSON documents are similar to GeoJSON, but not GeoJSON. However, you can reconstruct them into the GeoJSON format with some JSON transformers.

 

Example: reconstruct-geojson-example.fmwt (FME 2018.1.0.0)

 

Hope this helps.

I wish I could vote up this particular comment, @takashi. I think this example is what I need to get my data into MapBoxGL-compatible format to color thematic each feature individually. MapBox(leaflet) within HTMLReportGenerator fails to allow the individual formatting capability.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings