Understanding spsample in R?How to make RASTER from irregular point data without interpolationWhat's wrong...

Life insurance that covers only simultaneous/dual deaths

Use of undefined constant bloginfo

Why is the President allowed to veto a cancellation of emergency powers?

Could the Saturn V actually have launched astronauts around Venus?

Most cost effective thermostat setting: consistent temperature vs. lowest temperature possible

My Graph Theory Students

What is the significance behind "40 days" that often appears in the Bible?

How to change two letters closest to a string and one letter immediately after a string using notepad++

Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?

A sequence that has integer values for prime indexes only:

What do Xenomorphs eat in the Alien series?

A link redirect to http instead of https: how critical is it?

(Calculus) Derivative Thinking Question

Unexpected result from ArcLength

Python if-else code style for reduced code for rounding floats

Does Mathematica reuse previous computations?

Opacity of an object in 2.8

How to write cleanly even if my character uses expletive language?

Charles Hockett - 'F' article?

Why doesn't using two cd commands in bash script execute the second command?

Existence of subset with given Hausdorff dimension

AG Cluster db upgrade by vendor

Do I need to be arrogant to get ahead?

Are ETF trackers fundamentally better than individual stocks?



Understanding spsample in R?


How to make RASTER from irregular point data without interpolationWhat's wrong with my IDW interpolation function (Python)?QGIS raster from interpolation not scaled correctlyDefining number of cells in sample grid for IDW?QGIS Raster->Interpolation Error: “wkb access out of bounds”Spatial interpolation from categorical data in RContour TIN InterpolationReprojecting a rasterPyQGIS interpolation classes and triangulation file without interpolation rasterExtract points/pixels from raster based on % of intersection using PostGIS and PostgreSQL













1















I have read the documentation for this but still unsure of what the function spsample does.



The documentation is here:



https://www.rdocumentation.org/packages/sp/versions/1.3-1/topics/spsample



I came across this while trying to do interpolation on a dataset, referencing this page: https://mgimond.github.io/Spatial/interpolation-in-r.html



Just to clarify, is this function trying to split an area of interest using a grid, and trying to put a value for each cell on the grid using the data that we feed into the function? But I am not sure why the idw function would require a grid that has values. I thought the inputs to idw would just be the points we are trying to interpolate.



Can someone clarify?










share|improve this question









New contributor




