Git Product home page Git Product logo

casa0005repo's Issues

DBSCAN code

Updated from MSc student

I wrote a bit of code for creating convex hulls for the dbscan output, which are a bit more nicely shaped than those in the practical, maybe someone will find it useful ๐Ÿ™‚
convex hulls to wrap around points

chulls <- data.frame() for (cluster in 1:max(BluePlaquesSubPoints$dbcluster)) { cluster_data <- BluePlaquesSubPoints %>% filter(dbcluster == cluster) ch <- chull(cluster_data$coords.x1, cluster_data$coords.x2) chulls <- chulls %>% bind_rows(cluster_data[c(ch), ]) }

Tips on Chap7 data preprocessing

Currently I'm learning this tutorial on my own, and I find that in 7.7.2, it takes a long time to resample such big data. Therefore I suggest we do the clipping in 7.7.3 first, and then resample. This may save some time. Will problem arise in it? Thanks.

My codes:


library(pacman)
p_load(sp,raster,rgeos,rgdal,rasterVis,raster,fs,sf,tidyverse)

# read data
manchester_boundary <- st_read("data/manchester_boundary_download/Manchester_boundary.shp")
listlandsat <- dir("data/LC08_L1TP_203023_20190513_20190521_01_T1",
    pattern = "[B123456790].TIF",full.names = T) %>% stack()
#check they have the same Coordinate Reference System (CRS)
crs(manchester_boundary)
crs(listlandsat)

# get only Manchester
lsatmask <- listlandsat %>%
  # now crop our temp data to the extent
  crop(.,manchester_boundary)%>%
  mask(.,  manchester_boundary)

# handle 8th band
b8list = dir("data/LC08_L1TP_203023_20190513_20190521_01_T1",
    pattern = "[B8].TIF",full.names = T) %>% 
  raster()

## ngb is a nearest neighbour sampling method
b8correct <- b8list%>%
  # now crop our temp data to the extent
  crop(.,manchester_boundary)%>%
  mask(.,  manchester_boundary)%>%
  resample(., lsatmask$LC08_L1TP_203023_20190513_20190521_01_T1_B1, 
           method = "ngb") 

lsatmask <- lsatmask %>%
  addLayer(., b8correct)

raster::compareRaster(listlandsat$LC08_L1TP_203023_20190513_20190521_01_T1_B1,
                      listlandsat$LC08_L1TP_203023_20190513_20190521_01_T1_B8)




# add mask to the filenames within the raster stack

names(lsatmask) <- names(lsatmask)%>%
  str_c(., 
        "mask", 
        sep="_")



Thank you for your contribution. I've learned a lot from this course.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.