0

I'm trying to create spatial point data and lay it over a shapefile. I'm starting out with simple LatLons, converting to sp using Coordinates(), changing the CRS to the same as the shapefile, and then reprojecting using spTransform into the same projection as the shapefile. However, when I check the summary of my point data afterward, it still appears to be in LatLon form. E.g.:

# Before spTransform

summary(new)

Object of class SpatialPointsDataFrame
Coordinates:
                min       max
coords.x1  40.68967  40.73516
coords.x2 -73.96243 -73.90697
Is projected: TRUE 
proj4string :
[+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333
+lat_0=40.16666666666666 +lon_0=-74 +x_0=300000.0000000001 +y_0=0
+datum=NAD83 +units=us-ft +no_defs +ellps=GRS80 +towgs84=0,0,0]
Number of points: 25

new<-spTransform(new,CRS(proj4string(bb)))

> summary(new)

Object of class SpatialPointsDataFrame
Coordinates:
                min       max
coords.x1  40.68967  40.73516
coords.x2 -73.96243 -73.90697
Is projected: TRUE 
proj4string :
[+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333
+lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +datum=NAD83
+units=us-ft +no_defs +ellps=GRS80 +towgs84=0,0,0]
Number of points: 25

The shapefile I'm taking the projection from looks like this:

summary(bb)

Object of class SpatialPolygonsDataFrame
Coordinates:
       min       max
x 972619.7 1030453.5
y 146772.0  208564.1
Is projected: TRUE 
proj4string :
[+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333
+lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +datum=NAD83
+units=us-ft +no_defs +ellps=GRS80 +towgs84=0,0,0]

I know that I've done this before, which is why I'm scratching my head at why spTransform leaves me with point data that is still in LatLon form?

  • Just call proj4string and remove the CRS wrapper. – Jeffrey Evans Apr 26 '18 at 1:53
  • You must first set the CRS into what it really is, I suppose EPSG:4326 '+proj=longlat +datum=WGS84 +no_defs '. Then you can ask spTransform to re-project data into another system. Stop and think and you will see what is wrong with what you have at status # Before spTransform – user30184 Apr 26 '18 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.