Error to obtain coordinate reference system argument from a raster image in R2 Shapefile vectors will not...

How to prevent YouTube from showing already watched videos?

How to deal with or prevent idle in the test team?

Java - What do constructor type arguments mean when placed *before* the type?

How do I repair my stair bannister?

Simulating a probability of 1 of 2^N with less than N random bits

How will losing mobility of one hand affect my career as a programmer?

Superhero words!

How can I successfully establish a nationwide combat training program for a large country?

Is it okay / does it make sense for another player to join a running game of Munchkin?

Giant Toughroad SLR 2 for 200 miles in two days, will it make it?

Is there an wasy way to program in Tikz something like the one in the image?

Did US corporations pay demonstrators in the German demonstrations against article 13?

Greatest common substring

Books on the History of math research at European universities

Word describing multiple paths to the same abstract outcome

Why is delta-v is the most useful quantity for planning space travel?

The One-Electron Universe postulate is true - what simple change can I make to change the whole universe?

Calculating the number of days between 2 dates in Excel

Indicating multiple different modes of speech (fantasy language or telepathy)

Is exact Kanji stroke length important?

Can the harmonic series explain the origin of the major scale?

Pronouncing Homer as in modern Greek

How can I raise concerns with a new DM about XP splitting?

What is the term when two people sing in harmony, but they aren't singing the same notes?



Error to obtain coordinate reference system argument from a raster image in R


2 Shapefile vectors will not plot properly in same spaceExtract values from raster using point data with buffer in RProcessing vector to raster faster with RCrop a raster by a grid shapefile with different extensions in RCRS Projection problems prevent spatial merge in RExport RGB data (from a tiff image) in excel formatAccess to attribute in rasterlayer in ROpening rotated raster in RRaster alignment doesn't produce aligned resultsProblem using 'masker' while plotting KDE - R













3















I got an error when i wanted to obtain the CRS from stacklayer. I don´t know what could it be. I need some advice or help to obtain it.
This is my code.



#LOAD RASTER LIBRARY
>library(rgdal)
>library(raster)
>ndvi<-raster('ndvi2005.tif')
>ndvi2<-raster('ndvi2006.tif')

#RASTER STACK
>stk <- stack(ndvi1, ndvi2)
#DISPLAY STK
>stk
class : RasterStack
dimensions : 1160, 1573, 1824680, 2 (nrow, ncol, ncell, nlayers)
resolution : 0.008627311, 0.008627319 (x, y)
extent : -74.49244, -60.92168, -20.00769, -10 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
names : ndvi2005, ndvi2006
min values : NA, NA
max values : NA, NA


then I changed the NA values



>stk[stk==0]<- NA
>stk
class : RasterBrick
dimensions : 1160, 1573, 1824680, 2 (nrow, ncol, ncell, nlayers)
resolution : 0.008627311, 0.008627319 (x, y)
extent : -74.49244, -60.92168, -20.00769, -10 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : ndvi2005, ndvi2006
min values : -0.3, -0.3
max values : 0.9990, 0.9993


then when i wanted to obtain de coordinate reference system with CRS() i got the next message



>cord<-CRS(stk)
>Error in !is.na(projargs) && !nzchar(projargs) :
invalid 'x' type in 'x && y'


I know that my projection is +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 but i have in total 100 stacklayers in differents proyections that i need to analize each one, but i dont know what is my mistake or is something wrong with my code because then i want to use the output of CRS(stk)in the function raster(...., CRS=cord) as an input.










share|improve this question




















  • 1





    Use projection() not CRS. Sp weirdly has two functions for this, really painful

    – mdsumner
    May 25 '16 at 0:40






  • 1





    You could also proj4string which is the sp convention.

    – Jeffrey Evans
    May 25 '16 at 2:10
















3















I got an error when i wanted to obtain the CRS from stacklayer. I don´t know what could it be. I need some advice or help to obtain it.
This is my code.



#LOAD RASTER LIBRARY
>library(rgdal)
>library(raster)
>ndvi<-raster('ndvi2005.tif')
>ndvi2<-raster('ndvi2006.tif')

#RASTER STACK
>stk <- stack(ndvi1, ndvi2)
#DISPLAY STK
>stk
class : RasterStack
dimensions : 1160, 1573, 1824680, 2 (nrow, ncol, ncell, nlayers)
resolution : 0.008627311, 0.008627319 (x, y)
extent : -74.49244, -60.92168, -20.00769, -10 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
names : ndvi2005, ndvi2006
min values : NA, NA
max values : NA, NA


