1

According to the GeoJson spec (https://www.rfc-editor.org/rfc/rfc7946), features with different sets of properties are allowed, but when i am processing my GeoJson file using FeatureJSON.readFeatureCollection i get an error saying no such attribute:tract_boundary.

here's the part of my file showing the two features with different properties (notice the attribute name "tract_boundary" appears in the second feature properties):

{
      "type": "Feature",
      "properties": {
        "clu_identifier": "3ecc54fc-5077-11d6-8e82-00065b4a19c0",
        "clu_alt_id": "{5626C60F-23B1-4172-BCFA-842EBDEE776F}",
        "data_source": "danna.steffens",
        "clu_status": null,
        "tract_number": "768",
        "last_change_date": 1352656579000,
        "last_chg_user_nm": null,
        "creation_date": 1113921633000,
        "admin_state": "20",
        "clu_calculated_acreage": 152.41,
        "OBJECTID": 582,
        "cropland_indicator_3CM": 1,
        "edit_reason": null,
        "GlobalId": "{DE7A11AA-BFB6-4DFE-A1D7-D795D7DD7990}",
        "SHAPE_STArea__": 1012852.6422872,
        "state_code": "20",
        "cdist_fips": "2001",
        "highly_erodible_land_type_code": "NHEL",
        "admin_county": "171",
        "clu_classification_code": "2",
        "sap_crp": null,
        "farm_number": "4384",
        "SHAPE_STLength__": 4161.19756459,
        "ESRI_OID": 530,
        "clu_number": "1",
        "data_source_site_identifier": null,
        "comments": " ",
        "county_code": "171"
      },
      "geometry": {...
},
{
      "type": "Feature",
      "properties": {
        "farm_number": "4384",
        "admin_state": "20",
        "tract_number": "5468",
        "admin_county": "171",
        "tract_boundary": true
      },
      "geometry": {...
}

Any ideas?

Community
  • 1
  • 1
ido flax
  • 528
  • 1
  • 10
  • 19
  • 2
    did you see http://osgeo-org.1560.x6.nabble.com/GeoJSON-No-such-Attribute-problem-td4950845.html ? –  Jun 09 '17 at 11:25

1 Answers1

1

You can get the "full" schema by calling org.geotools.geojson.feature.FeatureJSON.readFeatureCollectionSchema(Object, boolean) with the 2nd argument set to false so that the whole collection is read rather than just the first item. Then you can set the FeatureType of your features correctly.

Ian Turton
  • 10,018
  • 1
  • 28
  • 47
  • Does not work everytime ... I do not know why but on specific case, this call gives me an error like `java.lang.IllegalStateException: Found conflicting types Double and Long for property y` for example. – cactuschibre Mar 27 '21 at 14:44
  • that's a different problem - unlikely to be fixed as we're trying to deprecate that package, but feel free to raise a ticket with an example file. – Ian Turton Mar 27 '21 at 17:01