Skip to main content
Question

Transform a coordinates array into a polygon


arnaud974
Contributor
Forum|alt.badge.img+3

Hi,

 

I've downloaded a json file that contains geometries defined as an array of coordinates. A portion of this json file is described below. One json feature can have one or more geometries. I can't find the proper way to parse this json file and transform this array of coordinates to a polygon.

 

Do you have any solution ? 

 

Thanks for your help.

{
			"identifier" : "2",
			"country" : "REU",
			"name" : "[FM][D 2] La grande montée/Plaine des cafres",
			"type" : "COMMON",
			"restriction" : "PROHIBITED",
			"restrictionConditions" : "",
			"region" : 931,
			"reason" : "OTHER" ],
			"otherReasonInfo" : "Zone dangereuse",
			"regulationExemption" : "",
			"uSpaceClass" : "",
			"message" : "Vols interdits sauf lorsque la publication d'information aéronautique l'autorise explicitement ou avec l'accord du gestionnaire de la zone lorsqu'il est désigné par l'information aéronautique",
			"applicability" : [],
			"zoneAuthority" : [
				{
					"name" : "Autorité mentionnée en ENR 5.1 de l’AIP",
					"service" : "",
					"email" : "",
					"contactName" : "",
					"siteURL" : "",
					"phone" : "",
					"purpose" : "",
					"intervalBefore" : ""
				}
			],
			"geometry" : [
				{
					"uomDimensions" : "M",
					"lowerLimit" : 0,
					"lowerVerticalReference" : "AGL",
					"upperLimit" : 213.36,
					"upperVerticalReference" : "AGL",
					"horizontalProjection" : {
						"type" : "Polygon",
						"coordinates" : [
							[
								[ 55.591667, -21.161667 ],
								[ 55.590278, -21.184167 ],
								[ 55.635278, -21.187222 ],
								[ 55.634444, -21.164722 ],
								[ 55.591667, -21.161667 ]
							]
						]
					}
				},
				{
					"uomDimensions" : "M",
					"lowerLimit" : 213.36,
					"lowerVerticalReference" : "AGL",
					"upperLimit" : 2987.08,
					"upperVerticalReference" : "AGL",
					"horizontalProjection" : {
						"type" : "Polygon",
						"coordinates" : [
							[
								[ 55.591667, -21.161667 ],
								[ 55.590278, -21.184167 ],
								[ 55.635278, -21.187222 ],
								[ 55.634444, -21.164722 ],
								[ 55.591667, -21.161667 ]
							]
						]
					}
				}
			]
		}

2 replies

ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • July 28, 2022

If you want to extract the geometry information from the fragment displayed here you can use a JSONFragmenter with

json["geometry"][*]

This will give you two features with an attribute called horiztonalProjection containing the 2d geometry. You will need to expose this attribute. You can then use this attribute in a GeometryReplacer with Geometry Encoding GeoJSON to build the geometry. The other attributes e.g. lowerLimit will also be populated but you will also need to expose them

 

Depending on what want to do with other data contained within the file there may be better ways to process the file


arnaud974
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • August 3, 2022

Hi,

 

@ebygomm​ , thanks for your help.

Agter extracting the array of coordinates I was able to create a geojson geometry with the help of the GeometryReplacer Transformer !

 

Thanks again.


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