understanding and using geometry, projections, and spatial...

52
Understanding and Using Geometry, Understanding and Using Geometry, Projections, and Spatial Reference Projections, and Spatial Reference Systems in Systems in ArcGIS ArcGIS Melita Melita Kennedy, Rob Kennedy, Rob Juergens Juergens

Upload: others

Post on 31-Oct-2019

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Understanding and Using Geometry, Understanding and Using Geometry, Projections, and Spatial Reference Projections, and Spatial Reference

Systems in Systems in ArcGISArcGIS

MelitaMelita Kennedy, Rob Kennedy, Rob JuergensJuergens

Page 2: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

IntroductionIntroduction

We present fundamental concepts necessary for the correct and efficient use of geometry and spatial reference APIs

• Spatial references and their properties• The geometry type system• Relational operators• Using geometry efficiently• What’s new at 10?

Page 3: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

The Spatial Reference

Page 4: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Spatial referencesSpatial 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

Page 5: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Accessing properties of spatial referencesAccessing properties of spatial references

• Python- Import arcpy- arcpy.Describe(“layer name”).SpatialReference.XYTolerance

• C#IMxDocument d = ArcMap.Document;

IFeatureLayer fl = (.) d.FocusMap.get_Layer(layer index);

IGeoDataset fcGridDS = (.) fl.FeatureClass;

ISpatialReferenceTolerance srt = (.)fcGridDS.SpatialReference;

MessageBox.Show(System.Convert.ToString(srt.XYTolerance));

Page 7: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Datum

Spheroid

Prime Meridian

Projection Parameters

Projection

Projected Coordinate

System

Geographic Coordinate

System

Coordinate System

Angular Unit

Linear Unit

Page 8: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

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

Page 9: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Well-Known Text string

PROJCS[ "Test",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] ]

Page 10: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

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- Currently no GT exposed via REST

Page 11: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

ED50 versus WGS84

Page 12: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Multiple transformations between two GCSMultiple transformations between two GCS

Page 13: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

PROJCS A2

GEOGCS A

PROJCS A1

Projection

(lon, lat)

(x, y)

(λ, φ)

Projection data flow

Page 14: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Projection using common GCS

ISpatialReferenceFactory3 sre =new SpatialReferenceEnvironmentClass();

IProjectedCoordinateSystempcs1 = sre.CreateProjectedCoordinateSystem(wkid1),pcs2 = sre.CreateProjectedCoordinateSystem(wkid2);

IGeometry g = <create a geometry somehow>g.SpatialReference = pcs1;

g.Project(pcs2);

Page 15: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

GEOGCS A

PROJCS A1

GEOGCS B

PROJCS B1

Projection

Geographic Transformation

(lon, lat)

(x, y)

(λ, φ)

Projection with transformation data flow

Page 16: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

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);

Page 17: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

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 EPSG- EPSG EPSG- Old IDs will still work

• ISpatialReference2GEN.FactoryCode

Page 18: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

• 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

NGA datum converter

Page 19: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Projection Engine Add-ins

Page 20: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Web Mercator

• Online mapping services use a sphere-only Mercator

• Two ways to emulate it- Sphere-based GCS (102113)- Projection that can force sphere equations (102100 or 3857)

• Mathematically EQUAL

• It distorts distances and areas

Page 21: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

The Spatial Reference (tolerance & resolution)

Page 22: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Coordinate resolution gridCoordinate 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

Page 23: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Ex: Horizon and Grid for NAD 1983 UTM Zone 11Ex: Horizon and Grid for NAD 1983 UTM Zone 11

False Origin:Xmin = -5,136,135 m Ymin = -9,950,490 m

Xmax = 14,890,535 m Ymax = 9,992,387 m

XY resolution = 2.2 x 10-9 m(finest resolution, smallest extent)

……

Page 24: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Coordinate resolution grid properties exampleCoordinate 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

Page 25: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Cluster toleranceCluster tolerance

• Used for consistent spatial decisions with vector data- With an iterative procedure called integration (AKA cracking /

clustering)

• Tolerance = 1/10th minimum separation between geometries

• Resolution = 1/10th tolerance

• Default tolerance = 1.0 mm• Default resolution = 0.1 mm

ISpatialReferenceTolerance.XYTolerance

Page 26: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Visualizing the coordinate grid

Page 27: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Geometry

Page 28: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Core geometry typesCore geometry types

• “Top Level Types” can be stored in a geodatabase or shapefile

- Points- Multipoints- Polylines- Polygons- Multipatches

• Polylines are sequences of Paths• Polygons are sequences of Rings• Paths and rings are sequences of Segments

- Lines- Circular and elliptical arcs- Bezier curves

Page 29: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Coordinate access interfacesCoordinate access interfaces

• IPointCollection- Treat ring, path, polyline, or polygon as a set of points - Add, remove, or iterate over vertices

• ISegmentCollection- Treat as a set of segments

• IGeometryCollection- References to parts of multipoints, polylines, polygons- GeometryBag

• Reduces memory footprint• Efficient access

Page 30: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Enumerator exampleEnumerator example

IEditSketch es = (.) ArcMap.Application.FindExtensionByName(

"ESRI Object Editor");

ISegmentCollection segs = (.) es.Geometry;IEnumSegment segEnum = segs.EnumSegments;ISegment seg;int iPart = 0, iSeg = 0;segEnum.Next(out seg, ref iPart, ref iSeg);while (seg != null)

segEnum.Next(out seg, ref iPart, ref iSeg);

• Vertex enumerators are similar• Update properties (x,y,z,m,id) of existing vertices and segments

Page 31: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Geometry Service

• D/COM access via GeoDatabase .NET assembly

• Access from any client via SOAP or REST

Page 32: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Geometry environment thread singletonGeometry environment thread singleton

• Creates (empty) objects

• Sets thread global variables like default densification tolerance

Page 33: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Geometry environment example

// Export and Import WKB format

IPoint p = new PointClass();

p.PutCoords(1.0, 1.0);

IWkb pw = (IWkb) p;

int cBytes = pw.WkbSize;

byte [] aBytes = new byte[cBytes];

pw.ExportToWkb(ref cBytes, out aBytes[0]);

IGeometryFactory3 ge = new GeometryEnvironmentClass();

IGeometry outG;

ge.CreateGeometryFromWkb(ref cBytes, ref aBytes[0], out outG);

IPoint outP = (.) outG;

Page 34: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Other objectsOther objects

• Geometry Bags- anything that supports the IGeometry interface

• WKSPoint (structure)• Transformation objects

- pass a transformation to a geometry

ITransform2D geometryToBeTransformed = …

IAffineTransformation2D T = new AffineTransformation2DClass();

T.Move(1.0, 1.0);

geometryToBeTransformed.Transform (esriTransformDirection. esriTransformForward, T);

Page 35: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Simple geometriesSimple geometries

• Multipoints- each point must be unique

• Polylines- segment length > resolution, - vertical lines permitted when z-aware

• Polygons – uses cluster tolerance - definite inside-outside-boundary- finite area- multiple rings, outer: clockwise, inner: counter-clockwise

- Rings can touch at points- note difference between connected and outer components

Page 36: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Enforcing simplicityEnforcing simplicityFor low level objects

• Multipoints- ITopologicalOperator::Simplify

• Polylines- IPolyline6::SimplifyNonPlanar (10.0)- IPolyline::SimplifyNetwork (merges valence two parts)

• Polygons- ITopologicalOperator::Simplify- SimplifyPreserveFromTo, less efficient

Page 37: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Enforcing simplicityFor higher level objects

• IFeatureSimplify::SimplifyGeometry- If Polygon, simplify (preserve from / to)- Project to dataset (doesn’t clear isSimple bit)- Simplify again

- preserve from / to for polygons- non-planar for polylines- snap to grid for points / multipoints

Page 38: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Relational operatorsRelational operators

• 5 core operators - defined in terms of interior, boundary, exterior

• Point has an interior only• Polyline

- boundary is set of path endpoints- interior is everything except the endpoints - we do not planarize before applying this definition

• Polygon - boundary is rings - interior is the inside of rings

Page 39: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Relational operators (cont.)Relational operators (cont.)

• Disjoint – boundary and interiors disjoint• In – the usual, but interior intersection can’t be empty

- same for contains

• Touch – shapes are not disjoint but interiors are• Cross – interior intersection dimension is < max dimension

of inputs- no containment

• Overlap – interior intersection dimension = dimension of inputs

- no containment

• IRelationalOperator.Disjoint, Contains, Crosses…

Page 40: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Contains examples

Overlap examples

Page 41: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

TipsTips

• Always tag geometry with a spatial reference• Tag geometry bag with an sr before adding geometries to it• Know when you’re sharing references to rings / paths /

segments• Shapefiles can’t store curves, vertex IDs, or some

properties of Multipatches (e.g. textures)

• Use point and segment enumerators to access existing polylines and polygons (recycling)

• Use array-based methods (IGeometryBridge/2) to add data to geometries

• Use WKSPoint structures when possible • Watch your object burn rate

Page 42: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

What’s new at 10

Page 43: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

WhatWhat’’s new at 10.0?s new at 10.0?

• Geometry server methods - support web editing- some geodesic operations (distance, length)

• http://servicesbeta.esri.com/arcgis/sdk/soap/• http://servicesbeta.esri.com/ArcGIS/rest/services/Geometr

y/GeometryServer

• Vertical segments in polylines

Page 44: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

WhatWhat’’s new at 10.0? (cont)s new at 10.0? (cont)

• Geodetic constructions- IConstructGeodetic- IPolycurveGeodetic

• Exposed in- Editor UI- Measurement tool UI

Page 45: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

WhatWhat’’s new example: Geodesic ellipsess new example: Geodesic ellipses

IConstructGeodetic.ConstructGeodesicEllipse (centerPoint, linearUnit, semiMajor, semiMinor, majorAz, esriCurveDensifyMethod.esriCurveDensifyByDeviation, 1.0);

Page 46: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

What’s new at 10 (cont.)

Notation transformation• Supported notations

- MGRS - Military Grid Reference System

- USNG - US National Grid

- UTM - Universal Transverse Mercator

- GEOREF - Geographic Reference System

- GARS - Global Area Reference System

- DMS - Degree Minute Second

- DDM - Degree Decimal-Minute

- DD - Decimal Degree

• Conversions- Notation to coordinates- Coordinates to notation

• Point::IConversionNotation

Page 47: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Coming up 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!

Page 48: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

ResourcesResources

• 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

Page 49: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

More resources

• ArcGIS Desktop help, Professional Library- Map Projections Guide Book

- Data Management Editing Data Fundamentals of editing About editing data in a different projection (projecting on the fly).

• Resolution and tolerance default values

• ArcObjects SDK help- Geometry library overview topic

- Working with vertical polyline segments (accessible from geometry library overview topic)

Page 50: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Other recommended sessionsOther recommended sessions……

• ArcGIS 10.1 and the Road Ahead- Thu 8:30 am - Primrose B (Palm Springs Convention Center)

• Working with Image Services - Thu 8:30 am - Catalina/Madera (Renaissance Hotel)

• The File Geodatabase API- Thu 10:15 am - Primrose B (Palm Springs Convention Center)

Page 51: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional

Questions?

Please fill out the session survey.

Thank you!

Page 52: Understanding and Using Geometry, Projections, and Spatial ...proceedings.esri.com/library/userconf/devsummit11/papers/tech/underst_1.pdf · • ArcGIS Desktop help, Professional