leombastos / 2024_dsa

0 stars 20 forks source link

isssue warning: GDAL/PROJ error #32

Open tjaraoz opened 1 month ago

tjaraoz commented 1 month ago

I am working with yield monitor data from an agricultural plot and I am having an issue when loading the yield data, the shp file of the plot boundary and also when creating a grid to later perform operations on its cells.

The code and its corresponding output are as follows:

Code:

fl03_maiz0809 <- st_read("../data/Capas FL3/Mapas de rendimiento/Corregido/SHP/LIAG - Las Balas - FL3 - 0809 - Maiz.shp")

fl03_maiz0809

Output: Reading layer LIAG - Las Balas - FL3 - 0809 - Maiz' from data source/Users/tomasaraoz/Desktop/tesis_scripts/data/Capas FL3/Mapas de rendimiento/Corregido/SHP/LIAG - Las Balas - FL3 - 0809 - Maiz.shp' using driver `ESRI Shapefile' Warning: GDAL Error 1: PROJ: proj_identify: Cannot find proj.dbSimple feature collection with 377923 features and 2 fields Geometry type: POINT Dimension: XY Bounding box: xmin: -6856507 ymin: -4086073 xmax: -6852886 ymax: -4079936 Projected CRS: WGS_1984_Web_Mercator_Auxiliary_Sphere Simple feature collection with 377923 features and 2 fields Geometry type: POINT Dimension: XY Bounding box: xmin: -6856507 ymin: -4086073 xmax: -6852886 ymax: -4079936 Projected CRS: WGS_1984_Web_Mercator_Auxiliary_Sphere First 10 features: fid Rinde geometry 1 1 6270.6 POINT (-6852959 -4085384) 2 2 6753.0 POINT (-6852961 -4085382) 3 3 7226.9 POINT (-6852963 -4085380) 4 4 9163.4 POINT (-6852966 -4085378) 5 5 9768.1 POINT (-6852968 -4085376) 6 6 9403.8 POINT (-6852969 -4085374) 7 7 10426.0 POINT (-6852971 -4085372) 8 8 10532.0 POINT (-6852973 -4085370) 9 9 12017.0 POINT (-6852975 -4085368) 10 10 10373.0 POINT (-6852977 -4085366) [1] "sf" "data.frame"

BOUNDARY issue

Code:

boundary_w <- read_sf("../data/Capas FL3/Limite/Limite FL3 UTM.shp") 

boundary_w
plot(boundary_w)

Output:

boundary_w <- read_sf("../data/Capas FL3/Limite/Limite FL3 UTM.shp") Warning: GDAL Error 1: PROJ: proj_identify: Cannot find proj.db

boundary_w Simple feature collection with 1 feature and 3 fields Geometry type: MULTIPOLYGON Dimension: XY Bounding box: xmin: 629321.2 ymin: 6189728 xmax: 632273.1 ymax: 6194799 Projected CRS: WGS_1984_UTM_Zone_20S plot(boundary_w)

GRID issue

Code:

#grid in vector format
grid_v <- st_make_grid(boundary_w, 
                       cellsize = 10 #como el limite esta en UTM,
                                     #estará expresado en metros.
                       )
grid_v

class(grid_v)

Output: Geometry set for 150368 features Geometry type: POLYGON Dimension: XY Bounding box: xmin: 629321.2 ymin: 6189728 xmax: 632281.2 ymax: 6194808 Projected CRS: WGS_1984_UTM_Zone_20S First 5 geometries: POLYGON ((629321.2 6189728, 629331.2 6189728, 6... POLYGON ((629331.2 6189728, 629341.2 6189728, 6... POLYGON ((629341.2 6189728, 629351.2 6189728, 6... POLYGON ((629351.2 6189728, 629361.2 6189728, 6... POLYGON ((629361.2 6189728, 629371.2 6189728, 6... [1] "sfc_POLYGON" "sfc"

Code:

ggplot() +
  geom_sf(data = fl03_maiz0809) +
  geom_sf(data = grid_v, 
          alpha = 0.5,
          fill = NA, 
          size = 0.1
          )

Output: Warning: GDAL Error 1: PROJ: proj_create_from_database: Cannot find proj.dbWarning: GDAL Error 1: PROJ: proj_create_from_database: Cannot find proj.dbError: node stack overflow Error during wrapup: node stack overflow Error: no more error handlers available (recursive errors?); invoking 'abort' restart

leombastos commented 2 weeks ago

Hi @tjaraoz,

It looks like GDAL can't find the projection file of your shape file.

Shape files are comprised of at least 3-4 other files that need to be in the same folder and named the same as the .shp file.

Questions for you: 1) Do you have other files accompanying your .shp file in the same folder? Please share a screenshot of that folder.

2) Have you tried plotting these layers to see if they appear?

3) Are you on a windows PC or on a Mac?

tjaraoz commented 2 weeks ago

Hi @leombastos ,

  1. Sure, I am attaching the screenshots of the folders with the data.
  2. It plots the yield map points and the boundary (Although I haven't tried overlapping them yet.), but not the grid.
  3. I'm on Mac Captura de Pantalla 2024-07-02 a la(s) 14 58 08 Captura de Pantalla 2024-07-02 a la(s) 14 58 25 Captura de Pantalla 2024-07-02 a la(s) 14 58 47 Captura de Pantalla 2024-07-02 a la(s) 14 58 59 Captura de Pantalla 2024-07-02 a la(s) 14 59 17 Captura de Pantalla 2024-07-02 a la(s) 14 59 54
leombastos commented 2 weeks ago

Your shape file files are correct. I was taking a look online, and it seems like this could be related to your GDAL installation (outside and independent of R).

Try to locate the file proj.db in your computer, and set is path as the GDAL path in R. Some resources here:

tjaraoz commented 1 week ago

Hi Leonardo!

I ran the code on a Windows computer and it worked, so as you mentioned, it must be a configuration issue with my Mac.

Thank you very much for your help,

best regards.