Giter Club home page Giter Club logo

Comments (8)

ChristopherTracey avatar ChristopherTracey commented on July 24, 2024

Done. Removed nm_StudyAreaExtent from the aquatic branch, as its no longer needed.

image

from regional_sdm.

dnbucklin avatar dnbucklin commented on July 24, 2024

Is this necessary to save it, if it's only used in the map(?) Seems it could be generated on the fly just in step 5.

Terrestrial already has methods in helper/crop_rast_mask.r, to pull from a huc10 shapefile:

db <- dbConnect(SQLite(),dbname=nm_db_file)
SQLquery <- paste0("SELECT huc10_id from lkpRange
                   inner join lkpSpecies on lkpRange.EGT_ID = lkpSpecies.EGT_ID
                   where lkpSpecies.sp_code = '", model_species, "';")
hucList <- dbGetQuery(db, statement = SQLquery)$huc10_id
dbDisconnect(db)
rm(db)

# now get that info spatially
nm_range <- nm_HUC_file
qry <- paste("SELECT * from HUC10 where HUC10 IN ('", paste(hucList, collapse = "', '"), "')", sep = "")
hucRange <- st_zm(st_read(nm_range, query = qry))

One option to have consistent aquatic/terrestrial methods here would be to calculate and write the huc10s values (that make up the aquatic range) to lkpRange.

from regional_sdm.

ChristopherTracey avatar ChristopherTracey commented on July 24, 2024

I did not know about that happening in Terrestrial. I was saving it, as I thought it could be useful as a standalone product. I had thought of just making it a temporary file.

from regional_sdm.

dnbucklin avatar dnbucklin commented on July 24, 2024

Sounds good, saving a shapefile probably is a good idea.

We could also adjust terrestrial methods to pull from the huc12 table you generated, if there are not concerns about differences between versions as discussed yesterday in #62.

from regional_sdm.

ChristopherTracey avatar ChristopherTracey commented on July 24, 2024

In order to make a layer of HUC10s that match the aquatic ranges for the model review tool, I've been trying to dissolve the by the HUC10 column using sf without success. @tghoward and @dnbucklin, do you have any experience with this?

from regional_sdm.

dnbucklin avatar dnbucklin commented on July 24, 2024

If I'm understanding correctly I think dplyr is the way to go for something like this:

library(sf)
library(dplyr)

huc <- st_read("hucs.shp")
names(huc)

# use your huc10 field in group_by, geometry field in st_union
huc10 <- huc %>% group_by(HUC_10) %>% summarize(geometry = st_union(geometry))

from regional_sdm.

ChristopherTracey avatar ChristopherTracey commented on July 24, 2024

Thanks @dnbucklin! I had most of it together, but I was trying to use a different group_by approach. This works a lot better and cleaner than my draft code.

from regional_sdm.

ChristopherTracey avatar ChristopherTracey commented on July 24, 2024

Note that dplyr has to loaded before sf for this to work.

from regional_sdm.

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.