[gdal-dev] How to read CSV with GeoJSON correctly?

jratike80 jukka.rahkonen at maanmittauslaitos.fi
Thu Sep 7 03:16:03 PDT 2017


Even Rouault-2 wrote
> Hi Jukka,
> ...
> That's not enough. As there are quoted strings in the GeoJSON content,
> they
> confuse the CSV reader. So you need to surround the whole GeoJSON content
> by double-quotes, and escape the inside double quotes with a repeated
> double quote character
> (You can the use regular comma for separator, but semicolon is fine too)
> ...

Thanks. It is actually well documented in one place of
http://www.gdal.org/drv_csv.html
"Complex attribute values (such as those containing commas, quotes or
newlines) may be placed in double quotes. Any occurrences of double quotes
within the quoted string should be doubled up to "escape" them."

However, it contradicts with what is said about reading spatial information
from CSV
"...Otherwise, if one or several columns contain a geometry definition
encoded as WKT, WKB (encoded in hexadecimal) or GeoJSON, the name of such
column(s) the GEOM_POSSIBLE_NAMES open option." 

Adding extra double quotes inside GeoJSON make it invalid as GeoJSON and
JSON as well. I would say that CSV driver does not support GeoJSON encoding
at the moment.

-Jukka-






--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html


More information about the gdal-dev mailing list