<html><body><div>Hi,</div><div><br></div><div>Thanks for all the helpful comments I've received through this list.</div><div><br></div><div>Aside from solving the original issue, I've learned some incidentally useful things just by observing some of the code snippets.</div><div><br></div><div>As it turns out, I may have been calculating everything correctly -- but in a far less elegant way than by the methods suggested on this list, and I'm glad to know the proper way to handle this now regardless -- but making one fundamental error that hadn't occurred to me previously (as I'd thought it must have been my code, having no experience with GIS before now).  I had been checking, as a test case, to see whether a school was in a school attendance area using its geocoded address.  As I'm a Mac user, I quickly grabbed the test coordinates from geocoder.us, to avoid going back to the office, as all the GIS software seems to be Windows-based.  However, the coordinates that site generates are not sufficiently accurate, unlike Google Maps or Mappoint.</div><div><br></div><div>Regarding the datum, yes, it's NAD83.</div><div><br></div><div>Thanks,</div><div>Jonathan</div><pre style="font-family: Helvetica,Arial,sans-serif; font-size: 13px" _mce_style="font-family: Helvetica,Arial,sans-serif; font-size: 13px;">Jonathan Marc Bearak
PhD Candidate in Sociology
Institute of Education Sciences Predoctoral Fellow
New York University
jonathan.bearak@nyu.edu</pre><div><br><br><br><br>On 24 Aug, 2010,at 01:54 PM, Dan Putler <dan.putler@sauder.ubc.ca> wrote:<br><br></div><div><blockquote type="cite"><div><div class="_stretch">Roger,<br>
<br>
This won't really matter since they are very close, but given the data <br>
source and a North America based company, my guess is the underlying <br>
datum is NAD83.<br>
<br>
Dan<br>
<br>
On 08/24/2010 10:45 AM, Roger Bivand wrote:<br>
> On Tue, 24 Aug 2010, Alexandre Villers wrote:<br>
><br>
>    <br>
>> Hey,<br>
>><br>
>> There is an ESRI code (ESRI:102318<br>
>> <<a href="http://spatialreference.org/ref/esri/102318/&gt" _mce_href="http://spatialreference.org/ref/esri/102318/&gt">http://spatialreference.org/ref/esri/102318/&gt</a>;) corresponding to the<br>
>> requested projection... However, I doubt CRS will take an ESRI code (Roger<br>
>> ?).<br>
>>      <br>
> CRS("+init=esri:102318")<br>
><br>
> but the ESRI version doesn't give a +datum=, so WGS84 will be assumed. The<br>
> difference is the reversal of the +lat1= and +lat2= values, so probably<br>
> not drastic.<br>
><br>
> Roger<br>
><br>
>    <br>
>> Jonathan, have a look at the rgdal and sp packages help pages for the "How<br>
>> To" in CRS()<br>
>><br>
>> Best regards<br>
>><br>
>> Alex<br>
>><br>
>> Le 24/08/2010 17:58, Roger Bivand a écrit :<br>
>>      <br>
>>> On Tue, 24 Aug 2010, Alexandre Villers wrote:<br>
>>><br>
>>>        <br>
>>>> Hello,<br>
>>>><br>
>>>> Have a look at spTransform (in rgdal package) and the EPSG code of the<br>
>>>> desired projection (this is to me the easiest way not to mess with digits<br>
>>>> and various copy errors that can be made while writing the projection<br>
>>>> properties) at <a href="http://www.spatialreference.org" _mce_href="http://www.spatialreference.org">www.spatialreference.org</a><br>
>>>><br>
>>>> then, you just have to do something like this<br>
>>>><br>
>>>> library(rgdal)<br>
>>>><br>
>>>> data<-read.table ("mydata.txt", h=T, sep=",") #your original dataset<br>
>>>> coordinates(data)<-~ X + Y # where X and Y stand for the name of your<br>
>>>> lat/lon columns<br>
>>>> proj4string(data)<-CRS("+init=epsg:4326")  #if your coordinates are in<br>
>>>> WGS84<br>
>>>> data.proj<-spTransfrom(data,<br>
>>>> CRS("+init=epsg:the.correct.epsg.number.of.your.projection")<br>
>>>>          <br>
>>> Looks like:<br>
>>><br>
>>> <a href="http://spatialreference.org/ref/epsg/32118/" _mce_href="http://spatialreference.org/ref/epsg/32118/">http://spatialreference.org/ref/epsg/32118/</a><br>
>>><br>
>>> but has some different parameters. Search on "New York" in this site for<br>
>>> alternatives.<br>
>>><br>
>>> Roger<br>
>>><br>
>>>        <br>
>>>> HTH<br>
>>>><br>
>>>> Alex<br>
>>>><br>
>>>><br>
>>>> Le 24/08/2010 16:51, Jonathan Marc Bearak a écrit :<br>
>>>>          <br>
>>>>> Hi,<br>
>>>>><br>
>>>>> I'm new to GIS and have been trying to convert latitude and longitude<br>
>>>>> to/from state plane coordinates.<br>
>>>>><br>
>>>>> I've tried using the project() program from the proj4 library to convert<br>
>>>>> lat/lng to FIPS 3104 (New York State Long Island).<br>
>>>>><br>
>>>>> No matter how I go about this, however, the coordinates come out wrong.<br>
>>>>> Eg.,<br>
>>>>>                "+proj=lcc +lat_1=40.66666666666666<br>
>>>>> +lat_2=41.03333333333333 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000<br>
>>>>> +y_0=0 +units=ft +no_defs +datum=NAD83",<br>
>>>>>                "+proj=lcc +a=6378137 +es=.0066943800229 +lon_0=-74<br>
>>>>> +lat_1=41d2 +lat_2=40d40 +lat_0=40d10 +x_0=300000 +y_0=0 +units=ft<br>
>>>>> +no_defs +datum=NAD83",<br>
>>>>><br>
>>>>> E.g., if I try the inverse, to convert 1062791, 209606.6 to lat/lng,<br>
>>>>> project() prints:  43.04762 -76.89626.  The correct coordinates, however,<br>
>>>>> are: 40.7416495 -073.7165681.<br>
>>>>><br>
>>>>> I've been reading the mailing lists and searching Google and R project<br>
>>>>> PDFs and manual pages without any luck for an embarrassingly long number<br>
>>>>> of hours without any luck.<br>
>>>>><br>
>>>>> Thanks for any help.<br>
>>>>><br>
>>>>> Best,<br>
>>>>> Jonathan<br>
>>>>> _______________________________________________<br>
>>>>> R-sig-Geo mailing list<br>
>>>>> R-sig-Geo@stat.math.ethz.ch<br>
>>>>> <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" _mce_href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br>
>>>>><br>
>>>>>            <br>
>>>> _______________________________________________<br>
>>>> R-sig-Geo mailing list<br>
>>>> R-sig-Geo@stat.math.ethz.ch<br>
>>>> <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" _mce_href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br>
>>>><br>
>>>>          <br>
>>><br>
>>> _______________________________________________<br>
>>> R-sig-Geo mailing list<br>
>>> R-sig-Geo@stat.math.ethz.ch<br>
>>> <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" _mce_href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br>
>>><br>
>>>        <br>
><br>
<br>
_______________________________________________<br>
R-sig-Geo mailing list<br>
R-sig-Geo@stat.math.ethz.ch<br>
<a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" _mce_href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br>
</div></div></blockquote></div></body></html>