Code Monkey home page Code Monkey logo

sptools's People

Watchers

 avatar  avatar  avatar

sptools's Issues

Changing the output of make_grid()

The function make_grid() returns a SpatialPointsDataFrame object with the coordinates as variables. It doesn't make much sense and contains the coordinates informations twice. It would make more sense if make_grid() returned a SpatialPoints object instead.

Checking new function rescale_raster

Can you check the new function rescale_raster please?
Including trying the run the example?
(I know... I should have made a branch for that... Next time!)

Need to update the examples with `imhen`

As the package imhen has been updated and the output stations is now an sf class object. The examples using this package are not working anymore and need to be updated.

Bug in resample_from_grid()

Here is a demonstration of the bug. For that, we need the following packages:

# devtools::install_github("choisy/srtmVN")
# devtools::install_github("choisy/worldpopVN")
library(magrittr)
library(sp)

The data we need:

country <- sptools::gadm("vietnam", "sp", 0)
elevation <- srtmVN::getsrtm()
popdensity <- worldpopVN::getpop()

Let's make a grid:

grid <- country %>%
  sptools::make_grid(100) %>%
  sptools::add_from_raster(elevation, "elevation")

Let's make a second version of this grid, where we remove the variable longitude:

grid2 <- grid
grid2@data[, "longitude"] <- NULL

So, the only difference between grid and grid2 is that grid contains the variable longitude that grid2 does not have. We can check that the coordinates are the same:

identical(coordinates(grid), coordinates(grid2))

The bug is due to the fact that

sptools::resample_from_grid(popdensity, grid)

works just fine whereas

sptools::resample_from_grid(popdensity, grid2)

fails with the following message:

Error in .intersectExtent(x, y, validate = TRUE) : 
  Objects do not intersect 

Bug in points_in_polygon

Let's consider the climatic stations in the province of Hanoi:

library(sp)
provinces <- sptools::gadm("vietnam", "sp", 1)
hanoi <- subset(provinces, VARNAME_1 == "Ha Noi")
stations <- as(imhen::stations, "Spatial")

From the plot, we can see that there are 3 stations in the province of Hanoi:

plot(hanoi)
plot(stations, add = TRUE)

Yet, the function points_in_polygons fails to return 3 points:

length(sptools::points_in_polygon(stations, hanoi))

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.