Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculating total area of a map #10

Closed
jywarren opened this issue Sep 14, 2011 · 2 comments
Closed

calculating total area of a map #10

jywarren opened this issue Sep 14, 2011 · 2 comments

Comments

@jywarren
Copy link
Owner

Some notes and starter code for this:

start by merging polygons and discarding all but exterior, largest poly?

dunno how to do that... missing step


If you want to do this with a more "GIS" flavor, then you need to select an unit-of-measure for your area and find an appropriate projection that preserves area (not all do). Since you are talking about calculating an arbitrary polygon, I would use something like a Lambert Azimuthal Equal Area projection. Set the origin/center of the projection to be the center of your polygon, project the polygon to the new coordinate system, then calculate the area using standard planar techniques.

http://mathworld.wolfram.com/LambertAzimuthalEqual-AreaProjection.html

PROJ4.js: (support was added for Lambert Azimuthal Equal Area projection (proj=laea, ported from PROJ.4))
http://proj4js.org/

-- how to get the result of Lambert proj in meters?

proj_laea=Proj("+proj=laea +lat_0=55n +lon_0=20e +x_0=0.0 +y_0=0.0 +units=m")
proj_latlon=Proj("+proj=latlon")
transform(proj, Proj("+proj=latlon" ), 9999000, 8000000)


Proj4js.defs["EPSG:27563"]="+title=LAMB sud france +proj=lcc +lat_1=44.1 +lat_0=44.1 +lon_0=0 +k_0=0.999877499
+x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";

Proj4js.defs["EPSG:????"]="+title=???? +proj=laea +lat_0=55n +lon_0=20e +x_0=0.0 +y_0=0.0 +units=m";
Proj4js.defs["EPSG:8008"]="+title=LAMB azimuthal equal area +proj=laea +lat_0=55n +lon_0=20e +x_0=0.0 +y_0=0.0 +units=m";


// include the library

<script src="lib/proj4js-combined.js"></script> //adjust the path for your server

// not sure about this, trying to define custom projection at 55 N 20 E... center of polygon, using meters
// Proj4js.defs["EPSG:8008"]="+title=LAMB azimuthal equal area +proj=laea +lat_0=55n +lon_0=20e +x_0=0.0 +y_0=0.0 +units=m";

// creating source and destination Proj4js objects
// once initialized, these may be re-used as often as needed
var source = new Proj4js.Proj(‘EPSG:4236’); //source coordinates will be in Longitude/Latitude
var dest = new Proj4js.Proj(‘EPSG:27563’); //destination coordinates in LCC, south of France

// transforming point coordinates
var p = new Proj4js.Point(-76.0,45.0); //any object will do as long as it has 'x' and 'y' properties
Proj4js.transform(source, dest, p); //do the transformation. x and y are modified in place

//p.x and p.y are now EPSG:27563 easting and northing in meters


Then use Geometry.poly_area() in Cartagen, result in meters, unsigned probably.

@jywarren
Copy link
Owner Author

Rough version: pixel resolution squared times summed pixel area of images

Use poly_area from Cartagen: https://github.com/jywarren/cartagen/blob/master/public/cartagen/src/util/geometry.js

@jywarren
Copy link
Owner Author

this would be cool but is not in high demand and would be better done as a Leaflet plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant