Following the death of their second son, the Ellicotts moved to Baltimore in 1785, where Andrew taught mathematics at the Baltimore Academy and was even elected to the General Assembly of Maryland (state legislature) in 1786. The same year, he was called upon for a survey to define the western border of Pennsylvania with the Ohio Country. This "Ellicott Line" (running north–south at longitude meridian 80°31'12" W) later became the principal meridian for the surveys of the future Northwest Territory of the United States. His work in Pennsylvania intensified his ties with Rittenhouse and other members of the American Philosophical Society, to which he had been elected a member in 1785, and led to encounters with Benjamin Franklin and Simeon De Witt. When he was subsequently appointed to lead other surveys in Pennsylvania, the family moved again in 1789 to Philadelphia. By recommendation of Franklin, Ellicott got a position with the newly established government under the Constitution and was tasked by first President George Washington to survey the lands between Lake Erie and Pennsylvania to determine the border between Western New York and U.S. federal territory, resulting in the Erie Triangle. This survey, during which he also made the first topographical study of the Niagara River including the Niagara Falls, gained Ellicott a reputation for superb accuracy in surveys.