Re: [R] Projecting data on a world map using long/lat

2010-12-13 Thread mathijsdevaan

Hi Patrick,

Thanks! That worked perfectly!

M
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Projecting-data-on-a-world-map-using-long-lat-tp3081298p3085834.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Projecting data on a world map using long/lat

2010-12-11 Thread Patrick Hausmann

Hi Mathijs,

this should work:

library(maptools)
library(ggplot2)
gpclibPermit()
theme_set(theme_bw())

#setwd(C:\\foo) point to your local dir
# Data: http://thematicmapping.org/downloads/world_borders.php
world.shp - readShapeSpatial(TM_WORLD_BORDERS-0.3.shp)

# check for region-id - Use FIPS
head(world@data)

## see licence, not GPL
world.shp.p - fortify.SpatialPolygonsDataFrame(world.shp, region=FIPS)

world - merge(world.shp.p, world.shp, by.x=id, by.y=FIPS)

head(world)
dim(world)

# only the worldmap
p - ggplot(data=world, aes(x=long, y=lat, group=group)) + 
geom_polygon(fill=#63D1F4)

p - p + geom_path(color=white) + coord_equal()
ggsave(p, width=11.69, height=8.27, file=world_map.jpg)

## Add some locations
cities - read.table(textConnection(
longlat  city  pop
-58.381944 -34.599722 'Buenos Aires' 11548541
14.25 40.83 Neapel 962940), header = TRUE)

p1 - p + geom_point(data = cities, aes(group = NULL), shape=5,
 color='black')
ggsave(p1, width=11.69, height=8.27, file=world_map_2.jpg)

Regards,
Patrick


Am 10.12.2010 17:53, schrieb mathijsdevaan:


Thanks for the suggestions, but I am not there yet (I'm a real novice). In
the code provided by Patrick (see below), I changed the shape input (from
sids to world) which I downloaded here:
http://thematicmapping.org/downloads/world_borders.php. As a result I also
need to change the CNTY_ID and id in the code, but I have no idea what
to put there. Could you please help me? Thanks!

Mathijs

library(maptools)
library(ggplot2)
gpclibPermit()

myshp- readShapeSpatial(system.file(shapes/sids.shp,
package=maptools))

## see licence, not GPL
myshp.points- fortify.SpatialPolygonsDataFrame(myshp,
region=CNTY_ID)

shpm- merge(myshp.points, myshp, by.x=id, by.y=CNTY_ID)

head(shpm)

p- ggplot(shpm, aes(long, lat, group=group, fill=NWBIR74))
p- p + geom_polygon() + geom_path(color=white) + coord_equal()

## Add some locations
cities- read.table(textConnection(
longlat  city  val
-78.644722 35.818889  Raleigh   323
-80.84 35.226944  Charlotte  510
-82.555833 35.58  Asheville400), header = TRUE)

p- p + geom_point(aes( fill=NULL, group = NULL, size=val),
  data = cities, color= 'black')
p


__
R-help@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.


Re: [R] Projecting data on a world map using long/lat

2010-12-10 Thread Barry Rowlingson
On Fri, Dec 10, 2010 at 2:21 AM, mathijsdevaan mathijsdev...@gmail.com wrote:

 Hi,

 I have a dataset (CSV) with some counts of firms located around the globe.
 Each count is assigned to the longitude and latitude of the specific
 location. Now I want to plot these counts on a world map using dots (size of
 dots represent the count). I have been unable to find any info on whether
 this is possible and if so, how? Can you please help me? Thanks!


 Plotting points is trivial - plot(data$x,data$y,pch=19,cex=data$size)
will do for a start. i'm guessing your real problem is when you say
'on a world map'.

 How detailed a world map do you need? There's an outline one in the
'maps' package, or you should be able to find a shapefile of the world
on the web somewhere and use that via the rgdal package.

 Other options include making a KML file of your points and overlaying
on google earth. Or getting google map tiles and overlaying on
that Or exporting your data to a GIS format and doing the pretty
map in something like Quantum GIS. What are you trying to do exactly?

also, you might want to post to r-sig-geo



Barry

__
R-help@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.


Re: [R] Projecting data on a world map using long/lat

2010-12-10 Thread Michael Sumner
Oh, whoops I was looking for the vote up button and accidentally hit
Reply All.



On Fri, Dec 10, 2010 at 8:25 PM, Barry Rowlingson
b.rowling...@lancaster.ac.uk wrote:
 On Fri, Dec 10, 2010 at 2:21 AM, mathijsdevaan mathijsdev...@gmail.com 
 wrote:

 Hi,

 I have a dataset (CSV) with some counts of firms located around the globe.
 Each count is assigned to the longitude and latitude of the specific
 location. Now I want to plot these counts on a world map using dots (size of
 dots represent the count). I have been unable to find any info on whether
 this is possible and if so, how? Can you please help me? Thanks!


  Plotting points is trivial - plot(data$x,data$y,pch=19,cex=data$size)
 will do for a start. i'm guessing your real problem is when you say
 'on a world map'.

  How detailed a world map do you need? There's an outline one in the
 'maps' package, or you should be able to find a shapefile of the world
 on the web somewhere and use that via the rgdal package.

  Other options include making a KML file of your points and overlaying
 on google earth. Or getting google map tiles and overlaying on
 that Or exporting your data to a GIS format and doing the pretty
 map in something like Quantum GIS. What are you trying to do exactly?

 also, you might want to post to r-sig-geo



 Barry

 __
 R-help@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.




-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@gmail.com

__
R-help@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.


Re: [R] Projecting data on a world map using long/lat

2010-12-10 Thread mathijsdevaan

Thanks for the suggestions, but I am not there yet (I'm a real novice). In
the code provided by Patrick (see below), I changed the shape input (from
sids to world) which I downloaded here:
http://thematicmapping.org/downloads/world_borders.php. As a result I also
need to change the CNTY_ID and id in the code, but I have no idea what
to put there. Could you please help me? Thanks!

Mathijs

library(maptools)
library(ggplot2)
gpclibPermit()

myshp- readShapeSpatial(system.file(shapes/sids.shp,
package=maptools))

## see licence, not GPL
myshp.points- fortify.SpatialPolygonsDataFrame(myshp,
region=CNTY_ID)

shpm- merge(myshp.points, myshp, by.x=id, by.y=CNTY_ID)

head(shpm)

p - ggplot(shpm, aes(long, lat, group=group, fill=NWBIR74))
p - p + geom_polygon() + geom_path(color=white) + coord_equal()

## Add some locations
cities - read.table(textConnection(
longlat  city  val
-78.644722 35.818889  Raleigh   323
-80.84 35.226944  Charlotte  510
-82.555833 35.58  Asheville400), header = TRUE)

p - p + geom_point(aes( fill=NULL, group = NULL, size=val),
 data = cities, color= 'black')
p
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Projecting-data-on-a-world-map-using-long-lat-tp3081298p3082305.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


[R] Projecting data on a world map using long/lat

2010-12-09 Thread mathijsdevaan

Hi,

I have a dataset (CSV) with some counts of firms located around the globe.
Each count is assigned to the longitude and latitude of the specific
location. Now I want to plot these counts on a world map using dots (size of
dots represent the count). I have been unable to find any info on whether
this is possible and if so, how? Can you please help me? Thanks!

Mathijs   
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Projecting-data-on-a-world-map-using-long-lat-tp3081298p3081298.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Projecting data on a world map using long/lat

2010-12-09 Thread Greg Snow
The symbols function can add circles to an existing plot with the diameter 
based on another variable.  You may need to project points if you draw a map 
with a projection.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of mathijsdevaan
 Sent: Thursday, December 09, 2010 7:21 PM
 To: r-help@r-project.org
 Subject: [R] Projecting data on a world map using long/lat
 
 
 Hi,
 
 I have a dataset (CSV) with some counts of firms located around the
 globe.
 Each count is assigned to the longitude and latitude of the specific
 location. Now I want to plot these counts on a world map using dots
 (size of
 dots represent the count). I have been unable to find any info on
 whether
 this is possible and if so, how? Can you please help me? Thanks!
 
 Mathijs
 --
 View this message in context: http://r.789695.n4.nabble.com/Projecting-
 data-on-a-world-map-using-long-lat-tp3081298p3081298.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@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.

__
R-help@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.