Converting line vector layer to raster with pixellate.psp creating missing data? The Next CEO...

Is it possible to create a QR code using text?

My boss doesn't want me to have a side project

Can Sri Krishna be called 'a person'?

Find the majority element, which appears more than half the time

How dangerous is XSS

MT "will strike" & LXX "will watch carefully" (Gen 3:15)?

Could you use a laser beam as a modulated carrier wave for radio signal?

Ising model simulation

What is a typical Mizrachi Seder like?

How to coordinate airplane tickets?

Does the Idaho Potato Commission associate potato skins with healthy eating?

Creating a script with console commands

Is it a bad idea to plug the other end of ESD strap to wall ground?

How seriously should I take size and weight limits of hand luggage?

Which acid/base does a strong base/acid react when added to a buffer solution?

Compensation for working overtime on Saturdays

What difference does it make matching a word with/without a trailing whitespace?

What is the difference between 'contrib' and 'non-free' packages repositories?

logical reads on global temp table, but not on session-level temp table

Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact

That's an odd coin - I wonder why

How to pronounce fünf in 45

What happens if you break a law in another country outside of that country?

Does int main() need a declaration on C++?



Converting line vector layer to raster with pixellate.psp creating missing data?



The Next CEO of Stack OverflowConverting vector layer to raster using QGIS?Creating raster or vector raster from DEM point file?Converting raster to im object for point process model covariate in R?Converting vector layer to raster with cell size same as other raster using QGIS?Creating raster layer from data frame in R?Processing vector to raster faster with RCreating raster layer from line with PyQGIS?Processing vector to raster faster with R on WindowsConverting single point layer to buffered raster using QGIS?Missing raster data from masking with a spatial polygon layer in R












0















The following example converts a line vector layer (road network) into a density raster. It seems to be working for others', but it looks like it's creating data gaps at my resolution (50m).



library(spatstat)
library(raster)
library(rgdal)
library(magrittr)

# Set common CRS
crs <- "+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs "

# Read in our vector & raster data
rast <- readRDS(gzcon(url('http://web.pdx.edu/~porlando/study_area.RDS'))) %>%
spTransform(CRSobj = crs) %>% raster(res = 50, crs = crs)
vect <- readRDS(gzcon(url('http://web.pdx.edu/~porlando/fwy.RDS'))) %>%
spTransform(CRSobj = crs) %>% crop(rast)

# Use spatstat to create density raster
roadsPSP <- as.psp(as(vect, "SpatialLines"))
roadLengthIM <- pixellate.psp(roadsPSP, eps = 50) # meters
roadLengthRaster <- raster(roadLengthIM, crs = projection(vect))

# The resolution isn't exactly 50m x 50m so I resample again
roadLengthRaster50m <- resample(roadLengthRaster, rast)

# Recode values to exaggerate presence/absence
values(roadLengthRaster50m)[values(roadLengthRaster50m)<=0] <- NA
values(roadLengthRaster50m)[values(roadLengthRaster50m)>0] <- 100

# Plot raster layer on top of vector layer
plot(vect, col="black")
plot(roadLengthRaster50m, add = T)


enter image description here



There are many areas where the black vector layer is poking through the rasterized version. At this point, I'm not sure whether it's a visualization issue, or a limitation of this approach entirely!









