I'm trying to run an ogr2ogr command that requires a version of GDAL that is built with new enough SpatiaLite to have the ST_MakeValid function---from discussion groups, this seem to be 4.0+
However, the version of gdal in ubuntugis has what looks like a modern version of gdal
$ gdalinfo --version
GDAL 2.2.4, released 2018/03/19
And I have a modern spatialite:
$ sudo apt-get install libspatialite-dev spatialite-bin libspatialite7
... already installed
$ spatialite
SpatiaLite version ..: 4.3.0a Supported Extensions:
but the ogr2ogr
command does not seem to be compiled with the version of spatialite that is in the repos as a stand-alone binary, but rather something older. (I cannot tell how to check which version it is compiled with, simply that this command that succeeds when it is up to date, fails)
Here's my Dockerfile:
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y && apt-get update \
&& apt-get install --yes gdal-bin curl \
&& curl -LKS 'https://github.com/OpenDataDE/State-zip-code-GeoJSON/raw/master/ks_kansas_zip_codes_geo.min.json' -o ks_kansas_zip_codes_geo.min.json \
&& ogrinfo --version \
&& ogr2ogr -f GeoJSON -dialect sqlite -sql "select ST_MakeValid(geometry),STATEFP10,ZCTA5CE10,GEOID10,CLASSFP10,MTFCC10,FUNCSTAT10,ALAND10,AWATER10,INTPTLAT10,INTPTLON10,PARTFLG10 from \"ks_kansas_zip_codes_geo.min\"" clean.json ks_kansas_zip_codes_geo.min.json
What can I change in the repos or how do I manually compile gdal
to have a version of spatialite that contains the ST_MakeValid
function?
Notes
Collecting search results that might be relevant:
- https://gis.stackexchange.com/questions/157406/how-to-re-compile-ogrinfo-against-gdal-used-by-qgis?rq=1]
- http://trac.osgeo.org/gdal/wiki/BuildHints
- https://pastebin.com/iE4zwQTb
- https://github.com/GeographicaGS/Docker-GDAL2 This Docker image is not compiled against the correct libspatialite
- https://hub.docker.com/r/roblabs/gdal/ This Docker image is also not compiled against the correct libspatialite
Updates to dockerfile
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y \
# # INSTALLING GRASS DOES NOT SEEM HELPFUL
# && add-apt-repository ppa:grass/grass-devel -y \
&& apt-get update \
&& apt-get install --yes curl git autoconf libtool \
# # TRIED RTTOPO FROM HERE:
# # http://postgis.17.x6.nabble.com/Why-can-t-PostGIS-configure-find-libgeos-c-td3552982.html
# # AND HERE:
# # https://gitlab.com/rttopo/rttopo
# # DOES NOT SEEM FRUITFUL
# apt-get install --yes libgeos-dev \
# && git clone https://gitlab.com/rttopo/rttopo.git \
# && cd rttopo && ./autogen.sh && ./configure --enable-rttopo=yes --with-geosconfig=/usr/bin/geos-config && make && make install \
# && cd \
&& apt-get install --yes gdal-bin \
&& curl -LKS 'https://github.com/OpenDataDE/State-zip-code-GeoJSON/raw/master/ks_kansas_zip_codes_geo.min.json' -o ks_kansas_zip_codes_geo.min.json \
&& ogrinfo --version \
&& ogr2ogr -f GeoJSON -dialect sqlite -sql "select ST_MakeValid(geometry),STATEFP10,ZCTA5CE10,GEOID10,CLASSFP10,MTFCC10,FUNCSTAT10,ALAND10,AWATER10,INTPTLAT10,INTPTLON10,PARTFLG10 from \"ks_kansas_zip_codes_geo.min\"" clean.json ks_kansas_zip_codes_geo.min.json