Hi R users I need the map of France?s ? communes ? (towns) to build a map Is there a way to get it? More generally: How to do to get the map of a country and its different geographical levels? Best regards -- View this message in context: http://old.nabble.com/map-of-a-country-and-its-different-geographical-levels-tp26225645p26225645.html Sent from the R help mailing list archive at Nabble.com.
Greg Snow
2009-Nov-06 17:35 UTC
[R] map of a country and its different geographical levels
The maptools and sp packages have functions to read in and plot shapefiles. There are many sources of shapefiles on the web that you could download and read into R. One possibility is: http://downloads.cloudmade.com/europe/france#breadcrumbs Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of CE.KA > Sent: Thursday, November 05, 2009 7:08 PM > To: r-help at r-project.org > Subject: [R] map of a country and its different geographical levels > > > > > Hi R users > > I need the map of France?s ? communes ? (towns) to build a map > > Is there a way to get it? > > More generally: > How to do to get the map of a country and its different geographical > levels? > > Best regards > > -- > View this message in context: http://old.nabble.com/map-of-a-country- > and-its-different-geographical-levels-tp26225645p26225645.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
Hi Greg I downloaded the file "france.shapefiles.zip" Then i unziped it. There were 4 files interesting me: - france_administrative.dbf - france_administrative.prj - france_administrative.shp - france_administrative.shx How can i do to read the map "france_administrative" with R I tried this script that i found on a french web site: library(maptools) library(rgdal) library(foreign) proj.string <- "+init=epsg:27572 +proj=lcc +lat_1=45.90287723937 +lat_2=47.69712276063 +lat_0=46.8 +lon_0=2.337229104484 +x_0=600000 +y_0=2200000 +units=m +pm=greenwich" proj.string.geo <- "+proj=longlat +datum=WGS84" france <- readShapePoly("france_administrative.shp", proj4string=CRS(proj.string)) france <- spTransform(france, CRS(proj.string.geo)) save(france, file="france.rda") But there was an error message: Error in .asSpatialPolygonsShapes(Map$Shapes, IDs, proj4string proj4string, : Not polygon shapes Best regards -- View this message in context: http://old.nabble.com/map-of-a-country-and-its-different-geographical-levels-tp26225645p26240900.html Sent from the R help mailing list archive at Nabble.com.
Roger Bivand
2009-Nov-07 12:31 UTC
[R] map of a country and its different geographical levels
Perhaps asking on R-sig-geo might help (as well as reading the function help files, scripts found lying around somewhere may be stale ...)? If readShapePoly() (deprecated - use readShapeSpatial() instead) says that the data are not polygons, then they are not. If you want to fill administrative boundaries polygons, you need polygons, not lines. The source you are using is based on OpenStreetMaps, so more likely to be lines, and as the website says, not authorised. You need to locate an appropriate source of boundary data first for your geographical features of interest. There are very few national mapping agencies that make these data available free (the US led on this, some others are understanding too, slowly). Having done that, use readOGR() in rgdal to read the polygon shapefile into a SpatialPolygonsDataFrame (maybe use ogrInfo() in rgdal to explore the shapefile). Choose readOGR() rather than readShapeSpatial() if the shapefile has a *.prj file specifying its coordinate reference system. If you need NUTS3 entities, try the "france" map data in the maps package. In addition, note that your shapefile is very detailed, and suitable for poster-size output with lots of boundary detail. You may prefer less boundary detail - another search criterion in looking for a source. Eurostat/GISCO provides some boundaries at various spatial "scales", so giving faster but coarser plotting when the 1:10M or 1:20M variants are chosen. Hope this helps, Roger CE.KA wrote:> > Hi Greg > > I downloaded the file "france.shapefiles.zip" > Then i unziped it. > There were 4 files interesting me: > - france_administrative.dbf > - france_administrative.prj > - france_administrative.shp > - france_administrative.shx > How can i do to read the map "france_administrative" with R > > I tried this script that i found on a french web site: > library(maptools) > > library(rgdal) > > library(foreign) > proj.string <- "+init=epsg:27572 +proj=lcc +lat_1=45.90287723937 > > +lat_2=47.69712276063 +lat_0=46.8 +lon_0=2.337229104484 > > +x_0=600000 +y_0=2200000 +units=m +pm=greenwich" > proj.string.geo <- "+proj=longlat +datum=WGS84" > france <- readShapePoly("france_administrative.shp", > proj4string=CRS(proj.string)) > france <- spTransform(france, CRS(proj.string.geo)) > save(france, file="france.rda") > > But there was an error message: > Error in .asSpatialPolygonsShapes(Map$Shapes, IDs, proj4string > proj4string, : > Not polygon shapes > > Best regards >-- View this message in context: http://old.nabble.com/map-of-a-country-and-its-different-geographical-levels-tp26225645p26240923.html Sent from the R help mailing list archive at Nabble.com.
hadley wickham
2009-Nov-07 12:51 UTC
[R] map of a country and its different geographical levels
> If readShapePoly() (deprecated - use readShapeSpatial() instead) says that > the data are not polygons, then they are not. If you want to fill > administrative boundaries polygons, you need polygons, not lines. The source > you are using is based on OpenStreetMaps, so more likely to be lines, and as > the website says, not authorised. You need to locate an appropriate source > of boundary data first for your geographical features of interest. There are > very few national mapping agencies that make these data available free (the > US led on this, some others are understanding too, slowly).http://gadm.org/country seems to provide this data for very many countries - and in sp objects too! Hadley -- http://had.co.nz/