0

I have an ASCII file with the following columns : ID, longitude, latitude, value

Is it possible to use OGR (ogr2ogr or ogrinfo) in command line in order to open the ASCII file and convert it to a shapefile (in WGS84) using the point coordinates (X field=longtitude, Y field=latitude) ?

What I want to do is similar with what QGIS does when opening an ascii file with "Delimited Text" and defining the geometry (point coordinates).

I want to do that for a high number of files so I want to know if this is possible in OGR.

I finally tried the following:

ogr2ogr -f "ESRI Shapefile" test.shp input.csv -oo X_POSSIBLE_NAMES=lon -oo Y_POSSIBLE_NAMES=lat -oo KEEP_GEOM_COLUMNS=NO

but I get an error Unable to open datasource test.shp with the following drivers

1
  • 2
    You need a wildcard after =lon such as =lon*, or you can include the full column name, X_POSSIBLE_NAMES=longitude
    – klewis
    Jun 11, 2019 at 22:37

1 Answer 1

3

What you have is basically comma-separated values, so you can use GDAL's csv driver. You can find its documentation at https://www.gdal.org/drv_csv.html , see especially the section "Building point geometries".

1
  • thank you, I tried what you suggested (see the edited question) but with no success. Is this possible with shapefiles or only for kml ?
    – nat
    Jun 11, 2019 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.