Solved

Generate polygon features from coordinates stored in a .JSON file

  • 17 August 2021
  • 8 replies
  • 182 views

I have been given a .JSON file to try and convert into an output Esri File Geodatabase format. I have managed to flatten the nested JSON values into attributes, and can view these ok. However, I am having a real issue trying to get my workbench to read the coordinate values that make up the polygon geometry objects. If someone could assist that would be much appreciated. I have attached a file, but stripped it back just to include the line containing the coordinate information for one polygon. Thanks, R

icon

Best answer by danminneyatsaf 18 August 2021, 21:15

View original

8 replies

Badge +20

Read it as GeoJSON and set a coordinate system

Read it as GeoJSON and set a coordinate system

Unfortunately, when I tried that I got this result i.e. json_process_no_schema 

Badge +20

Unfortunately, when I tried that I got this result i.e. json_process_no_schema 

Using your sample:Screenshot 2021-08-18 121047Maybe it's something else. How are you trying to read your JSON file (classic reader or FeatureReader or a JSON transformer)? Maybe you need to reinsert the reader.

I just pulled the file into workspace, after opening it in Notepad to see it's header to figure out the flavor of JSON, and it worked.

Unfortunately, when I tried that I got this result i.e. json_process_no_schema 

I reinserted the reader i.e. GeoJSON into a new workspace, and I managed to replicate your geometry output - so that's a good start.

Anyway, these coordinates are just part of a larger JSON file I received that contains other attribute information (see attached). When I try and process this using the GeoJSON reader that is when I do not get the results I am expecting i.e. being able to view the attributes in separate fields and being able to display the polygon that contains those attributes.AttributeParameters

Badge +20

Unfortunately, when I tried that I got this result i.e. json_process_no_schema 

The Geometry definition is definitely GeoJSON, your file, I don't know.

Try inserting it as JSON and before hitting OK on the Reader go to Parameters -> Feature Parameters and set Geometry Format to GeoJSON and it should automatically populate Geometry Key Name with json_geometry and Coordinate System Key Name with json_ogc_wkt_crs. Else, write them down yourself.

Alternatively, use GeometryExtractor after reading the JSON file with Geometry Encoding set to GeoJSON.

Your sample is recognized but gives an INVALID_GEOMETRY_VERTICES rejection code on the geometry that may be the work of your anonymizing/missing schema feature.

Unfortunately, when I tried that I got this result i.e. json_process_no_schema 

I tried your suggestions (on the full dataset that I have) - and unfortunately the process is failing due to the INVALID_GEOMETRY_VERTICES reason I am also receiving. Anyway, thank you for your ongoing assistance and advice on this matter!

Userlevel 2
Badge +9

Hi @gis_person​! I was able to create a polygon feature using the JSON Reader, and a few JSON transformers. Most importantly, I had to isolate the Geometry array in order to successfully create a polygon, otherwise it kept throwing up the same error you were getting.

 

I have attached the sample workspace. Hope this helps move you in the right direction!

Hi @gis_person​! I was able to create a polygon feature using the JSON Reader, and a few JSON transformers. Most importantly, I had to isolate the Geometry array in order to successfully create a polygon, otherwise it kept throwing up the same error you were getting.

 

I have attached the sample workspace. Hope this helps move you in the right direction!

Hi @danminneyatsaf​ - thank you for providing your solution, which has significantly helped with what I was trying to do. I have now been able to use your solution and expand it to process our full JSON extract. Thanks again!!

Reply