Skip to content

randomPolygon doesn't create Polygons in BBOX #1579

@gemo1011

Description

@gemo1011

I'm trying to create Polygons lying inside a specific BBOX, using @turf/random randomPolygon.
But the the Vertices of the Polygons are placed outside the BBOX.
Here my Code:

const random = require('@turf/random');
var polygon_5 = random.randomPolygon(5, {bbox: [8.3499527, 48.9791553, 8.4548033, 49.0402309]});
console.log(JSON.stringify(polygon_5))

And the output GEOJSON:
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[8.410435552232407,49.12182992410961],[8.430666301839237,49.11477653329593],[15.937824138751118,47.91988309354639],[9.839465128728557,48.391587353101436],[9.231092268136294,46.21017185678639],[6.577912938732337,45.60578706996851],[2.0719931029993583,41.611396013297956],[4.327288381451344,44.37348047171504],[5.692528516339682,49.62720191200328],[3.728838430479459,53.82300356740771],[8.410435552232407,49.12182992410961]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[17.122944606863562,53.518846740473485],[10.5965010655774,49.02007593136576],[16.441742517584586,47.440541939046184],[9.085366453645047,45.35710756863922],[8.904406154655486,45.84853290878585],[8.328633709603611,45.51464731020167],[0.09975614322928372,44.40355375919031],[-0.6014662122488481,47.82402794861627],[7.975556952956928,49.08060876078131],[-0.07364715712306769,53.32604516684321],[17.122944606863562,53.518846740473485]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[12.656519946593551,51.64732242564905],[9.898291876672365,49.400699834274754],[11.273461544531905,47.39983720457282],[8.306090493008929,42.85752305034545],[4.176261482058097,43.99688985520108],[5.45594293680991,45.79824918514274],[4.534943942494884,48.066451484526276],[7.647930877030042,49.38663820167861],[4.567296417864229,54.49339876840017],[6.04946364215073,54.65684312886992],[12.656519946593551,51.64732242564905]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[8.471006521737307,58.182691923328626],[10.819061295782193,53.19008318087975],[9.408550432871207,50.620211141769126],[12.03112636436479,50.28632996296014],[15.70839314938521,45.728995329469285],[8.601390596748157,45.01159896764774],[4.159502957594025,42.616887071703914],[1.778081947180599,48.285008044106696],[1.3468483468263672,49.98419467234629],[3.9894970965930554,54.59211700243788],[8.471006521737307,58.182691923328626]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[9.268591768716192,49.4994464082171],[17.398186144125248,46.47867608744711],[8.854505749648926,48.44010424633179],[10.256118362511188,45.753776347406166],[8.909326023007287,40.44664155325283],[7.621159512896644,40.574603081792546],[3.8598900820674604,41.58029234456838],[2.0198687059841216,49.422417970872175],[-0.6227360117173504,50.87599387847738],[7.844440241481954,49.92075997442101],[9.268591768716192,49.4994464082171]]]}}]}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions