ThinkGeo.com    |     Documentation    |     Premium Support

Projections with Raster Layer

I am working on adding additional projections to our mapping app.
I have converted the app the V12.0 because there seemed to be a lot of new features there.

I am having trouble both with keeping a consistent Zoom between projections and projecting Image data.
I am working with projections 4326 and 3857 right now.

When I use 4326 I get this, just a basic countries layer in this view.

When I switch to 3857 I get this:

But then if I zoom out a lot I get a more reasonable image:

If I switch back to 4326 no issue it appears fine without zooming.
What am I missing here.

I will show my code snippet:
SetLayerProjections(4326, 3857);

private void SetLayerProjections(int internalProj, int externalProj)
{
ProjectionConverter projConverter = new ProjectionConverter(internalProj, externalProj);
SetLayerProjections(projConverter);
}

private void SetLayerProjections(ProjectionConverter projConverter)
{
if (projConverter != null)
{
foreach (LayerOverlay overlay in OnyxMap.Overlays)
{
foreach (FeatureLayer layer1 in overlay.Layers)
{
layer1.Open();
layer1.FeatureSource.ProjectionConverter = projConverter;
layer1.FeatureSource.ProjectionConverter.Open();
}
}
}
OnyxMap.Refresh();
}

I also get exceptions thrown if I have NativeImageRasterLayers added to the map, as they cannot be casted to FeatureLayers. How do I project RasterLayers between the different projections? I noticed that Projection.CanConvertRasterToExternalProjection returned false for these projections. Is there a list of projections I could use that can convert rasters?

Thanks!

Thanks Chris,
We can re-produce the first issue. We are looking into the detail. The second one. We can not cast the raster layer to the feature layer. But we could do the re-project on the raster layer.

Here is how we do it.

        nativeImageRasterLayer.ImageSource.ProjectionConverter = new UnmanagedProjectionConverter(4326, 3857);

Do you may need check you layer type and then do the re-projection.

Thanks
Frank

Chris,
For the first issue. We find the reason. If the data source is 4236. Using 3857 to display on the map it works. now if the same data source 4326. We are try to convert from 3857 to 4326. That mean we force the map suite treat data source as 3857(actual it not. the longitude and latitude are decimal degree). The mapsuite will convert the longitude and latitude to smaller value. so you have to zoom into very detail to view the data. That mean we are using 4326 data doing 3857->4326 process.

So we could set the original projection for the shape layer. and check if the original projection equal the target one. If equal we don’t need convert the projection. I attach you the sample project to show you how to do this.

WpfAppCore.zip (1.7 MB)

Thanks

Frank

Thanks.
For the first issue that worked.

For the second issue I used the UnmanagedProjectionConverter but it still did not behave as I expect.

Initial view (4326)

Reprojected (Very slow to reproject bitmap):

Interesting if I got back to first projection (it fits continents correct but color is wrong):

Is there a better way to reproject bitmaps? (this is a 56 MB one) I can try to reproject before loading in this case, but will the reproject work correctly on other smaller bitmaps?

Thanks,
Chris.

Chris,
Can you send us the raster file by the ticket system. We could look into more detail.

Thanks

Frank