Understanding and Using Geometry, Projections, and Spatial Reference Systems in ArcGIS Annette Locke, Rob Juergens
Introduction We present fundamental concepts necessary for the correct and efficient use of geometry and spatial reference APIs Spatial references and their properties Geometry types Geometry operators ArcGIS Server Geometry Service What s new at 10.1?
The Spatial Reference
Spatial references Spatial references in ArcGIS define these key properties: Coordinate system (projection) Coordinate resolution grid Cluster tolerances In addition, geographic transformations move coordinates between different earth models
Coordinate system objects Projected (PCS) Geographic (GCS) Vertical (VCS) Unknown (UCS) Units - Linear and Angular Geographic (datum) transformations
Coordinate System Projected Coordinate System Geographic Coordinate System Projection Projection Parameters Linear Unit Datum Spheroid Prime Meridian Angular Unit
Well-Known Text string GEOGCS[ "GCS_WGS_1984", DATUM[ "D_WGS_1984", SPHEROID[ "WGS_1984", 6378137.0, 298.257223563] ], PRIMEM[ "Greenwich", 0.0], UNIT[ "Degree", 0.0174532925199433] ], Read/write these strings via IESRISpatialReferenceGEN2
Well-Known Text string PROJCS[ Mercator_Auxiliary_Sphere", GEOGCS[ "GCS_WGS_1984", DATUM[ "D_WGS_1984", SPHEROID[ "WGS_1984", 6378137.0, 298.257223563] ], PRIMEM[ "Greenwich", 0.0], UNIT[ "Degree", 0.0174532925199433] ], PROJECTION[ "Mercator " ], PARAMETER[ "Central_Meridian", -120.0], PARAMETER[ "Standard_Parallel_1", 0.0], PARAMETER[ "False_Easting", 500000.0], PARAMETER[ "False_Northing", 10000000.0], UNIT[ "Foot", 0.3048] ]
Geographic transformations datum transformations, geotransformations, GT Convert between GCS Includes unit, prime meridian, and spheroid changes Defined in a particular direction All are reversible Not all web APIs have full geotransformation support! Specify a GeoTransformation in these methods: - IGeometry5.ProjectEx5 Method ArcObjects - Geometry Server Project method SOAP - In 10.1, GT exposed via REST
ED50 versus WGS84
Projection data flow PROJCS A1 PROJCS A2 (x, y) Projection GEOGCS A (lon, lat) (λ, φ)
Projection using common GCS ISpatialReferenceFactory3 sre = new SpatialReferenceEnvironmentClass(); IProjectedCoordinateSystem pcs1 = sre.createprojectedcoordinatesystem(wkid1), pcs2 = sre.createprojectedcoordinatesystem(wkid2); IGeometry g = <create a geometry somehow> g.spatialreference = pcs1; g.project(pcs2);
Projection with transformation data flow PROJCS A1 PROJCS B1 (x, y) Projection GEOGCS A GEOGCS B (lon, lat) (λ, φ) Geographic Transformation
Projection with GeoTransformation ISpatialReferenceFactory3 sre = new SpatialReferenceEnvironmentClass(); IProjectedCoordinateSystem pcs1 = sre.createprojectedcoordinatesystem(wkid1), pcs2 = sre.createprojectedcoordinatesystem(wkid2); IGeometry5 g = <create a geometry somehow> IGeoTransformation gt = (.) sre.creategeotransformation(gtwkid); g.projectex(pcs2, esritransformdirection.esritransformforward, gt, false, 10.0, 1.0);
Multiple transformations between two GCS
Well-Known IDs Each object has an ID and a macro / enum - 4326 - PE_GCS_WGS_1984 - esrisrgeocs_wgs1984 IDs < 32766 are EPSG-assigned - EPSG Geodetic parameter Dataset, http://www.epsg.org IDs > 32767 are Esri-assigned IDs may change - ESRI fi EPSG - EPSG fi EPSG - Old IDs will still work ISpatialReference2GEN.FactoryCode
NGA datum converter Converts between NGA keyword and Esri WKID - ADI-A, HEN, NAS-C int pe_nga_gt_code_to_factory_gt_code( const char *ncode); const char *datum = "ADI-D"; int gt1_code = pe_nga_gt_code_to_factory_gt_code(datum); Can calculate error for the transformation
Projection Engine Add-ins
Web Mercator Online mapping services use a sphere-only Mercator Two ways to emulate it - Sphere-based GCS (102113 or 3785) ( WGS_1984_Web_Mercator ) - Projection that can force sphere equations (102100 or 3857) ( WGS_1984_Web_Mercator_Auxiliary_Sphere ) Mathematically EQUAL Preserves shapes and angles Distorts distances and areas
The Spatial Reference (tolerance & resolution)
Coordinate resolution grid Data sources except shapefiles snap to this grid when storing features Where points can be placed Start with a horizon polygon Put a square over it Slice it horizontally and vertically High precision (lots of slices, today) - versus basic precision (not so many slices, legacy) Majority of ArcGIS operations snap to this grid
Ex: Horizon and Grid for NAD 1983 UTM Zone 11 Xmax = 14,890,535 m Ymax = 9,992,387 m XY resolution = 2.2 x 10-9 m (finest resolution, smallest extent) False Origin: Xmin = -5,136,135 m Ymin = -9,950,490 m
Coordinate resolution grid properties example ISpatialReference sr = ArcMap.Document.FocusMap.SpatialReference; WKSPoint falseorigin; double xyunits, resolution; sr.getfalseoriginandunits (out falseorigin.x, out falseorigin.y, out xyunits); resolution = 1.0 / xyunits; // resolution is ground distance between grid lines
Cluster tolerance Used for consistent spatial decisions with vector data - With an iterative procedure called integration (AKA cracking / clustering) Tolerance = minimum separation between geometries Resolution = 1/10 th tolerance Default tolerance = 1.0 mm Default resolution = 0.1 mm ISpatialReferenceTolerance.XYTolerance
Geometry
Overview of Geometry What is a geometry? - Defines the shape of a feature - Vector representation for top level types i.e. vertices have x, y coordinates - Optional z- (height), m- (measure), and ID attributes - Simple or non-simple - Check with ITopologicalOperator.IsSimple() - Enforce with ITopologicalOperator.Simplify()
Overview of Geometry (continued) Supplies operations for editing, analysis, and symbolization All geometry type classes implement IGeometry interface
Core geometry types Top level types can be stored in a geodatabase or shapefile - Points - Multipoints - Polylines - Polygons - Multipatches
Building block geometry types Building blocks for polylines, polygons and mutipatches - Paths - Rings - Segments - Triangles - TriangleStrips - TriangleFans
Points Always simple Z (20, 20, 30) Y X
Points private static IPoint ConstructPoint2D(double x, double y) { IPoint point = new PointClass(); point.putcoords(x, y); return point; } private static IPoint ConstructPoint3D(double x, double y, double z) { IPoint point = ConstructPoint2D(x, y); MakeZAware(point as IGeometry); point.z = z; return point; }
Points public static IGeometry Get3DPoint(double x, double y, double z) { IPoint point = ConstructPoint3D(x, y, z); } return point as IGeometry;
Multipoints Each multipoint feature is a collection of points Simple if each point is unique
Multipoints public static IGeometry Get3DMultipoint() { // Define constants and arrays IPointCollection pointcollection = new MultipointClass(); MakeZAware(pointCollection as IGeometry); for (int i = 0; i < MultipointPointCount; i++) { pointcollection.addpoint(get3dpoint(<x>, <y>, <z>), ); } } return pointcollection as IGeometry;
Polylines An ordered collection of paths
Polylines Simple Non-simple
Polylines public static IGeometry Get2DPolyline () { // Define some constants and arrays } IGeometryCollection geometrycollection = new PolylineClass(); for (int i = 0; i < PathCount; i++) { IPointCollection pointcollection = new PathClass(); for (int j = 0; j < VertexCount; j++) pointcollection.addpoint(get2dpoint(<x>, <y>),...); geometrycollection.addgeometry(pointcollection as IGeometry, ); } return geometrycollection as IGeometry;
Polygons A collection of rings ordered by their containment relationship
Polygons Simple polygon Inner Ring Outer Ring
Polygons Non-Simple polygon
Polygons public static IGeometry GetPolygonGeometry() { // Define some constants and arrays IGeometryCollection geometrycollection = newpolygonclass(); IPointCollection outerring = new RingClass(); IPointCollection innerring = new RingClass();
Polygons for (int j = 0; j < RingVertexCount; j++) { OuterRing.AddPoint(<outerX>, <outery>, ); InnerRing.AddPoint(<innerX>, <innery>, ); } OuterRing.AddPoint(outerRing.get_Point(0), ); InnerRing.AddPoint(innerRing.get_Point(0), );
Polygons geometrycollection.addgeometry(outerring asigeometry, ); geometrycollection.addgeometry(innerring asigeometry, ); ITopologicalOperator topologicaloperator = geometrycollection as ITopologicalOperator; topologicaloperator.simplify(); } return geometrycollection as IGeometry;
Multipatches Advanced geometric representation of 3D polygons Unconstrained by 2D validity rules
Multipatches Triangle Strip Triangle Fan
Multipatches
Geometry operations ITopologicalOperator interface - Classical set-theoretic operations - Difference - Intersect - SymmetricDifference - Union and more
Geometry operations ITopologicalOperator interface - Geometric operations - Buffer Creates a polygon around this geometry to a specified distance
Geometry operations - Cut Splits this geometry into a left part and a right part - ConvexHull Constructs minimum bounding polygon of this geometry such that every internal angle is less than 180 and more
Geometry operations IRelationalOperator interface (Clementini) - Crosses polyline/polyline, polyline/polygon - Disjoint all types - Overlaps polyline/polyline, polygon/polygon
Geometry operations IRelationalOperator interface (Clementini) - Touches not (multi)point/(multi)point - Within all types - Others are constructed from these five
What s new at 10.1?
What s new at 10.1? Geometry service methods - BufferGeodesic() Construct buffer regions around points, lines, and polygons using geodesic distances and directions - GetAreasAndLengthsGeodesic() - GetLengthsGeodesic() Calculate areas/perimeters or lengths using geodesic distance
What s new at 10.1? (cont) Geometry service methods (continued) - GetAreasAndLengthsPreserveShape() - GetLengthsPreserveShape() Calculate areas/perimeters or lengths on the ellipsoid keeping points along lines in the same place as they appear in the current coordinate system - REST API supports Geographic transformations.
Geometry Service
New in the Projection Engine Native C# (.NET) API - Win32 and Compact Framework C++ API - wrapper around C API Updated and improved Java API - separate engine and factory - improved performance - previous version available but deprecated Consistent API across all languages C API unchanged!
Resources ESRI Technical paper: Understanding Coordinate Management in the Geodatabase ESRI Technical paper: Understanding Geometric Processing in ArcGIS Clementini, et al. A small set of formal topological relationships suitable for end-user interaction
More resources ArcGIS Desktop help, Professional Library - Map Projections Guide Book - Data Management fi Editing Data fi Fundamentals of editing fi About editing data in a different projection (projecting on the fly). ArcObjects SDK help - Geometry library overview topic - ITopologicalOperator interface - IRelationalOperator interface
Other recommended sessions Effective Geodatabase Programming - Wed 2:45 pm - Primrose B (Palm Springs Convention Center) - Thu 1:30 pm - Pasadena/Ventura/Sierra (Renaissance Hotel) Using the File Geodatabase API - Thu 10:15 am - Primrose B (Palm Springs Convention Center)
Questions? Please fill out the session survey. Thank you!