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

Splitting large geometries in query #99

Open
j-miszczyszyn opened this issue Feb 8, 2024 · 2 comments
Open

Splitting large geometries in query #99

j-miszczyszyn opened this issue Feb 8, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@j-miszczyszyn
Copy link

Hello, i find a problem with requesting date for big areas.

remotes::install_github("kadyb/rgugik")
library(rgugik)
library(sf)
library(tidyverse)

#Preparing data
counties = county_names
counties = counties[substr(counties$TERYT, 1, 2) == "16", "TERYT"]
counties_geom = borders_get(TERYT = counties)

#Subset for smaller area
counties_geom= counties_geom[1,]

req_df = DEM_request(counties_geom)

ERROR: DEM_request(counties_geom)': maximum number of records, reduce the area

May I suggest a solution using loops ?

aoi=st_as_sf(counties_geom)
grid=st_make_grid(aoi, n=10)  
aoi=st_intersection(aoi, grid)

result_dem=data_frame()

for (i in 1:nrow(aoi)) {
  req_df = DEM_request(aoi[i, ])
  result_dem = bind_rows(result_dem, req_df)
}
@kadyb
Copy link
Owner

kadyb commented Feb 8, 2024

req_df = DEM_request(counties_geom)
#> Warning message:
#> In DEM_request(counties_geom) : maximum number of records, reduce the area

Hi! This is not an error, but a warning and is expected. The server can return maximum 1000 records in a single query (unless anything has changed). This function expects the geometries will be small enough not to exceed the query limit, otherwise the geometries must be split into smaller parts as you showed.

@j-miszczyszyn
Copy link
Author

Thanks! Is it possible to add new function based on spliting ?

@kadyb kadyb added the enhancement New feature or request label Feb 9, 2024
@kadyb kadyb changed the title ERROR: DEM_request(counties_geom)': maximum number of records, reduce the area Splitting large geometries in query Feb 9, 2024
kadyb added a commit that referenced this issue Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants