Skip to main content
Solved

Reading API and extracting geometry

  • December 5, 2024
  • 9 replies
  • 110 views

fme_can_do_it
Enthusiast
Forum|alt.badge.img+9

 

Hi, I am retrieving data through an API using an HTTP caller. The data consists of points and lines. My plan is to pull this data, perform some attribute mapping, and then POST it to a website. However, I'm having trouble extracting geometry after flattening the JSON data. I used a Geometry Replacer, but it fails every time I run it. The error message says:

INVALID_PARAMETER_GEOMETRY_SOURCE

I would appreciate any assistance with this!

Best answer by todd_davis

Sorry, can’t tell a huge amount from the screenshots.

You have the building blocks, they are just in individual parts. Though I don’t really like it, you can just put in a AttributeCreator before the geometryreplacer and create a new field with the value:

"geometry": {"type": "@Value(geometry_type)",@Value(geometry)}

 

Then, just put the new attribute as the source for the geometryreplacer

 

View original
Did this help you find an answer to your question?

9 replies

nison
Safer
Forum|alt.badge.img+4
  • Safer
  • December 5, 2024

That error usually means it’s not valid GeoJSON. Are you able to share an example of what is in the geometry_type attribute that you were putting into the geometry replacer?


geomancer
Evangelist
Forum|alt.badge.img+46
  • Evangelist
  • December 5, 2024

Often when you read the response as GeoJSON the geometry is automatically read.

Hopefully this will also work in your case.


fme_can_do_it
Enthusiast
Forum|alt.badge.img+9
  • Author
  • Enthusiast
  • December 9, 2024

@nison My mistake. The geometry replacer was connected to the incorrect data. After fixing this, I could run it without any errors, but it still does not display the geometry. I have attached a screenshot of the attribute used in the geometry replacer. The attribute I used is "geometry."


fme_can_do_it
Enthusiast
Forum|alt.badge.img+9
  • Author
  • Enthusiast
  • December 11, 2024

@geomancer It is reading the geometry but not displaying it. I am not sure if I am doing anything incorrectly, as this is the first time I am handling data in JSON format.


geomancer
Evangelist
Forum|alt.badge.img+46
  • Evangelist
  • December 12, 2024

Can you share some of the relevant data?


todd_davis
Supporter
Forum|alt.badge.img+20
  • Supporter
  • December 13, 2024

It is flattened to far (you have recursively flattened) . So avoid that (depending on your data) or use something like a jsonextractor or jsonfragmentor to get the correct level.

Your “geometry” attribute is incorrect and is one of the nested values inside the geojson geometry (the coordinates line):

 

The whole geojson geometry object is like this

    "geometry": {
        "type": "Point",
        "coordinates": [-104.99404, 39.75621]
    }

fme_can_do_it
Enthusiast
Forum|alt.badge.img+9
  • Author
  • Enthusiast
  • December 16, 2024

@todd_davis I have used the JSON Fragmenter and am attaching the current transformer settings. I have also attached the screenshot of the geometry attribute column I received as output from the transformer. I am unsure why the geometry column doesn't match the format specified in your response.

 


todd_davis
Supporter
Forum|alt.badge.img+20
  • Supporter
  • Best Answer
  • December 16, 2024

Sorry, can’t tell a huge amount from the screenshots.

You have the building blocks, they are just in individual parts. Though I don’t really like it, you can just put in a AttributeCreator before the geometryreplacer and create a new field with the value:

"geometry": {"type": "@Value(geometry_type)",@Value(geometry)}

 

Then, just put the new attribute as the source for the geometryreplacer

 


fme_can_do_it
Enthusiast
Forum|alt.badge.img+9
  • Author
  • Enthusiast
  • December 17, 2024

@todd_davis That worked!! Thank you so much for all your help!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings