Skip to main content
deleted 114 characters in body
Source Link
Weequay
  • 101
  • 5

I am having a really difficult time trying to project the map extent (WGS84) into an envelope of a different spatial reference (Web Mercator or UTM). I have tried multiple ways of changing the spatial reference of an envelope, but none of them are working. I know they aren't working because I am drawing a graphic on the screen for the envelope, but nothing appears when changing the envelope to a different spatial reference. Using the map's spatial reference of WGS84 for the envelope works perfectly and it is drawn to the screen.

As an fyi, I am converting the envelope into a polygon, which I am using for the graphic.

The following are four different code attempts that I have made using Web Mercator. I have also tried with UTM:

SpatialReference sr3857 = SpatialReferenceBuilder.CreateSpatialReference(3857);
// Builder constructors need to run on the MCT.
using (SpatialReferenceBuilder srBuilder = new SpatialReferenceBuilder(3857))
{
    // do something with the builder
    sr3857 = srBuilder.ToSpatialReference();
}
ArcGIS.Core.Geometry.Polygon envPoly = null;
Envelope mapExtent = (Envelope)GeometryEngine.Instance.Project(MapView.Active.Extent, sr3857);

private Envelope BuildEnvelope(MapPoint mapPt, Envelope inputEnvelope)
{
    EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator);
    envelopeBuilder.XMin = inputEnvelope.XMin;
    envelopeBuilder.YMin = inputEnvelope.YMin;
    envelopeBuilder.XMax = inputEnvelope.XMax;
    envelopeBuilder.YMax = inputEnvelope.YMax;

    return envelopeBuilder.ToGeometry();
}
Envelope mapExtent = BuildEnvelope(MapView.Active.Extent)

Envelope mapExtent = EnvelopeBuilder.CreateEnvelope(MapView.Active.Extent, SpatialReferences.WebMercator);
 
Envelope mapExtent = EnvelopeBuilder.CreateEnvelope(MapView.Active.Extent, SpatialReferences.WebMercator);

I am having a really difficult time trying to project the map extent (WGS84) into an envelope of a different spatial reference (Web Mercator or UTM). I have tried multiple ways of changing the spatial reference of an envelope, but none of them are working. I know they aren't working because I am drawing a graphic on the screen for the envelope, but nothing appears when changing the envelope to a different spatial reference. Using the map's spatial reference of WGS84 for the envelope works perfectly and it is drawn to the screen.

As an fyi, I am converting the envelope into a polygon, which I am using for the graphic.

The following are four different code attempts that I have made using Web Mercator. I have also tried with UTM:

SpatialReference sr3857 = SpatialReferenceBuilder.CreateSpatialReference(3857);
// Builder constructors need to run on the MCT.
using (SpatialReferenceBuilder srBuilder = new SpatialReferenceBuilder(3857))
{
    // do something with the builder
    sr3857 = srBuilder.ToSpatialReference();
}
ArcGIS.Core.Geometry.Polygon envPoly = null;
Envelope mapExtent = (Envelope)GeometryEngine.Instance.Project(MapView.Active.Extent, sr3857);

private Envelope BuildEnvelope(MapPoint mapPt, Envelope inputEnvelope)
{
    EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator);
    envelopeBuilder.XMin = inputEnvelope.XMin;
    envelopeBuilder.YMin = inputEnvelope.YMin;
    envelopeBuilder.XMax = inputEnvelope.XMax;
    envelopeBuilder.YMax = inputEnvelope.YMax;

    return envelopeBuilder.ToGeometry();
}
Envelope mapExtent = BuildEnvelope(MapView.Active.Extent)

Envelope mapExtent = EnvelopeBuilder.CreateEnvelope(MapView.Active.Extent, SpatialReferences.WebMercator);
 
Envelope mapExtent = EnvelopeBuilder.CreateEnvelope(MapView.Active.Extent, SpatialReferences.WebMercator);

I am having a really difficult time trying to project the map extent (WGS84) into an envelope of a different spatial reference (Web Mercator or UTM). I have tried multiple ways of changing the spatial reference of an envelope, but none of them are working. I know they aren't working because I am drawing a graphic on the screen for the envelope, but nothing appears when changing the envelope to a different spatial reference. Using the map's spatial reference of WGS84 for the envelope works perfectly and it is drawn to the screen.

As an fyi, I am converting the envelope into a polygon, which I am using for the graphic.

The following are four different code attempts that I have made using Web Mercator. I have also tried with UTM:

SpatialReference sr3857 = SpatialReferenceBuilder.CreateSpatialReference(3857);
// Builder constructors need to run on the MCT.
using (SpatialReferenceBuilder srBuilder = new SpatialReferenceBuilder(3857))
{
    // do something with the builder
    sr3857 = srBuilder.ToSpatialReference();
}
ArcGIS.Core.Geometry.Polygon envPoly = null;
Envelope mapExtent = (Envelope)GeometryEngine.Instance.Project(MapView.Active.Extent, sr3857);

private Envelope BuildEnvelope(MapPoint mapPt, Envelope inputEnvelope)
{
    EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator);
    envelopeBuilder.XMin = inputEnvelope.XMin;
    envelopeBuilder.YMin = inputEnvelope.YMin;
    envelopeBuilder.XMax = inputEnvelope.XMax;
    envelopeBuilder.YMax = inputEnvelope.YMax;

    return envelopeBuilder.ToGeometry();
}
Envelope mapExtent = BuildEnvelope(MapView.Active.Extent)

Envelope mapExtent = EnvelopeBuilder.CreateEnvelope(MapView.Active.Extent, SpatialReferences.WebMercator);
Source Link
Weequay
  • 101
  • 5

How to successfully project the map extent into a different spatial reference with C# and ArcGIS Pro SDK

I am having a really difficult time trying to project the map extent (WGS84) into an envelope of a different spatial reference (Web Mercator or UTM). I have tried multiple ways of changing the spatial reference of an envelope, but none of them are working. I know they aren't working because I am drawing a graphic on the screen for the envelope, but nothing appears when changing the envelope to a different spatial reference. Using the map's spatial reference of WGS84 for the envelope works perfectly and it is drawn to the screen.

As an fyi, I am converting the envelope into a polygon, which I am using for the graphic.

The following are four different code attempts that I have made using Web Mercator. I have also tried with UTM:

SpatialReference sr3857 = SpatialReferenceBuilder.CreateSpatialReference(3857);
// Builder constructors need to run on the MCT.
using (SpatialReferenceBuilder srBuilder = new SpatialReferenceBuilder(3857))
{
    // do something with the builder
    sr3857 = srBuilder.ToSpatialReference();
}
ArcGIS.Core.Geometry.Polygon envPoly = null;
Envelope mapExtent = (Envelope)GeometryEngine.Instance.Project(MapView.Active.Extent, sr3857);

private Envelope BuildEnvelope(MapPoint mapPt, Envelope inputEnvelope)
{
    EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator);
    envelopeBuilder.XMin = inputEnvelope.XMin;
    envelopeBuilder.YMin = inputEnvelope.YMin;
    envelopeBuilder.XMax = inputEnvelope.XMax;
    envelopeBuilder.YMax = inputEnvelope.YMax;

    return envelopeBuilder.ToGeometry();
}
Envelope mapExtent = BuildEnvelope(MapView.Active.Extent)

Envelope mapExtent = EnvelopeBuilder.CreateEnvelope(MapView.Active.Extent, SpatialReferences.WebMercator);

Envelope mapExtent = EnvelopeBuilder.CreateEnvelope(MapView.Active.Extent, SpatialReferences.WebMercator);