Skip to content

z error (3 columns) with shapefile & 1.10 installation error #2081

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

Closed
itsmevictor opened this issue Jan 11, 2023 · 6 comments
Closed

z error (3 columns) with shapefile & 1.10 installation error #2081

itsmevictor opened this issue Jan 11, 2023 · 6 comments

Comments

@itsmevictor
Copy link

itsmevictor commented Jan 11, 2023

Hi, I tried to load a shapefile that can be downloaded here and got the following error message:

Error in CPL_get_z_range(obj, 2) : z error - expecting three columns;

Given that I seemed not to be the first to have this problem, I followed the suggestion made by @kadyb in this error thread to install the 1.10 version of the package. However, it did not work. When I ran install.packages("sf", repos = "https://r-spatial.r-universe.dev") I got the following message:

*installing source package ‘sf’ ...
** using staged installation
configure: CC: clang -arch arm64
configure: CXX: clang++ -arch arm64 -std=gnu++11
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘sf’
*removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/sf’
*restoring previous ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/sf’
Warning in install.packages :
installation of package ‘sf’ had non-zero exit status

I then ran remotes::install_github("r-spatial/sf") and got:

Downloading GitHub repo r-spatial/sf@HEAD
Running R CMD build...
*checking for file ‘/private/var/folders/8_/n10p4gls1rggj7frcghmj4y40000gn/T/RtmpL5L5wu/remotes1332e6d8caad9/r-spatial-sf-8afb003/DESCRIPTION’ ... OK
*preparing ‘sf’:
*checking DESCRIPTION meta-information ... OK
*cleaning src
*running ‘cleanup’
*checking for LF line-endings in source and make files and shell scripts
*checking for empty or unneeded directories
*building ‘sf_1.0-10.tar.gz’
*installing source package ‘sf’ ...
** using staged installation
configure: CC: clang -arch arm64
configure: CXX: clang++ -arch arm64 -std=gnu++11
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘sf’
*removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/sf’
*restoring previous ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/sf’
Warning message:
In i.p(...) :
installation of package ‘/var/folders/8_/n10p4gls1rggj7frcghmj4y40000gn/T//RtmpL5L5wu/file1332e38c1e457/sf_1.0-10.tar.gz’ had non-zero exit status

[Sorry I cannot manage to input multi-line code in Github's interface]

Would anyone be able to help, either by guiding me to install the 1.10 version of the package, or finding an alternative fix to the initial error message when loading the shapefile ?

Many thanks,

@kadyb
Copy link
Contributor

kadyb commented Jan 11, 2023

I'm not sure if this will work (there are many issues with installing sf from sources on macOS), but you can try this in the terminal:

brew install pkg-config
brew install gdal proj geos

and then in R:

remotes::install_github("r-spatial/sf", configure.args = "--with-proj-lib=/usr/local/lib/")

If that doesn't work, as workaround to the data loading problem, you can save the shapefile without the Z dimension in this way:

gdal_utils(util = "vectortranslate",
           source = "CoursEau_52_Pays de la Loire.shp",
           destination = "new.shp",
           options = c("-dim", "XY"))

@itsmevictor
Copy link
Author

Thank you for your quick, detailed feedback.

Unfortunately, there still seems to be a problem with the installation as I installed all the required dependencies with Homebrew, but still get the following error message when running the line of code you suggested :

configure: error: proj_api.h not found in standard or given locations.

It seems weird as I checked and the "proj" folder is indeed in /usr/local/lib. Any further suggestions? Sorry for the trouble!

Also, for my personal knowledge, would you mind enlightening me on how to write multi-line code in Github's interface?

@kadyb
Copy link
Contributor

kadyb commented Jan 11, 2023

I don't have macOS, so it's hard for me to help, but maybe you can find solution here.

Also, for my personal knowledge, would you mind enlightening me on how to write multi-line code in Github's interface?

Use a triple graves at the beginning and end of code block.

```r
code
```

@itsmevictor
Copy link
Author

Okay many thanks for both, I will look into the resource you linked me to. I forgot to tell you but your solution for loading the data does work well.

@walkerke
Copy link

walkerke commented Feb 6, 2023

We just solved a version of this issue over in the tidycensus issues, if it's helpful: walkerke/tidycensus#501 (comment)

@edzer
Copy link
Member

edzer commented Feb 6, 2023

Thanks, yes this can also be closed here.

@edzer edzer closed this as completed Feb 6, 2023
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