Giter VIP home page Giter VIP logo

Comments (7)

edzer avatar edzer commented on August 17, 2024

Yes, but the number of polygons returned is the same. Maybe some grid cells touching the pole become triangles in geographical coordinates, and loose one node, hence the smaller number of coordinates?

from sf.

TripleEmma avatar TripleEmma commented on August 17, 2024

Sorry to ask the very basic question but how to fix this then? Thank you!

from sf.

edzer avatar edzer commented on August 17, 2024

Fix what?

from sf.

TripleEmma avatar TripleEmma commented on August 17, 2024

There is error when applying st_join() on grid4326.

geneCoor <- geneMetaUsed %>% dplyr::select(ID, longitude, latitude)
geneMetaUsed.sf <- st_as_sf(geneCoor, coords=c("longitude", "latitude"))
st_crs(geneMetaUsed.sf) <- 4326
gridGenes <- st_join(grid4326, geneMetaUsed.sf)  # grid4326 resulted from grid4326 <- st_transform(grid, 'EPSG:4326')

Error in wk_handle.wk_wkb(wkb, s2_geography_writer(oriented = oriented, Loop 0 is not valid: Non-empty, non-full loops must have at least 3 vertices

from sf.

edzer avatar edzer commented on August 17, 2024

Please modify your reproducible example such that it exposes the error; geneMetaUsed is not known.

from sf.

TripleEmma avatar TripleEmma commented on August 17, 2024

geneMetaUsed is a data frame with several columns. Here I just selected three of them, including 'longitude' and 'latitude'.

geneCoor <- geneMetaUsed %>% dplyr::select(ID, longitude, latitude)
head(geneCoor)

> head(geneCoor)
# A tibble: 6 × 3
ID longitude latitude

1 MK262583_2309838992 172. -40.4
2 MK262588_2308522646 172. -43.2
3 MK262601_2311115935 172. -40.4
4 GQ481466_2309171845 50.4 58.4
5 GQ481467_2310943848 178. 64.2
6 GQ481468_2308837004 34.9 69.0

I once did it as following, and it works fine, no error.

geneCoor <- geneMetaUsed %>% dplyr::select(ID, longitude, latitude)
geneMetaUsed.sf <- st_as_sf(geneCoor, coords=c("longitude", "latitude"))
st_crs(geneMetaUsed.sf) <- 4326
geneMetaUsed.sf <- st_transform(geneMetaUsed.sf, "ESRI:54017")
gridGenes <- st_join(grid, geneMetaUsed.sf)  # CRS of grid is "ESRI:54017"

from sf.

TripleEmma avatar TripleEmma commented on August 17, 2024

@edzer I am sorry if I misunderstood your idea. I had a mistake in the original code, the final geneMetaUsed.sf should be derived from geneCoor (fixed in previous posts). geneCoo has three columns, including "longitude" and "latitude".

from sf.

Related Issues (20)

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.