0

I am trying to convert GeoJSON to Shapefile with an extent. The Shapefile is generated successfully, however it has no extent and data. Without extent and data, SAGA fails to run using the output Shapefile. Below is the ogr2ogr code.

ogr2ogr -f "ESRI Shapefile" -spat -88.987035 25.585476 -88.987035 30.160476 -clipsrc spat_extent "D:/MSU/watermonitor/monitor/temp/GKS7wuW1Rs9FIv-jAAAA/1598937441196.shp" "D:/MSU/watermonitor/monitor/temp/GKS7wuW1Rs9FIv-jAAAA/1598937441196.json"

This is how the source GeoJSON looks like:

{
  "type": "FeatureCollection",
  "bbox": [
    -88.987035,
    25.585476,
    -88.987035,
    30.160476
  ],
  "crs": {
    "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:EPSG::4326"
    }
  },
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -88.987035,
          25.585476
        ]
      },
      "properties": {
        "id": 239,
        "chlorophyll_a": 52,
        "capture_datetime": "2020-08-30T01:01:18.657+00:00",
        "equal": 1,
        "quantile": 1,
        "quantile_range": "51 - 53",
        "equal_range": "51 - 54"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -88.987035,
          28.964476
        ]
      },
      "properties": {
        "id": 346,
        "chlorophyll_a": 53,
        "capture_datetime": "2020-08-30T03:23:48.477+00:00",
        "equal": 1,
        "quantile": 1,
        "quantile_range": "51 - 53",
        "equal_range": "51 - 54"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -88.987035,
          28.964476
        ]
      },
      "properties": {
        "id": 511,
        "chlorophyll_a": 55,
        "capture_datetime": "2020-08-29T17:22:44.598+00:00",
        "equal": 2,
        "quantile": 2,
        "quantile_range": "54 - 57",
        "equal_range": "55 - 57"
      }
    }
  ]
}

The ogrinfo of the file is the following:

        D:\MSU\watermonitor\monitor\temp\GKS7wuW1Rs9FIv-jAAAA>ogrinfo -so -al 1598937441196.shp
    INFO: Open of `1598937441196.shp'
          using driver `ESRI Shapefile' successful.

    Layer name: 1598937441196
    Metadata:
      DBF_DATE_LAST_UPDATE=2020-09-01
    Geometry: Point
    Feature Count: 0
    Extent: (0.000000, 0.000000) - (0.000000, 0.000000)
    Layer SRS WKT:
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]]
    id: Integer (9.0)
    chlorophyl: Integer (9.0)
    capture_da: Date (10.0)
    equal: Integer (9.0)
    quantile: Integer (9.0)
    quantile_r: String (80.0)
    equal_rang: String (80.0)


    

And this is what I got from QGIS (Information from Provider): enter image description here

As you can see, there is no extent/bounding box specified. And it has no data it it even though the source data has 11 rows.

Is there any parameter to that fixes this issue?

6
  • 1
    What do you mean "it has no extent"? Please edit your question to clarify.
    – user2856
    Sep 1, 2020 at 6:07
  • what does ogrinfo say about your shapefile?
    – Ian Turton
    Sep 1, 2020 at 8:04
  • user2856 @ian Turton I have edited my question.
    – wondim
    Sep 1, 2020 at 9:12
  • try ogrinfo -so -al to show the actual data - It seems to have no data in it
    – Ian Turton
    Sep 1, 2020 at 9:14
  • @IanTurton I have updated it again Thank you!
    – wondim
    Sep 1, 2020 at 9:19

1 Answer 1

2

There is no data in your shapefile - the most likely cause is the -spat -88.987035 25.585476 -88.987035 30.160476 argument having it's coordinate order reversed. Since you are including the whole file anyway I would just leave this out.

2
  • 2
    The shapefile would also be very narrow if both min and max are -88.987035. Might still work with -spat that selects all intersected features without clipping them.
    – user30184
    Sep 1, 2020 at 10:51
  • That is right the xmin and xmax are the same! Removing the -spat fixed it. It would have been great to add a mask polygon....
    – wondim
    Sep 1, 2020 at 13:38

Your Answer

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

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