share



























    0















    The following example converts a line vector layer (road network) into a density raster. It seems to be working for others', but it looks like it's creating data gaps at my resolution (50m).



    library(spatstat)
    library(raster)
    library(rgdal)
    library(magrittr)

    # Set common CRS
    crs <- "+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs "

    # Read in our vector & raster data
    rast <- readRDS(gzcon(url('http://web.pdx.edu/~porlando/study_area.RDS'))) %>%
    spTransform(CRSobj = crs) %>% raster(res = 50, crs = crs)
    vect <- readRDS(gzcon(url('http://web.pdx.edu/~porlando/fwy.RDS'))) %>%
    spTransform(CRSobj = crs) %>% crop(rast)

    # Use spatstat to create density raster
    roadsPSP <- as.psp(as(vect, "SpatialLines"))
    roadLengthIM <- pixellate.psp(roadsPSP, eps = 50) # meters
    roadLengthRaster <- raster(roadLengthIM, crs = projection(vect))

    # The resolution isn't exactly 50m x 50m so I resample again
    roadLengthRaster50m <- resample(roadLengthRaster, rast)

    # Recode values to exaggerate presence/absence
    values(roadLengthRaster50m)[values(roadLengthRaster50m)<=0] <- NA
    values(roadLengthRaster50m)[values(roadLengthRaster50m)>0] <- 100

    # Plot raster layer on top of vector layer
    plot(vect, col="black")
    plot(roadLengthRaster50m, add = T)


    enter image description here



    There are many areas where the black vector layer is poking through the rasterized version. At this point, I'm not sure whether it's a visualization issue, or a limitation of this approach entirely!









    share

























      0












      0








      0








      The following example converts a line vector layer (road network) into a density raster. It seems to be working for others', but it looks like it's creating data gaps at my resolution (50m).



      library(spatstat)
      library(raster)
      library(rgdal)
      library(magrittr)

      # Set common CRS
      crs <- "+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs "

      # Read in our vector & raster data
      rast <- readRDS(gzcon(url('http://web.pdx.edu/~porlando/study_area.RDS'))) %>%
      spTransform(CRSobj = crs) %>% raster(res = 50, crs = crs)
      vect <- readRDS(gzcon(url('http://web.pdx.edu/~porlando/fwy.RDS'))) %>%
      spTransform(CRSobj = crs) %>% crop(rast)

      # Use spatstat to create density raster
      roadsPSP <- as.psp(as(vect, "SpatialLines"))
      roadLengthIM <- pixellate.psp(roadsPSP, eps = 50) # meters
      roadLengthRaster <- raster(roadLengthIM, crs = projection(vect))

      # The resolution isn't exactly 50m x 50m so I resample again
      roadLengthRaster50m <- resample(roadLengthRaster, rast)

      # Recode values to exaggerate presence/absence
      values(roadLengthRaster50m)[values(roadLengthRaster50m)<=0] <- NA
      values(roadLengthRaster50m)[values(roadLengthRaster50m)>0] <- 100

      # Plot raster layer on top of vector layer
      plot(vect, col="black")
      plot(roadLengthRaster50m, add = T)


      enter image description here



      There are many areas where the black vector layer is poking through the rasterized version. At this point, I'm not sure whether it's a visualization issue, or a limitation of this approach entirely!









      share














      The following example converts a line vector layer (road network) into a density raster. It seems to be working for others', but it looks like it's creating data gaps at my resolution (50m).



      library(spatstat)
      library(raster)
      library(rgdal)
      library(magrittr)

      # Set common CRS
      crs <- "+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs "

      # Read in our vector & raster data
      rast <- readRDS(gzcon(url('http://web.pdx.edu/~porlando/study_area.RDS'))) %>%
      spTransform(CRSobj = crs) %>% raster(res = 50, crs = crs)
      vect <- readRDS(gzcon(url('http://web.pdx.edu/~porlando/fwy.RDS'))) %>%
      spTransform(CRSobj = crs) %>% crop(rast)

      # Use spatstat to create density raster
      roadsPSP <- as.psp(as(vect, "SpatialLines"))
      roadLengthIM <- pixellate.psp(roadsPSP, eps = 50) # meters
      roadLengthRaster <- raster(roadLengthIM, crs = projection(vect))

      # The resolution isn't exactly 50m x 50m so I resample again
      roadLengthRaster50m <- resample(roadLengthRaster, rast)

      # Recode values to exaggerate presence/absence
      values(roadLengthRaster50m)[values(roadLengthRaster50m)<=0] <- NA
      values(roadLengthRaster50m)[values(roadLengthRaster50m)>0] <- 100

      # Plot raster layer on top of vector layer
      plot(vect, col="black")
      plot(roadLengthRaster50m, add = T)


      enter image description here



      There are many areas where the black vector layer is poking through the rasterized version. At this point, I'm not sure whether it's a visualization issue, or a limitation of this approach entirely!







      raster r rasterization density spatstat





      share












      share










      share



      share










      asked 4 mins ago









      spacedSparkingspacedSparking

      1709




      1709






















          0






          active

          oldest

          votes












          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%2f317439%2fconverting-line-vector-layer-to-raster-with-pixellate-psp-creating-missing-data%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f317439%2fconverting-line-vector-layer-to-raster-with-pixellate-psp-creating-missing-data%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 Содержание Параметры шины | Стандартизация |...