Being a newbie to GIS, I am trying to create a map using shapefiles and addresses found online, as an exercise. The steps are below:
- I downloaded a shapefile of Connecticut from the following link (Connecticut State House Districts; CT House Districts; 2010)
- I picked up a list of hospitals in Connecticut from this link
- I use the R script from this link to obtain a long/lat for each hospital
- I followed this discussion here to create a shapefile for hospitals; hospitals are presented as points
- I used QGIS to import the 2 shapefiles, the Connecticut boundary file, and the hospital location file
But I find that the hospitals are not located within Connecticut: the dots are displaced to other empty space, not on the Connecticut map.
I wonder if I missed anything when I was creating the shapefile for hospitals. Can anyone help? Thanks.
Below is my R-script for creating the hospital shapefile. I guess the
CRS is the problem, but I'm not sure.
hosp.shp <- SpatialPointsDataFrame(coords=hosp.list[,c("coord_x","coord_y")],data=data.frame(hosp_name=hosp.list[,"hosp_name"]),proj4string=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")) writeOGR(hosp.shp,dsn="hosp_shp",layer="hosp_shp",driver="ESRI Shapefile")
I am using wgs84 version of Connecticut State House Districts, CT House Districts, 2010. I don't have specific reason to use this shp file, I just see this has quite a few of polygon, which may be easier for me to continue my GIS exercise.
Some elaboration on step 2. From the link, I have the names of quite a few of hospital, I used R to access google map to extract the long/lat for each hospital, e.g. "Advanced Center for Rehabilitation Medicine" has the long/lat of 41.1175966,-73.4078968.
I used google map to help me do the geocoding, and now I have a table with the name of the hospital, its long and lat. Then this table goes to step 3, using R again to produce a shp file. I import the self-made and the Connecticut shp file into QGIS, both layer can be show, and I can see the hospital seems to cluster to some location, but all of the hospitals are not located within the boundary of Connecticut, they are FAR away.
For the hospital shp file, I used
CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"), which is copied direct from the Connecticut file, hoping that this will fix the "misalignment" problem, but no dice.