[R-sig-Geo] Error In proj4string
alannie
agg18 at pitt.edu
Mon Oct 20 21:09:57 CEST 2014
Thanks, Ebzer!
I see the issue now. I have no idea how my code became messed up that way. You are 100% correct, as the correct version that you provided is what has worked in the past and not the cbind("bio1","bio2").
Appreciate your response!
Alannie
________________________________
From: edzer [via R-sig-geo] <ml-node+s2731867n7587307h51 at n2.nabble.com>
Sent: Monday, October 20, 2014 2:57 PM
To: Grant, Alannie Grace Gabrielle
Subject: Re: Error In proj4string
Alannie, you get an error, not a warning, and I doubt this code has ever
worked before. Read on:
On 10/20/2014 08:21 PM, alannie wrote:
> Hi list!
>
> I have been trying to run some code that I have run tons of times before,
> only to get a warning message:
>
> ##add in ASCII raster maps bio1-11
>> bio1 <- readGDAL("bio1.asc")
> bio1.asc has GDAL driver AAIGrid
> and has 1486 rows and 1347 columns
>> bio2 <- readGDAL("bio2.asc")
> bio2.asc has GDAL driver AAIGrid
> and has 1486 rows and 1347 columns
>> bio3 <- readGDAL("bio3.asc")
> bio3.asc has GDAL driver AAIGrid
> and has 1486 rows and 1347 columns
>> bio4 <- readGDAL("bio4.asc")
> bio4.asc has GDAL driver AAIGrid
> and has 1486 rows and 1347 columns
>> bio5 <- readGDAL("bio5.asc")
> bio5.asc has GDAL driver AAIGrid
> and has 1486 rows and 1347 columns
>> bio6 <- readGDAL("bio6.asc")
> bio6.asc has GDAL driver AAIGrid
> and has 1486 rows and 1347 columns
>> bio7 <- readGDAL("bio7.asc")
> bio7.asc has GDAL driver AAIGrid
> and has 1486 rows and 1347 columns
>> bio8 <- readGDAL("bio8.asc")
> bio8.asc has GDAL driver AAIGrid
> and has 1486 rows and 1347 columns
>> bio9 <- readGDAL("bio9.asc")
> bio9.asc has GDAL driver AAIGrid
> and has 1486 rows and 1347 columns
>> bio10 <- readGDAL("bio10.asc")
> bio10.asc has GDAL driver AAIGrid
> and has 1486 rows and 1347 columns
>> bio11 <- readGDAL("bio11.asc")
> bio11.asc has GDAL driver AAIGrid
> and has 1486 rows and 1347 columns
> ###combine raster maps
>> temp <- cbind("bio1", "bio2", "bio3",
>> "bio4","bio5","bio6","bio7","bio8","bio9","bio10","bio11")
You are cbind-ing length-one character vectors, but you probably want to:
temp <- cbind(bio1, bio2, bio3) # etc
i.e. cbind-ing the SpatialGridDataFrame objects. Indeed,
> library(sp)
> methods(cbind)
[1] cbind.data.frame cbind.SpatialGridDataFrame*
[3] cbind.ts*
sp provides a method for this. After this, the rest should work.
>> names(temp) <- c("bio1", "bio2", "bio3",
>> "bio4","bio5","bio6","bio7","bio8","bio9","bio10","bio11")
> ###read in point file lin.shp
>> lin <- readShapePoints("lin.shp")
> ###set proj4strings to the same proj4string: *this is where the issue is*
>> proj4string(lin)= proj4string(temp)
> *Error in (function (classes, fdef, mtable) :
> unable to find an inherited method for function ‘proj4string’ for
> signature ‘"matrix"’*
> ###what is in "temp" ?
>> temp
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
> [,11]
> [1,] "bio1" "bio2" "bio3" "bio4" "bio5" "bio6" "bio7" "bio8" "bio9" "bio10"
> "bio11"
> attr(,"names")
> [1] "bio1" "bio2" "bio3" "bio4" "bio5" "bio6" "bio7" "bio8" "bio9"
> "bio10" "bio11"
>> class(temp)
> [1] "character"
> ###end
>
> I am not sure why this issue is occurring.
> I have checked all the projections - all files are in the same projection.
> I have restarted R - nothing gets better.
> I have tried data for a different organism (it is the same data, but
> belonging to a different species) - this does not work.
> I have the following packages loaded:
> library(maptools)
> library(adehabitatHS)
> library(SDMTools)
> library(spatial)
> library(sp)
> library(rgdal)
> library(dismo)
> library(shapefiles)
>
>
> Thanks, List!
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Error-In-proj4string-tp7587305.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]</user/SendEmail.jtp?type=node&node=7587307&i=0>
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Edzer Pebesma, Co-Editor-in-Chief Computers & Geosciences
Institute for Geoinformatics (ifgi), University of Münster
Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251
83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAC227795
_______________________________________________
R-sig-Geo mailing list
[hidden email]</user/SendEmail.jtp?type=node&node=7587307&i=1>
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[http://r-sig-geo.2731867.n2.nabble.com/images/icon_attachment.gif] signature.asc (501 bytes) Download Attachment<http://r-sig-geo.2731867.n2.nabble.com/attachment/7587307/0/signature.asc>
________________________________
If you reply to this email, your message will be added to the discussion below:
http://r-sig-geo.2731867.n2.nabble.com/Error-In-proj4string-tp7587305p7587307.html
To start a new topic under R-sig-geo, email ml-node+s2731867n2731867h11 at n2.nabble.com
To unsubscribe from Error In proj4string, click here<http://r-sig-geo.2731867.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7587305&code=YWdnMThAcGl0dC5lZHV8NzU4NzMwNXwtMjAxOTYzNDk0MQ==>.
NAML<http://r-sig-geo.2731867.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Error-In-proj4string-tp7587305p7587308.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list