phayes / geoPHP

Advanced geometry operations in PHP
https://geophp.net
Other
864 stars 263 forks source link

How to get area of multi-polygon in sqm or sqft? #131

Open srdealx opened 8 years ago

srdealx commented 8 years ago

Have tried

$poly1 = $geoPHP::load('{"type":"MultiPolygon","coordinates":[[[[-1.0137969378591,52.202544044576],[-1.0227841621677,52.202544044576],[-1.0227841621677,52.202743845076],[-1.0171658688845,52.216532032132],[-0.84809702671577,52.147116857692],
...
[-0.84809702671577,52.143126711571],[-0.85214659162944,52.143126711571],[-0.85214659162944,52.142544784464],[-0.85384716032767,52.142544784464],[-0.85384716032767,52.14221537165],[-0.85837185867233,52.14221537165],[-0.85837185867233,52.142544784464],[-0.86547087877056,52.142544784464]]]]}', 'json');
$poly1->getArea();
$poly1->SRID(27700); // also tried 81989
$poly1->getArea();

But only get the area in sqcoords.

BathoryPeter commented 8 years ago

GeoPHP cannot transform between SRIDs. If your geometry is in geographical coordinate system (latlon, or EPSG:4326), the area will be in square degrees.