then I changed the NA values



>stk[stk==0]<- NA
>stk
class : RasterBrick
dimensions : 1160, 1573, 1824680, 2 (nrow, ncol, ncell, nlayers)
resolution : 0.008627311, 0.008627319 (x, y)
extent : -74.49244, -60.92168, -20.00769, -10 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : ndvi2005, ndvi2006
min values : -0.3, -0.3
max values : 0.9990, 0.9993


then when i wanted to obtain de coordinate reference system with CRS() i got the next message



>cord<-CRS(stk)
>Error in !is.na(projargs) && !nzchar(projargs) :
invalid 'x' type in 'x && y'


I know that my projection is +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 but i have in total 100 stacklayers in differents proyections that i need to analize each one, but i dont know what is my mistake or is something wrong with my code because then i want to use the output of CRS(stk)in the function raster(...., CRS=cord) as an input.










share|improve this question




















  • 1





    Use projection() not CRS. Sp weirdly has two functions for this, really painful

    – mdsumner
    May 25 '16 at 0:40






  • 1





    You could also proj4string which is the sp convention.

    – Jeffrey Evans
    May 25 '16 at 2:10














3












3








3


0






I got an error when i wanted to obtain the CRS from stacklayer. I don´t know what could it be. I need some advice or help to obtain it.
This is my code.



#LOAD RASTER LIBRARY
>library(rgdal)
>library(raster)
>ndvi<-raster('ndvi2005.tif')
>ndvi2<-raster('ndvi2006.tif')

#RASTER STACK
>stk <- stack(ndvi1, ndvi2)
#DISPLAY STK
>stk
class : RasterStack
dimensions : 1160, 1573, 1824680, 2 (nrow, ncol, ncell, nlayers)
resolution : 0.008627311, 0.008627319 (x, y)
extent : -74.49244, -60.92168, -20.00769, -10 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
names : ndvi2005, ndvi2006
min values : NA, NA
max values : NA, NA


then I changed the NA values



>stk[stk==0]<- NA
>stk
class : RasterBrick
dimensions : 1160, 1573, 1824680, 2 (nrow, ncol, ncell, nlayers)
resolution : 0.008627311, 0.008627319 (x, y)
extent : -74.49244, -60.92168, -20.00769, -10 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : ndvi2005, ndvi2006
min values : -0.3, -0.3
max values : 0.9990, 0.9993


then when i wanted to obtain de coordinate reference system with CRS() i got the next message



>cord<-CRS(stk)
>Error in !is.na(projargs) && !nzchar(projargs) :
invalid 'x' type in 'x && y'


I know that my projection is +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 but i have in total 100 stacklayers in differents proyections that i need to analize each one, but i dont know what is my mistake or is something wrong with my code because then i want to use the output of CRS(stk)in the function raster(...., CRS=cord) as an input.










share|improve this question
















I got an error when i wanted to obtain the CRS from stacklayer. I don´t know what could it be. I need some advice or help to obtain it.
This is my code.



#LOAD RASTER LIBRARY
>library(rgdal)
>library(raster)
>ndvi<-raster('ndvi2005.tif')
>ndvi2<-raster('ndvi2006.tif')

#RASTER STACK
>stk <- stack(ndvi1, ndvi2)
#DISPLAY STK
>stk
class : RasterStack
dimensions : 1160, 1573, 1824680, 2 (nrow, ncol, ncell, nlayers)
resolution : 0.008627311, 0.008627319 (x, y)
extent : -74.49244, -60.92168, -20.00769, -10 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
names : ndvi2005, ndvi2006
min values : NA, NA
max values : NA, NA


then I changed the NA values



>stk[stk==0]<- NA
>stk
class : RasterBrick
dimensions : 1160, 1573, 1824680, 2 (nrow, ncol, ncell, nlayers)
resolution : 0.008627311, 0.008627319 (x, y)
extent : -74.49244, -60.92168, -20.00769, -10 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : ndvi2005, ndvi2006
min values : -0.3, -0.3
max values : 0.9990, 0.9993


then when i wanted to obtain de coordinate reference system with CRS() i got the next message



>cord<-CRS(stk)
>Error in !is.na(projargs) && !nzchar(projargs) :
invalid 'x' type in 'x && y'


I know that my projection is +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 but i have in total 100 stacklayers in differents proyections that i need to analize each one, but i dont know what is my mistake or is something wrong with my code because then i want to use the output of CRS(stk)in the function raster(...., CRS=cord) as an input.







