You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a raster and vector files, both have exactly the same .prj files which look like this. GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017453292519943295]]
The vector will display ok in mercator, but the raster does not. Am I missing something here? Thanks. (I realise I should be reading the wgs84 stuff from the source files but not not figured that out yet).
` // configure the coordinate systems service
ProjNet.CoordinateSystems.CoordinateSystemFactory csf = new ProjNet.CoordinateSystems.CoordinateSystemFactory();
ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory ctf = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
Session.Instance.SetCoordinateSystemServices(new SharpMap.CoordinateSystems.CoordinateSystemServices(csf, ctf, SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems()));
GeoAPI.CoordinateSystems.ICoordinateSystem webmercator = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator;
GeoAPI.CoordinateSystems.ICoordinateSystem wgs84 = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
// add the raster
var rasterLayer = new SharpMap.Layers.GdalRasterLayerCachingProxy("GeoTiff", @"C:\Users\me\Downloads\NE1_HR_LC_SR_W_DR\NE1_HR_LC_SR_W_DR.tif");
rasterLayer.CoordinateTransformation = ctf.CreateFromCoordinateSystems(wgs84, webmercator);
rasterLayer.ReverseCoordinateTransformation = ctf.CreateFromCoordinateSystems(webmercator, wgs84);
mapBox.Map.BackgroundLayer.Add(rasterLayer);
// add the coastlines
SharpMap.Layers.VectorLayer vectorLayer = new SharpMap.Layers.VectorLayer("Coastlines");
vectorLayer.DataSource = new SharpMap.Data.Providers.ShapeFile(@"C:\Users\me\Downloads\natural_earth_vector\10m_physical\ne_10m_coastline.shp", true);
vectorLayer.CoordinateTransformation = ctf.CreateFromCoordinateSystems(wgs84, webmercator);
vectorLayer.ReverseCoordinateTransformation = ctf.CreateFromCoordinateSystems(webmercator, wgs84);
mapBox.Map.Layers.Add(vectorLayer);`
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have a raster and vector files, both have exactly the same .prj files which look like this.
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017453292519943295]]The vector will display ok in mercator, but the raster does not. Am I missing something here? Thanks. (I realise I should be reading the wgs84 stuff from the source files but not not figured that out yet).
` // configure the coordinate systems service
ProjNet.CoordinateSystems.CoordinateSystemFactory csf = new ProjNet.CoordinateSystems.CoordinateSystemFactory();
ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory ctf = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
Session.Instance.SetCoordinateSystemServices(new SharpMap.CoordinateSystems.CoordinateSystemServices(csf, ctf, SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems()));
Beta Was this translation helpful? Give feedback.
All reactions