[R] map2poly - map lat/long cannot be unconstrained?

Roger Bivand Roger.Bivand at nhh.no
Tue Mar 16 12:54:04 CET 2010


An ideal question for R-sig-geo.

Firstly, consider using sp classes, which try to help more in plotting
correctly specified spatial data, and note that Map2poly has not only been
deprecated for a long time, but was recently removed from the namespace of
the maptools package.

Secondly, consider that the aspect of spatial data should not in general be
manipulable, meters should stay meters on both axes. 

Thrirdly, if you want to overplot points, do use points(), not plot(). Using
methods for sp classes would handle this directly, where plot(..., add=TRUE)
assumes that a previous plot() call has set the plotting window and axes.

Hope this helps,

Roger


Euan Reavie wrote:
> 
> Using the maptools function "map2poly" I have created a map/polylist
> object
> - a map of the Great Lakes. My goal is to passively plot additional data
> on
> this map. Unfortunately I am not able to change (distort) the relative
> scale
> of the axes for the map, and so the sample points do not line up correctly
> on the map.
> 
> In the code below, notice that I have set the same axis ranges on each
> plot
> for x (longitude) and y (latitude), and yet it has no effect on the map
> plot. For example, if I stretch the plot window vertically, the y data
> spread out accordingly, but the map remains undistorted. No matter how
> much
> I try to stretch the y axis, the y:x ratio scale remains 1:1. How do I
> force
> the map to fit the ranges that I set like I can for the data plot?
> 
> *# make the map object "lakes"
> tmp <- read.shape('D:/R/great lakes map/grtlakes/grtlakes')
> lakes <- Map2poly(tmp)
> 
> # read sample location data to be plotted on map
> locs <- read.table("locs.csv", header=TRUE, sep=",", na.strings="NA",
> dec=".", strip.white=TRUE)
> 
> # plot map, then sample locations
> plot(lakes,xlim=range(-76,-93), ylim=range(40,50))
> par(new=TRUE) # put next plot on same graph
> plot(LATITUDE~LONGITUDE, data=locs,xlim=range(-76,-93),ylim=range(40,50))
> box()*
> 
> 
> Thank you for any help - Euan.
> 
> Euan D. Reavie
> 
> Center for Water and the Environment
> 
> Natural Resources Research Institute
> 
> University of Minnesota Duluth
> 
> 1900 East Camp Street, Ely, MN 55731
> 
> email ereavie *at sign* nrri.umn.edu
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 


-----
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway

-- 
View this message in context: http://n4.nabble.com/map2poly-map-lat-long-cannot-be-unconstrained-tp1593866p1594757.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list