1

From the master branch and examples @ https://github.com/DotSpatial/DotSpatial the following fills the xy array with NaN but we expect 1755668,5922511

Dim x As Double() = {2666109}
Dim y As Double() = {6484213}
Dim z(x.Length - 1) As Double

Dim xy(2 * x.Length - 1) As Double
Dim ixy As Integer = 0
For i As Integer = 0 To x.Length - 1
    xy(ixy) = x(i)
    xy(ixy + 1) = y(i)
    z(i) = 0
    ixy += 2
Next

Dim srcsys As ProjectionInfo = ProjectionInfo.FromEpsgCode(27200)
Dim destsys As ProjectionInfo = ProjectionInfo.FromEpsgCode(2193)

Reproject.ReprojectPoints(xy:=xy,
                          z:=z,
                          source:=srcsys,
                          dest:=destsys,
                          startIndex:=0,
                          numPoints:=x.Length)
  • seems this is specific to New Zealand Map Grid (EPSG:27200) re projections (other projections work OK). I've posted a GitHub issue and will try to debug the source code, – ajayel Jun 27 '17 at 19:42
  • I am getting the same thing from Dotspatial. I am growing concerned about the robustness of this library. Can anyone from Dotspatial answer why NaNs are returned? Here is my code that returns NaNs. ``` ProjectionInfo dest = KnownCoordinateSystems.Projected.StatePlaneNad1927.NAD1927StatePlaneWyomingEastCentralFIPS4902; int googleEPSGCode = 3857; ProjectionInfo src = ProjectionInfo.FromEpsgCode(googleEPSGCode); double[] xy = { 43.265081, -106.17565155 }; double[] z = { 0 }; Reproject.ReprojectPoints(xy, z, src, dest, 0, 1); ``` – Chris Dec 19 '19 at 13:13
0

I'm not a .Net developer but I suspect that your arrays Z and XY are both initialized to length 0 (x.length - 1) when they should be length 1 (x.length) and 2 (2 * x.length) respectively. And, depending on how loops work in .Net you may not even execute the loop as it runs from 0 to 0 to fill them in so there is no error.

| improve this answer | |
0

I had a similar thing using BNG (EPSG:27700) - I dodged this by using a literal Proj4 string instead for the specific projection which wasn't working:

if (origProjCode == 27700)
{
    prjSource = DotSpatial.Projections.ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +units=m +no_defs");
}
else
{
    prjSource = DotSpatial.Projections.ProjectionInfo.FromEpsgCode(origProjCode);
}

Thinking about it, I could probably work out what the issue was by inspecting the result from the literal string vs the result from the .FromEpsgCode thing - but a dodge is a dodge.

| improve this answer | |
0

I had exactly the same thing happen when using Sphere Azimuthal Equidistant http://epsg.io/53032.

(Proj.4): +proj=aeqd +lat_0=-40 +lon_0=60 +x_0=0 +y_0=0 +a=6371000 +b=6371000 +units=m +no_defs

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.