raster coordinate-system r error






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 25 '16 at 2:37









PolyGeo

53.8k1781244




53.8k1781244










asked May 24 '16 at 23:42









GuisseppeGuisseppe

163




163








  • 1





    Use projection() not CRS. Sp weirdly has two functions for this, really painful

    – mdsumner
    May 25 '16 at 0:40






  • 1





    You could also proj4string which is the sp convention.

    – Jeffrey Evans
    May 25 '16 at 2:10














  • 1





    Use projection() not CRS. Sp weirdly has two functions for this, really painful

    – mdsumner
    May 25 '16 at 0:40






  • 1





    You could also proj4string which is the sp convention.

    – Jeffrey Evans
    May 25 '16 at 2:10








1




1





Use projection() not CRS. Sp weirdly has two functions for this, really painful

– mdsumner
May 25 '16 at 0:40





Use projection() not CRS. Sp weirdly has two functions for this, really painful

– mdsumner
May 25 '16 at 0:40




1




1





You could also proj4string which is the sp convention.

– Jeffrey Evans
May 25 '16 at 2:10





You could also proj4string which is the sp convention.

– Jeffrey Evans
May 25 '16 at 2:10










3 Answers
3






active

oldest

votes


















0














CRS is an Interface class. It is not supposed to work like that. Use projection(raster) or proj4string(raster) as per comments.






