[GRASS-dev] [GRASS GIS] #2878: "v.in.ogr -i" throws an error when importing a GeoJSON file containing a single point.
GRASS GIS
trac at osgeo.org
Thu Jan 28 00:19:04 PST 2016
#2878: "v.in.ogr -i" throws an error when importing a GeoJSON file containing a
single point.
--------------------------+-------------------------------
Reporter: pmav99 | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone:
Component: Vector | Version: unspecified
Resolution: | Keywords: v.in.ogr v.import
CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------------
Changes (by mlennert):
* milestone: 7.0.4 =>
Comment:
Replying to [comment:4 pmav99]:
> 2. These are the contents of the file. This is directly created by
GRASS/GDAL:
> {{{
> GRASS 7.0.3svn (damflood):~/repo > cat sample.json
> {
> "type": "FeatureCollection",
> "crs": { "type": "name", "properties": { "name":
"urn:ogc:def:crs:OGC:1.3:CRS84" } },
> "features": [
> { "type": "Feature", "properties": { "cat": 1 }, "geometry": { "type":
"Point", "coordinates": [ -78.690549087210798, 35.769783222348899 ] } },
> { "type": "Feature", "properties": { "cat": 2 }, "geometry": { "type":
"Point", "coordinates": [ -78.687924462941851, 35.769783222348899 ] } }
> ]
> }
> }}}
[...]
> 5. Trying to create a new location using `v.in.ogr -i` fails. This
failure is actually the reason that `v.import` fails too (step 3):
> {{{
> v.in.ogr -i --verbose input=/home/grassuser/repo/sample.json output=qwer
location=new_location
> Location <new_location> created
> ERROR: Syntax error in cell header
> }}}
Interestingly, when I convert the json file to shape before import, I get
the same error:
{{{
v.in.ogr -i in=test.json location=new_location1 --verbose
ATTENTION: All available OGR layers will be imported into vector map
<OGRGeoJSON>
Location <new_location1> created
ERREUR :Syntax error in cell header
}}}
then
{{{
ogr2ogr test.shp test.json
}}}
and
{{{
v.in.ogr -i in=test.shp location=new_location2 --verbose
ATTENTION: All available OGR layers will be imported into vector map
<test>
Location <new_location2> created
ERREUR :Syntax error in cell header
}}}
I also opened the json file in QGIS, saved as a new shapefile and tried to
import that: same error.
IIUC the error comes from the fact that the Y coordinates are strictly
identical and that thus N = S in the DEFAULT_WIND & WIND files and GRASS
has trouble dealing with a mapset with 0 resolution in any direction...
The following hack let's you import the file, but this is not a complete
solution. One question we have to answer is whether GRASS should allow the
creation of mapsets with 0 resolution in any direction, and, if not (as I
think it should be), then what would be a reasonable default when creating
a location from a file containing data with identical coordinates in
either of the directions or with just one point.
{{{
Index: vector/v.in.ogr/main.c
===================================================================
--- vector/v.in.ogr/main.c (révision 67579)
+++ vector/v.in.ogr/main.c (copie de travail)
@@ -535,6 +535,8 @@
if ((OGR_L_GetExtent(Ogr_layer, &oExt, 1)) == OGRERR_NONE) {
cellhd.north = ymax = oExt.MaxY;
cellhd.south = ymin = oExt.MinY;
+ if (cellhd.north == cellhd.south)
+ cellhd.north += 0.0001;
cellhd.west = xmin = oExt.MinX;
cellhd.east = xmax = oExt.MaxX;
cellhd.rows = 20; /* TODO - calculate useful values */
}}}
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2878#comment:10>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list