shibaducks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    1















    I have read the documentation for this but still unsure of what the function spsample does.



    The documentation is here:



    https://www.rdocumentation.org/packages/sp/versions/1.3-1/topics/spsample



    I came across this while trying to do interpolation on a dataset, referencing this page: https://mgimond.github.io/Spatial/interpolation-in-r.html



    Just to clarify, is this function trying to split an area of interest using a grid, and trying to put a value for each cell on the grid using the data that we feed into the function? But I am not sure why the idw function would require a grid that has values. I thought the inputs to idw would just be the points we are trying to interpolate.



    Can someone clarify?










    share|improve this question









    New contributor




    shibaducks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1








      I have read the documentation for this but still unsure of what the function spsample does.



      The documentation is here:



      https://www.rdocumentation.org/packages/sp/versions/1.3-1/topics/spsample



      I came across this while trying to do interpolation on a dataset, referencing this page: https://mgimond.github.io/Spatial/interpolation-in-r.html



      Just to clarify, is this function trying to split an area of interest using a grid, and trying to put a value for each cell on the grid using the data that we feed into the function? But I am not sure why the idw function would require a grid that has values. I thought the inputs to idw would just be the points we are trying to interpolate.



      Can someone clarify?










      share|improve this question









      New contributor




      shibaducks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I have read the documentation for this but still unsure of what the function spsample does.



      The documentation is here:



      https://www.rdocumentation.org/packages/sp/versions/1.3-1/topics/spsample



      I came across this while trying to do interpolation on a dataset, referencing this page: https://mgimond.github.io/Spatial/interpolation-in-r.html



      Just to clarify, is this function trying to split an area of interest using a grid, and trying to put a value for each cell on the grid using the data that we feed into the function? But I am not sure why the idw function would require a grid that has values. I thought the inputs to idw would just be the points we are trying to interpolate.



      Can someone clarify?







      r interpolation sampling






      share|improve this question









      New contributor




      shibaducks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      shibaducks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 1 min ago









      PolyGeo

      53.7k1781244




      53.7k1781244






      New contributor




      shibaducks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 4 hours ago









      shibaducksshibaducks

      111




      111




      New contributor




      shibaducks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      shibaducks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      shibaducks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Yes, gstat::idw can predict at any x,y location, but if you want to show that as a continuous map then you need a raster. The example does:



          # Interpolate the grid cells using a power value of 2 (idp=2.0)
          P.idw <- gstat::idw(Precip_in ~ 1, P, newdata=grd, idp=2.0)


          to predict at a regular grid of x,y coordinates generated by spsample



          It then converts the output from idw to a raster:



          # Convert to raster object then clip to Texas
          r <- raster(P.idw)


          then plotting r will show it as a continuous raster surface (although its really only a grid of point samples).



          Equivalently you could create an empty raster object first, and use coordinates(r) to generate a matrix of X,Y coordinates to pass to idw, and then put the returned values into the raster.






          share|improve this answer


























          • so spsample generates a grid of x, y coordinates? Sorry but what is it sampling from and why do we need to sample them? I dont quite get that part. How is it possible to randomly sample coordinates? arent coordinates fixed?

            – shibaducks
            3 hours ago











          • Its being fed P which is a polygon, and spsample in this instance is creating a set of grid points within P. spsample can do regular, random or other patterns of points.

            – Spacedman
            2 hours ago











          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
          });


          }
          });






          shibaducks is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f315698%2funderstanding-spsample-in-r%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Yes, gstat::idw can predict at any x,y location, but if you want to show that as a continuous map then you need a raster. The example does:



          # Interpolate the grid cells using a power value of 2 (idp=2.0)
          P.idw <- gstat::idw(Precip_in ~ 1, P, newdata=grd, idp=2.0)


          to predict at a regular grid of x,y coordinates generated by spsample



          It then converts the output from idw to a raster:



          # Convert to raster object then clip to Texas
          r <- raster(P.idw)


          then plotting r will show it as a continuous raster surface (although its really only a grid of point samples).



          Equivalently you could create an empty raster object first, and use coordinates(r) to generate a matrix of X,Y coordinates to pass to idw, and then put the returned values into the raster.






          share|improve this answer


























          • so spsample generates a grid of x, y coordinates? Sorry but what is it sampling from and why do we need to sample them? I dont quite get that part. How is it possible to randomly sample coordinates? arent coordinates fixed?

            – shibaducks
            3 hours ago











          • Its being fed P which is a polygon, and spsample in this instance is creating a set of grid points within P. spsample can do regular, random or other patterns of points.

            – Spacedman
            2 hours ago
















          1














          Yes, gstat::idw can predict at any x,y location, but if you want to show that as a continuous map then you need a raster. The example does:



          # Interpolate the grid cells using a power value of 2 (idp=2.0)
          P.idw <- gstat::idw(Precip_in ~ 1, P, newdata=grd, idp=2.0)


          to predict at a regular grid of x,y coordinates generated by spsample



          It then converts the output from idw to a raster:



          # Convert to raster object then clip to Texas
          r <- raster(P.idw)


          then plotting r will show it as a continuous raster surface (although its really only a grid of point samples).



          Equivalently you could create an empty raster object first, and use coordinates(r) to generate a matrix of X,Y coordinates to pass to idw, and then put the returned values into the raster.






          share|improve this answer


























          • so spsample generates a grid of x, y coordinates? Sorry but what is it sampling from and why do we need to sample them? I dont quite get that part. How is it possible to randomly sample coordinates? arent coordinates fixed?

            – shibaducks
            3 hours ago











          • Its being fed P which is a polygon, and spsample in this instance is creating a set of grid points within P. spsample can do regular, random or other patterns of points.

            – Spacedman
            2 hours ago














          1












          1








          1







          Yes, gstat::idw can predict at any x,y location, but if you want to show that as a continuous map then you need a raster. The example does:



          # Interpolate the grid cells using a power value of 2 (idp=2.0)
          P.idw <- gstat::idw(Precip_in ~ 1, P, newdata=grd, idp=2.0)


          to predict at a regular grid of x,y coordinates generated by spsample



          It then converts the output from idw to a raster:



          # Convert to raster object then clip to Texas
          r <- raster(P.idw)


          then plotting r will show it as a continuous raster surface (although its really only a grid of point samples).



          Equivalently you could create an empty raster object first, and use coordinates(r) to generate a matrix of X,Y coordinates to pass to idw, and then put the returned values into the raster.






          share|improve this answer















          Yes, gstat::idw can predict at any x,y location, but if you want to show that as a continuous map then you need a raster. The example does:



          # Interpolate the grid cells using a power value of 2 (idp=2.0)
          P.idw <- gstat::idw(Precip_in ~ 1, P, newdata=grd, idp=2.0)


          to predict at a regular grid of x,y coordinates generated by spsample



          It then converts the output from idw to a raster:



          # Convert to raster object then clip to Texas
          r <- raster(P.idw)


          then plotting r will show it as a continuous raster surface (although its really only a grid of point samples).



          Equivalently you could create an empty raster object first, and use coordinates(r) to generate a matrix of X,Y coordinates to pass to idw, and then put the returned values into the raster.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 3 hours ago

























          answered 4 hours ago









          SpacedmanSpacedman

          24.4k23551




          24.4k23551













          • so spsample generates a grid of x, y coordinates? Sorry but what is it sampling from and why do we need to sample them? I dont quite get that part. How is it possible to randomly sample coordinates? arent coordinates fixed?

            – shibaducks
            3 hours ago











          • Its being fed P which is a polygon, and spsample in this instance is creating a set of grid points within P. spsample can do regular, random or other patterns of points.

            – Spacedman
            2 hours ago



















          • so spsample generates a grid of x, y coordinates? Sorry but what is it sampling from and why do we need to sample them? I dont quite get that part. How is it possible to randomly sample coordinates? arent coordinates fixed?

            – shibaducks
            3 hours ago











          • Its being fed P which is a polygon, and spsample in this instance is creating a set of grid points within P. spsample can do regular, random or other patterns of points.

            – Spacedman
            2 hours ago

















          so spsample generates a grid of x, y coordinates? Sorry but what is it sampling from and why do we need to sample them? I dont quite get that part. How is it possible to randomly sample coordinates? arent coordinates fixed?

          – shibaducks
          3 hours ago





          so spsample generates a grid of x, y coordinates? Sorry but what is it sampling from and why do we need to sample them? I dont quite get that part. How is it possible to randomly sample coordinates? arent coordinates fixed?

          – shibaducks
          3 hours ago













          Its being fed P which is a polygon, and spsample in this instance is creating a set of grid points within P. spsample can do regular, random or other patterns of points.

          – Spacedman
          2 hours ago





          Its being fed P which is a polygon, and spsample in this instance is creating a set of grid points within P. spsample can do regular, random or other patterns of points.

          – Spacedman
          2 hours ago










          shibaducks is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          shibaducks is a new contributor. Be nice, and check out our Code of Conduct.













          shibaducks is a new contributor. Be nice, and check out our Code of Conduct.












          shibaducks is a new contributor. Be nice, and check out our Code of Conduct.
















          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%2f315698%2funderstanding-spsample-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 Содержание Параметры шины | Стандартизация |...