share|improve this answer































    0














    due to the comments i did this.



    >cord<-projection(stk, asText = F)
    >cord
    CRS arguments:
    +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0


    But now whe i used cordas an input in the function raster(nrows,ncols,CRS=cord) i got an error because cord had to be text, so i did this.



    >cord<-projection(stk, asText = T)


    and finally works.






    share|improve this answer
























    • You only need CRS to wrap the string for some sp functions, but notably not for spTransform any more. Suggest always use string with raster::projection for set and get. raster adds a lot of usability to sp, but it's ad hoc unfortunately and not always adopted by sp

      – mdsumner
      May 25 '16 at 22:37











    • Yes that is true. thanks for the suggestion @mdsumner

      – Guisseppe
      May 26 '16 at 20:01





















    -1














    use crs instead of CRS.

    Read rgdal package for see the differences.






    share|improve this answer















    We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.










    • 2





      maybe you could add a reference to exactly >where< in the rgdal package one should look. Or you could add a quote of the relevant part

      – LaughU
      Sep 5 '17 at 9:27











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "79"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f194853%2ferror-to-obtain-coordinate-reference-system-argument-from-a-raster-image-in-r%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    CRS is an Interface class. It is not supposed to work like that. Use projection(raster) or proj4string(raster) as per comments.






    share|improve this answer




























      0














      CRS is an Interface class. It is not supposed to work like that. Use projection(raster) or proj4string(raster) as per comments.






      share|improve this answer


























        0












        0








        0







        CRS is an Interface class. It is not supposed to work like that. Use projection(raster) or proj4string(raster) as per comments.






        share|improve this answer













        CRS is an Interface class. It is not supposed to work like that. Use projection(raster) or proj4string(raster) as per comments.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 25 '16 at 18:52









        Farid CheraghiFarid Cheraghi

        8,27411447




        8,27411447

























            0














            due to the comments i did this.



            >cord<-projection(stk, asText = F)
            >cord
            CRS arguments:
            +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0


            But now whe i used cordas an input in the function raster(nrows,ncols,CRS=cord) i got an error because cord had to be text, so i did this.



            >cord<-projection(stk, asText = T)


            and finally works.






            share|improve this answer
























            • You only need CRS to wrap the string for some sp functions, but notably not for spTransform any more. Suggest always use string with raster::projection for set and get. raster adds a lot of usability to sp, but it's ad hoc unfortunately and not always adopted by sp

              – mdsumner
              May 25 '16 at 22:37











            • Yes that is true. thanks for the suggestion @mdsumner

              – Guisseppe
              May 26 '16 at 20:01


















            0














            due to the comments i did this.



            >cord<-projection(stk, asText = F)
            >cord
            CRS arguments:
            +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0


            But now whe i used cordas an input in the function raster(nrows,ncols,CRS=cord) i got an error because cord had to be text, so i did this.



            >cord<-projection(stk, asText = T)


            and finally works.






            share|improve this answer
























            • You only need CRS to wrap the string for some sp functions, but notably not for spTransform any more. Suggest always use string with raster::projection for set and get. raster adds a lot of usability to sp, but it's ad hoc unfortunately and not always adopted by sp

              – mdsumner
              May 25 '16 at 22:37











            • Yes that is true. thanks for the suggestion @mdsumner

              – Guisseppe
              May 26 '16 at 20:01
















            0












            0








            0







            due to the comments i did this.



            >cord<-projection(stk, asText = F)
            >cord
            CRS arguments:
            +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0


            But now whe i used cordas an input in the function raster(nrows,ncols,CRS=cord) i got an error because cord had to be text, so i did this.



            >cord<-projection(stk, asText = T)


            and finally works.






            share|improve this answer













            due to the comments i did this.



            >cord<-projection(stk, asText = F)
            >cord
            CRS arguments:
            +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0


            But now whe i used cordas an input in the function raster(nrows,ncols,CRS=cord) i got an error because cord had to be text, so i did this.



            >cord<-projection(stk, asText = T)


            and finally works.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered May 25 '16 at 21:16









            GuisseppeGuisseppe

            163




            163













            • You only need CRS to wrap the string for some sp functions, but notably not for spTransform any more. Suggest always use string with raster::projection for set and get. raster adds a lot of usability to sp, but it's ad hoc unfortunately and not always adopted by sp

              – mdsumner
              May 25 '16 at 22:37











            • Yes that is true. thanks for the suggestion @mdsumner

              – Guisseppe
              May 26 '16 at 20:01





















            • You only need CRS to wrap the string for some sp functions, but notably not for spTransform any more. Suggest always use string with raster::projection for set and get. raster adds a lot of usability to sp, but it's ad hoc unfortunately and not always adopted by sp

              – mdsumner
              May 25 '16 at 22:37











            • Yes that is true. thanks for the suggestion @mdsumner

              – Guisseppe
              May 26 '16 at 20:01



















            You only need CRS to wrap the string for some sp functions, but notably not for spTransform any more. Suggest always use string with raster::projection for set and get. raster adds a lot of usability to sp, but it's ad hoc unfortunately and not always adopted by sp

            – mdsumner
            May 25 '16 at 22:37





            You only need CRS to wrap the string for some sp functions, but notably not for spTransform any more. Suggest always use string with raster::projection for set and get. raster adds a lot of usability to sp, but it's ad hoc unfortunately and not always adopted by sp

            – mdsumner
            May 25 '16 at 22:37













            Yes that is true. thanks for the suggestion @mdsumner

            – Guisseppe
            May 26 '16 at 20:01







            Yes that is true. thanks for the suggestion @mdsumner

            – Guisseppe
            May 26 '16 at 20:01













            -1














            use crs instead of CRS.

            Read rgdal package for see the differences.






            share|improve this answer















            We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.










            • 2





              maybe you could add a reference to exactly >where< in the rgdal package one should look. Or you could add a quote of the relevant part

              – LaughU
              Sep 5 '17 at 9:27
















            -1














            use crs instead of CRS.

            Read rgdal package for see the differences.






            share|improve this answer















            We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.










            • 2





              maybe you could add a reference to exactly >where< in the rgdal package one should look. Or you could add a quote of the relevant part

              – LaughU
              Sep 5 '17 at 9:27














            -1












            -1








            -1







            use crs instead of CRS.

            Read rgdal package for see the differences.






            share|improve this answer















            use crs instead of CRS.

            Read rgdal package for see the differences.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 7 mins ago









            Midavalo

            25.7k53274




            25.7k53274










            answered Sep 5 '17 at 9:16









            baharsabaharsa

            1




            1



            We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.




            We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.









            • 2





              maybe you could add a reference to exactly >where< in the rgdal package one should look. Or you could add a quote of the relevant part

              – LaughU
              Sep 5 '17 at 9:27














            • 2





              maybe you could add a reference to exactly >where< in the rgdal package one should look. Or you could add a quote of the relevant part

              – LaughU
              Sep 5 '17 at 9:27








            2




            2





            maybe you could add a reference to exactly >where< in the rgdal package one should look. Or you could add a quote of the relevant part

            – LaughU
            Sep 5 '17 at 9:27





            maybe you could add a reference to exactly >where< in the rgdal package one should look. Or you could add a quote of the relevant part

            – LaughU
            Sep 5 '17 at 9:27


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f194853%2ferror-to-obtain-coordinate-reference-system-argument-from-a-raster-image-in-r%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Щит и меч (фильм) Содержание Названия серий | Сюжет |...

            is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

            Meter-Bus Содержание Параметры шины | Стандартизация |...