[R-sig-Geo] map projections with sp data
Alex Mandel
tech_dev at wildintellect.com
Fri Mar 16 04:04:37 CET 2012
http://spatialreference.org/ is a great resource for looking up proj
strings for existing defined projections.
Enjoy,
Alex
On 03/15/2012 07:29 PM, Jonathan Callahan wrote:
> Thanks for the helpful suggestion Michael.
>
> I have done this kind of conversion from shapefile to lon-lat projection
> before.
>
> My problem now is that I would like to take lon-lat data and transform it
> into a lambert conformal projection with particular parameters. What I'm
> failing on is how to specify the destination projection I want. Where is
> there a description of all the projection strings for things like Lambert
> conformal?
>
> ...
>
> Aha ... I found what I wanted: the PROJ strings are specified in the users
> manual
>
> ftp://ftp.remotesensing.org/proj/OF90-284.pdf
>
> In my case I wanted Lambert conformal conic:
>
> +proj=lcc +lon 0=90w +lat 1=20n +lat 2=60n
>
>
>
>
> On Thu, Mar 15, 2012 at 5:28 PM, Michael Sumner <mdsumner at gmail.com> wrote:
>
>> spTransform in the rgdal package will do this very simply. You just
>> need the source metadata set on the original object, and spTransform
>> handles the rest.
>>
>> From the help page:
>>
>> require(rgdal)
>> scot_BNG <- readOGR(system.file("vectors", package = "rgdal")[1],
>> "scot_BNG")
>> scot_LL <- spTransform(scot_BNG, CRS("+proj=longlat +datum=WGS84"))
>>
>> ## metadata is already correctly set
>> proj4string(scot_BNG)
>> ## [1] " +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000
>> +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy
>> +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894"
>>
>>
>> class(scot_BNG) ## "SpatialPolygonsDataFrame"
>>
>> ## transform (from whatever the current CRS is to any other supported
>> PROJ.4 CRS)
>> scot_LL <- spTransform(scot_BNG, CRS("+proj=longlat +datum=WGS84"))
>>
>> mapproject (in package mapproj I assume) is a much more raw interface
>> for transforming from long/lat, and you might as well use ?project
>> from rgdal which also can do the inverse. If you cannot install rgdal
>> that's another story, but it's trivial on Windows (because of work by
>> the maintainers and the R Core Team), and well documented for other
>> platforms.
>>
>> Cheers, Mike.
>>
>>
>> On Fri, Mar 16, 2012 at 11:15 AM, Jonathan Callahan
>> <jonathan at mazamascience.com> wrote:
>>> I am looking for a way to reproject data that exists in a
>>> SpatialPolygonsDataFrame. (I think it's the same data as in the rworldmap
>>> package.)
>>>
>>> I am quite familiar with mapproject() which works well the maps and
>> mapdata
>>> packages and am hoping there is an equivalent to mapproject() that could
>>> work with SpatialPolygons data.
>>>
>>> Or is there a simple way to get the x an y data arrays out of the
>>> SpatialPolygons?
>>>
>>> Thanks in advance,
>>>
>>> Jon
>>>
>>> --
>>> Jonathan Callahan, PhD
>>> Mazama Science
>>> 206-708-5028
>>> mazamascience.com
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
>>
>> --
>> Michael Sumner
>> Institute for Marine and Antarctic Studies, University of Tasmania
>> Hobart, Australia
>> e-mail: mdsumner at gmail.com
>>
>>
>
>
More information about the R-sig-Geo
mailing list