Problem when saving geojson file with SampleSelection app

Hi,

I try to generate a vector file in geosjon (because of a very large number of features). But I get the following error:

2020-06-16 14:26:13 (FATAL) SampleSelection: itk::ERROR: No OGR driver known to OTB to create and handle a DataSource named <toto.json>.

I also try geojson extension, same problem
I use OTB 7.0. I try to first generate a small file in sqlite, then convert is to geojson with ogr. It works. I also check this:

$ ogrinfo --formats | grep GeoJSON
GeoJSON -vector- (rw+v): GeoJSON
GeoJSONSeq -vector- (rw+v): GeoJSON Sequence

From https://www.orfeo-toolbox.org/doxygen-current/classotb_1_1OGRVectorDataIO.html#a97241be7843e8258b9bdba1c48d60e25 geojson should be supported.

Any idea ?

Best regards,

Mathieu

Hello Mathieu,

no, Json and GeoJson are not supported in this application. Some explanations :

There are two group of classes to read and write vector data in OTB :

  • VectorData (and OGRVectorDataIO, VectorDataSource etc …)
  • Datasource (and associated classes)

Datasource is a wrapper over the GDAL class of the same name, and is the preferred way to read, write and process vector files. This class does not support JSON and GeoJSON, you can find the list of supported driver and associated file extension here in the code.

This class is used in a lot of applications, including SampleSelection (but not all applications).

VectorData is another way to use vector files in OTB and as you noted it supports JSON/GeoJSON. It is older than DataSource and very unpratical to use. DataSource has been developed as a replacement, but there is no systematic way to convert from VectorData to DataSource . The goal is to remove VectorData completely in the future, but at the moment both classes coexist.

But the fact that the supported sensor differ between DataSource and VectorDatais problematic. End users should not have to worry about these details. Adding support for Json in Datasourceshould not be a problem (everything is done by ogr anyway).

I hope that clarifies things,
Cédric

Dear Cedric,
Thank for the clear answer. Pointing me the code reminds me that I could use CSV format.

My initial problem was the limitation of 1000 features for sqlite and size bigger than 4Go for shp. I read that GeoJSON does not have such limits that why I wanted to use it.

It seems that CSV does (slowly) the job.

Edit: CSV does not work too :frowning: I open a new threads regarding my problem.

Best regards,

Mathieu