Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get a denser grid? #9

Open
PachecoMC opened this issue Nov 25, 2021 · 9 comments
Open

How to get a denser grid? #9

PachecoMC opened this issue Nov 25, 2021 · 9 comments

Comments

@PachecoMC
Copy link

Hi,

Thank you for the nice software.

I have successfully run the example dataset, but when I try to use my data I had two issues:

  1. When running the function prepare_graph_inputs with the argument translated=True as in the example it gives me the error message "AssertionError: grid is empty changing translation" and the output is not generate. But if I run it with translated=False it runs smoothly without any errors. So I was wondering what would be the impact of changing this argument.

  2. Since my study area is at country level, I would like to perform the analysis with a denser grid (with more demes) than the one provided in the example to improve the resolution of the analysis. Would that be possible? and if so, could you provide some guidelines on how to generate such input?

Thank you for your time.
Best,
Carolina

@jbruxaux
Copy link

Hi Carolina!

I got exactly the same problem yesterday, so would be interested in the translated argument description as well.

In the meantime, I managed to create my own grid with the R package dggridR available here: https://github.com/r-barnes/dggridR
It is only one line of command:
filename <- dgearthgrid(dgconstruct(res=8, projection = "ISEA", aperture = 4, topology = "TRIANGLE"),savegrid = "world_triangle_res8.shp")
And you can change the resolution (from 0 to 30, the larger values corresponding to a better resolution).
I hope it helps!

Jade

@PachecoMC
Copy link
Author

Hi Jade,

Sorry for the late reply, but thank you so much for your feedback.
I have applied your suggestion and I was able to progress in the analysis.

Best,
Carolina

@Yung-Chien
Copy link

Hi @jbruxaux @jhmarcus @jnovembre
I've tried your solution and I got my own grid files, however I still got the same issue like @PachecoMC 's question. Just like this:
File "<stdin>", line 1, in <module> File "/home/Yungchien/miniconda3/envs/feems_analysis_e/lib/python3.8/site-packages/feems/utils.py", line 107, in prepare_graph_inputs assert grid.shape[0] != 0, "grid is empty changing translation" AssertionError: grid is empty changing translation
So I'm confused about how to difine the correct grid format.

Thanks in advance
Yung-Chien

@jbruxaux
Copy link

Hi Yung-Chien!

Not sure I can really help, as I'm not the developer, but did you try to change the argument translated=True to translated=False in the prepare_graph_inputs command, as suggested by Carolina? This solved my problem (however, I can't say what it means...).

Jade

@Yung-Chien
Copy link

Hi @jbruxaux
Thanks for your reply and actually I tried both translated=True and translated=False in the prepare_graph_inputs and get the same error above. So that's why I'm confused about that.

Best,
Yung-Chien

@Yung-Chien
Copy link

Hi Yung-Chien!

Not sure I can really help, as I'm not the developer, but did you try to change the argument translated=True to translated=False in the prepare_graph_inputs command, as suggested by Carolina? This solved my problem (however, I can't say what it means...).

Jade

Hey @jbruxaux ,
You guess what? I've just finished this step successfully. But I need to move all my input files(bim,bed,fam,coord and outer files) to feems's test data directory and change the argument translated=True to translated=False. In addtion, this command works based on both his default grid file(grid_100.shp) and the grid file generated by dggridR.
Wow I was confused and didn't know what to say.

Anyway I'll go on to the rest of this tutorial.

Best,
Yung-Chien

@space-beaver
Copy link

Hi @jbruxaux, thanks for the suggestion - I'm also trying to generate a denser grid. Do you happen to know how this code can be modified to create a grid for a smaller specified region rather than a global grid? Thanks!

@jbruxaux
Copy link

Hi Melissa!
If it's to use the grid for feems, you do not have to cut the grid to adapt it to your specific region. That is done by selecting your area in the outer file. In this file you give the coordinates of several locations that will form the limits of your area.

@space-beaver
Copy link

space-beaver commented Mar 26, 2023

Hello @jbruxaux and thanks for getting back to me :)

The issue I had creating a global dgg was that R crashed when I ran it at higher resolutions. I managed to get what I needed with:

#create discrete global grid
dggs <- dgconstruct(spacing=5, metric=FALSE, resround='nearest', projection='ISEA', aperture = 4, topology = "TRIANGLE")

#read in uk shapefile
scotne_border <- st_read(".", layer="scot_ne")
st_crs(scotne_border)=4326

#view boundary
plot(scotne_border)

shape <- read_sf(dsn = ".", layer = "scot_ne")

#create grid
grid <- dgshptogrid(dggs, "scot_ne.shp", cellsize = 0.01, savegrid=".")

#plot
p <- ggplot() +
geom_sf(data=scotne_border, fill=NA, color="black") +
geom_sf(data=grid, fill=alpha("blue", 0.4), color=alpha("white", 0.4))
p

However, when I use it in feems I get the following error:
ERROR 1: PROJ: proj_identify: /path/to/anaconda/envs/feems_e/share/proj/proj.db lacks DATABASE.LAYOUT.VERSION.MAJOR / DATABASE.LAYOUT.VERSION.MINOR metadata. It comes from another PROJ installation.

I think perhaps there's a conflict in the projection systems between my grid and the program, but I'm not sure - this is very out of my comfort zone! solved by removing the .prj file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants