[mapguide-dev] area calculation conversion to meters

Traian Stanev traian.stanev at autodesk.com
Sun Dec 3 23:42:55 EST 2006


 
Why don't you just use the formula Orest posted to find the nearest meridian for a UTM zone?
 
I imagine it's possible to take the WKT string for a UTM Zone projection and replace the "central_meridian" value by what you need, but that approach would have to be checked empirically to see if Proj likes it.
 
Traian 
 

	-----Original Message----- 
	From: Paul Spencer (External) 
	Sent: Sun 12/3/2006 10:42 PM 
	To: dev at mapguide.osgeo.org 
	Cc: 
	Subject: Re: [mapguide-dev] area calculation conversion to meters
	
	

	over my head, for sure!  I don't think I need that kind of accuracy.  
	I would like to know if there is a programmatic way to determine a 
	UTM coordinate system centered on a particular location or, as a 
	minimum, a way to find the UTM zone that a given coordinate lies in.
	
	Is there some base string I could use and just substitute in some 
	values?
	
	Cheers
	
	Paul
	
	On 3-Dec-06, at 3:49 PM, Traian Stanev wrote:
	
	>
	> Right, I forgot about state planes. Those would have a central 
	> meridian that's closer to the data.
	>
	> For distance computations, MapGuide has great circle distance 
	> functions. Another resource for great circle I've used is here:
	>
	> http://www.codeguru.com/Cpp/Cpp/algorithms/article.php/c5115
	>
	>
	> The relevant section about a very accurate distance approximation 
	> on the ellipsoid is at the bottom of the page:
	>
	> ==================================================
	> double ApproxDistance(double lat1, double lon1, double lat2,
	>                       double lon2)
	> {
	>    lat1 = GEO::DE2RA * lat1;
	>    lon1 = -GEO::DE2RA * lon1;
	>    lat2 = GEO::DE2RA * lat2;
	>    lon2 = -GEO::DE2RA * lon2;
	>
	>    double F = (lat1 + lat2) / 2.0;
	>    double G = (lat1 - lat2) / 2.0;
	>    double L = (lon1 - lon2) / 2.0;
	>
	>    double sing = sin(G);
	>    double cosl = cos(L);
	>    double cosf = cos(F);
	>    double sinl = sin(L);
	>    double sinf = sin(F);
	>    double cosg = cos(G);
	>
	>    double S = sing*sing*cosl*cosl + cosf*cosf*sinl*sinl;
	>    double C = cosg*cosg*cosl*cosl + sinf*sinf*sinl*sinl;
	>    double W = atan2(sqrt(S),sqrt(C));
	>    double R = sqrt((S*C))/W;
	>    double H1 = (3 * R - 1.0) / (2.0 * C);
	>    double H2 = (3 * R + 1.0) / (2.0 * S);
	>    double D = 2 * W * GEO::ERAD;
	>    return (D * (1 + GEO::FLATTENING * H1 * sinf*sinf*cosg*cosg -
	>    GEO::FLATTENING*H2*cosf*cosf*sing*sing));
	> }
	> =======================================
	>
	>
	> Traian
	>
	> -----Original Message-----
	> From:   Orest Halustchak
	> Sent:   Sun 12/3/2006 2:33 PM
	> To:     dev at mapguide.osgeo.org
	> Cc:
	> Subject:        RE: [mapguide-dev] area calculation conversion to 
	> meters
	>
	> Hi,
	>
	> Yes, converting to a UTM zone would work. However, if the original 
	> data is in the US, e.g. Sheboygan, you could project to the 
	> corresponding State Plane zone. Then you could do length and area 
	> calculations more accurately.
	>
	> For UTM, central meridian = zone*6 -183.
	>
	> For lat/long data, the correct way to compute length is on the 
	> spheroid. Libraries such as Proj4 or Mentor include distance 
	> calculation functions based on a particular spheroid. Most 
	> libraries unfortunately do not include an area calculation on the 
	> spheroid.
	>
	> Orest.
	>
	> -----Original Message-----
	> From: Paul Spencer (External)
	> Sent: Sun 12/3/2006 2:11 PM
	> To: dev at mapguide.osgeo.org
	> Cc:
	> Subject: Re: [mapguide-dev] area calculation conversion to meters
	>
	>
	>
	> Thanks Traian, it hurts my head too!  All calculations will be
	> advertised as approximate, but I'd like them to be close to reality.
	>
	> How can I construct a UTM coordinate system definition centered
	> around the meridian that crosses the centroid of the feature?  Or
	> find the UTM Zone projection that contains the centroid of a feature
	> (I manually found it for the Sheboygan data and it gave decent
	> results)?  Would I need to manually build an array of UTM Zone -> LL
	> mappings?
	>
	> Cheers
	>
	> Paul
	>
	>
	> On 3-Dec-06, at 12:58 PM, Traian Stanev wrote:
	>
	> > I'm far from an expert either, but here is what makes sense to me...
	> >
	> > The simplest solution to me seems to transform to the nearest UTM
	> > Zone projection in meters and compute the area of the resulting
	> > geometry. I think this will be accurate enough for what you are
	> > doing, since it is very likely that the original data (for
	> > Sheboygan) was measured in that UTM zone and then converted to
	> > LatLon after the fact anyway. That's why it seems to me that this
	> > approach will give you exact results, even though in theory it is
	> > not exact (since the data can be far away from the UTM Zone's
	> > central meridian).
	> >
	> > Another, more generic approach, that would be good for small
	> > features, would be to construct a UTM coordinate system definition
	> > centered around the meridian that crosses the centroid of the
	> > feature. This will give you an LL-UTM transformation with the least
	> > distortion for the feature at hand.
	> >
	> > My hunch is that computing an exact area on the ellipsoid without
	> > projection involves elliptical integrals, since even the area of a
	> > whole ellipsoid involves those. Elliptic integrals have no closed
	> > form solution so you would need a numerical integration approach,
	> > which hurts my head even thinking about it.
	> >
	> >
	> > Traian
	> >
	> >
	> >
	> >
	> > -----Original Message-----
	> > From: Paul Spencer (External)
	> > Sent: Sat 12/2/2006 12:04 PM
	> > To: dev at mapguide.osgeo.org
	> > Cc:
	> > Subject: Re: [mapguide-dev] area calculation conversion to meters
	> >
	> > Trevor,
	> >
	> > That would work for GetLength() but I wonder if you need to adjust
	> > for latitude as well ... and it doesn't work for area.  I pondered
	> > doing this for the square root of the area and then squaring the
	> > result ... I think that would work, but again it would have to be
	> > adjusted for the latitude ... or am I over-engineering this?
	> >
	> > Paul
	> >
	> > On 1-Dec-06, at 4:10 PM, Trevor Wekel wrote:
	> >
	> > > Hi Paul,
	> > >
	> > > For the most general case, I think you're on the right track.
	> > Most of
	> > > the geometry classes support the Transform() operation.  The
	> > > MgCoordinateSystemTransform allows transformation from one
	> > coordinate
	> > > system to another.  I'm not a coordinate system expert but from
	> > what I
	> > > understand most coordinate systems projections have an accurate
	> > sweet
	> > > spot in the center and become more inaccurate around the edges.  I
	> > > wonder if there is a programmatic way to determine the
	> > appropriateness
	> > > of the target system?  Possibly based on center point of the
	> > > projection?
	> > >
	> > > But if your target system is in decimal degrees, doesn't that
	> > imply a
	> > > direct mapping to the world space?  Isn't a decimal degree some
	> > number
	> > > of meters?  Could you just use
	> > > MgCoordinateSystem::ConvertCoordinateSystemUnitsToMeters(double
	> > units)
	> > > as the conversion factor?  I suspect this may also work in the 
	> sweet
	> > > spot of projected systems as well.
	> > >
	> > > Thanks,
	> > > Trevor
	> > >
	> > > -----Original Message-----
	> > > From: Paul Spencer (External)
	> > > Sent: Thursday, November 30, 2006 3:03 PM
	> > > To: dev at mapguide.osgeo.org
	> > > Subject: [mapguide-dev] area calculation conversion to meters
	> > >
	> > > Hi all,
	> > >
	> > > I'm measuring the area and length of features using
	> > > MgGeometricEntity::GetArea() and GetLength() in the Sheboygan 
	> data.
	> > > This returns values in the units of the projection, which happens
	> > > to be
	> > > decimal degrees.  Not so useful.  I'd like the result to be in
	> > meters.
	> > >
	> > > Since this code needs to be generic, I've implemented some 
	> stuff to
	> > > transform the geometry into a coordinate system that supports
	> > meters.
	> > > This is not too accurate since I arbitrarily picked a World LCC
	> > > projection wkt :)
	> > >
	> > > What is the recommended way of doing this calculation?
	> > >
	> > > Cheers
	> > >
	> > > Paul
	> > >
	> > > 
	> +-----------------------------------------------------------------+
	> > > |Paul Spencer                          
	> pspencer at dmsolutions.ca    |
	> > > 
	> +-----------------------------------------------------------------+
	> > > |Chief Technology 
	> Officer                                         |
	> > > |DM Solutions Group Inc                http://
	> www.dmsolutions.ca/ |
	> > > 
	> +-----------------------------------------------------------------+
	> > >
	> > >
	> > >
	> > >
	> > >
	> > >
	> > 
	> ---------------------------------------------------------------------
	> > > To unsubscribe, e-mail: dev-unsubscribe at mapguide.osgeo.org
	> > > For additional commands, e-mail: dev-help at mapguide.osgeo.org
	> > >
	> > >
	> > >
	> > >
	> > 
	> ---------------------------------------------------------------------
	> > > To unsubscribe, e-mail: dev-unsubscribe at mapguide.osgeo.org
	> > > For additional commands, e-mail: dev-help at mapguide.osgeo.org
	> > >
	> >
	> > +-----------------------------------------------------------------+
	> > |Paul Spencer                          pspencer at dmsolutions.ca    |
	> > +-----------------------------------------------------------------+
	> > |Chief Technology Officer                                         |
	> > |DM Solutions Group Inc                http://www.dmsolutions.ca/ |
	> > +-----------------------------------------------------------------+
	> >
	> >
	> >
	> >
	> >
	> > 
	> ---------------------------------------------------------------------
	> > To unsubscribe, e-mail: dev-unsubscribe at mapguide.osgeo.org
	> > For additional commands, e-mail: dev-help at mapguide.osgeo.org
	> >
	> >
	>
	> +-----------------------------------------------------------------+
	> |Paul Spencer                          pspencer at dmsolutions.ca    |
	> +-----------------------------------------------------------------+
	> |Chief Technology Officer                                         |
	> |DM Solutions Group Inc                http://www.dmsolutions.ca/ |
	> +-----------------------------------------------------------------+
	>
	>
	>
	>
	>
	> ---------------------------------------------------------------------
	> To unsubscribe, e-mail: dev-unsubscribe at mapguide.osgeo.org
	> For additional commands, e-mail: dev-help at mapguide.osgeo.org
	>
	>
	>
	
	+-----------------------------------------------------------------+
	|Paul Spencer                          pspencer at dmsolutions.ca    |
	+-----------------------------------------------------------------+
	|Chief Technology Officer                                         |
	|DM Solutions Group Inc                http://www.dmsolutions.ca/ |
	+-----------------------------------------------------------------+
	
	
	
	
	
	---------------------------------------------------------------------
	To unsubscribe, e-mail: dev-unsubscribe at mapguide.osgeo.org
	For additional commands, e-mail: dev-help at mapguide.osgeo.org
	
	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-internals/attachments/20061203/2f2f1585/attachment.html


More information about the Mapguide-internals mailing list