mardi 24 mars 2015

CRS not embedded by maptools in R


I'm using the maptools package in R to merge some data to a shapefile.


When I open the original input shapefile in QGIS, QGIS automatically picks up on the CRS.


When I open the output shapefile from R, I need to select the CRS.


This happens even if I specify the CRS in my R code. Is there a solution to this?



# Load libraries ----------
library("maptools")

# Read shapefile ----------
LSOA <- readShapeSpatial("c:\\Temp\\LSOA11.shp")

# Set CRS ----------
# http://ift.tt/1DSDtv6
OSGB36.CRS <- CRS("+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs")
proj4string(LSOA)<-OSGB36.CRS

# Check CRS ----------
proj4string(LSOA)

# Filter ----------
LSOA$Flag <- grepl("YORK",LSOA$LSOA11NM, ignore.case = TRUE)
LSOA <- LSOA[LSOA$Flag==TRUE,]

# Plot to check filtering ----------
plot(LSOA, col = 'light blue')

# Export shapefile ----------
writeSpatialShape(LSOA,fn="c:\\Temp\\LSOA_Fuel_Poverty")




Aucun commentaire:

Enregistrer un commentaire