How to re-project feature class after changing central meridian

413
3
10-14-2010 07:44 AM
GarySchneir
New Contributor
I am working on an application where I want to change central meridian so that if the user is looking at data near the IDL, the data is in the center of the map and there isn't an issue where data must wrap around.

I am adding the data to the feature class using standard central meridian = 0.  I then get the dataset extent's and then setting the map's spatialreference central merian to the midpoint of the extent.

I have tried a variety of simple things such as setting the same modified spatial reference to the map layers.  I have removed and re-added the layers to the map.

Is there a simple solution for this or do I need to retrieve each piece of geometry of each feature and somehow apply a transformation for the new central meridian?

Also looking at the documentation for ILayer::putref_SpatialReference the Remarks say:
This property is only used for map display, setting this property does not change the spatial reference of the layer's underlying data.  The ArcGIS framework uses this propert to pass the spatial reference from the map to the layer in order to support on-the-fly projection.

To me, this sounds like exactly what I want.  I want to add the data to the feature class, change the map's spatial reference and see the data projected correctly.

What am I missing?

I load and display the world shape file (from the sample data) and this projects exactly like I would expect when changing the central meridian.

I have tested this on 9.2 SP5 and 9.3.1 SP 2 on Solaris.


Thanks,


Gary
0 Kudos
3 Replies
MelitaKennedy
Esri Notable Contributor
I am working on an application where I want to change central meridian so that if the user is looking at data near the IDL, the data is in the center of the map and there isn't an issue where data must wrap around.

I am adding the data to the feature class using standard central meridian = 0.  I then get the dataset extent's and then setting the map's spatialreference central merian to the midpoint of the extent.

I have tried a variety of simple things such as setting the same modified spatial reference to the map layers.  I have removed and re-added the layers to the map.

Is there a simple solution for this or do I need to retrieve each piece of geometry of each feature and somehow apply a transformation for the new central meridian?

Also looking at the documentation for ILayer::putref_SpatialReference the Remarks say:
This property is only used for map display, setting this property does not change the spatial reference of the layer's underlying data.  The ArcGIS framework uses this propert to pass the spatial reference from the map to the layer in order to support on-the-fly projection.

To me, this sounds like exactly what I want.  I want to add the data to the feature class, change the map's spatial reference and see the data projected correctly.

What am I missing?

I load and display the world shape file (from the sample data) and this projects exactly like I would expect when changing the central meridian.

I have tested this on 9.2 SP5 and 9.3.1 SP 2 on Solaris.


Thanks,


Gary


Hi Gary,

I can't understand what you're trying to do. It sounds to me like you're trying to change the coordinate system (spatial reference) of a layer/dataset without projecting it. I think you're on the right track that you just want to update the data frame's coordinate system. You want to set the central meridian of IMap::SpatialReference to the center of the area of interest.

What coordinate systems will generally be used for the map and for your data layers?

Melita
0 Kudos
GarySchneir
New Contributor
Hi Melita,

Your understanding of the problem sounds correct but I may not be attempting to solve it properly.  If you have any samples source code that I can look at, I would appreciate it.

Just to clarify what i m attempting:  I am reading data from our DB, creating features in several feature classes that exist in in-memory-workspaces, After building all of the feature classes, I want to center the map on the visible features.

The original data is stored in decimal degrees but the map is displayed using Mercator projection with meter units.  I am able to project the original data to mercator without any issue.

After all the data has been processed, I want to cener the map on the visible data.  I am attempting to do this by changing the central meridian from 0, to an appropriate value.  This seems to be where my problem is.  I am calculating the visible data by examing the extent of certain feature classes of my data.

While running the application, I can reload some data and I want to repopulate some (but not all) of the feature classes and re-center on this data.  For performance reasons, I am attempting to leave some of the feature classes alone and not re-load / re-process this data.

On the map, I am displaying the sample world shape file that came with the sample application data.  When I recenter the map, the shape file displays correctly, with the new central meridian.  My feature class data does not appear correct.  For example, if I change the central meridian to 180 degrees, the IDL of the shape file is displayed on the center of my map.  The coordinates that I display tracking the mouse movement are correct as well.  It is just the features related to the feature classes I created, that do not display correctly.

Any ideas on what I am doing wrong?


Thanks,

Gary
0 Kudos
MelitaKennedy
Esri Notable Contributor
Hi Melita,

Your understanding of the problem sounds correct but I may not be attempting to solve it properly.  If you have any samples source code that I can look at, I would appreciate it.

Just to clarify what i m attempting:  I am reading data from our DB, creating features in several feature classes that exist in in-memory-workspaces, After building all of the feature classes, I want to center the map on the visible features.

The original data is stored in decimal degrees but the map is displayed using Mercator projection with meter units.  I am able to project the original data to mercator without any issue.

After all the data has been processed, I want to cener the map on the visible data.  I am attempting to do this by changing the central meridian from 0, to an appropriate value.  This seems to be where my problem is.  I am calculating the visible data by examing the extent of certain feature classes of my data.

While running the application, I can reload some data and I want to repopulate some (but not all) of the feature classes and re-center on this data.  For performance reasons, I am attempting to leave some of the feature classes alone and not re-load / re-process this data.

On the map, I am displaying the sample world shape file that came with the sample application data.  When I recenter the map, the shape file displays correctly, with the new central meridian.  My feature class data does not appear correct.  For example, if I change the central meridian to 180 degrees, the IDL of the shape file is displayed on the center of my map.  The coordinates that I display tracking the mouse movement are correct as well.  It is just the features related to the feature classes I created, that do not display correctly.

Any ideas on what I am doing wrong?


Thanks,

Gary


Hi Gary,

The only thing I can think of is that the new feature layers don't have any coordinate system attached to them. If you check them in ArcMap, is their coordinate system "Unknown"?

Melita
0 Kudos