Feature #456

gmtspatial -Q need modifier to force line or polygon

Added by Paul over 3 years ago. Updated over 2 years ago.

Status:ClosedStart date:2013-12-05
Priority:NormalDue date:
Assignee:Paul% Done:

100%

Category:-
Target version:Candidate for next minor release
Platform:

Description

If the user has unclosed polygons (i.e., missing repeating point) then -Q will assume input is a line and compute length and mid-point, not area and centroid. I suggest we add a modifier +p or +l to the -Q option to force the input to either be automatically closed to a polygon (+p) or to be consider a line despite being possibly closed (+l).

History

#1 Updated by Paul over 3 years ago

  • Status changed from New to In Progress

This has now been implemented in branch 5.2 and seem to work.

#2 Updated by Florian over 3 years ago

It would be nice to exploit this functionality to transform a multisegment file with unclosed polygons into a sequence of polygons which are closed (separate option/feature), e.g.:

gmtspatial unclosedPolygons -L > closedPolygons

#3 Updated by Paul over 3 years ago

I wonder if that is more of a thing for gmtconvert? In general, GMT does not care if things are closed or not (e.g., psxy, grdmask, etc), but in gmtspatial -Q we made a decision to compute line lengths vs polygon area based on lines being closed/open. In that case a modifier is needed to override that automatic decision.
I suppose you want closed polygons for something outside of GMT? Otherwise I don't think it is necessary to explicitly do this.
GMT_Read_Data can be give a geometry (polygon) and then it automatically closes polygons when reading. So gmtconvert could take a new -F option or something and then on output those polygons would be closed. Or if you think this is really a needed geospatial operation then we could do it in gmtspatial I guess.

#4 Updated by Florian over 3 years ago

I wonder if that is more of a thing for gmtconvert?

Might as well. I don't mind.

I suppose you want closed polygons for something outside of GMT?

Right, I often convert to ESRI Shapefile or other formats and then I really have to make sure every Polygon is closed. Having this feature would make the process much easier.

So gmtconvert could take a new -F option or something and then on output those polygons would be closed.

Thanks, that would be great!

#5 Updated by Paul over 3 years ago

Second thought, does not gmtconnect inputfiles already do this for you? You could even specify your threshold with -T.

#6 Updated by Florian over 3 years ago

Second thought, does not gmtconnect inputfiles already do this for you? You could even specify your threshold with -T.

Not really: gmtconnect joins segments when start/endpoints are within a tolerance limit. This is undesired behavior.

#7 Updated by Paul over 3 years ago

Please clarify then. I thought the issue was that you have open polygons that you wish closed forcibly. Surely gmtconnect -T1e1000 would do that?

#8 Updated by Florian over 3 years ago

I thought the issue was that you have open polygons that you wish closed forcibly. Surely gmtconnect -T1e1000 would do that?

Then this gmtconnect feature is still undocumented. I will try...

#9 Updated by Paul almost 3 years ago

  • Status changed from In Progress to Resolved
  • Target version set to Candidate for next minor release
  • % Done changed from 0 to 100

In 5.2 branch, clarified that -T without any arguments will forcefully close every polygon.

#10 Updated by Paul over 2 years ago

  • Status changed from Resolved to Closed

Closing this issue as -T in 5.2 addresses this situation.

Also available in: Atom PDF