Skip to main content
Question

How can I turn an attribute (bunch of coordinates) into an object (polygon)?

  • November 6, 2017
  • 4 replies
  • 50 views

Hey folks,

 

I'm in a bit of a trouble. The readout of an xml file gives me an attribute that contains coordinates.

 

The attribute's content is like this:

'47.609703,9.858943 47.620427,9.867245 47.613033,9.92076 47.600331,9.930115 47.612142,9.960663 47.61008,9.972698 47.631773,9.980192 47.609703,9.858943 47.609703,9.858943'

Please be aware that i shortend the count of numbers.

All I am trying is to build a polygon with these coordinates to write an Esri shapefile.

The PolygonBuilder/AreaBuilder won't help because it needs polylines to work with.

 

Thanks you so much,

Ed

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • November 6, 2017

The GeometryReplacer can do this for you after you format the string to match a WKT.


jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • November 6, 2017

If you rebuild the GML you can use a geometryReplacer

 

 

<gml:Polygon>   <gml:exterior>     <gml:LinearRing>       <gml:coordinates>@Value(_coord)</gml:coordinates>     </gml:LinearRing>   </gml:exterior> </gml:Polygon>

mark2atsafe
Safer
Forum|alt.badge.img+56
  • Safer
  • 2554 replies
  • November 6, 2017

I'd first try one of the GeometryReplacer suggestions, or just use the GML reader, which I think might pull geometry out of any XML file.

The long way around would be to use an AttributeSplitter to split the attribute at each space character, a ListExploder, SubstringExtractors (to get out each x/y), and a VertexCreator to turn those values into points. Then a PointConnector.

But there shouldn't be a need to self-parse XML like that. I feel sure you'll be able to handle the content directly in a much easier way.


erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • November 6, 2017

The GeometryReplacer can do this for you after you format the string to match a WKT.

Syntax of WKT for polygon:

 

POLYGON ((@Value(_coords)))

 

will result in:

 

POLYGON ((47.609703,9.858943 47.620427,9.867245 47.613033,9.92076 47.600331,9.930115 47.612142,9.960663 47.61008,9.972698 47.631773,9.980192 47.609703,9.858943 47.609703,9.858943)))