Select to view content in your preferred language

MapView.Extent is wrong on spatial reference change

1699
8
Jump to solution
06-08-2019 07:32 AM
MaxMax2
Frequent Contributor

Code for test:

var sr = mapView.Map.SpatialReference;
var extent = mapView.Extent;‍‍

Steps to reproduce the problem:

1. Create new project. Variables now will have values:

2. Add layer with WGS84 spatial reference and zoom to full extent (the issue will be without zooming too). Now execute the code above:

We see that spatial reference now is WGS84, but extent coordinates doesn't correspond to WGS84. Max extent for this sr must be -180 -90 180 90 in degrees, but the values from screenshot are obviously wrong.

More than that I can't project extent to WGS84, because it's already in WGS84, so coordinates still the same!

0 Kudos
1 Solution

Accepted Solutions
CharlesMacleod
Esri Regular Contributor

Max, the issue to me looks like you are not specifying a cell size. The resulting cell size of the raster is 10600614 which matches the dimension of the raster. I do not know the significance of that number (i.e. why is it used as the default cell size). However, if I do specify a cell size explicitly (eg "90" or "180" ) then the extent of the layer is correct (as, in, it is a proper extent).

As the cell size, in this case because of the projection being used, is in decimal degrees and the WGS projection is wider than it is tall, I assume that the maximum possible cell size will be "180" while still retaining a "real" spatial extent.

For example, using your same settings and a cell size of 180:

View solution in original post

0 Kudos
8 Replies
MaxMax2
Frequent Contributor

Any news on this issue?

0 Kudos
CharlesMacleod
Esri Regular Contributor

I cannot reproduce. My results using 2.4:

SR Domain, MapView Extent, layer "QueryExtent"

Initial extent:

Zoom to layer extent

Pan to date line (or approx) with "Enable wrapping around the date line" enabled

layer properties:

map properties:

0 Kudos
MaxMax2
Frequent Contributor

Hi Charles,

I found exact scenario to reproduce issue. I suppose you added feature layer with WGS84 and all is OK. Yes, in this case I see valid values too.

But if I add raster dataset with WGS84 to new project, values will be invalid:

I've attached zip archive with GDB with raster dataset to my question.

Raster dataset created with this code:

var fullExtent = await QueuedTask.Run(() => EnvelopeBuilder.CreateEnvelope(-180, -90, 180, 90, SpatialReferences.WGS84));
var args = Geoprocessing.MakeValueArray(datastorePath, RasterDatasetName, null, "32_BIT_UNSIGNED", null, 1, null, "NONE");
var env = Geoprocessing.MakeEnvironmentArray(outputCoordinateSystem: SpatialReferences.WGS84, extent: fullExtent);
var gpResult = await Geoprocessing.ExecuteToolAsync("CreateRasterDataset_management", args, env, cancellationToken, flags: GPExecuteToolFlags.AddOutputsToMap);
0 Kudos
CharlesMacleod
Esri Regular Contributor

Hi Max, the layer extent looks bogus:

0 Kudos
MaxMax2
Frequent Contributor

OK, but it has been created with Create Raster Dataset tool, so dataset is created in legitimate way. Is it a bug in Create Raster Dataset geoprocessing tool? How can I create valid raster dataset in GDB?

0 Kudos
MaxMax2
Frequent Contributor

I've also checked Create Raster Dataset for GDB and file rasters, and in all cases output dataset has such strange extent. Please give advice how can I create valid raster dataset with valid extent for WGS84?

0 Kudos
CharlesMacleod
Esri Regular Contributor

Max, the issue to me looks like you are not specifying a cell size. The resulting cell size of the raster is 10600614 which matches the dimension of the raster. I do not know the significance of that number (i.e. why is it used as the default cell size). However, if I do specify a cell size explicitly (eg "90" or "180" ) then the extent of the layer is correct (as, in, it is a proper extent).

As the cell size, in this case because of the projection being used, is in decimal degrees and the WGS projection is wider than it is tall, I assume that the maximum possible cell size will be "180" while still retaining a "real" spatial extent.

For example, using your same settings and a cell size of 180:

0 Kudos
MaxMax2
Frequent Contributor

Thanks, that works! Quite strange behavior since cell size is optional parameter.

0 Kudos