English

How To: Convert a user-supplied Decimal Degree coordinate to a State Plane coordinate

Summary

This Avenue script shows how to convert a set of user-supplied coordinates in Decimal Degrees to State Plane coordinates or viceversa.

Procedure

  1. Open a New Script window.
  2. Copy and paste this script into the Script Window.

    The script is set to run for State Plane Texas North Central.

    Code:
    '--- Script DD-SPF.AVE

    '-- This script addresses the need to project TO and FROM Texas
    '-- North-Central State Plane, NAD27, map units FEET.
    '
    '-- It prompts you for the coordinate input.
    '
    '-- If the input coordinates are in State Plane, the script converts
    '-- them to DD and displays them.
    '
    '-- If the input coordinates are in DD, the script converts them
    '-- to State Plane and displays them.
    '
    '-- If the DD X/Longitude coordinate is a positive number, the script
    '-- converts it to a negative number before unprojecting it,
    '-- assuming the data is located in the Western Hemisphere.
    '
    '-- Since ArcView calculates projections using meters, it is
    '-- necessary to multiply State Plane coordinates by 3.2808
    '-- after projecting them. It is also necessary to divide
    '-- State Plane coordinates by 3.2808 before unprojecting them.
    '-- If your State Plane map units are in meters, this extra
    '-- processing is not needed.

    theView = av.getactivedoc

    r = Rect.MakeXY(-180,-90,180,90)
    mySP = Lambert.Make(r)
    mySP.SetCentralMeridian(-97.5)
    mySP.SetReferenceLatitude(31.6667)
    mySP.SetLowerStandardParallel(32.1333)
    mySP.SetUpperStandardParallel(33.9667)
    mySP.SetFalseEasting(609601)
    mySP.SetFalseNorthing(0)

    theLabels = {"Long-X","Lat-Y"}
    theDefs = {"",""}
    theInCoords = MsgBox.MultiInput
    ("Enter Coords either DD or Stateplane",
    "",theLabels,theDefs)
    theXval = theInCoords.Get(0).AsNumber
    theYval = theInCoords.Get(1).AsNumber
    thePoint = Point.Make(theXval,theYval)

    if (theXval < 180)
    then
    if (theXval > 0)
    then 'just in case the input DD longitude is positive.
    thePoint.SetX(theXval * -1)
    end
    mySP.ProjectPt(thePoint)
    theX = ((thePoint.GetX) * 3.2808).SetFormat("d.d").AsString
    theY = ((thePoint.GetY) * 3.2808).SetFormat("d.d").AsString
    theFinalLabel = "DD converted into Stateplane"
    else
    thePoint.SetX(theXval / 3.2808)
    thePoint.SetY(theYval / 3.2808)
    mySP.UnprojectPt(thePoint)
    theX = thePoint.GetX.SetFormat("d.dddd").AsString
    theY = thePoint.GetY.SetFormat("d.dddd").AsString
    theFinalLabel = "Stateplane converted into DD"
    end

    MsgBox.Info("Longitude/X-coord"++theX+NL+"Latitude/Y-coord"++theY,
    theFinalLabel)

    '--- End of Script

  3. From the Script menu select Compile
  4. From the Script menu select Run.