Message Boards Message Boards

0
|
5870 Views
|
3 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Get a region from a filled curve?

Posted 4 years ago

I have a closed curve, say:

curve = BSplineCurve[{{-0.1, -0.2}, {0.9, 
     1.1}, {0.9, -1.2}, {-0.8, -1.2}, {-1.1, 1.1}, {-0.1, -0.2}}, 
   SplineClosed -> True];
Graphics[curve, Axes -> True, ImageSize -> Small]

enter image description here

I want to build a Region from its interior.

At first I build a filled curve:

filledcurve = FilledCurve[{curve}];
Graphics[{Lighter[Gray], filledcurve}, Axes -> True,ImageSize->Small]

enter image description here

..., which is not yet a Region:

RegionQ[filledcurve]
False

How can I get a Region from filledcurve? Region[filledcurve] does not work. It is "not a correctly specified region":

Region[filledcurve]
During evaluation of In[321]:= Region::reg: FilledCurve[{BSplineCurve[{{-0.1,-0.2},{0.9,1.1},{0.9,-1.2},{-0.8,-1.2},{-1.1,1.1},{-0.1,-0.2}},SplineClosed->True]}] 
is not a correctly specified region.
POSTED BY: Werner Geiger
3 Replies

I had a similar problem.
x11002 is a mixed list {Polygon....,{Polygon,...},FilledCurve...} describing sectors of a city. Coming from an SHP import. I wanted to get only the shape of to the contour of the city.

x11002a = 
 OuterPolygon[
  RegionUnion[
   Flatten[x11002] /. {FilledCurve[b__] :> 
      BoundaryDiscretizeGraphics@FilledCurve[b]}]]

x1102a is only the city contour

Attachment

Attachment

POSTED BY: Chris Van Damme
Posted 4 years ago

Hi Werner,

Is this what you are looking for?

r = Region@BoundaryDiscretizeGraphics@curve
RegionQ@r
(* True *)

enter image description here

POSTED BY: Rohit Namjoshi
Posted 4 years ago

Thanks a lot, Rohit. This works. I wonder that it works with curve (instead of filledcurve). The documentation says it renders full-dimensional parts of Graphics only. But curve has dimension 1, not 2.

Anyway. It works. Thanks again.

POSTED BY: Werner Geiger
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract